aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-07-16 12:48:27 -0700
committerAlex Yatskov <alex@foosoft.net>2017-07-16 12:48:27 -0700
commit516c7f5381700700dcfdfb06682f11de8205137b (patch)
treec8d15b000dfdd6ba066a0de6c517229865177d24 /ext
parent1ed8997240ba5d8ee4fe57062d2dbe8ba46436e2 (diff)
refactor mixed/js/util.js
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/background.html2
-rw-r--r--ext/bg/search.html2
-rw-r--r--ext/fg/frame.html2
-rw-r--r--ext/mixed/js/audio.js (renamed from ext/mixed/js/util.js)19
-rw-r--r--ext/mixed/js/display.js18
5 files changed, 19 insertions, 24 deletions
diff --git a/ext/bg/background.html b/ext/bg/background.html
index 4410c249..4a2d8c8d 100644
--- a/ext/bg/background.html
+++ b/ext/bg/background.html
@@ -8,7 +8,7 @@
<script src="/mixed/lib/dexie.min.js"></script>
<script src="/mixed/lib/wanakana.min.js"></script>
<script src="/mixed/lib/jszip.min.js"></script>
- <script src="/mixed/js/util.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/anki-connect.js"></script>
diff --git a/ext/bg/search.html b/ext/bg/search.html
index 4c07ee61..0fc3caf7 100644
--- a/ext/bg/search.html
+++ b/ext/bg/search.html
@@ -34,7 +34,7 @@
<script src="/mixed/lib/jquery.min.js"></script>
<script src="/bg/js/util.js"></script>
- <script src="/mixed/js/util.js"></script>
+ <script src="/mixed/js/audio.js"></script>
<script src="/mixed/js/display.js"></script>
<script src="/mixed/lib/wanakana.min.js"></script>
<script src="/bg/js/display-window.js"></script>
diff --git a/ext/fg/frame.html b/ext/fg/frame.html
index c20745af..ecaee323 100644
--- a/ext/fg/frame.html
+++ b/ext/fg/frame.html
@@ -33,7 +33,7 @@
<script src="/mixed/lib/jquery.min.js"></script>
<script src="/mixed/lib/wanakana.min.js"></script>
<script src="/fg/js/util.js"></script>
- <script src="/mixed/js/util.js"></script>
+ <script src="/mixed/js/audio.js"></script>
<script src="/mixed/js/display.js"></script>
<script src="/fg/js/display-frame.js"></script>
</body>
diff --git a/ext/mixed/js/util.js b/ext/mixed/js/audio.js
index 0a8c914d..451fe1d9 100644
--- a/ext/mixed/js/util.js
+++ b/ext/mixed/js/audio.js
@@ -18,25 +18,6 @@
/*
- * Cloze
- */
-
-function clozeBuild(sentence, source) {
- const result = {
- sentence: sentence.text.trim()
- };
-
- if (source) {
- result.prefix = sentence.text.substring(0, sentence.offset).trim();
- result.body = source.trim();
- result.suffix = sentence.text.substring(sentence.offset + source.length).trim();
- }
-
- return result;
-}
-
-
-/*
* Audio
*/
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index da0cd351..e54bc0f9 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -80,7 +80,7 @@ class Display {
if (context) {
for (const definition of definitions) {
if (context.sentence) {
- definition.cloze = clozeBuild(context.sentence, definition.source);
+ definition.cloze = Display.clozeBuild(context.sentence, definition.source);
}
definition.url = context.url;
@@ -119,7 +119,7 @@ class Display {
if (context) {
for (const definition of definitions) {
if (context.sentence) {
- definition.cloze = clozeBuild(context.sentence);
+ definition.cloze = Display.clozeBuild(context.sentence);
}
definition.url = context.url;
@@ -394,6 +394,20 @@ class Display {
}).catch(this.handleError.bind(this)).then(() => this.spinner.hide());
}
+ static clozeBuild(sentence, source) {
+ const result = {
+ sentence: sentence.text.trim()
+ };
+
+ if (source) {
+ result.prefix = sentence.text.substring(0, sentence.offset).trim();
+ result.body = source.trim();
+ result.suffix = sentence.text.substring(sentence.offset + source.length).trim();
+ }
+
+ return result;
+ }
+
static entryIndexFind(element) {
return $('.entry').index(element.closest('.entry'));
}