aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-09-15 20:10:11 -0700
committerAlex Yatskov <alex@foosoft.net>2016-09-15 20:10:11 -0700
commit7069f428eee7134416bb72ea4f7a7ec3e214a465 (patch)
tree198f40745708c8bb3d7f4a3a2a6c3ba8d4d697e7 /ext/bg
parent3608c9c16e7154802bacbf38356fd4f36824e267 (diff)
Cleanup
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/import.html2
-rw-r--r--ext/bg/js/import.js13
-rw-r--r--ext/bg/js/options.js10
-rw-r--r--ext/bg/js/yomichan.js2
4 files changed, 21 insertions, 6 deletions
diff --git a/ext/bg/import.html b/ext/bg/import.html
index 47483c25..85841eee 100644
--- a/ext/bg/import.html
+++ b/ext/bg/import.html
@@ -15,7 +15,7 @@
<p>Importing dictionary data, this can take a while...</p>
<div class="progress">
- <div class="progress-bar" style="width: 0%" />
+ <div class="progress-bar progress-bar-striped" style="width: 0%">0%</div>
</div>
</div>
diff --git a/ext/bg/js/import.js b/ext/bg/js/import.js
index 905b4580..ebc7c7be 100644
--- a/ext/bg/js/import.js
+++ b/ext/bg/js/import.js
@@ -17,7 +17,16 @@
*/
-chrome.runtime.onMessage.addListener(({state, progress}, sender, callback) => {
- $('.progress-bar').css('width', progress + '%');
+function api_setProgress({state, progress}) {
+ const str = `${progress}%`;
+ $('.progress-bar').css('width', str).text(str);
+}
+
+chrome.runtime.onMessage.addListener(({action, params}, sender, callback) => {
+ const method = this['api_' + action];
+ if (typeof(method) === 'function') {
+ method.call(this, params);
+ }
+
callback();
});
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 290b5b05..83eb1f0a 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -47,9 +47,15 @@ function sanitizeOptions(options) {
}
function loadOptions() {
- return new Promise((resolve, reject) => chrome.storage.sync.get(null, resolve));
+ return new Promise((resolve, reject) => {
+ chrome.storage.sync.get(null, opts => {
+ resolve(sanitizeOptions(opts));
+ });
+ });
}
function saveOptions(opts) {
- return new Promise((resolve, reject) => chrome.storage.sync.set(sanitizeOptions(opts), resolve));
+ return new Promise((resolve, reject) => {
+ chrome.storage.sync.set(sanitizeOptions(opts), resolve);
+ });
}
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index bec34691..24ddf92d 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -54,7 +54,7 @@ class Yomichan {
}
if (this.importTabId !== null) {
- chrome.tabs.sendMessage(this.importTabId, {state, progress}, () => null);
+ this.tabInvoke(this.importTabId, 'setProgress', {state, progress});
}
if (state === 'end') {