summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-09-16 20:28:59 -0700
committerAlex Yatskov <alex@foosoft.net>2016-09-16 20:28:59 -0700
commitc05f7a7c1cb9f25e3658ced51aefd61233f65bd3 (patch)
treed0c147a300f02244b0172776e11acbf864d817de /ext/bg/js
parentdc273c0c73dd39e8cad45e591b02231cb2cbed8c (diff)
Work on progress bar
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/deinflector.js4
-rw-r--r--ext/bg/js/import.js10
-rw-r--r--ext/bg/js/yomichan.js9
3 files changed, 12 insertions, 11 deletions
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js
index e5b1efe5..8b9f88e2 100644
--- a/ext/bg/js/deinflector.js
+++ b/ext/bg/js/deinflector.js
@@ -66,6 +66,10 @@ class Deinflection {
}
const term = this.term.slice(0, -variant.ki.length) + variant.ko;
+ if (term.length === 0) {
+ continue;
+ }
+
const child = new Deinflection(term, variant.to, rule);
promises.push(
child.deinflect(validator, rules).then(valid => {
diff --git a/ext/bg/js/import.js b/ext/bg/js/import.js
index ebc7c7be..0601cb9f 100644
--- a/ext/bg/js/import.js
+++ b/ext/bg/js/import.js
@@ -17,9 +17,13 @@
*/
-function api_setProgress({state, progress}) {
- const str = `${progress}%`;
- $('.progress-bar').css('width', str).text(str);
+function api_setProgress(progress) {
+ $('.progress-bar').css('width', `${progress}%`);
+
+ if (progress === 100.0) {
+ $('.progress').hide();
+ $('.alert').show();
+ }
}
chrome.runtime.onMessage.addListener(({action, params}, sender, callback) => {
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 24ddf92d..f1b3ffc4 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -28,7 +28,6 @@ class Yomichan {
this.ankiConnectVer = 0;
this.setState('disabled');
- chrome.runtime.onInstalled.addListener(this.onInstalled.bind(this));
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
chrome.tabs.onCreated.addListener(tab => this.onTabReady(tab.id));
@@ -42,19 +41,13 @@ class Yomichan {
});
}
- onInstalled(details) {
- if (details.reason === 'install') {
- chrome.tabs.create({url: chrome.extension.getURL('bg/guide.html')});
- }
- }
-
onImport({state, progress}) {
if (state === 'begin') {
chrome.tabs.create({url: chrome.extension.getURL('bg/import.html')}, tab => this.importTabId = tab.id);
}
if (this.importTabId !== null) {
- this.tabInvoke(this.importTabId, 'setProgress', {state, progress});
+ this.tabInvoke(this.importTabId, 'setProgress', progress);
}
if (state === 'end') {