formatting tweaks to suggest.js,a=chris

Chris Pollett [2013-01-01 08:Jan:st]
formatting tweaks to suggest.js,a=chris
Filename
scripts/history.js
scripts/suggest.js
diff --git a/scripts/history.js b/scripts/history.js
index d4b907b04..23cb97f08 100644
--- a/scripts/history.js
+++ b/scripts/history.js
@@ -47,17 +47,17 @@ if(typeof(elt) == "undefined") {
 /*
  * Handles History toggle in cached pages
  */
-var historylink = elt('#history');
+var history_link = elt('#history');

-historylink.onclick = function() {
-    var historylink = elt('#history');
+history_link.onclick = function() {
+    var history_link = elt('#history');
     var m_id = elt('#month');
     var y_id = elt('#year');
     var cur_year = y_id.options[y_id.selectedIndex].value;
     var cur_month = m_id.options[m_id.selectedIndex].value;
     cur_div = elt('#'+cur_year+cur_month);
     m_id.options.length = 0;
-    var monthjs = historylink.getAttribute("months");
+    var monthjs = history_link.getAttribute("months");
     monthjs = eval(monthjs);
     for(j = 0; j < monthjs.length; j++) {
         var id = elt('#'+cur_year+monthjs[j]);
@@ -98,7 +98,7 @@ year.onchange = function() {
         for(j = 0; j < monops.length; j++) {
             var y = yearops[i].value;
             var m = monops[j].value;
-            var id ='#'+y+m;
+            var id ='#' + y + m;
             var div = elt(id);
             if(div !== null){
                 div.style.display = 'none';
@@ -152,9 +152,9 @@ month.onchange = function() {
     }
     var month = m_id.options[m_id.selectedIndex].value;
     var year = y_id.options[y_id.selectedIndex].value;
-    var id = '#'+year+month;
+    var id = '#' + year + month;
     ldiv = elt(id);
     if((ldiv !== null) && (ldiv.style.display == 'none')) {
         ldiv.style.display = 'block';
     }
-}
\ No newline at end of file
+}
diff --git a/scripts/suggest.js b/scripts/suggest.js
index 6af93f9ae..7ee60fcb0 100644
--- a/scripts/suggest.js
+++ b/scripts/suggest.js
@@ -75,7 +75,7 @@ function processSubmit()
  */

 function isVowel(c) {
-    return ['a', 'e', 'i', 'o', 'u'].indexOf(c) !== -1
+    return ['a', 'e', 'i', 'o', 'u'].indexOf(c) !== -1;
 }

 /*
@@ -241,7 +241,7 @@ function onTypeTerm(event, text_field)
             }
             scroll_pos = (cursor_pos - MAX_DISPLAY + scroll_count >= 0) ?
                 (cursor_pos - MAX_DISPLAY + scroll_count) : 0;
-            scroll_count = (MAX_DISPLAY > scroll_count) ? scroll_count + 1 :
+            scroll_count = (MAX_DISPLAY > scroll_count) ? scroll_count + 1:
                 MAX_DISPLAY;
             suggest_dropdown.scrollTop = scroll_pos * FONT_HEIGHT;
         }
@@ -258,9 +258,9 @@ function correctSpelling(word)
 {
     var prob = 0;

-    ret_array = exist(dictionary, word);
-    if(ret_array != false) {
-        prob = parseInt(ret_array[END_OF_TERM_MARKER]);
+    trie_subtree = exist(dictionary, word);
+    if(trie_subtree != false) {
+        prob = parseInt(trie_subtree[END_OF_TERM_MARKER]);
     }
     var trie_subtree;
     var curr_prob = 0;
@@ -268,7 +268,7 @@ function correctSpelling(word)

     candidates.push(word);
     var corrected_word = "";
-    var correct_threshold = 2;
+    var correct_threshold = 25;

     // Use the frequencies to get the best match
     for(var i = 0; i < candidates.length; i++) {
@@ -300,11 +300,11 @@ function edits1(word)
     var transposes =new Array();
     var replaces = new Array();
     var inserts = new Array();
-    var j=0;
+    var j = 0;

     splits[""] = word;
-    for(var i=0;i<word.length;i++) {
-        splits[word.substring(0,i+1)] = word.substring(i+1,word.length);
+    for(var i = 0; i < word.length; i++) {
+        splits[word.substring(0, i + 1)] = word.substring(i+1, word.length);
     }
     // Deletes
     for (key in splits) {
@@ -314,19 +314,19 @@ function edits1(word)
         }
     }
     // Transposes
-    j=0;
+    j = 0;
     for (key in splits) {
         if (splits[key].length > 1) {
-            transposes[j] = key + splits[key].substring(1,2) +
+            transposes[j] = key + splits[key].substring(1, 2) +
             splits[key].substring(0,1) + splits[key].substring(2);
             j++;
         }
     }
     // Replaces
-    j=0;
+    j = 0;
     for (key in splits) {
         if (splits[key] != "") {
-            for(var i=0;i<alpha.length;i++) {
+            for(var i = 0;i < alpha.length; i++) {
                 replaces[j] = key + alpha.substring(i,i+1) +
                  splits[key].substring(1);
                 j++;
@@ -334,10 +334,10 @@ function edits1(word)
         }
     }
     // Inserts
-    j=0;
+    j = 0;
     for (key in splits) {
-        for(var i=0;i<alpha.length;i++) {
-            inserts[j] = key + alpha.substring(i,i+1) + splits[key];
+        for(var i=0; i < alpha.length; i++) {
+            inserts[j] = key + alpha.substring(i, i + 1) + splits[key];
             j++;
         }
     }
@@ -348,8 +348,8 @@ function edits1(word)

 Array.prototype.unique = function() {
     var a = this.concat();
-    for(var i=0; i<a.length; ++i) {
-        for(var j=i+1; j<a.length; ++j) {
+    for(var i = 0; i<a.length; ++i) {
+        for(var j=i+1; j < a.length; ++j) {
             if(a[i] === a[j])
                 a.splice(j, 1);
         }
@@ -371,7 +371,7 @@ function known(words_ip)
     for(var i=0;i < words_ip.length;i++) {
         ret_array = exist(dictionary, words_ip[i]);
         if(ret_array[END_OF_TERM_MARKER] != null) {
-            known_words[j] =  words_ip[i];
+            known_words[j] = words_ip[i];
             j++;
         }
     }
ViewGit