summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhackademix <giorgio@maone.net>2016-11-03 17:31:56 +0100
committerhackademix <giorgio@maone.net>2016-11-03 17:31:56 +0100
commit01dd3b5da91722c4c3a531fbc92160ef6e7d953e (patch)
tree4f83c567c367da2bc7e4e931a3cb18c9c819273b
parentf024097253ead33b1a2d8397829307dff08def79 (diff)
Bug #11268 - Make .download-again buttons reset download to step 1
-rw-r--r--build.sh5
-rw-r--r--tails-download-and-verify/data/download-page.js38
-rw-r--r--tails-download-and-verify/index.js3
-rw-r--r--tails-download-and-verify/lib/downloader.js10
-rw-r--r--tails-download-and-verify/package.json2
-rw-r--r--www/dave.xpibin19043 -> 22776 bytes
-rw-r--r--www/download.html2
7 files changed, 36 insertions, 24 deletions
diff --git a/build.sh b/build.sh
index 13ab33e..231b711 100644
--- a/build.sh
+++ b/build.sh
@@ -2,6 +2,7 @@
base=$(dirname "$0")
dir="$base/tails-download-and-verify"
mirror_dispatcher_url='https://git-tails.immerda.ch/mirror-pool-dispatcher/plain/lib/js/mirror-dispatcher.js'
+mirror_dispatcher_file="lib/mirror-dispatcher.js"
pushd "$dir" >/dev/null 2>&1 || (
echo >&2 "FATAL: Channot chdir to $dir."
exit 1
@@ -10,10 +11,10 @@ echo -n "Removing old XPIs... "
rm -f *.xpi >/dev/null && echo "done."
ver=$(egrep '"version": "[0-9]+\.[^"]+"' package.json | sed -re 's/.*"([0-9]+\.[^"]+)".*/\1/')
echo "Importing mirror-dispatcher.js library"
-curl \
+[ -f "$mirror_dispatcher_file" ] || curl \
--proto -all,https \
--tlsv1 \
- --output "lib/mirror-dispatcher.js" \
+ --output "$mirror_dispatcher_file" \
"$mirror_dispatcher_url"
echo "Building extension version $ver"
jpm xpi || exit 2
diff --git a/tails-download-and-verify/data/download-page.js b/tails-download-and-verify/data/download-page.js
index 0c181f6..5a6f434 100644
--- a/tails-download-and-verify/data/download-page.js
+++ b/tails-download-and-verify/data/download-page.js
@@ -193,7 +193,6 @@ initWidgets = (status) => {
}
}
on("a.iso-url", "click", e => {
- e.preventDefault();
if (/-retry$/.test(e.target.id)) return;
Download.cmd('start', { prompt: e.target.title });
});
@@ -201,30 +200,24 @@ initWidgets = (status) => {
for (let action of ['pause', 'resume', 'cancel']) {
let cmd = action;
on(`#download-button-state-${cmd}`, "click", e => {
- e.preventDefault();
- Download.cmd(cmd);
+ if (/\bdownload-again\b/.test(e.target.className)) {
+ Download.reset();
+ } else {
+ Download.cmd(cmd);
+ }
});
}
+ on(".download-again", "click", e => Download.reset());
+ on("#download-button-state-retry", "click", e => Download.retry());
- on("#download-button-state-retry", "click", e => {
- e.preventDefault();
- Download.cmd('retry');
- });
-
- on("#i_have_iso", "click", e => {
- e.preventDefault();
- Download.cmd('verify', { prompt: e.target.title });
- });
+ on("#i_have_iso", "click", e => Download.cmd('verify', { prompt: e.target.title }));
- on("#verify-text-success .btn", "click", e => {
- // if (verifySuccess) Download.cmd('reveal', { path: verifySuccess });
- e.preventDefault();
- Download.cmd('retry');
- });
+ on("#verify-text-success .btn", "click", e => Download.cmd('retry'));
initWidgets = null;
},
Download = {
+ resetting: false,
start() {
toggle("#download-eta, #download-path", false);
@@ -232,6 +225,12 @@ Download = {
document.documentElement.dataset.phase = "started";
this.cmd('init');
},
+
+ reset() {
+ this.resetting = true;
+ this.cmd("reset");
+ },
+
cmd(cmd, data) {
console.log(`Sending command Download.${cmd}`);
self.port.emit("download-control", Object.assign({ cmd, page: document.URL, domain: document.domain }, data));
@@ -267,6 +266,11 @@ Download = {
case 'verified':
updateVerifyView(status);
break;
+ case 'init':
+ if (Download.resetting) {
+ reload();
+ }
+ break;
}
document.documentElement.dataset.phase = status.phase;
diff --git a/tails-download-and-verify/index.js b/tails-download-and-verify/index.js
index 771ee93..4c4861a 100644
--- a/tails-download-and-verify/index.js
+++ b/tails-download-and-verify/index.js
@@ -3,7 +3,7 @@ var self = require('sdk/self');
var downloader = null;
var workers = new Set();
-var Config = require("../conf.json");
+var Config = require("conf.json");
if (Config.pinGlobally) {
require("./lib/cert-pinner").pinGlobally(Config.pins);
@@ -30,6 +30,7 @@ function onUI(msg) {
case "cancel":
case "resume":
case "retry":
+ case "reset":
downloader[msg.cmd].call(downloader, msg.page);
break;
case "verify":
diff --git a/tails-download-and-verify/lib/downloader.js b/tails-download-and-verify/lib/downloader.js
index 1eaf056..35f0bfd 100644
--- a/tails-download-and-verify/lib/downloader.js
+++ b/tails-download-and-verify/lib/downloader.js
@@ -258,8 +258,8 @@ var Verify = {
status.phase = 'verifying';
status.failed = false;
},
- get working() status.phase === 'verifying',
- get done() status.phase === 'verified',
+ get working() { return status.phase === 'verifying' },
+ get done() { return status.phase === 'verified' },
onProgressUnclamped(read, total) {
if (!Verify.working) return;
@@ -524,6 +524,12 @@ var api = {
downloadList.removeView(downloadView);
downloadList = downloadView = null;
}
+ },
+
+ reset() {
+ this.cancel();
+ reset();
+ notify();
}
};
diff --git a/tails-download-and-verify/package.json b/tails-download-and-verify/package.json
index 7d853f7..28dce46 100644
--- a/tails-download-and-verify/package.json
+++ b/tails-download-and-verify/package.json
@@ -3,7 +3,7 @@
"id": "dave@tails.boum.org",
"name": "tails-download-and-verify",
"homepage": "https://tails.boum.org",
- "version": "0.2.7rc60",
+ "version": "0.2.8rc1",
"description": "A browser extension to download and verify Tails ISO images",
"main": "index.js",
"permissions": {
diff --git a/www/dave.xpi b/www/dave.xpi
index bcd34fe..753a80e 100644
--- a/www/dave.xpi
+++ b/www/dave.xpi
Binary files differ
diff --git a/www/download.html b/www/download.html
index 73fc652..99a93f7 100644
--- a/www/download.html
+++ b/www/download.html
@@ -250,7 +250,7 @@ For your security, it is very important to also verify your download. We propose
two techniques to do this verification automatically.</p>
<div id="download-and-verify" class="chrome-unsupported">
- <div id="extension-version">0.2.7rc60</div>
+ <div id="extension-version">0.2.8rc1</div>
<div id="undetected-browser">
<p>We failed to detect your browser vendor, maybe because JavaScript is disabled.</p>