From cce0e9307499a8ab15d9ea322a91c3ca1428f8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Fuglede=20J=C3=B8rgensen?= Date: Tue, 10 Feb 2015 22:30:00 +0100 Subject: [PATCH 1/2] Changed the counter to include the number of total applicable rules. --- src/chrome/content/toolbar_button.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/chrome/content/toolbar_button.js b/src/chrome/content/toolbar_button.js index de479999dba5..1b67affd63c7 100644 --- a/src/chrome/content/toolbar_button.js +++ b/src/chrome/content/toolbar_button.js @@ -181,21 +181,29 @@ httpsEverywhere.toolbarButton = { } // Make sure the list is up to date alist.populate_list(); - - var counter = 0; + + var totalCounter = 0; + for (var x in alist.all) { + ++totalCounter; + } + var activeCounter = 0; for (var x in alist.active) { if (!(x in alist.breaking)) { - ++counter; + ++activeCounter; } } for (var x in alist.moot) { if (!(x in alist.active)) { - ++counter; + ++activeCounter; } } - - toolbarbutton.setAttribute('rulesetsApplied', counter); - HTTPSEverywhere.log(INFO, 'Setting icon counter to: ' + counter); + if (totalCounter != 0) { + var counterLabel = activeCounter + '/' + totalCounter; + } else { + var counterLabel = 0; + } + toolbarbutton.setAttribute('rulesetsApplied', counterLabel); + HTTPSEverywhere.log(INFO, 'Setting icon counter to: ' + counterLabel); }, /** From 0383ff8d57a582e5dfdaebb9d555cec4a39a70a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Fuglede=20J=C3=B8rgensen?= Date: Tue, 10 Feb 2015 22:59:41 +0100 Subject: [PATCH 2/2] Made it so that the label only includes the total count when it differs from the active count --- src/chrome/content/toolbar_button.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/chrome/content/toolbar_button.js b/src/chrome/content/toolbar_button.js index 1b67affd63c7..489073a0d297 100644 --- a/src/chrome/content/toolbar_button.js +++ b/src/chrome/content/toolbar_button.js @@ -197,10 +197,10 @@ httpsEverywhere.toolbarButton = { ++activeCounter; } } - if (totalCounter != 0) { + if (totalCounter != activeCounter) { var counterLabel = activeCounter + '/' + totalCounter; } else { - var counterLabel = 0; + var counterLabel = totalCounter; } toolbarbutton.setAttribute('rulesetsApplied', counterLabel); HTTPSEverywhere.log(INFO, 'Setting icon counter to: ' + counterLabel);