From ae92e0b3781e27d54cbac2570ba2a1b8a6b11999 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 24 Feb 2021 21:54:58 -0500 Subject: AnkiUtil (#1439) * Add AnkiUtil * Update AnkiConnect to use AnkiUtil * Use AnkiUtil in AnkiNoteBuilder * Replace containsAnyMarker with AnkiUtil.stringContainsAnyFieldMarker * Add AnkiUtil.getFieldMarkers * Add fieldsObjectContainsMarker to AnkiUtil * Remove unused global * Remove unused parameter: enabled * Add cloneFieldMarkerPattern --- ext/js/comm/anki.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ext/js/comm') diff --git a/ext/js/comm/anki.js b/ext/js/comm/anki.js index 251e0e0c..da234eff 100644 --- a/ext/js/comm/anki.js +++ b/ext/js/comm/anki.js @@ -15,6 +15,10 @@ * along with this program. If not, see . */ +/* global + * AnkiUtil + */ + class AnkiConnect { constructor() { this._enabled = false; @@ -113,7 +117,7 @@ class AnkiConnect { query = `"deck:${this._escapeQuery(note.deckName)}" `; break; case 'deck-root': - query = `"deck:${this._escapeQuery(this.getRootDeckName(note.deckName))}" `; + query = `"deck:${this._escapeQuery(AnkiUtil.getRootDeckName(note.deckName))}" `; break; } query += this._fieldsToQuery(note.fields); @@ -138,11 +142,6 @@ class AnkiConnect { return await this.findCards(`nid:${noteId}`); } - getRootDeckName(deckName) { - const index = deckName.indexOf('::'); - return index >= 0 ? deckName.substring(0, index) : deckName; - } - // Private async _checkVersion() { -- cgit v1.2.3