From 8e4342637e26770f396a98de8ff584d5a8d691aa Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sun, 1 Jan 2023 16:18:56 +0100 Subject: js: Move constants out of function context. --- assets/js/mumi.js | 128 +++++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/assets/js/mumi.js b/assets/js/mumi.js index 9936f34..151cb43 100644 --- a/assets/js/mumi.js +++ b/assets/js/mumi.js @@ -1,75 +1,75 @@ // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3.0-or-later var mumi = (function () { - var initTokenInput = function () { - var inputElement = document.querySelector (".tokenInput input#query"); - if (inputElement == null) { - return; - } - const queryTokenizer = { - [Symbol.split](str) { - let phrase = false; - let phrasePos = 0; - let pos = 0; - const result = []; - while (pos < str.length) { - let matchPos = str.substring(pos).search(/(\s|\")/); - if (matchPos === -1) { - result.push(str.substring(pos)); - break; - } + const possibleTokens = [ + { text: 'is:open' }, + { text: 'is:pending' }, + { text: 'is:done' }, + { text: 'is:closed' }, - matchPos += pos; - let char = str.charAt(matchPos); - let begin = pos; + { text: 'tag:confirmed' }, + { text: 'tag:easy' }, + { text: 'tag:fixed' }, + { text: 'tag:help' }, + { text: 'tag:moreinfo' }, + { text: 'tag:notabug' }, + { text: 'tag:patch' }, + { text: 'tag:pending' }, + { text: 'tag:security' }, + { text: 'tag:unreproducible' }, + { text: 'tag:wontfix' }, - if (char === '"') { - if (phrase) { - /* finished phrase, record from beginning */ - phrase = false; - begin = phrasePos; - matchPos += 1; - } else { - /* beginning phrase, remember position */ - phrase = true; - phrasePos = matchPos; - } - } + { text: 'severity:critical' }, + { text: 'severity:grave' }, + { text: 'severity:important' }, + { text: 'severity:minor' }, + { text: 'severity:normal' }, + { text: 'severity:serious' }, + { text: 'severity:wishlist' }, + ]; + const queryTokenizer = { + [Symbol.split](str) { + let phrase = false; + let phrasePos = 0; + let pos = 0; + const result = []; + while (pos < str.length) { + let matchPos = str.substring(pos).search(/(\s|\")/); + if (matchPos === -1) { + result.push(str.substring(pos)); + break; + } - /* don't push anything while inside a phrase */ - if (!phrase) { - result.push(str.substring(begin, matchPos)); + matchPos += pos; + let char = str.charAt(matchPos); + let begin = pos; + + if (char === '"') { + if (phrase) { + /* finished phrase, record from beginning */ + phrase = false; + begin = phrasePos; + matchPos += 1; + } else { + /* beginning phrase, remember position */ + phrase = true; + phrasePos = matchPos; } - pos = matchPos + 1; } - return result; - }, - }; - var possibleTokens = [ - { text: 'is:open' }, - { text: 'is:pending' }, - { text: 'is:done' }, - { text: 'is:closed' }, - - { text: 'tag:confirmed' }, - { text: 'tag:easy' }, - { text: 'tag:fixed' }, - { text: 'tag:help' }, - { text: 'tag:moreinfo' }, - { text: 'tag:notabug' }, - { text: 'tag:patch' }, - { text: 'tag:pending' }, - { text: 'tag:security' }, - { text: 'tag:unreproducible' }, - { text: 'tag:wontfix' }, - { text: 'severity:critical' }, - { text: 'severity:grave' }, - { text: 'severity:important' }, - { text: 'severity:minor' }, - { text: 'severity:normal' }, - { text: 'severity:serious' }, - { text: 'severity:wishlist' }, - ]; + /* don't push anything while inside a phrase */ + if (!phrase) { + result.push(str.substring(begin, matchPos)); + } + pos = matchPos + 1; + } + return result; + }, + }; + var initTokenInput = function () { + var inputElement = document.querySelector (".tokenInput input#query"); + if (inputElement == null) { + return; + } var completionsForTextWithSuggestions = function (suggestions) { return function (text) { var completions = []; -- cgit v1.2.3