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/pages/settings/anki-controller.js | 9 ++------- ext/js/pages/settings/anki-templates-controller.js | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'ext/js/pages') diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 26cab68f..509e263c 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -17,7 +17,7 @@ /* global * AnkiConnect - * AnkiNoteBuilder + * AnkiUtil * ObjectPropertyAccessor * SelectorObserver */ @@ -26,7 +26,6 @@ class AnkiController { constructor(settingsController) { this._settingsController = settingsController; this._ankiConnect = new AnkiConnect(); - this._ankiNoteBuilder = new AnkiNoteBuilder(false); this._selectorObserver = new SelectorObserver({ selector: '.anki-card', ignoreSelector: null, @@ -156,10 +155,6 @@ class AnkiController { return this._settingsController.permissionsUtil.getRequiredPermissionsForAnkiFieldValue(fieldValue); } - containsAnyMarker(field) { - return this._ankiNoteBuilder.containsAnyMarker(field); - } - // Private async _onOptionsChanged({options: {anki}}) { @@ -439,7 +434,7 @@ class AnkiCardController { _validateField(node, index) { let valid = (node.dataset.hasPermissions !== 'false'); - if (valid && index === 0 && !this._ankiController.containsAnyMarker(node.value)) { + if (valid && index === 0 && !AnkiUtil.stringContainsAnyFieldMarker(node.value)) { valid = false; } node.dataset.invalid = `${!valid}`; diff --git a/ext/js/pages/settings/anki-templates-controller.js b/ext/js/pages/settings/anki-templates-controller.js index 8e3a1a70..710946be 100644 --- a/ext/js/pages/settings/anki-templates-controller.js +++ b/ext/js/pages/settings/anki-templates-controller.js @@ -32,7 +32,7 @@ class AnkiTemplatesController { this._renderFieldInput = null; this._renderResult = null; this._fieldTemplateResetModal = null; - this._ankiNoteBuilder = new AnkiNoteBuilder(true); + this._ankiNoteBuilder = new AnkiNoteBuilder(); } async prepare() { -- cgit v1.2.3