From 7b2f828cb982c6a05db9370963186cbee97a3b5f Mon Sep 17 00:00:00 2001 From: Shmuel83 Date: Wed, 22 Jun 2016 11:04:34 +0200 Subject: Minify To resume : Fix minor bug : If user select the same word, do nothing On list : First letter Upper On grid : Delete accents for lattin letters (french, Spanish...) and hebrew letters Write on grid the same letters : available to Latin/Hebrew/Greek/Cyrillic/Arab/Chinese/Hiragana --- 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 2511d88..57e0209 100644 --- a/js/wordsearch.min.js +++ b/js/wordsearch.min.js @@ -1 +1 @@ -!function(){"use strict";function t(t,e){this.wrapEl=t,this.wrapEl.classList.add("ws-area"),this.solved=0;var r={directions:["W","N","WN","EN"],gridSize:10,words:["one","two","three","four","five"],debug:!1};if(this.settings=Object.merge(e,r),this.parseWords(this.settings.gridSize)){for(var i=!1;0==i;)this.initialize(),i=this.addWords();this.settings.debug||this.fillUpFools(),this.drawmatrix()}}Element.prototype.wordSearch=function(e){return new t(this,e)},t.prototype.parseWords=function(t){for(var e=!0,r=0;rt&&(alert("The length of word `"+i+"` is overflow the gridSize."),console.error("The length of word `"+i+"` is overflow the gridSize."),e=!1)}return e},t.prototype.addWords=function(){for(var t=!0,e=0,r=!0;t;){var i=this.settings.directions[Math.rangeInt(this.settings.directions.length-1)],s=this.addWord(this.settings.words[e],i),r=!0;0==s&&(t=!1,r=!1),e++,e>=this.settings.words.length&&(t=!1)}return r},t.prototype.addWord=function(t,e){var r,i,s=!0,o={W:[0,1],N:[1,0],WN:[1,1],EN:[1,-1]};switch(e){case"W":var r=Math.rangeInt(this.settings.gridSize-1),i=Math.rangeInt(this.settings.gridSize-t.length);break;case"N":var r=Math.rangeInt(this.settings.gridSize-t.length),i=Math.rangeInt(this.settings.gridSize-1);break;case"WN":var r=Math.rangeInt(this.settings.gridSize-t.length),i=Math.rangeInt(this.settings.gridSize-t.length);break;case"EN":var r=Math.rangeInt(this.settings.gridSize-t.length),i=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 r=0;t>r;r++){var i={letter:".",row:e,col:r};this.matrix[e]||(this.matrix[e]=[]),this.matrix[e][r]=i}},t.prototype.drawmatrix=function(){for(var t=0;tt?1:-1,n=e===i?0:i>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!==r||h!==i)}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 r=0;r"+a[r].innerHTML+"");this.solved++,this.solved==this.settings.words.length&&this.gameOver()}},t.prototype.gameOver=function(){var t=document.createElement("div");t.setAttribute("id","ws-game-over-outer"),t.setAttribute("class","ws-game-over-outer"),this.wrapEl.parentNode.appendChild(t);var t=document.getElementById("ws-game-over-outer");t.innerHTML="

Congratulations!

You've found all of the words!

"},t.prototype.onMousedown=function(t){var e=this;return function(){e.selectFrom=t}},t.prototype.onMouseover=function(t){var e=this;return function(){if(e.selectFrom){e.selected=e.getItems(e.selectFrom.row,e.selectFrom.col,t.row,t.col),e.clearHighlight();for(var r=0;r=65&&codefirstLetter<=90?t=[65,90]:codefirstLetter>=1488&&codefirstLetter<=1514?t=[1488,1514]:codefirstLetter>=913&&codefirstLetter<=937?t=[913,929]:codefirstLetter>=1040&&codefirstLetter<=1071?t=[1040,1071]:codefirstLetter>=1569&&codefirstLetter<=1610?t=[1569,1594]:codefirstLetter>=19969&&codefirstLetter<=40891?t=[19969,40891]:codefirstLetter>=12354&&codefirstLetter<=12436?t=[12388,12418]:(console.log("Letter not detected : "+e+":"+codefirstLetter),t)}!function(){"use strict";function e(e,t){this.wrapEl=e,this.wrapEl.classList.add("ws-area"),this.solved=0;var u={directions:["W","N","WN","EN"],gridSize:10,words:["one","two","three","four","five"],wordsList:[],debug:!1};if(this.settings=Object.merge(t,u),this.parseWords(this.settings.gridSize)){for(var s=!1;0==s;)this.initialize(),s=this.addWords();this.settings.debug||this.fillUpFools(),this.drawmatrix()}}Element.prototype.wordSearch=function(t){return new e(this,t)},e.prototype.parseWords=function(e){for(var t=!0,u=0;ue&&(alert("The length of word `"+s+"` is overflow the gridSize."),console.error("The length of word `"+s+"` is overflow the gridSize."),t=!1)}return t},e.prototype.addWords=function(){for(var e=!0,t=0,u=!0;e;){var s=this.settings.directions[Math.rangeInt(this.settings.directions.length-1)],r=this.addWord(this.settings.words[t],s),u=!0;0==r&&(e=!1,u=!1),t++,t>=this.settings.words.length&&(e=!1)}return u},e.prototype.addWord=function(e,t){var u,s,r=!0,i={W:[0,1],N:[1,0],WN:[1,1],EN:[1,-1]};switch(t){case"W":var u=Math.rangeInt(this.settings.gridSize-1),s=Math.rangeInt(this.settings.gridSize-e.length);break;case"N":var u=Math.rangeInt(this.settings.gridSize-e.length),s=Math.rangeInt(this.settings.gridSize-1);break;case"WN":var u=Math.rangeInt(this.settings.gridSize-e.length),s=Math.rangeInt(this.settings.gridSize-e.length);break;case"EN":var u=Math.rangeInt(this.settings.gridSize-e.length),s=Math.rangeInt(e.length-1,this.settings.gridSize-1);break;default:var o="UNKNOWN DIRECTION "+t+"!";alert(o),console.log(o)}for(var a=0;at;t++)for(var u=0;e>u;u++){var s={letter:".",row:t,col:u};this.matrix[t]||(this.matrix[t]=[]),this.matrix[t][u]=s}},e.prototype.drawmatrix=function(){for(var e=0;ee?1:-1,o=t===s?0:s>t?1:-1,a=e,n=t;r.push(this.getItem(a,n));do a+=i,n+=o,r.push(this.getItem(a,n));while(a!==u||n!==s)}return r},e.prototype.getItem=function(e,t){return this.matrix[e]?this.matrix[e][t]:void 0},e.prototype.clearHighlight=function(){for(var e=document.querySelectorAll(".ws-selected"),t=0;t-1||this.settings.words.indexOf(t[1])>-1){for(var u=0;u"+a[u].innerHTML+""&&(a[u].innerHTML=""+a[u].innerHTML+"",this.solved++);this.solved==this.settings.words.length&&this.gameOver()}},e.prototype.gameOver=function(){var e=document.createElement("div");e.setAttribute("id","ws-game-over-outer"),e.setAttribute("class","ws-game-over-outer"),this.wrapEl.parentNode.appendChild(e);var e=document.getElementById("ws-game-over-outer");e.innerHTML="

Congratulations!

You've found all of the words!

"},e.prototype.onMousedown=function(e){var t=this;return function(){t.selectFrom=e}},e.prototype.onMouseover=function(e){var t=this;return function(){if(t.selectFrom){t.selected=t.getItems(t.selectFrom.row,t.selectFrom.col,e.row,e.col),t.clearHighlight();for(var u=0;u