This commit is contained in:
Alex Yatskov 2017-07-19 21:41:30 -07:00
parent fe137e94c9
commit ac2e079c98
8 changed files with 12 additions and 35 deletions

View File

@ -10,7 +10,7 @@
<script src="/mixed/lib/jszip.min.js"></script>
<script src="/mixed/js/audio.js"></script>
<script src="/bg/js/templates.js"></script>
<script src="/bg/js/util.js"></script>
<script src="/bg/js/instance.js"></script>
<script src="/bg/js/handlebars.js"></script>
<script src="/bg/js/dictionary.js"></script>
<script src="/mixed/js/japanese.js"></script>

View File

@ -17,19 +17,6 @@
*/
/*
* Commands
*/
function commandExec(command) {
instYomi().onCommand(command);
}
/*
* Instance
*/
function instYomi() {
return chrome.extension.getBackgroundPage().yomichan;
}
@ -41,20 +28,3 @@ function instDb() {
function instAnki() {
return instYomi().anki;
}
/*
* Foreground
*/
function fgBroadcast(action, params) {
chrome.tabs.query({}, tabs => {
for (const tab of tabs) {
chrome.tabs.sendMessage(tab.id, {action, params}, () => null);
}
});
}
function fgOptionsSet(options) {
fgBroadcast('optionsSet', options);
}

View File

@ -127,6 +127,5 @@ function optionsSave(options) {
chrome.storage.local.set({options: JSON.stringify(options)}, resolve);
}).then(() => {
instYomi().optionsSet(options);
fgOptionsSet(options);
});
}

View File

@ -18,6 +18,8 @@
$(document).ready(() => {
const commandExec = command => instYomi().onCommand(command);
$('#open-search').click(() => commandExec('search'));
$('#open-options').click(() => commandExec('options'));
$('#open-help').click(() => commandExec('help'));

View File

@ -59,6 +59,12 @@ window.yomichan = new class {
} else {
this.anki = new AnkiNull();
}
chrome.tabs.query({}, tabs => {
for (const tab of tabs) {
chrome.tabs.sendMessage(tab.id, {action: 'optionsSet', params: options}, () => null);
}
});
}
noteFormat(definition, mode) {

View File

@ -30,7 +30,7 @@
<script src="/mixed/lib/jquery.min.js"></script>
<script src="/mixed/lib/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="/mixed/lib/handlebars.min.js"></script>
<script src="/bg/js/util.js"></script>
<script src="/bg/js/instance.js"></script>
<script src="/bg/js/dictionary.js"></script>
<script src="/mixed/js/request.js"></script>
<script src="/mixed/js/japanese.js"></script>

View File

@ -33,7 +33,7 @@
</div>
<script src="/mixed/lib/jquery.min.js"></script>
<script src="/bg/js/util.js"></script>
<script src="/bg/js/instance.js"></script>
<script src="/bg/js/dictionary.js"></script>
<script src="/mixed/js/request.js"></script>
<script src="/mixed/js/japanese.js"></script>

View File

@ -276,7 +276,7 @@
<script src="/mixed/lib/bootstrap/js/bootstrap.min.js"></script>
<script src="/mixed/lib/handlebars.min.js"></script>
<script src="/bg/js/templates.js"></script>
<script src="/bg/js/util.js"></script>
<script src="/bg/js/instance.js"></script>
<script src="/bg/js/handlebars.js"></script>
<script src="/bg/js/dictionary.js"></script>
<script src="/mixed/js/japanese.js"></script>