aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/backend.js9
-rw-r--r--ext/bg/js/search.js9
-rw-r--r--ext/bg/js/settings/popup-preview.js5
3 files changed, 16 insertions, 7 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index d23fda10..693a9ad6 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -496,7 +496,7 @@ class Backend {
async _onApiDefinitionAdd({definition, mode, context, details, optionsContext}) {
const options = this.getOptions(optionsContext);
- const templates = this.defaultAnkiFieldTemplates;
+ const templates = this._getTemplates(options);
if (mode !== 'kanji') {
const {customSourceUrl} = options.audio;
@@ -522,7 +522,7 @@ class Backend {
async _onApiDefinitionsAddable({definitions, modes, context, optionsContext}) {
const options = this.getOptions(optionsContext);
- const templates = this.defaultAnkiFieldTemplates;
+ const templates = this._getTemplates(options);
const states = [];
try {
@@ -945,6 +945,11 @@ class Backend {
return handlebarsRenderDynamic(template, data);
}
+ _getTemplates(options) {
+ const templates = options.anki.fieldTemplates;
+ return typeof templates === 'string' ? templates : this.defaultAnkiFieldTemplates;
+ }
+
static _getTabUrl(tab) {
return new Promise((resolve) => {
chrome.tabs.sendMessage(tab.id, {action: 'getUrl'}, {frameId: 0}, (response) => {
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 266cccc8..684ea6d3 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -22,6 +22,7 @@
* apiClipboardGet
* apiOptionsSet
* apiTermsFind
+ * wanakana
*/
class DisplaySearch extends Display {
@@ -83,7 +84,7 @@ class DisplaySearch extends Display {
if (this.options.general.enableWanakana === true) {
this.wanakanaEnable.checked = true;
- window.wanakana.bind(this.query);
+ wanakana.bind(this.query);
} else {
this.wanakanaEnable.checked = false;
}
@@ -250,9 +251,9 @@ class DisplaySearch extends Display {
onWanakanaEnableChange(e) {
const enableWanakana = e.target.checked;
if (enableWanakana) {
- window.wanakana.bind(this.query);
+ wanakana.bind(this.query);
} else {
- window.wanakana.unbind(this.query);
+ wanakana.unbind(this.query);
}
apiOptionsSet({general: {enableWanakana}}, this.getOptionsContext());
}
@@ -292,7 +293,7 @@ class DisplaySearch extends Display {
}
setQuery(query) {
- const interpretedQuery = this.isWanakanaEnabled() ? window.wanakana.toKana(query) : query;
+ const interpretedQuery = this.isWanakanaEnabled() ? wanakana.toKana(query) : query;
this.query.value = interpretedQuery;
this.queryParser.setText(interpretedQuery);
}
diff --git a/ext/bg/js/settings/popup-preview.js b/ext/bg/js/settings/popup-preview.js
index 091872be..45bf531e 100644
--- a/ext/bg/js/settings/popup-preview.js
+++ b/ext/bg/js/settings/popup-preview.js
@@ -15,6 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+/* global
+ * wanakana
+ */
function appearanceInitialize() {
let previewVisible = false;
@@ -37,7 +40,7 @@ function showAppearancePreview() {
frame.src = '/bg/settings-popup-preview.html';
frame.id = 'settings-popup-preview-frame';
- window.wanakana.bind(text[0]);
+ wanakana.bind(text[0]);
const targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, '');