diff options
| author | Alon Levy <alon@pobox.com> | 2014-09-28 14:05:41 +0300 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-09-28 14:05:41 +0300 |
| commit | c2447006cb631233076f055670b76a6f1f267039 (patch) | |
| tree | 8d48ff038836389de4d027ed2f5e087df2370fa8 /scripts | |
| parent | 49801ba2c99c0397ede59d46a2dc4d4f8c94f6cb (diff) | |
textanalysis-ui: protect #textanalyser access for easier node.js usage for testing
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/textanalysis-ui.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/scripts/textanalysis-ui.js b/scripts/textanalysis-ui.js index 0481ef7c..c6554083 100644 --- a/scripts/textanalysis-ui.js +++ b/scripts/textanalysis-ui.js @@ -137,16 +137,21 @@ function changeType(arg, id) { graph.updateGraph(); } -/* TODO: don't use interval by default but only if keys are comming to fast (but still - 5 ms??) */ -window.setInterval(function() { - if ($('#textanalyser').val() != text) { - - if(text.length*8 > 500)$('#textanalyser').css('width',text.length*8+20); - // text changed - text = $('#textanalyser').val(); - analyzeSentence(text, false); - suggestionChange = false; - } -}, 5); +var analysis_element = '#textanalyser'; +if ($(analysis_element).length == 1) { + /* TODO: don't use interval by default but only if keys are comming to fast (but still - 5 ms??) */ + window.setInterval(function() { + var e = $(analysis_element); + if (e.val() != text) { + if (text.length * 8 > 500) { + e.css('width', text.length * 8 + 20); + } + // text changed + text = e.val(); + analyzeSentence(text, false); + suggestionChange = false; + } + }, 5); +} |
