From c2447006cb631233076f055670b76a6f1f267039 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 28 Sep 2014 14:05:41 +0300 Subject: textanalysis-ui: protect #textanalyser access for easier node.js usage for testing --- scripts/textanalysis-ui.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'scripts/textanalysis-ui.js') 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); +} -- cgit v1.3.1