[bug] improve data export module

This commit is contained in:
Kuldeep M 2019-07-31 21:33:02 +01:00
parent cfa802cfc5
commit d47b354039
3 changed files with 20 additions and 8 deletions

View File

@ -12,6 +12,13 @@ var data = (function() {
}; };
mod.export = function() { mod.export = function() {
var encode = function(string) {
var out = [];
for (var i = 0; i < string.length; i++) {
out[i] = string.charCodeAt(i);
};
return new Uint8Array(out);
};
var tempAchor = helper.node("a"); var tempAchor = helper.node("a");
var timeStamp = helper.getDateTime(); var timeStamp = helper.getDateTime();
var _timeStampPrefix = function(value) { var _timeStampPrefix = function(value) {
@ -28,12 +35,17 @@ var data = (function() {
timeStamp.year = _timeStampPrefix(timeStamp.year); timeStamp.year = _timeStampPrefix(timeStamp.year);
timeStamp = timeStamp.hours + " " + timeStamp.minutes + " " + timeStamp.seconds + " - " + timeStamp.date + "." + timeStamp.month + "." + timeStamp.year; timeStamp = timeStamp.hours + " " + timeStamp.minutes + " " + timeStamp.seconds + " - " + timeStamp.date + "." + timeStamp.month + "." + timeStamp.year;
var fileName = "nightTab backup - " + timeStamp + ".json"; var fileName = "nightTab backup - " + timeStamp + ".json";
var data = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(load())); var str = JSON.stringify(load());
tempAchor.setAttribute("href", data); var data = encode(str);
tempAchor.setAttribute("download", fileName); var blob = new Blob([data], {
helper.e("html").appendChild(tempAchor); type: 'application/octet-stream'
tempAchor.click(); });
tempAchor.remove(); var url = URL.createObjectURL(blob);
var link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("download", fileName);
link.click();
link.remove();
}; };
mod.restore = function(data) { mod.restore = function(data) {

View File

@ -1,6 +1,6 @@
var version = (function() { var version = (function() {
var current = "3.67.2"; var current = "3.68.0";
var compare = function(a, b) { var compare = function(a, b) {
var pa = a.split("."); var pa = a.split(".");

View File

@ -2,7 +2,7 @@
"name": "nightTab", "name": "nightTab",
"short_name": "nightTab", "short_name": "nightTab",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.", "description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"version": "3.67.2", "version": "3.68.0",
"manifest_version": 2, "manifest_version": 2,
"chrome_url_overrides": { "chrome_url_overrides": {
"newtab": "index.html" "newtab": "index.html"