summaryrefslogtreecommitdiff
path: root/ext/mixed/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-18 14:12:41 -0400
committerGitHub <noreply@github.com>2020-04-18 14:12:41 -0400
commit106172e2c1261f2d685802280af580c70ac4580b (patch)
tree1e96325ee884db8c946e7401882fd7b46f3552e8 /ext/mixed/js
parent9e7750125c40d1c4121e8d015957606721bede7c (diff)
parentcdd817a0e1c573b24114836a389236f49dd9b279 (diff)
Merge pull request #447 from toasted-nutbread/util-conversions
Util conversions
Diffstat (limited to 'ext/mixed/js')
-rw-r--r--ext/mixed/js/api.js24
-rw-r--r--ext/mixed/js/core.js9
2 files changed, 33 insertions, 0 deletions
diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js
index 30c08347..7080d93a 100644
--- a/ext/mixed/js/api.js
+++ b/ext/mixed/js/api.js
@@ -116,6 +116,30 @@ function apiGetDefaultAnkiFieldTemplates() {
return _apiInvoke('getDefaultAnkiFieldTemplates');
}
+function apiGetAnkiDeckNames() {
+ return _apiInvoke('getAnkiDeckNames');
+}
+
+function apiGetAnkiModelNames() {
+ return _apiInvoke('getAnkiModelNames');
+}
+
+function apiGetAnkiModelFieldNames(modelName) {
+ return _apiInvoke('getAnkiModelFieldNames', {modelName});
+}
+
+function apiGetDictionaryInfo() {
+ return _apiInvoke('getDictionaryInfo');
+}
+
+function apiGetDictionaryCounts(dictionaryNames, getTotal) {
+ return _apiInvoke('getDictionaryCounts', {dictionaryNames, getTotal});
+}
+
+function apiPurgeDatabase() {
+ return _apiInvoke('purgeDatabase');
+}
+
function _apiInvoke(action, params={}) {
const data = {action, params};
return new Promise((resolve, reject) => {
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index 2d11c11a..6a3298fc 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -316,6 +316,15 @@ const yomichan = (() => {
this.trigger('orphaned', {error});
}
+ isExtensionUrl(url) {
+ try {
+ const urlBase = chrome.runtime.getURL('/');
+ return url.substring(0, urlBase.length) === urlBase;
+ } catch (e) {
+ return false;
+ }
+ }
+
getTemporaryListenerResult(eventHandler, userCallback, timeout=null) {
if (!(
typeof eventHandler.addListener === 'function' &&