From c346cb74078ea9ef8280764e35a6d8c1bfa3ceca Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 20 Aug 2014 08:34:30 +0300 Subject: textanalysis & textanalysis-ui split complete --- scripts/textanalysis-ui.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'scripts/textanalysis-ui.js') diff --git a/scripts/textanalysis-ui.js b/scripts/textanalysis-ui.js index f5d2d5fe..92407d69 100644 --- a/scripts/textanalysis-ui.js +++ b/scripts/textanalysis-ui.js @@ -10,11 +10,11 @@ $('#textanalyser').autocompleteTrigger({ // TODO - hide this in a scope function analyzeSentence(sentence, finalize) { - var d = TextAnalyser2(graph, sentence, finalize); - for (var k in d.sugg) { + var ret = TextAnalyser2(sentence, finalize); + for (var k in ret.sugg) { sugg.push(k); } - switch (d.state) { + switch (ret.state) { case ANALYSIS_NODE_START: $('.typeselection').css({top:window.innerHeight/2-115,left:window.innerWidth/2-325}); $('.typeselection').html('
Use [TAB] key to pick a type
'); @@ -24,6 +24,25 @@ function analyzeSentence(sentence, finalize) $('.typeselection').css('left', 0); break; } + //REINITIALISE GRAPH (DUMB BUT IT WORKS) + graph.removeNodes("temp"); + graph.removeLinks("temp"); + for (var k in ret.nodes) { + var n = ret.nodes[k]; + graph.addNode(n.id, n.type, n.state); + } + for (var k in ret.links) { + var l = ret.links[k]; + graph.addLink(l.sourceId, l.targetId, l.name, l.state); + } + + //UPDATE GRAPH ONCE + graph.update(); + + if (finalize) { + $('.typeselection').css('top', -300); + $('.typeselection').css('left', 0); + } } -- cgit v1.3.1