Work on progress bar

This commit is contained in:
Alex Yatskov 2016-09-16 20:28:59 -07:00
parent dc273c0c73
commit c05f7a7c1c
5 changed files with 53 additions and 44 deletions

View File

@ -1,29 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Yomichan Guide</title>
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Yomichan Guide</h1>
</div>
<p>This is a minimal guide to get you started with Yomichan. For complete documentation, visit the <a href="https://foosoft.net/projects/yomichan-chrome/">official homepage</a>.</p>
<ol>
<li>Left-click on the <img src="../img/icon16.png" alt> icon to enable or disable Yomichan for the current browser instance.</li>
<li>Right-click on the <img src="../img/icon16.png" alt> icon and select <em>Options</em> to open the Yomichan options page.</li>
<li>Hold down <kbd>Shift</kbd> or the middle mouse button as you move your cursor over text to see definitions.</li>
<li>Resize the definition window by dragging the bottom-left corner inwards or outwards.</li>
<li>Click on Kanji in the definition window to view additional information about that character.</li>
</ol>
<p>Enjoy!</p>
</div>
</body>
</html>

View File

@ -5,18 +5,55 @@
<title>Yomichan Dictionary Import</title>
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-3.3.6-dist/css/bootstrap-theme.min.css">
<style>
div.alert {
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="page-header">
<h1>Yomichan Dictionary Import</h1>
<h1>Welcome to Yomichan!</h1>
</div>
<p>Importing dictionary data, this can take a while...</p>
<p>Thank you for downloading this extension! I sincerely hope that it will assist you on your language learning journey.</p>
<div>
<h2>Dictionary Import</h2>
<p>
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.
</p>
<div class="progress">
<div class="progress-bar progress-bar-striped" style="width: 0%">0%</div>
<div class="progress-bar progress-bar-striped" style="width: 0%"></div>
</div>
<div class="alert alert-success">Dictionary import complete!</div>
</div>
<div>
<h2>Quick Guide</h2>
<p>
Please read the steps outlined below to get quickly get up and running with Yomichan. For complete documentation,
visit the <a href="https://foosoft.net/projects/yomichan-chrome/">official homepage</a>.
</p>
<ol>
<li>Left-click on the <img src="../img/icon16.png" alt> icon to enable or disable Yomichan for the current browser instance.</li>
<li>Right-click on the <img src="../img/icon16.png" alt> icon and select <em>Options</em> to open the Yomichan options page.</li>
<li>Hold down <kbd>Shift</kbd> or the middle mouse button as you move your cursor over text to see definitions.</li>
<li>Resize the definitions window by dragging the bottom-left corner inwards or outwards.</li>
<li>Click on Kanji in the definition window to view additional information about that character.</li>
</ol>
</div>
<br>
<p>よろしくね!</p>
</div>
<script src="../lib/jquery-2.2.2.min.js"></script>

View File

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

View File

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

View File

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