From c05f7a7c1cb9f25e3658ced51aefd61233f65bd3 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 16 Sep 2016 20:28:59 -0700 Subject: Work on progress bar --- ext/bg/guide.html | 29 ----------------------------- ext/bg/import.html | 45 +++++++++++++++++++++++++++++++++++++++++---- ext/bg/js/deinflector.js | 4 ++++ ext/bg/js/import.js | 10 +++++++--- ext/bg/js/yomichan.js | 9 +-------- 5 files changed, 53 insertions(+), 44 deletions(-) delete mode 100644 ext/bg/guide.html (limited to 'ext/bg') diff --git a/ext/bg/guide.html b/ext/bg/guide.html deleted file mode 100644 index a3fa8221..00000000 --- a/ext/bg/guide.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - Yomichan Guide - - - - -
- - - -

This is a minimal guide to get you started with Yomichan. For complete documentation, visit the official homepage.

- -
    -
  1. Left-click on the icon to enable or disable Yomichan for the current browser instance.
  2. -
  3. Right-click on the icon and select Options to open the Yomichan options page.
  4. -
  5. Hold down Shift or the middle mouse button as you move your cursor over text to see definitions.
  6. -
  7. Resize the definition window by dragging the bottom-left corner inwards or outwards.
  8. -
  9. Click on Kanji in the definition window to view additional information about that character.
  10. -
- -

Enjoy!

-
- - diff --git a/ext/bg/import.html b/ext/bg/import.html index 85841eee..3dcdfdbd 100644 --- a/ext/bg/import.html +++ b/ext/bg/import.html @@ -5,18 +5,55 @@ Yomichan Dictionary Import +
-

Importing dictionary data, this can take a while...

+

Thank you for downloading this extension! I sincerely hope that it will assist you on your language learning journey.

-
-
0%
+
+

Dictionary Import

+ +

+ Before it can be used for the first time, Yomichan must import the Japanese dictionary data included with this extension. This process can take a + couple of minutes to finish so please be patient! Please do not completely exit out of your browser until this process completes. +

+ +
+
+
+ +
Dictionary import complete!
+ +
+

Quick Guide

+ +

+ Please read the steps outlined below to get quickly get up and running with Yomichan. For complete documentation, + visit the official homepage. +

+ +
    +
  1. Left-click on the icon to enable or disable Yomichan for the current browser instance.
  2. +
  3. Right-click on the icon and select Options to open the Yomichan options page.
  4. +
  5. Hold down Shift or the middle mouse button as you move your cursor over text to see definitions.
  6. +
  7. Resize the definitions window by dragging the bottom-left corner inwards or outwards.
  8. +
  9. Click on Kanji in the definition window to view additional information about that character.
  10. +
+
+ +
+ +

よろしくね!

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') { -- cgit v1.2.3