summaryrefslogtreecommitdiff
path: root/assets/js/mumi.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js/mumi.js')
-rw-r--r--assets/js/mumi.js28
1 files changed, 17 insertions, 11 deletions
diff --git a/assets/js/mumi.js b/assets/js/mumi.js
index 151cb43..b37b138 100644
--- a/assets/js/mumi.js
+++ b/assets/js/mumi.js
@@ -65,6 +65,22 @@ var mumi = (function () {
return result;
},
};
+
+ var tokenizeText = function (input, options, tokenInput) {
+ let items = input.value.split(queryTokenizer).filter(entry => entry.trim() != '');
+ let tokens = [];
+ for (item of items) {
+ if (possibleTokens.find(element => element.text == item)) {
+ tokens.push({text: item});
+ } else {
+ tokens.push(options.freeTextToken(item));
+ }
+ }
+ input.value = "";
+ var existing = tokenInput.getTokens () || [];
+ tokenInput.setTokens(existing.concat(tokens));
+ };
+
var initTokenInput = function () {
var inputElement = document.querySelector (".tokenInput input#query");
if (inputElement == null) {
@@ -125,17 +141,7 @@ var mumi = (function () {
/* tokenize existing input text */
if (inputElement.value.length > 0) {
- let items = inputElement.value.split(queryTokenizer).filter(entry => entry.trim() != '');
- let tokens = [];
- for (item of items) {
- if (possibleTokens.find(element => element.text == item)) {
- tokens.push({text: item});
- } else {
- tokens.push(options.freeTextToken(item));
- }
- }
- inputElement.value = "";
- tokenInput.setTokens(tokens);
+ tokenizeText (inputElement, options, tokenInput);
}
inputElement.style.visibility = 'visible';
};