This commit is contained in:
Alex Yatskov 2016-09-15 20:10:11 -07:00
parent 3608c9c16e
commit 7069f428ee
4 changed files with 21 additions and 6 deletions

View File

@ -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>

View File

@ -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();
});

View File

@ -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);
});
}

View File

@ -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') {