From 726c52191b687252d447dd92122f74653c3271b8 Mon Sep 17 00:00:00 2001 From: Steven Thomas Date: Thu, 20 Mar 2014 09:12:42 -0700 Subject: Fixed spelling - renamed wordseach occurrences to wordsearch. --- js/wordsearch.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/wordsearch.min.js') diff --git a/js/wordsearch.min.js b/js/wordsearch.min.js index 76854e3..a825a89 100644 --- a/js/wordsearch.min.js +++ b/js/wordsearch.min.js @@ -1 +1 @@ -(function(){Element.prototype.wordSeach=function(b){return new a(this,b)};function a(b,d){this.wrapEl=b;this.wrapEl.classList.add("ws-area");var c={"directions":["W","N","WN","EN"],"gridSize":10,"words":["one","two","three","four","five"],"debug":false};this.settings=Object.merge(d,c);if(this.parseWords(this.settings.gridSize)){var e=false;while(e==false){this.initialize();e=this.addWords()}if(!this.settings.debug){this.fillUpFools()}this.drawmatrix()}}a.prototype.parseWords=function(e){var b=true;for(var c=0;ce){alert("The length of word `"+d+"` is overflow the gridSize.");console.error("The length of word `"+d+"` is overflow the gridSize.");b=false}}return b};a.prototype.addWords=function(){var e=true,c=0,f=true;while(e){var d=this.settings.directions[Math.rangeInt(this.settings.directions.length-1)],b=this.addWord(this.settings.words[c],d),f=true;if(b==false){e=false;f=false}c++;if(c>=this.settings.words.length){e=false}}return f};a.prototype.addWord=function(b,j){var d=true,g={"W":[0,1],"N":[1,0],"WN":[1,1],"EN":[1,-1]},m,e;switch(j){case"W":var m=Math.rangeInt(this.settings.gridSize-1),e=Math.rangeInt(this.settings.gridSize-b.length);break;case"N":var m=Math.rangeInt(this.settings.gridSize-b.length),e=Math.rangeInt(this.settings.gridSize-1);break;case"WN":var m=Math.rangeInt(this.settings.gridSize-b.length),e=Math.rangeInt(this.settings.gridSize-b.length);break;case"EN":var m=Math.rangeInt(this.settings.gridSize-b.length),e=Math.rangeInt(b.length-1,this.settings.gridSize-1);break;default:var h="UNKNOWN DIRECTION "+j+"!";alert(h);console.log(h);break}for(var f=0;fe)?1:-1,g=(c===h)?0:(h>c)?1:-1,j=e,b=c;d.push(this.getItem(j,b));do{j+=f;b+=g;d.push(this.getItem(j,b))}while(j!==i||b!==h)}return d};a.prototype.getItem=function(c,b){return(this.matrix[c]?this.matrix[c][b]:undefined)};a.prototype.clearHighlight=function(){var b=document.querySelectorAll(".ws-selected");for(var c=0;c-1||this.settings.words.indexOf(g[1])>-1){for(var c=0;ct&&(alert("The length of word `"+r+"` is overflow the gridSize."),console.error("The length of word `"+r+"` is overflow the gridSize."),e=!1)}return e},t.prototype.addWords=function(){for(var t=!0,e=0,i=!0;t;){var r=this.settings.directions[Math.rangeInt(this.settings.directions.length-1)],s=this.addWord(this.settings.words[e],r),i=!0;0==s&&(t=!1,i=!1),e++,e>=this.settings.words.length&&(t=!1)}return i},t.prototype.addWord=function(t,e){var i,r,s=!0,o={W:[0,1],N:[1,0],WN:[1,1],EN:[1,-1]};switch(e){case"W":var i=Math.rangeInt(this.settings.gridSize-1),r=Math.rangeInt(this.settings.gridSize-t.length);break;case"N":var i=Math.rangeInt(this.settings.gridSize-t.length),r=Math.rangeInt(this.settings.gridSize-1);break;case"WN":var i=Math.rangeInt(this.settings.gridSize-t.length),r=Math.rangeInt(this.settings.gridSize-t.length);break;case"EN":var i=Math.rangeInt(this.settings.gridSize-t.length),r=Math.rangeInt(t.length-1,this.settings.gridSize-1);break;default:var n="UNKNOWN DIRECTION "+e+"!";alert(n),console.log(n)}for(var a=0;ae;e++)for(var i=0;t>i;i++){var r={letter:".",row:e,col:i};this.matrix[e]||(this.matrix[e]=[]),this.matrix[e][i]=r}},t.prototype.drawmatrix=function(){for(var t=0;tt?1:-1,n=e===r?0:r>e?1:-1,a=t,h=e;s.push(this.getItem(a,h));do a+=o,h+=n,s.push(this.getItem(a,h));while(a!==i||h!==r)}return s},t.prototype.getItem=function(t,e){return this.matrix[t]?this.matrix[t][e]:void 0},t.prototype.clearHighlight=function(){for(var t=document.querySelectorAll(".ws-selected"),e=0;e-1||this.settings.words.indexOf(e[1])>-1)for(var i=0;i