[tor-commits] [snowflake/master] Updated popup icon to be purple when it's enabled

cohosh at torproject.org cohosh at torproject.org
Tue Jul 2 14:11:01 UTC 2019


commit f890739a389c959442e8e74a025929ffed96271d
Author: Cecylia Bocovich <cohosh at torproject.org>
Date:   Thu Jun 27 10:41:15 2019 -0400

    Updated popup icon to be purple when it's enabled
---
 proxy/snowflake.coffee |  2 +-
 proxy/ui.coffee        |  6 +++---
 proxy/webext/popup.js  | 10 ++++++----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee
index 4bf6cb6..99dd2bd 100644
--- a/proxy/snowflake.coffee
+++ b/proxy/snowflake.coffee
@@ -73,7 +73,7 @@ class Snowflake
     msg += '[retries: ' + @retries + ']' if @retries > 0
     @ui.setStatus msg
     recv = @broker.getClientOffer pair.id
-    recv.then (desc) ->
+    recv.then (desc) =>
       @receiveOffer pair, desc
     , (err) ->
       pair.active = false
diff --git a/proxy/ui.coffee b/proxy/ui.coffee
index a47e224..e316e54 100644
--- a/proxy/ui.coffee
+++ b/proxy/ui.coffee
@@ -86,6 +86,9 @@ class WebExtUI extends UI
   onMessage: (m) =>
     @enabled = m.enabled
     update()
+    chrome.browserAction.setIcon
+      path:
+        32: "icons/status-" + (if @enabled then "on" else "off") + ".png"
     @postActive()
 
   onDisconnect: (port) =>
@@ -95,6 +98,3 @@ class WebExtUI extends UI
     super connected
     if connected then @stats[0] += 1
     @postActive()
-    chrome.browserAction.setIcon
-      path:
-        32: "icons/status-" + (if connected then "on" else "off") + ".png"
diff --git a/proxy/webext/popup.js b/proxy/webext/popup.js
index f02bdff..b926f75 100644
--- a/proxy/webext/popup.js
+++ b/proxy/webext/popup.js
@@ -6,17 +6,19 @@ port.onMessage.addListener((m) => {
 	const active = m.active;
 	const div = document.getElementById('active');
 	const img = div.querySelector('img');
-	img.src = `icons/status-${active ? "on" : "off"}.png`;
+        const enabled = m.enabled
+	img.src = `icons/status-${enabled ? "on" : "off"}.png`;
 	const ps = div.querySelectorAll('p');
 	const clients = active ? 1 : 0;
-	ps[0].innerText = `${clients} client${(clients !== 1) ? 's' : ''} connected.`;
-	ps[1].innerText = `Your snowflake has helped ${m.total} user${(m.total !== 1) ? 's' : ''} circumvent censorship in the last 24 hours.`;
-        const enabled = m.enabled
         const enabledText = document.getElementById('toggle');
         if (enabled) {
             document.getElementById('enabled').checked = true;
             enabledText.innerText = 'Turn Off';
+            ps[0].innerText = `${clients} client${(clients !== 1) ? 's' : ''} connected.`;
+            ps[1].innerText = `Your snowflake has helped ${m.total} user${(m.total !== 1) ? 's' : ''} circumvent censorship in the last 24 hours.`;
         } else {
+            ps[0].innerText = "Snowflake is off";
+            ps[1].innerText = "";
             document.getElementById('enabled').checked = false;
             enabledText.innerText = 'Turn On';
         }





More information about the tor-commits mailing list