From 6c63a17d669b57fdbc1a5a71daf89c6c95e7d5ef Mon Sep 17 00:00:00 2001 From: siikamiika Date: Thu, 6 Feb 2020 04:00:02 +0200 Subject: query parser html templates --- ext/bg/js/search-query-parser.js | 60 ++++++++++++---------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index e8e6d11f..3a93c7e7 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -19,14 +19,16 @@ class QueryParser extends TextScanner { constructor(search) { - super(document.querySelector('#query-parser'), [], [], []); + super(document.querySelector('#query-parser-content'), [], [], []); this.search = search; this.parseResults = []; this.selectedParser = null; - this.queryParser = document.querySelector('#query-parser'); - this.queryParserSelect = document.querySelector('#query-parser-select'); + this.queryParser = document.querySelector('#query-parser-content'); + this.queryParserSelect = document.querySelector('#query-parser-select-container'); + + this.queryParserGenerator = new QueryParserGenerator(); } onError(error) { @@ -64,7 +66,7 @@ class QueryParser extends TextScanner { const selectedParser = e.target.value; this.selectedParser = selectedParser; apiOptionsSet({parsing: {selectedParser}}, this.search.getOptionsContext()); - this.renderParseResult(this.getParseResult()); + this.renderParseResult(); } getMouseEventListeners() { @@ -113,13 +115,13 @@ class QueryParser extends TextScanner { async setText(text) { this.search.setSpinnerVisible(true); - await this.setPreview(text); + this.setPreview(text); this.parseResults = await this.parseText(text); this.refreshSelectedParser(); this.renderParserSelect(); - await this.renderParseResult(); + this.renderParseResult(); this.search.setSpinnerVisible(false); } @@ -146,57 +148,29 @@ class QueryParser extends TextScanner { return results; } - async setPreview(text) { + setPreview(text) { const previewTerms = []; for (let i = 0, ii = text.length; i < ii; i += 2) { const tempText = text.substring(i, i + 2); - previewTerms.push([{text: tempText.split('')}]); + previewTerms.push([{text: tempText}]); } - this.queryParser.innerHTML = await apiTemplateRender('query-parser.html', { - terms: previewTerms, - preview: true - }); + this.queryParser.textContent = ''; + this.queryParser.appendChild(this.queryParserGenerator.createParseResult(previewTerms, true)); } renderParserSelect() { this.queryParserSelect.innerHTML = ''; if (this.parseResults.length > 1) { - const select = document.createElement('select'); - select.classList.add('form-control'); - for (const parseResult of this.parseResults) { - const option = document.createElement('option'); - option.value = parseResult.id; - option.innerText = parseResult.name; - option.defaultSelected = this.selectedParser === parseResult.id; - select.appendChild(option); - } + const select = this.queryParserGenerator.createParserSelect(this.parseResults, this.selectedParser); select.addEventListener('change', this.onParserChange.bind(this)); this.queryParserSelect.appendChild(select); } } - async renderParseResult() { + renderParseResult() { const parseResult = this.getParseResult(); - if (!parseResult) { - this.queryParser.innerHTML = ''; - return; - } - - this.queryParser.innerHTML = await apiTemplateRender( - 'query-parser.html', - {terms: QueryParser.processParseResultForDisplay(parseResult.parsedText)} - ); - } - - static processParseResultForDisplay(result) { - return result.map((term) => { - return term.filter((part) => part.text.trim()).map((part) => { - return { - text: part.text.split(''), - reading: part.reading, - raw: !part.reading || !part.reading.trim() - }; - }); - }); + this.queryParser.textContent = ''; + if (!parseResult) { return; } + this.queryParser.appendChild(this.queryParserGenerator.createParseResult(parseResult.parsedText)); } } -- cgit v1.2.3 From 9c98c631afde843f8b5ed4c54fc1f4ff0ec3a00a Mon Sep 17 00:00:00 2001 From: siikamiika Date: Mon, 10 Feb 2020 22:09:23 +0200 Subject: fix async issues --- ext/bg/js/search-query-parser-generator.js | 3 +-- ext/bg/js/search-query-parser.js | 4 ++++ ext/bg/js/search.js | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/ext/bg/js/search-query-parser-generator.js b/ext/bg/js/search-query-parser-generator.js index 67a1ccad..8d71890b 100644 --- a/ext/bg/js/search-query-parser-generator.js +++ b/ext/bg/js/search-query-parser-generator.js @@ -20,10 +20,9 @@ class QueryParserGenerator { constructor() { this._templateHandler = null; - this._initialize(); } - async _initialize() { + async prepare() { const html = await apiGetQueryParserTemplatesHtml(); this._templateHandler = new TemplateHandler(html); } diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 3a93c7e7..f648fdd4 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -31,6 +31,10 @@ class QueryParser extends TextScanner { this.queryParserGenerator = new QueryParserGenerator(); } + async prepare() { + await this.queryParserGenerator.prepare(); + } + onError(error) { logError(error, false); } diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 4da27513..6641255f 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -49,6 +49,8 @@ class DisplaySearch extends Display { try { await this.initialize(); + await this.queryParser.prepare(); + const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); if (this.search !== null) { -- cgit v1.2.3 From 4629fb3639ec28e6c514b4a364b71e4192575b9b Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 1 Feb 2020 15:00:34 -0500 Subject: Change no-undef from off to error --- .eslintrc.json | 37 +++++++++++++++++++++++++++++-- ext/bg/js/anki.js | 1 + ext/bg/js/audio.js | 1 + ext/bg/js/backend.js | 8 +++++++ ext/bg/js/context.js | 1 + ext/bg/js/database.js | 1 + ext/bg/js/dictionary.js | 1 + ext/bg/js/handlebars.js | 1 + ext/bg/js/japanese.js | 1 + ext/bg/js/options.js | 1 + ext/bg/js/search-frontend.js | 1 + ext/bg/js/search-query-parser.js | 1 + ext/bg/js/search.js | 3 +++ ext/bg/js/settings/anki-templates.js | 3 +++ ext/bg/js/settings/anki.js | 3 +++ ext/bg/js/settings/audio-ui.js | 1 + ext/bg/js/settings/audio.js | 2 ++ ext/bg/js/settings/backup.js | 4 ++++ ext/bg/js/settings/conditions-ui.js | 1 + ext/bg/js/settings/dictionaries.js | 5 +++++ ext/bg/js/settings/main.js | 8 +++++++ ext/bg/js/settings/popup-preview-frame.js | 1 + ext/bg/js/settings/profiles.js | 4 ++++ ext/bg/js/settings/storage.js | 1 + ext/bg/js/translator.js | 6 +++++ ext/mixed/js/audio.js | 1 + ext/mixed/js/display-generator.js | 1 + ext/mixed/js/display.js | 5 +++++ ext/mixed/js/text-scanner.js | 1 + 29 files changed, 103 insertions(+), 2 deletions(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/.eslintrc.json b/.eslintrc.json index 81fe517f..9b1a19b3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -23,7 +23,8 @@ "no-case-declarations": "error", "no-const-assign": "error", "no-constant-condition": "off", - "no-undef": "off", + "no-global-assign": "error", + "no-undef": "error", "no-unused-vars": ["error", {"vars": "local", "args": "after-used", "argsIgnorePattern": "^_", "caughtErrors": "none"}], "no-unused-expressions": "error", "no-var": "error", @@ -32,5 +33,37 @@ "quotes": ["error", "single", "avoid-escape"], "require-atomic-updates": "off", "semi": "error" - } + }, + "overrides": [ + { + "files": ["*.js"], + "excludedFiles": ["ext/mixed/js/core.js"], + "globals": { + "yomichan": "readonly", + "errorToJson": "readonly", + "jsonToError": "readonly", + "logError": "readonly", + "isObject": "readonly", + "hasOwn": "readonly", + "toIterable": "readonly", + "stringReverse": "readonly", + "promiseTimeout": "readonly", + "stringReplaceAsync": "readonly", + "EventDispatcher": "readonly", + "EXTENSION_IS_BROWSER_EDGE": "readonly" + } + }, + { + "files": ["ext/mixed/js/core.js"], + "globals": { + "chrome": "writable" + } + }, + { + "files": ["ext/bg/js/settings/*.js"], + "env": { + "jquery": true + } + } + ] } diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js index 10a07061..39c6ad51 100644 --- a/ext/bg/js/anki.js +++ b/ext/bg/js/anki.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global requestJson*/ /* * AnkiConnect diff --git a/ext/bg/js/audio.js b/ext/bg/js/audio.js index d1e4af9e..6389528b 100644 --- a/ext/bg/js/audio.js +++ b/ext/bg/js/audio.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global jpIsStringEntirelyKana, audioGetFromSources*/ const audioUrlBuilders = new Map([ ['jpod101', async (definition) => { diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 529055d2..1a1dc735 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -16,6 +16,14 @@ * along with this program. If not, see . */ +/*global optionsSave, utilIsolate +conditionsTestValue, profileConditionsDescriptor, profileOptionsGetDefaultFieldTemplates +handlebarsRenderDynamic, handlebarsRenderStatic +requestText, requestJson, optionsLoad +dictConfigured, dictTermsSort, dictEnabledSet, dictNoteFormat +audioGetUrl, audioInject +jpConvertReading, jpDistributeFuriganaInflected, jpKatakanaToHiragana +Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema*/ class Backend { constructor() { diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js index 37adb6b7..bec964fb 100644 --- a/ext/bg/js/context.js +++ b/ext/bg/js/context.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiCommandExec, apiGetEnvironmentInfo, apiOptionsGet*/ function showExtensionInfo() { const node = document.getElementById('extension-info'); diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index e87cc64b..b54d832c 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global dictFieldSplit, dictTagSanitize, JSZip*/ class Database { constructor() { diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js index 48f65d6c..e03dece0 100644 --- a/ext/bg/js/dictionary.js +++ b/ext/bg/js/dictionary.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global utilSetEqual, utilSetIntersection, apiTemplateRender*/ function dictEnabledSet(options) { const dictionaries = {}; diff --git a/ext/bg/js/handlebars.js b/ext/bg/js/handlebars.js index 62f89ee4..e8cb67eb 100644 --- a/ext/bg/js/handlebars.js +++ b/ext/bg/js/handlebars.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global jpIsCharCodeKanji, jpDistributeFurigana, Handlebars*/ function handlebarsEscape(text) { return Handlebars.Utils.escapeExpression(text); diff --git a/ext/bg/js/japanese.js b/ext/bg/js/japanese.js index c45c0958..e8a6fa08 100644 --- a/ext/bg/js/japanese.js +++ b/ext/bg/js/japanese.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global wanakana*/ const JP_HALFWIDTH_KATAKANA_MAPPING = new Map([ ['ヲ', 'ヲヺ-'], diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js index 97032660..f9db99a2 100644 --- a/ext/bg/js/options.js +++ b/ext/bg/js/options.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global utilStringHashCode*/ /* * Generic options functions diff --git a/ext/bg/js/search-frontend.js b/ext/bg/js/search-frontend.js index e453ccef..509c4009 100644 --- a/ext/bg/js/search-frontend.js +++ b/ext/bg/js/search-frontend.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiOptionsGet*/ async function searchFrontendSetup() { const optionsContext = { diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index f648fdd4..ff0dbaef 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner*/ class QueryParser extends TextScanner { constructor(search) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 6641255f..312d1de4 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +/*global jpIsStringPartiallyJapanese, apiOptionsSet, apiTermsFind, apiClipboardGet, apiGetEnvironmentInfo +Display, QueryParser*/ + class DisplaySearch extends Display { constructor() { super(document.querySelector('#spinner'), document.querySelector('#content')); diff --git a/ext/bg/js/settings/anki-templates.js b/ext/bg/js/settings/anki-templates.js index 5e74358f..2e80e334 100644 --- a/ext/bg/js/settings/anki-templates.js +++ b/ext/bg/js/settings/anki-templates.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, settingsSaveOptions +profileOptionsGetDefaultFieldTemplates, ankiGetFieldMarkers, ankiGetFieldMarkersHtml, dictFieldFormat +apiOptionsGet, apiTermsFind*/ function onAnkiFieldTemplatesReset(e) { e.preventDefault(); diff --git a/ext/bg/js/settings/anki.js b/ext/bg/js/settings/anki.js index f55989fc..4263fc51 100644 --- a/ext/bg/js/settings/anki.js +++ b/ext/bg/js/settings/anki.js @@ -16,6 +16,9 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, settingsSaveOptions +utilBackgroundIsolate, utilAnkiGetDeckNames, utilAnkiGetModelNames, utilAnkiGetModelFieldNames +onFormOptionsChanged*/ // Private diff --git a/ext/bg/js/settings/audio-ui.js b/ext/bg/js/settings/audio-ui.js index 711c2291..e918609e 100644 --- a/ext/bg/js/settings/audio-ui.js +++ b/ext/bg/js/settings/audio-ui.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global toIterable*/ class AudioSourceUI { static instantiateTemplate(templateSelector) { diff --git a/ext/bg/js/settings/audio.js b/ext/bg/js/settings/audio.js index cff3f521..588d9a11 100644 --- a/ext/bg/js/settings/audio.js +++ b/ext/bg/js/settings/audio.js @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, settingsSaveOptions +AudioSourceUI, audioGetTextToSpeechVoice*/ let audioSourceUI = null; diff --git a/ext/bg/js/settings/backup.js b/ext/bg/js/settings/backup.js index becdc568..6d1f28e9 100644 --- a/ext/bg/js/settings/backup.js +++ b/ext/bg/js/settings/backup.js @@ -16,6 +16,10 @@ * along with this program. If not, see . */ +/*global apiOptionsGetFull, apiGetEnvironmentInfo +utilBackend, utilIsolate, utilBackgroundIsolate, utilReadFileArrayBuffer +optionsGetDefault, optionsUpdateVersion +profileOptionsGetDefaultFieldTemplates*/ // Exporting diff --git a/ext/bg/js/settings/conditions-ui.js b/ext/bg/js/settings/conditions-ui.js index 4d041451..5a271321 100644 --- a/ext/bg/js/settings/conditions-ui.js +++ b/ext/bg/js/settings/conditions-ui.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global conditionsNormalizeOptionValue*/ class ConditionsUI { static instantiateTemplate(templateSelector) { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index 0d827f49..c80aac73 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -16,6 +16,11 @@ * along with this program. If not, see . */ +/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull +utilBackgroundIsolate, utilDatabaseDeleteDictionary, utilDatabaseGetDictionaryInfo, utilDatabaseGetDictionaryCounts +utilDatabasePurge, utilDatabaseImport +storageUpdateStats, storageEstimate +PageExitPrevention*/ let dictionaryUI = null; diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index cf0f08db..1ba4a7ef 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -16,6 +16,14 @@ * along with this program. If not, see . */ +/*global getOptionsContext, apiOptionsSave +utilBackend, utilIsolate, utilBackgroundIsolate +ankiErrorShown, ankiFieldsToDict +ankiTemplatesUpdateValue, onAnkiOptionsChanged, onDictionaryOptionsChanged +appearanceInitialize, audioSettingsInitialize, profileOptionsSetup, dictSettingsInitialize +ankiInitialize, ankiTemplatesInitialize, storageInfoInitialize +*/ + function getOptionsMutable(optionsContext) { return utilBackend().getOptions( utilBackgroundIsolate(optionsContext) diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 37a4b416..042f335f 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiOptionsGet, Popup, PopupProxyHost, Frontend, TextSourceRange*/ class SettingsPopupPreview { constructor() { diff --git a/ext/bg/js/settings/profiles.js b/ext/bg/js/settings/profiles.js index c4e68b53..3e589809 100644 --- a/ext/bg/js/settings/profiles.js +++ b/ext/bg/js/settings/profiles.js @@ -16,6 +16,10 @@ * along with this program. If not, see . */ +/*global getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull +utilBackgroundIsolate, formWrite +conditionsClearCaches, ConditionsUI, profileConditionsDescriptor*/ + let currentProfileIndex = 0; let profileConditionsContainer = null; diff --git a/ext/bg/js/settings/storage.js b/ext/bg/js/settings/storage.js index 6c10f665..cbe1bb4d 100644 --- a/ext/bg/js/settings/storage.js +++ b/ext/bg/js/settings/storage.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetEnvironmentInfo*/ function storageBytesToLabeledString(size) { const base = 1000; diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index d32f8c67..81c2464b 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -16,6 +16,12 @@ * along with this program. If not, see . */ +/*global requestJson +dictTermsMergeBySequence, dictTagBuildSource, dictTermsMergeByGloss, dictTermsSort, dictTagsSort +dictEnabledSet, dictTermsGroup, dictTermsCompressTags, dictTermsUndupe, dictTagSanitize +jpDistributeFurigana, jpConvertHalfWidthKanaToFullWidth, jpConvertNumericTofullWidth +jpConvertAlphabeticToKana, jpHiraganaToKatakana, jpKatakanaToHiragana, jpIsCharCodeJapanese +Database, Deinflector*/ class Translator { constructor() { diff --git a/ext/mixed/js/audio.js b/ext/mixed/js/audio.js index b0c5fa82..76a3e7da 100644 --- a/ext/mixed/js/audio.js +++ b/ext/mixed/js/audio.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiAudioGetUrl*/ class TextToSpeechAudio { constructor(text, voice) { diff --git a/ext/mixed/js/display-generator.js b/ext/mixed/js/display-generator.js index d5ab9dbc..3617e546 100644 --- a/ext/mixed/js/display-generator.js +++ b/ext/mixed/js/display-generator.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetDisplayTemplatesHtml*/ class DisplayGenerator { constructor() { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index a6cfe848..b18e275d 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -16,6 +16,11 @@ * along with this program. If not, see . */ +/*global docRangeFromPoint, docSentenceExtract +apiKanjiFind, apiTermsFind, apiNoteView, apiOptionsGet, apiDefinitionsAddable, apiDefinitionAdd +apiScreenshotGet, apiForward +audioPrepareTextToSpeech, audioGetFromSources +DisplayGenerator, WindowScroll, DisplayContext, DOM*/ class Display { constructor(spinner, container) { diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js index 88f1e27a..e6da1e5e 100644 --- a/ext/mixed/js/text-scanner.js +++ b/ext/mixed/js/text-scanner.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global docRangeFromPoint, TextSourceRange, DOM*/ class TextScanner { constructor(node, ignoreNodes, ignoreElements, ignorePoints) { -- cgit v1.2.3 From e2ac478cb7635cbd15d0033bd2c486689a7b4e67 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 11 Feb 2020 22:19:47 -0500 Subject: Define more globals --- .eslintrc.json | 1 + ext/bg/js/backend.js | 2 +- ext/bg/js/clipboard-monitor.js | 1 + ext/bg/js/search-query-parser-generator.js | 1 + ext/bg/js/search-query-parser.js | 2 +- ext/bg/js/search.js | 2 +- ext/bg/js/settings/dictionaries.js | 2 +- ext/fg/js/document.js | 1 + ext/fg/js/float.js | 1 + ext/fg/js/frontend-initialize.js | 1 + ext/fg/js/frontend.js | 1 + ext/fg/js/popup-nested.js | 1 + ext/fg/js/popup-proxy-host.js | 1 + ext/fg/js/popup-proxy.js | 1 + ext/fg/js/popup.js | 1 + 15 files changed, 15 insertions(+), 4 deletions(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/.eslintrc.json b/.eslintrc.json index 9b1a19b3..f502479d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -49,6 +49,7 @@ "stringReverse": "readonly", "promiseTimeout": "readonly", "stringReplaceAsync": "readonly", + "parseUrl": "readonly", "EventDispatcher": "readonly", "EXTENSION_IS_BROWSER_EDGE": "readonly" } diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 1a1dc735..7b2ec46d 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -23,7 +23,7 @@ requestText, requestJson, optionsLoad dictConfigured, dictTermsSort, dictEnabledSet, dictNoteFormat audioGetUrl, audioInject jpConvertReading, jpDistributeFuriganaInflected, jpKatakanaToHiragana -Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema*/ +Translator, AnkiConnect, AnkiNull, Mecab, BackendApiForwarder, JsonSchema, ClipboardMonitor*/ class Backend { constructor() { diff --git a/ext/bg/js/clipboard-monitor.js b/ext/bg/js/clipboard-monitor.js index b4a27fa2..c2f41385 100644 --- a/ext/bg/js/clipboard-monitor.js +++ b/ext/bg/js/clipboard-monitor.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiClipboardGet, jpIsStringPartiallyJapanese*/ class ClipboardMonitor { constructor() { diff --git a/ext/bg/js/search-query-parser-generator.js b/ext/bg/js/search-query-parser-generator.js index 8d71890b..f842644e 100644 --- a/ext/bg/js/search-query-parser-generator.js +++ b/ext/bg/js/search-query-parser-generator.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetQueryParserTemplatesHtml, TemplateHandler*/ class QueryParserGenerator { constructor() { diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index ff0dbaef..49c0bb34 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner*/ +/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner, QueryParserGenerator*/ class QueryParser extends TextScanner { constructor(search) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 312d1de4..50ec146f 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -17,7 +17,7 @@ */ /*global jpIsStringPartiallyJapanese, apiOptionsSet, apiTermsFind, apiClipboardGet, apiGetEnvironmentInfo -Display, QueryParser*/ +Display, QueryParser, ClipboardMonitor*/ class DisplaySearch extends Display { constructor() { diff --git a/ext/bg/js/settings/dictionaries.js b/ext/bg/js/settings/dictionaries.js index c80aac73..fb459404 100644 --- a/ext/bg/js/settings/dictionaries.js +++ b/ext/bg/js/settings/dictionaries.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull +/*global getOptionsContext, getOptionsMutable, getOptionsFullMutable, settingsSaveOptions, apiOptionsGetFull, apiOptionsGet utilBackgroundIsolate, utilDatabaseDeleteDictionary, utilDatabaseGetDictionaryInfo, utilDatabaseGetDictionaryCounts utilDatabasePurge, utilDatabaseImport storageUpdateStats, storageEstimate diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index 71654b29..7284cdd1 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global TextSourceElement, TextSourceRange, DOM*/ const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 8d61d8f6..d31b8336 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global popupNestedInitialize, Display*/ class DisplayFloat extends Display { constructor() { diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index 9c923fea..c32e97d4 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global PopupProxyHost, PopupProxy, Frontend*/ async function main() { const data = window.frontendInitializationData || {}; diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 2286bf19..3611d44e 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiGetZoom, apiOptionsGet, apiTermsFind, apiKanjiFind, docSentenceExtract, TextScanner*/ class Frontend extends TextScanner { constructor(popup, ignoreNodes) { diff --git a/ext/fg/js/popup-nested.js b/ext/fg/js/popup-nested.js index 3f3c945e..3e5f5b80 100644 --- a/ext/fg/js/popup-nested.js +++ b/ext/fg/js/popup-nested.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiOptionsGet*/ let popupNestedInitialized = false; diff --git a/ext/fg/js/popup-proxy-host.js b/ext/fg/js/popup-proxy-host.js index 427172c6..98729796 100644 --- a/ext/fg/js/popup-proxy-host.js +++ b/ext/fg/js/popup-proxy-host.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiFrameInformationGet, FrontendApiReceiver, Popup*/ class PopupProxyHost { constructor() { diff --git a/ext/fg/js/popup-proxy.js b/ext/fg/js/popup-proxy.js index 63aa6bbe..db6dffb1 100644 --- a/ext/fg/js/popup-proxy.js +++ b/ext/fg/js/popup-proxy.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global FrontendApiSender*/ class PopupProxy { constructor(depth, parentId, parentFrameId, url) { diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js index e7dae93e..0b142dda 100644 --- a/ext/fg/js/popup.js +++ b/ext/fg/js/popup.js @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +/*global apiInjectStylesheet*/ class Popup { constructor(id, depth, frameIdPromise) { -- cgit v1.2.3 From c8e7a1543ee52943157ff54b2a9983ad20deaa15 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 11 Feb 2020 22:25:48 -0500 Subject: Remove unused --- ext/bg/js/search-query-parser.js | 2 +- ext/bg/js/search.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 49c0bb34..3d38e6e8 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, apiTemplateRender, TextScanner, QueryParserGenerator*/ +/*global apiTermsFind, apiOptionsSet, apiTextParse, apiTextParseMecab, TextScanner, QueryParserGenerator*/ class QueryParser extends TextScanner { constructor(search) { diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 50ec146f..93bcfa53 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -16,8 +16,7 @@ * along with this program. If not, see . */ -/*global jpIsStringPartiallyJapanese, apiOptionsSet, apiTermsFind, apiClipboardGet, apiGetEnvironmentInfo -Display, QueryParser, ClipboardMonitor*/ +/*global apiOptionsSet, apiTermsFind, Display, QueryParser, ClipboardMonitor*/ class DisplaySearch extends Display { constructor() { -- cgit v1.2.3 From c3e7280365a78f648ab15c8460cabfb276e077d4 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 15 Feb 2020 19:49:20 -0500 Subject: Simplify ternary --- ext/bg/js/search-query-parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 3d38e6e8..8c434990 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -59,7 +59,7 @@ class QueryParser extends TextScanner { this.search.setContent('terms', {definitions, context: { focus: false, - disableHistory: cause === 'mouse' ? true : false, + disableHistory: cause === 'mouse', sentence: {text: searchText, offset: 0}, url: window.location.href }}); -- cgit v1.2.3 From 53220af68eabdda27b35224056f3bd589e8c4785 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 23 Feb 2020 11:49:52 -0500 Subject: Don't use innerHTML --- ext/bg/js/search-query-parser.js | 2 +- ext/fg/js/source.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ext/bg/js/search-query-parser.js') diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js index 8c434990..0d4aaa50 100644 --- a/ext/bg/js/search-query-parser.js +++ b/ext/bg/js/search-query-parser.js @@ -164,7 +164,7 @@ class QueryParser extends TextScanner { } renderParserSelect() { - this.queryParserSelect.innerHTML = ''; + this.queryParserSelect.textContent = ''; if (this.parseResults.length > 1) { const select = this.queryParserGenerator.createParserSelect(this.parseResults, this.selectedParser); select.addEventListener('change', this.onParserChange.bind(this)); diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js index fa785ec4..6dc482bd 100644 --- a/ext/fg/js/source.js +++ b/ext/fg/js/source.js @@ -366,7 +366,7 @@ class TextSourceElement { setEndOffset(length) { switch (this.element.nodeName.toUpperCase()) { case 'BUTTON': - this.content = this.element.innerHTML; + this.content = this.element.textContent; break; case 'IMG': this.content = this.element.getAttribute('alt'); -- cgit v1.2.3