diff --git a/app/js/index.js b/app/js/index.js index bd90d08..0e2bcb4 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -8,8 +8,19 @@ if (typeof(sw) == 'undefined') { //helper functions - var shuffle = function(obj) { - return obj.sort( function() { return 0.5 - Math.random(); } ); + var shuffle = function(myArray) { + var i = myArray.length, j, tempi, tempj; + if (i === 0) + return myArray; + while (--i) { + j = Math.floor(Math.random() * (i + 1)); + tempi = myArray[i]; + tempj = myArray[j]; + myArray[i] = tempj; + myArray[j] = tempi; + } + + return myArray; }; var getKey = function(obj) { @@ -23,20 +34,13 @@ if (typeof(sw) == 'undefined') { var words = sw.words[Math.round(Math.random() * sw.words.length)]; var word = getKey(words); - var similar = words[word]; - //i really should include _ - var filtered = []; - for(var i=0; i