use space instead of tab

master
adbenitez 2022-01-02 18:34:13 -05:00
parent a2dc524416
commit 7e9536c806
1 changed files with 33 additions and 33 deletions

View File

@ -2,50 +2,50 @@
window.xdcStorage = (() => { window.xdcStorage = (() => {
var updatesKey = "__xdcUpdatesKey__"; var updatesKey = "__xdcUpdatesKey__";
var fakeStorage = { var fakeStorage = {
_data: {}, _data: {},
setItem: function (id, val) { setItem: function (id, val) {
return this._data[id] = String(val); return this._data[id] = String(val);
}, },
getItem: function (id) { getItem: function (id) {
return this._data.hasOwnProperty(id) ? this._data[id] : undefined; return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
}, },
removeItem: function (id) { removeItem: function (id) {
return delete this._data[id]; return delete this._data[id];
}, },
clear: function () { clear: function () {
return this._data = {}; return this._data = {};
} }
}; };
var localStorageSupported = () => { var localStorageSupported = () => {
var testKey = "__xdcTestKey__"; var testKey = "__xdcTestKey__";
try { try {
var storage = window.localStorage; var storage = window.localStorage;
storage.setItem(testKey, "1"); storage.setItem(testKey, "1");
storage.removeItem(testKey); storage.removeItem(testKey);
return true; return true;
} catch (error) { } catch (error) {
return false; return false;
} }
}; };
var storage = localStorageSupported() ? window.localStorage : fakeStorage; var storage = localStorageSupported() ? window.localStorage : fakeStorage;
return { return {
getUpdates: () => { getUpdates: () => {
var updatesJSON = storage.getItem(updatesKey); var updatesJSON = storage.getItem(updatesKey);
return updatesJSON ? JSON.parse(updatesJSON) : []; return updatesJSON ? JSON.parse(updatesJSON) : [];
}, },
saveUpdate: (update) => { saveUpdate: (update) => {
var updates = window.xdcStorage.getUpdates(); var updates = window.xdcStorage.getUpdates();
updates.push(update); updates.push(update);
storage.setItem(updatesKey, JSON.stringify(updates)); storage.setItem(updatesKey, JSON.stringify(updates));
}, },
clear: () => { clear: () => {
storage.clear(); storage.clear();
} }
}; };
})(); })();
@ -114,10 +114,10 @@ function alterApp() {
if (getXdcRoot() === window) { if (getXdcRoot() === window) {
var div = document.createElement('div'); var div = document.createElement('div');
div.innerHTML = div.innerHTML =
'<div style="' + styleControlPanel + '">' + '<div style="' + styleControlPanel + '">' +
'<a href="javascript:addXdcPeer();" style="' + styleMenuLink + '">Add Peer</a> | ' + '<a href="javascript:addXdcPeer();" style="' + styleMenuLink + '">Add Peer</a> | ' +
'<a href="javascript:clearXdcStorage();" style="' + styleMenuLink + '">Clear Storage</a>' + '<a href="javascript:clearXdcStorage();" style="' + styleMenuLink + '">Clear Storage</a>' +
'<div>'; '<div>';
document.getElementsByTagName('body')[0].append(div.firstChild); document.getElementsByTagName('body')[0].append(div.firstChild);
} }
} }