aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/background.html2
-rw-r--r--ext/bg/js/instance.js (renamed from ext/bg/js/util.js)30
-rw-r--r--ext/bg/js/options.js1
-rw-r--r--ext/bg/js/popup.js2
-rw-r--r--ext/bg/js/yomichan.js6
-rw-r--r--ext/bg/popup.html2
-rw-r--r--ext/bg/search.html2
-rw-r--r--ext/bg/settings.html2
8 files changed, 12 insertions, 35 deletions
diff --git a/ext/bg/background.html b/ext/bg/background.html
index 7d352561..de3cbf20 100644
--- a/ext/bg/background.html
+++ b/ext/bg/background.html
@@ -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>
diff --git a/ext/bg/js/util.js b/ext/bg/js/instance.js
index c7ebbb0e..0df267cc 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/instance.js
@@ -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);
-}
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index a9345fdd..d611ae59 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -127,6 +127,5 @@ function optionsSave(options) {
chrome.storage.local.set({options: JSON.stringify(options)}, resolve);
}).then(() => {
instYomi().optionsSet(options);
- fgOptionsSet(options);
});
}
diff --git a/ext/bg/js/popup.js b/ext/bg/js/popup.js
index 8577dd96..01994827 100644
--- a/ext/bg/js/popup.js
+++ b/ext/bg/js/popup.js
@@ -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'));
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index eb083396..214bdef3 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -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) {
diff --git a/ext/bg/popup.html b/ext/bg/popup.html
index b3d38533..baeb2ffb 100644
--- a/ext/bg/popup.html
+++ b/ext/bg/popup.html
@@ -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>
diff --git a/ext/bg/search.html b/ext/bg/search.html
index 45603f17..472907c2 100644
--- a/ext/bg/search.html
+++ b/ext/bg/search.html
@@ -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>
diff --git a/ext/bg/settings.html b/ext/bg/settings.html
index 4c7198c3..9c3995eb 100644
--- a/ext/bg/settings.html
+++ b/ext/bg/settings.html
@@ -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>