Commit 561440e8 authored by Kathleen Brade's avatar Kathleen Brade
Browse files

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.
parent fb7e0576
......@@ -124,5 +124,9 @@
</html:li>
</html:ol>
</vbox>
<panel id="copyLogFeedbackPanel" type="arrow" fade="slow"
onclick="closeCopyLogFeedbackPanel()">
<description flex="1" />
</panel>
</overlay>
......@@ -189,4 +189,5 @@
<hbox pack="start">
<label id="forAssistance" />
</hbox>
<panel id="copyLogFeedbackPanel" />
</wizard>
......@@ -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();
}
......
......@@ -85,4 +85,5 @@
</deck>
<spring flex="1" />
<label id="forAssistance" />
<panel id="copyLogFeedbackPanel" />
</dialog>
......@@ -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
......
......@@ -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,
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment