diff options
| author | Alon Levy <alon@pobox.com> | 2014-12-05 20:17:46 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-12-05 20:39:53 +0200 |
| commit | c53dce9f564b3d8bcb712f3047d48a700ad2f82d (patch) | |
| tree | 9af17877f2f6e45654b4e04e2372f5990f96a764 /src/textanalysis.js | |
| parent | f5569e0b4d0fa21999e1be6334cd25dd67f5d86b (diff) | |
replace jquery.autocomplete with our own autocompletion
Missing:
- handling dropdown in the middle of the sentence correctly (almost
there, extra space added)
- clicking changes focus (transition event related?) and .focus() doesn't
work - could not find how to fix it.
Diffstat (limited to 'src/textanalysis.js')
| -rw-r--r-- | src/textanalysis.js | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/src/textanalysis.js b/src/textanalysis.js index 98ca8aea..f2d5f555 100644 --- a/src/textanalysis.js +++ b/src/textanalysis.js @@ -9,7 +9,8 @@ var typeStack = []; var lastnode; -var sugg = {}; // suggestions for autocompletion of node names +var sugg = {}, // suggestions for autocompletion of node names + suggestions_options = new Bacon.Bus(); // TODO: Property: same as bus, but with initial value var ANALYSIS_NODE_START = 'ANALYSIS_NODE_START'; var ANALYSIS_NODE = 'ANALYSIS_NODE' @@ -24,36 +25,7 @@ function autoSuggestAddName(name) { /* note that name can contain spaces - this is ok. We might want to limit this though? */ sugg[name] = 1; -} - -function unquoted(name) -{ - var start = 0, - end = name.length; - - if (name.length >= 1) { - if (name.charAt(0) == '"') { - start = 1; - if (name.length > 1 && name.charAt(name.length - 1) == '"') { - end = name.length - 1; - } - } - return name.substring(start, end); - } - return name; -} - -function autocompleteCallback(request, response_callback) -{ - var ret = []; - if (request.term === "" || request.term) { - for (var name in sugg) { - if (name.toLowerCase().indexOf(unquoted(request.term.toLowerCase())) === 0) { - ret.push(name); - } - } - } - response_callback(ret); + suggestions_options.push(sugg); } /* up_to_two_renames: @@ -502,9 +474,8 @@ function init(graph) return { init:init, - autocompleteCallback:autocompleteCallback, textAnalyser:textAnalyser, - autoSuggestAddName:autoSuggestAddName, + suggestions_options: suggestions_options, ANALYSIS_NODE_START:ANALYSIS_NODE_START, ANALYSIS_NODE: ANALYSIS_NODE, ANALYSIS_LINK:ANALYSIS_LINK, |
