From 69223f1700457c3e4fde25e91303144c73c12765 Mon Sep 17 00:00:00 2001 From: Joshua Bryant Date: Fri, 21 Dec 2018 15:54:23 -0500 Subject: [PATCH] Keep loop indexes out of global scope The examples (which will presumably be copied and pasted) define the loop indexes in the global scope. --- demo.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/demo.html b/demo.html index ab7b1a2..6e91a1f 100644 --- a/demo.html +++ b/demo.html @@ -156,7 +156,7 @@

Searching in local data

term = term.toLowerCase(); var choices = ['ActionScript', 'AppleScript', 'Asp', ...]; var matches = []; - for (i=0; i<choices.length; i++) + for (var i=0; i<choices.length; i++) if (~choices[i].toLowerCase().indexOf(term)) matches.push(choices[i]); suggest(matches); } @@ -221,7 +221,7 @@

Advanced suggestions handling and custom layout

term = term.toLowerCase(); var choices = [['Australia', 'au'], ['Austria', 'at'], ['Brasil', 'br'], ...]; var suggestions = []; - for (i=0;i<choices.length;i++) + for (var i=0;i<choices.length;i++) if (~(choices[i][0]+' '+choices[i][1]).toLowerCase().indexOf(term)) suggestions.push(choices[i]); suggest(suggestions); }, @@ -273,7 +273,7 @@

Advanced suggestions handling and custom layout

term = term.toLowerCase(); var choices = ['ActionScript', 'AppleScript', 'Asp', 'Assembly', 'BASIC', 'Batch', 'C', 'C++', 'CSS', 'Clojure', 'COBOL', 'ColdFusion', 'Erlang', 'Fortran', 'Groovy', 'Haskell', 'HTML', 'Java', 'JavaScript', 'Lisp', 'Perl', 'PHP', 'PowerShell', 'Python', 'Ruby', 'Scala', 'Scheme', 'SQL', 'TeX', 'XML']; var suggestions = []; - for (i=0;iAdvanced suggestions handling and custom layout term = term.toLowerCase(); var choices = [['Australia', 'au'], ['Austria', 'at'], ['Brasil', 'br'], ['Bulgaria', 'bg'], ['Canada', 'ca'], ['China', 'cn'], ['Czech Republic', 'cz'], ['Denmark', 'dk'], ['Finland', 'fi'], ['France', 'fr'], ['Germany', 'de'], ['Hungary', 'hu'], ['India', 'in'], ['Italy', 'it'], ['Japan', 'ja'], ['Netherlands', 'nl'], ['Norway', 'no'], ['Portugal', 'pt'], ['Romania', 'ro'], ['Russia', 'ru'], ['Spain', 'es'], ['Swiss', 'ch'], ['Turkey', 'tr'], ['USA', 'us']]; var suggestions = []; - for (i=0;i