[tor-launcher/master] Bug 12444: Feedback when “Copy Tor Log” is clicked.

brade at torproject.org brade at torproject.org
Wed Aug 20 12:25:06 UTC 2014


commit 561440e8d64ca9b60f09d2b6869c4d07c5d06834
Author: Kathy Brade <brade at pearlcrescent.com>
Date:   Wed Aug 20 08:21:45 2014 -0400

    Bug 12444: Feedback when “Copy Tor Log” is clicked.
    
    Show a transient popup near the "Copy Tor Log To Clipboard" button after
    is is clicked.  The popup panel fades away after 4 seconds and can also
    be dismissed by clicking anywhere.
---
 src/chrome/content/network-settings-overlay.xul |    4 ++++
 src/chrome/content/network-settings-wizard.xul  |    1 +
 src/chrome/content/network-settings.js          |   23 ++++++++++++++++++++++-
 src/chrome/content/network-settings.xul         |    1 +
 src/chrome/locale/en/torlauncher.properties     |    2 ++
 src/chrome/skin/network-settings.css            |    5 +++++
 src/components/tl-protocol.js                   |    8 ++++++--
 7 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/src/chrome/content/network-settings-overlay.xul b/src/chrome/content/network-settings-overlay.xul
index 6422802..c9a6a82 100644
--- a/src/chrome/content/network-settings-overlay.xul
+++ b/src/chrome/content/network-settings-overlay.xul
@@ -124,5 +124,9 @@
       </html:li>
     </html:ol>
   </vbox>
+  <panel id="copyLogFeedbackPanel" type="arrow" fade="slow"
+         onclick="closeCopyLogFeedbackPanel()">
+     <description flex="1" />
+  </panel>
 </overlay>
 
diff --git a/src/chrome/content/network-settings-wizard.xul b/src/chrome/content/network-settings-wizard.xul
index 70d1bcf..6682fdd 100644
--- a/src/chrome/content/network-settings-wizard.xul
+++ b/src/chrome/content/network-settings-wizard.xul
@@ -189,4 +189,5 @@
   <hbox pack="start">
     <label id="forAssistance" />
   </hbox>
+  <panel id="copyLogFeedbackPanel" />
 </wizard>
diff --git a/src/chrome/content/network-settings.js b/src/chrome/content/network-settings.js
index 5f3f698..518d16d 100644
--- a/src/chrome/content/network-settings.js
+++ b/src/chrome/content/network-settings.js
@@ -713,9 +713,30 @@ function onCancel()
 
 function onCopyLog()
 {
+  // Copy tor log messages to the system clipboard.
   var chSvc = Cc["@mozilla.org/widget/clipboardhelper;1"]
                              .getService(Ci.nsIClipboardHelper);
-  chSvc.copyString(gProtocolSvc.TorGetLog());
+  let countObj = { value: 0 };
+  chSvc.copyString(gProtocolSvc.TorGetLog(countObj));
+
+  // Display a feedback popup that fades away after a few seconds.
+  let forAssistance = document.getElementById("forAssistance");
+  let panel = document.getElementById("copyLogFeedbackPanel");
+  if (forAssistance && panel)
+  {
+    panel.firstChild.textContent = TorLauncherUtil.getFormattedLocalizedString(
+                                     "copiedNLogMessages", [countObj.value], 1);
+    let rectObj = forAssistance.getBoundingClientRect();
+    panel.openPopup(null, null, rectObj.left, rectObj.top, false, false);
+  }
+}
+
+
+function closeCopyLogFeedbackPanel()
+{
+  let panel = document.getElementById("copyLogFeedbackPanel");
+  if (panel && (panel.state =="open"))
+    panel.hidePopup();
 }
 
 
diff --git a/src/chrome/content/network-settings.xul b/src/chrome/content/network-settings.xul
index a81a5f0..4f98559 100644
--- a/src/chrome/content/network-settings.xul
+++ b/src/chrome/content/network-settings.xul
@@ -85,4 +85,5 @@
   </deck>
   <spring flex="1" />
   <label id="forAssistance" />
+  <panel id="copyLogFeedbackPanel" />
 </dialog>
diff --git a/src/chrome/locale/en/torlauncher.properties b/src/chrome/locale/en/torlauncher.properties
index 816d831..20f6db2 100644
--- a/src/chrome/locale/en/torlauncher.properties
+++ b/src/chrome/locale/en/torlauncher.properties
@@ -37,6 +37,8 @@ torlauncher.done=Done
 
 torlauncher.forAssistance=For assistance, contact %S
 
+torlauncher.copiedNLogMessages=Copy complete. %S tor log messages are ready to be pasted into a text editor or an email message.
+
 torlauncher.bootstrapStatus.conn_dir=Connecting to a relay directory
 torlauncher.bootstrapStatus.handshake_dir=Establishing an encrypted directory connection
 torlauncher.bootstrapStatus.requesting_status=Retrieving network status
diff --git a/src/chrome/skin/network-settings.css b/src/chrome/skin/network-settings.css
index 03f84d7..60f1ef2 100644
--- a/src/chrome/skin/network-settings.css
+++ b/src/chrome/skin/network-settings.css
@@ -148,6 +148,11 @@ dialog .help {
   margin-bottom: 8px;
 }
 
+#copyLogFeedbackPanel {
+  margin: -15px 0px 0px 0px;
+  max-width: 34em;
+}
+
 /* Increase font size on Windows for readability */
 .os-windows div,
 .os-windows label,
diff --git a/src/components/tl-protocol.js b/src/components/tl-protocol.js
index 9c4d957..09ec468 100644
--- a/src/components/tl-protocol.js
+++ b/src/components/tl-protocol.js
@@ -458,7 +458,8 @@ TorProtocolService.prototype =
   },
 
   // Returns captured log message as a text string (one message per line).
-  TorGetLog: function()
+  // If aCountObj is passed, aCountObj.value is set to the message count.
+  TorGetLog: function(aCountObj)
   {
     let s = "";
     if (this.mTorLog)
@@ -468,7 +469,10 @@ TorProtocolService.prototype =
       let dateFormat = dateFmtSvc.dateFormatShort;
       let timeFormat = dateFmtSvc.timeFormatSecondsForce24Hour;
       let eol = (TorLauncherUtil.isWindows) ? "\r\n" : "\n";
-      for (let i = 0; i < this.mTorLog.length; ++i)
+      let count = this.mTorLog.length;
+      if (aCountObj)
+        aCountObj.value = count;
+      for (let i = 0; i < count; ++i)
       {
         let logObj = this.mTorLog[i];
         let secs = logObj.date.getSeconds();



More information about the tbb-commits mailing list