Cleanup
This commit is contained in:
parent
3608c9c16e
commit
7069f428ee
@ -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>
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -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') {
|
||||
|
Loading…
Reference in New Issue
Block a user