diff options
| author | Alon Levy <alon@pobox.com> | 2014-11-24 20:30:09 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-11-24 20:30:09 +0200 |
| commit | f2ce89be26456be0fba9b298a19e98b83482170d (patch) | |
| tree | d4cc432d2f8023859bfa91278484b250fa8eaf50 /src/main.js | |
| parent | 224b9b40ef7ac3b560c28eaef8dea0473d362e71 (diff) | |
add search
The added input lets you select by *oring* multiple space less
expressions. i.e. 'a b' will find all nodes with name containing either
'a' or 'b'. Not the specification, will be remedied later (i.e. maybe
tomorrow, who knows).
excuse the bulk commit, this does 3 things:
splits off selection logic into src/view/selection
- handles setting state explicityl on Node's, still bad.
- bad at least the 'selected' state (i.e. boolean) is in one place.
- common point for clicking on nodes/edges and selecting view selection
input
makes graph.getConnectedNodesAndLinks accept an array and not just a
single node
implements the search functionality outlined in the first paragraph.
Diffstat (limited to 'src/main.js')
| -rw-r--r-- | src/main.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main.js b/src/main.js index b4f71001..feefcf57 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,5 @@ -define(['textanalysis.ui', 'textanalysis', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config', 'rz_core'], -function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, robot, model_core, rz_config, rz_core) { +define(['textanalysis.ui', 'textanalysis', 'buttons', 'history', 'drag_n_drop', 'robot', 'model/core', 'rz_config', 'rz_core', 'view/selection'], +function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, robot, model_core, rz_config, rz_core, selection) { function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); @@ -43,6 +43,18 @@ function(textanalysis_ui, textanalysis, buttons, history, drag_n_drop, $('#search').focus(); } }; + // TODO: move me somewhere + $('#search').on('input', function(e) { + var text = this.value, + r = new RegExp(text.replace(' ', '|')); // TODO fails for quotes + console.log('search: ' + text); + if (text.length > 0) { + selection.byVisitors(function (n) { return n.name.match(r); }); + } else { + selection.clear(); + } + rz_core.update_view__graph(false); + }); // TODO: interaction between the hack above and this model_core.init(rz_config); textanalysis.init(); |
