mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 14:15:36 +07:00
Fix global counter issue
The total elements field need async to long to load, so that this value is NaN by scanning the first url. We check now first of NaN or Null and get the current value. The browser is waiting until the value is loaded.
This commit is contained in:
28
popup_new.js
28
popup_new.js
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Initialize the UI.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
@@ -21,9 +21,9 @@ function changeStatistics(){
|
||||
var elTotal = $('#statistics_total_elements');
|
||||
var globalPercentage = 0;
|
||||
var globalCounter;
|
||||
var globalURLCounter;
|
||||
var globalurlcounter;
|
||||
|
||||
browser.storage.local.get('globalCounter', function(data){
|
||||
browser.storage.local.get('globalCounter', function(data){
|
||||
if(data.globalCounter){
|
||||
globalCounter = data.globalCounter;
|
||||
}
|
||||
@@ -34,29 +34,29 @@ function changeStatistics(){
|
||||
element.text(globalCounter.toLocaleString());
|
||||
});
|
||||
|
||||
browser.storage.local.get('globalURLCounter', function(data){
|
||||
if(data.globalURLCounter){
|
||||
globalURLCounter = data.globalURLCounter;
|
||||
browser.storage.local.get('globalurlcounter', function(data){
|
||||
if(data.globalurlcounter){
|
||||
globalurlcounter = data.globalurlcounter;
|
||||
}
|
||||
else {
|
||||
globalURLCounter = 0;
|
||||
globalurlcounter = 0;
|
||||
}
|
||||
|
||||
globalPercentage = ((globalCounter/globalURLCounter)*100).toFixed(3);
|
||||
globalPercentage = ((globalCounter/globalurlcounter)*100).toFixed(3);
|
||||
|
||||
if(isNaN(Number(globalPercentage))) globalPercentage = 0;
|
||||
|
||||
elGlobalPercentage.text(globalPercentage+"%");
|
||||
elProgressbar_blocked.css('width', globalPercentage+'%');
|
||||
elProgressbar_non_blocked.css('width', (100-globalPercentage)+'%');
|
||||
elTotal.text(globalURLCounter);
|
||||
elTotal.text(globalurlcounter.toLocaleString());
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Change the value of the globalStatus.
|
||||
* Call by onChange()
|
||||
*
|
||||
*
|
||||
*/
|
||||
function changeGlobalStatus() {
|
||||
var element = $('#globalStatus').is(':checked');
|
||||
@@ -87,7 +87,7 @@ function setGlobalStatus() {
|
||||
/**
|
||||
* Change the value of the badgedStatus.
|
||||
* Call by onChange()
|
||||
*
|
||||
*
|
||||
*/
|
||||
function changeTabcounter() {
|
||||
var element = $('#tabcounter').is(':checked');
|
||||
@@ -118,11 +118,11 @@ function setTabcounter() {
|
||||
|
||||
/**
|
||||
* Reset the global statistic
|
||||
*
|
||||
*
|
||||
*/
|
||||
function resetGlobalCounter(){
|
||||
browser.storage.local.set({"globalCounter": 0});
|
||||
browser.storage.local.set({"globalURLCounter": 0});
|
||||
browser.storage.local.set({"globalurlcounter": 0});
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
@@ -132,4 +132,4 @@ $(document).ready(function(){
|
||||
$('#tabcounter').on('change', changeTabcounter);
|
||||
|
||||
browser.storage.onChanged.addListener(changeStatistics);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user