diff options
| author | Alon Levy <alon@pobox.com> | 2014-11-11 13:00:40 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-11-11 13:22:39 +0200 |
| commit | 6ee3190eba841c6e1888e8365dab84d329f453da (patch) | |
| tree | d5f2ed7eaf1f0ddb82b1d1289b431418e664d5cd | |
| parent | 28b944d2500a6ca38c17aa3ba7d7aad166b7ce07 (diff) | |
textanalysis: factor out selectedType
| -rw-r--r-- | scripts/textanalysis.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/textanalysis.js b/scripts/textanalysis.js index e5729ef3..99286e00 100644 --- a/scripts/textanalysis.js +++ b/scripts/textanalysis.js @@ -12,6 +12,11 @@ var sugg = {}; // suggestions for autocompletion of node names var ANALYSIS_NODE_START = 'ANALYSIS_NODE_START'; var ANALYSIS_LINK = 'ANALYSIS_LINK'; +function selectedType() +{ + return nodetypes[typeindex]; +} + function autoSuggestAddName(name) { /* note that name can contain spaces - this is ok. We might want to limit this though? */ @@ -288,7 +293,7 @@ var textAnalyser = function (newtext, finalize) { switch (orderStack[m]) { case START: if (!typeStack[nodeindex]) { - typeStack[nodeindex] = nodetypes[typeindex]; + typeStack[nodeindex] = selectedType(); } break; case NODE: @@ -308,7 +313,7 @@ var textAnalyser = function (newtext, finalize) { //FINAL N ORDER switch (orderStack[orderStack.length - 1]) { case START: - typeStack[nodeindex]=nodetypes[typeindex]; + typeStack[nodeindex] = selectedType(); addNode("new node", typeStack[nodeindex], "temp"); if (!starGraph) { addLink(newnodes[nodeindex - 1], "new node", newlinks[linkindex], "temp"); @@ -317,7 +322,7 @@ var textAnalyser = function (newtext, finalize) { ret.state = ANALYSIS_NODE_START; break; case NODE: - typeStack[nodeindex]=nodetypes[typeindex]; + typeStack[nodeindex] = selectedType(); addNode(newnodes[nodeindex], typeStack[nodeindex], typesetter); if (!starGraph) { addLink(newnodes[nodeindex - 1], newnodes[nodeindex], newlinks[linkindex], typesetter); |
