storage improvement

The command pattern has been implemented so that ClearURLs also works in private mode.
See also: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage
This commit is contained in:
Kevin Röbert
2019-02-13 18:02:08 +01:00
parent 03cdcbb38a
commit 81bc71de5e
9 changed files with 687 additions and 469 deletions

View File

@@ -1,20 +1,20 @@
/*jshint esversion: 6 */
/**
* Get the log and display the data as table.
*/
var log = {};
var core = function (func) {
return browser.runtime.getBackgroundPage().then(func);
};
/**
* Reset the global log
*/
function resetGlobalLog(){
core(function (ref){
obj = {"log": []};
ref.setData('log', JSON.stringify(obj));
obj = {"log": []};
browser.runtime.sendMessage({
function: "setData",
params: ['log', JSON.stringify(obj)]
});
getLog();
location.reload();
}
@@ -24,8 +24,11 @@ function resetGlobalLog(){
*/
function getLog()
{
core(function (ref){
log = ref.getData('log');
browser.runtime.sendMessage({
function: "getData",
params: ['log']
}).then((data) => {
log = data.response;
// Sort the log | issue #70
log.log.sort(function(a,b) {
@@ -108,3 +111,7 @@ function setText()
$('#head_3').text(translate('log_html_table_head_3'));
$('#head_4').text(translate('log_html_table_head_4'));
}
function handleError(error) {
console.log(`Error: ${error}`);
}