From 0f0adf750c8cde668cdcf369cbe0ac173a9edf3f Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 15 Aug 2019 19:39:58 -0400 Subject: Add ability to save screenshot to anki cards --- ext/fg/js/api.js | 12 ++++++++---- ext/fg/js/frontend.js | 4 ++++ ext/fg/js/popup.js | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) (limited to 'ext/fg/js') diff --git a/ext/fg/js/api.js b/ext/fg/js/api.js index 4b4d9d74..0c86b412 100644 --- a/ext/fg/js/api.js +++ b/ext/fg/js/api.js @@ -33,8 +33,8 @@ function apiKanjiFind(text) { return utilInvoke('kanjiFind', {text}); } -function apiDefinitionAdd(definition, mode) { - return utilInvoke('definitionAdd', {definition, mode}); +function apiDefinitionAdd(definition, mode, context) { + return utilInvoke('definitionAdd', {definition, mode, context}); } function apiDefinitionsAddable(definitions, modes) { @@ -53,6 +53,10 @@ function apiCommandExec(command) { return utilInvoke('commandExec', {command}); } -function apiAudioGetUrl(definition, source) { - return utilInvoke('audioGetUrl', {definition, source}); +function apiScreenshotGet(options) { + return utilInvoke('screenshotGet', {options}); +} + +function apiForward(action, params) { + return utilInvoke('forward', {action, params}); } diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index bd652f3b..bafd06bd 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -244,6 +244,10 @@ class Frontend { if (!this.options.enable) { this.searchClear(); } + }, + + popupSetVisible: ({visible}) => { + this.popup.setVisible(visible); } }; diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index c8cc9baa..18dc0386 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -113,6 +113,14 @@ class Popup { return this.injected && this.container.style.visibility !== 'hidden'; } + setVisible(visible) { + if (visible) { + this.container.style.setProperty('display', ''); + } else { + this.container.style.setProperty('display', 'none', 'important'); + } + } + containsPoint(point) { if (!this.isVisible()) { return false; -- cgit v1.2.3