Add interface features

+ statistics for totally blocked elements
+ statistics for percentage of total traffic
This commit is contained in:
Kevin Röbert
2017-08-23 02:24:16 +02:00
parent 89086d38dd
commit 050c97a615
5 changed files with 154 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
function init()
{
setStatus();
changeStatistics();
}
function setStatus()
@@ -40,9 +41,49 @@ function changeStatus(){
});
};
/**
* Get the globalCounter value from the browser storage
* @param {(data){} Return value form browser.storage.local.get
*/
function changeStatistics(){
var element = $("#statistics_value");
var globalPercentage = $("#statistics_value_global_percentage");
var globalCounter;
var globalURLCounter;
browser.storage.local.get('globalCounter', function(data){
if(data.globalCounter){
globalCounter = data.globalCounter;
}
else {
globalCounter = 0;
}
element.text(globalCounter.toLocaleString());
});
browser.storage.local.get('globalURLCounter', function(data){
if(data.globalURLCounter){
globalURLCounter = data.globalURLCounter;
}
else {
globalURLCounter = 0;
}
globalPercentage.text((globalCounter/globalURLCounter).toFixed(3)+"%");
});
};
function resetGlobalCounter(){
browser.storage.local.set({"globalCounter": 0});
browser.storage.local.set({"globalURLCounter": 0});
};
$(document).ready(function(){
init();
//Hier neue ID des Mülleimers
$("#globalStatus").on("click", changeStatus);
$('.reset_counter_btn').on("click", resetGlobalCounter);
browser.storage.onChanged.addListener(changeStatistics);
});