summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-10 19:55:14 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-18 19:14:04 -0400
commitdcfe722ba626a439db621385005aaa57b61835ca (patch)
tree7da108355eb69ae6b9ef26cbf4e7a8064ea5bb3a /ext/fg/js/frontend.js
parent8c4fb28a300b84ce876c35c370bd43daf2e65228 (diff)
Add support for using optionsContext to select which profile to use
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index c98a9a33..cef7fffd 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -27,7 +27,8 @@ class Frontend {
this.ignoreNodes = (Array.isArray(ignoreNodes) && ignoreNodes.length > 0 ? ignoreNodes.join(',') : null);
this.optionsContext = {
- depth: popup.depth
+ depth: popup.depth,
+ url: popup.url
};
this.primaryTouchIdentifier = null;
@@ -42,9 +43,9 @@ class Frontend {
static create() {
const initializationData = window.frontendInitializationData;
const isNested = (initializationData !== null && typeof initializationData === 'object');
- const {id, depth, parentFrameId, ignoreNodes} = isNested ? initializationData : {};
+ const {id, depth, parentFrameId, ignoreNodes, url} = isNested ? initializationData : {};
- const popup = isNested ? new PopupProxy(depth + 1, id, parentFrameId) : PopupProxyHost.instance.createPopup(null);
+ const popup = isNested ? new PopupProxy(depth + 1, id, parentFrameId, url) : PopupProxyHost.instance.createPopup(null);
const frontend = new Frontend(popup, ignoreNodes);
frontend.prepare();
return frontend;
@@ -52,7 +53,7 @@ class Frontend {
async prepare() {
try {
- this.options = await apiOptionsGet(this.optionsContext);
+ this.options = await apiOptionsGet(this.getOptionsContext());
window.addEventListener('message', this.onFrameMessage.bind(this));
window.addEventListener('mousedown', this.onMouseDown.bind(this));
@@ -262,7 +263,7 @@ class Frontend {
}
async updateOptions() {
- this.options = await apiOptionsGet(this.optionsContext);
+ this.options = await apiOptionsGet(this.getOptionsContext());
if (!this.options.enable) {
this.searchClear();
}
@@ -330,7 +331,7 @@ class Frontend {
return;
}
- const {definitions, length} = await apiTermsFind(searchText, this.optionsContext);
+ const {definitions, length} = await apiTermsFind(searchText, this.getOptionsContext());
if (definitions.length === 0) {
return false;
}
@@ -363,7 +364,7 @@ class Frontend {
return;
}
- const definitions = await apiKanjiFind(searchText, this.optionsContext);
+ const definitions = await apiKanjiFind(searchText, this.getOptionsContext());
if (definitions.length === 0) {
return false;
}
@@ -507,6 +508,11 @@ class Frontend {
}
}
+ getOptionsContext() {
+ this.optionsContext.url = this.popup.url;
+ return this.optionsContext;
+ }
+
static isScanningModifierPressed(scanningModifier, mouseEvent) {
switch (scanningModifier) {
case 'alt': return mouseEvent.altKey;