diff options
| author | Alon Levy <alon@pobox.com> | 2015-03-08 14:55:15 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-03-08 14:55:16 +0200 |
| commit | 59c23de887c2938533b735f0dedbb788e22d0f6f (patch) | |
| tree | 0433b8b943ba13d599e7978bb861113706f4d9d9 /src/client/textanalysis.js | |
| parent | 84cf1a4f50ef5b5094b4e250b664fb0e7089ee10 (diff) | |
client/completion: support links as well
the suggestions from textanalysis now come as a dictionary with
{nodes: {name: id},
links: {name: id}}
(before it was a single dictionary, {name:id})
And the options bus for the textanalyser and search completion have been
updated accordingly. textanalyser also takes into account the cursor
position to determine which of the option dictionaries to use.
Diffstat (limited to 'src/client/textanalysis.js')
| -rw-r--r-- | src/client/textanalysis.js | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js index 64d7af7c..215c3fa8 100644 --- a/src/client/textanalysis.js +++ b/src/client/textanalysis.js @@ -27,11 +27,10 @@ var _get_lastnode, }; var sugg_name = {}, - id_to_name_map = {}, suggestions_bus = new Bacon.Bus(), suggestions_options = suggestions_bus.toProperty(); -suggestions_bus.push([]); +suggestions_bus.push({nodes:{}, links:{}}); var ANALYSIS_NODE_START = 'ANALYSIS_NODE_START'; var ANALYSIS_NODE = 'ANALYSIS_NODE'; @@ -305,27 +304,14 @@ function tokenize(text, node_token, quote) } -/* - * id - undefined | node id - * - */ -function auto_suggest__update_name(name, id) -{ - if (id !== undefined && id_to_name_map[id] !== undefined) { - delete sugg_name[id_to_name_map[id]]; - id_to_name_map[id] = name; - } - /* note that name can contain spaces - this is ok. We might want to limit this though? */ - sugg_name[name] = 1; - suggestions_bus.push(sugg_name); -} - function auto_suggest__update_from_graph() { - sugg_name = {}; - id_to_name_map = {}; + sugg_name = {nodes:{}, links:{}}; rz_core.main_graph.nodes().forEach(function (node) { - auto_suggest__update_name(node.name, node.id); + sugg_name.nodes[node.name] = node.id; + }); + rz_core.main_graph.links().forEach(function (link) { + sugg_name.links[link.name] = link.id; }); suggestions_bus.push(sugg_name); } |
