[bug] change export to support special characters in JSON file

Switch back to encodeURIComponent when exporting data as JSON. This supports special characters better than "new Blob".
This commit is contained in:
zombieFox 2020-02-20 12:54:37 +00:00
parent e6eed72463
commit dc59045cc3
5 changed files with 7 additions and 20 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "nightTab",
"version": "4.40.3",
"version": "4.40.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "nightTab",
"version": "4.40.3",
"version": "4.40.4",
"description": "A neutral new tab page accented with a chosen colour. Customise the layout, style, background and bookmarks in nightTab.",
"main": "index.js",
"scripts": {

View File

@ -12,14 +12,6 @@ var data = (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 timeStamp = helper.getDateTime();
var _timeStampPrefix = function(value) {
if (value < 10) {
@ -34,15 +26,10 @@ var data = (function() {
timeStamp.month = _timeStampPrefix(timeStamp.month + 1);
timeStamp.year = _timeStampPrefix(timeStamp.year);
timeStamp = timeStamp.hours + " " + timeStamp.minutes + " " + timeStamp.seconds + " - " + timeStamp.date + "." + timeStamp.month + "." + timeStamp.year;
var fileName = "nightTab backup - " + timeStamp + ".json";
var str = JSON.stringify(load());
var data = encode(str);
var blob = new Blob([data], {
type: "application/json"
});
var url = URL.createObjectURL(blob);
var fileName = _saveName + " backup - " + timeStamp + ".json";
var data = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(load()));
var link = document.createElement("a");
link.setAttribute("href", url);
link.setAttribute("href", data);
link.setAttribute("download", fileName);
link.addEventListener("click", function(event) {
this.remove();

View File

@ -1,6 +1,6 @@
var version = (function() {
var current = "4.40.3";
var current = "4.40.4";
var name = "Naughty Goose";

View File

@ -2,7 +2,7 @@
"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.",
"version": "4.40.3",
"version": "4.40.4",
"manifest_version": 2,
"chrome_url_overrides": {
"newtab": "index.html"