[tor-commits] [snowflake/master] Fix ui.coffee debug mode message log

serene at torproject.org serene at torproject.org
Sun Feb 7 01:29:26 UTC 2016


commit e0081ea9540996fad835eabf03479f280c1c5e97
Author: Serene Han <keroserene+git at gmail.com>
Date:   Sat Feb 6 17:28:23 2016 -0800

    Fix ui.coffee debug mode message log
---
 proxy/Cakefile         |  4 ++--
 proxy/snowflake.coffee |  2 +-
 proxy/ui.coffee        | 13 +++++++------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/proxy/Cakefile b/proxy/Cakefile
index a41b55b..97d7978 100644
--- a/proxy/Cakefile
+++ b/proxy/Cakefile
@@ -21,10 +21,10 @@ STATIC = 'static'
 
 concatCoffeeFiles = -> exec 'cat ' + FILES.join(' ') + ' | cat > ' + OUTFILE
 
-copyStaticFiles = -> exec '' + STATIC + '/* build/'
+copyStaticFiles = -> exec 'cp ' + STATIC + '/* build/'
 
 compileCoffee = ->
-  exec 'coffee -o build -b -c build/snowflake.coffee', (err, stdout, stderr) ->
+  exec 'coffee -o build -cb ' + OUTFILE, (err, stdout, stderr) ->
     throw err if err
 
 task 'test', 'snowflake unit tests', ->
diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee
index eea1518..e49b375 100644
--- a/proxy/snowflake.coffee
+++ b/proxy/snowflake.coffee
@@ -192,7 +192,7 @@ log = (msg) ->
   console.log 'Snowflake: ' + msg
   ui.log msg
 
-dbg = (msg) -> log msg if ui.debug
+dbg = (msg) -> log msg if true == ui.debug
 
 init = ->
   ui = new UI()
diff --git a/proxy/ui.coffee b/proxy/ui.coffee
index 648a88e..f951f67 100644
--- a/proxy/ui.coffee
+++ b/proxy/ui.coffee
@@ -13,8 +13,8 @@ class UI
 
   constructor: ->
     @$badge = document.getElementById('badge')
-    debug = !@$badge
-    return if !debug
+    @debug = null == @$badge
+    return if !@debug
 
     # Setup other DOM handlers if it's debug mode.
     @$status = document.getElementById('status')
@@ -26,15 +26,16 @@ class UI
 
     @$input = document.getElementById('input')
     @$input.focus()
-    @$input.onkeydown = (e) -> @$send.onclick() if 13 == e.keyCode  # enter
+    @$input.onkeydown = (e) =>
+      @$send.onclick() if 13 == e.keyCode  # enter
 
   # Status bar
   setStatus: (msg) =>
-    return if !debug
+    return if !@debug
     @$status.innerHTML = 'Status: ' + msg
 
   setActive: (connected) =>
-    if debug
+    if @debug
       @$msglog.className = if connected then 'active' else ''
     else
       @$badge.className = if connected then 'active' else ''
@@ -55,7 +56,7 @@ class UI
     @$input.focus()
 
   log: (msg) =>
-    return if !debug
+    return if !@debug
     # Scroll to latest
     @$msglog.value += msg + '\n'
     @$msglog.scrollTop = @$msglog.scrollHeight



More information about the tor-commits mailing list