From ce49a126cf156d6886e664f80417a2b65ff118ba Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Wed, 14 Sep 2016 21:08:51 -0700 Subject: Progress bar --- ext/bg/import.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 ext/bg/import.html (limited to 'ext/bg/import.html') diff --git a/ext/bg/import.html b/ext/bg/import.html new file mode 100644 index 00000000..47483c25 --- /dev/null +++ b/ext/bg/import.html @@ -0,0 +1,25 @@ + + + + + Yomichan Dictionary Import + + + + +
+ + +

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

+ +
+
+
+
+ + + + + -- cgit v1.2.3 From 7069f428eee7134416bb72ea4f7a7ec3e214a465 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Thu, 15 Sep 2016 20:10:11 -0700 Subject: Cleanup --- ext/bg/import.html | 2 +- ext/bg/js/import.js | 13 +++++++++++-- ext/bg/js/options.js | 10 ++++++++-- ext/bg/js/yomichan.js | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'ext/bg/import.html') 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 @@

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

-
+
0%
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') { -- cgit v1.2.3 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/import.html') 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 From 4e2d7327c5b1aa8eed035dc4c177a3b9b49c5ab7 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 18 Sep 2016 19:49:59 -0700 Subject: Bumping version number --- ext/bg/import.html | 2 +- ext/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/bg/import.html') diff --git a/ext/bg/import.html b/ext/bg/import.html index 3dcdfdbd..b5d2db68 100644 --- a/ext/bg/import.html +++ b/ext/bg/import.html @@ -45,7 +45,7 @@
  1. Left-click on the icon to enable or disable Yomichan for the current browser instance.
  2. Right-click on the icon and select Options to open the Yomichan options page.
  3. -
  4. Hold down Shift or the middle mouse button as you move your cursor over text to see definitions.
  5. +
  6. Hold down Shift or the middle mouse button as you move your cursor over text to see definitions (or Shift + Ctrl for Kanji).
  7. Resize the definitions window by dragging the bottom-left corner inwards or outwards.
  8. Click on Kanji in the definition window to view additional information about that character.
diff --git a/ext/manifest.json b/ext/manifest.json index fcf7cef7..f8c55172 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Yomichan", - "version": "0.97", + "version": "0.98", "description": "Japanese dictionary with Anki integration", "icons": {"16": "img/icon16.png", "48": "img/icon48.png", "128": "img/icon128.png"}, -- cgit v1.2.3