(function e(t, n, r){
function s(o, u){
if(!n[o]){
if(!t[o]){
var a=typeof require=="function"&&require;
if(!u&&a) return a(o, !0);
if(i) return i(o, !0);
throw new Error("Cannot find module '" + o + "'")
}
var f=n[o]={exports: {}};
t[o][0].call(f.exports, function (e){
var n=t[o][1][e];
return s(n ? n:e)
}, f, f.exports, e, t, n, r)
}
return n[o].exports
}
var i=typeof require=="function"&&require;
for (var o=0; o < r.length; o++) s(r[o]);
return s
})({
1: [function (require, module, exports){
(function (global){
(function (){
var ALPHABET, Cell, DIRECTIONS, LetterGrid, NUM_COLORS, angular, defaultWordlist, wordFromPath, _,
__indexOf=[].indexOf||function (item){
for (var i=0, l=this.length; i < l; i++){
if(i in this&&this[i]===item) return i;
}
return -1;
};
angular=(typeof window!=="undefined" ? window['angular']:typeof global!=="undefined" ? global['angular']:null);
_=(typeof window!=="undefined" ? window['_']:typeof global!=="undefined" ? global['_']:null);
defaultWordlist=require('./wordlist');
NUM_COLORS=5;
var whaws_alphabet_option=jQuery('#whaws_alphabet_option').val();
var whaws_rightwards_arrow=jQuery('#whaws_rightwards_arrow').val();
var whaws_downwards_arrow=jQuery('#whaws_downwards_arrow').val();
var whaws_leftwards_arrow=jQuery('#whaws_leftwards_arrow').val();
var whaws_upwards_arrow=jQuery('#whaws_upwards_arrow').val();
var whaws_south_east_arrow=jQuery('#whaws_south_east_arrow').val();
var whaws_north_east_arrow=jQuery('#whaws_north_east_arrow').val();
var whaws_south_west_arrow=jQuery('#whaws_south_west_arrow').val();
var whaws_north_west_arrow=jQuery('#whaws_north_west_arrow').val();
var level_difficulty_val=optional_wordsearch_vars.whaws_level_difficulty;
var use_global_options=optional_wordsearch_vars.whaws_use_global_options;
var direction=[];
if(whaws_rightwards_arrow=='on'){
direction.push([1, 0]);
}
if(whaws_downwards_arrow=='on'){
direction.push([0, 1]);
}
if(whaws_leftwards_arrow=='on'){
direction.push([-1, 0]);
}
if(whaws_upwards_arrow=='on'){
direction.push([0, -1]);
}
if(whaws_south_east_arrow=='on'){
direction.push([1, 1]);
}
if(whaws_north_east_arrow=='on'){
direction.push([1, -1]);
}
if(whaws_south_west_arrow=='on'){
direction.push([-1, 1]);
}
if(whaws_north_west_arrow=='on'){
direction.push([-1, -1]);
}
ALPHABET='AABBCCDDEEFFGGHHIIJKLLMMNNOOPPQRSSTTUUVWXYZ';
if(jQuery('#whaws_alphabet_option').length > 0){
if(whaws_alphabet_option.trim().length!=0){
ALPHABET=whaws_alphabet_option.trim();
}}
if(direction.length > 0){
DIRECTIONS=_.shuffle(direction);
}else{
DIRECTIONS=_.shuffle([[1, 0], [0, 1], [-1, 0], [0, -1], [1, 1], [1, -1], [-1, 1], [-1, -1]]);
}
wordFromPath=function (path){
var cell, word, _i, _len;
word='';
if(path!=null){
for (_i=0, _len=path.length; _i < _len; _i++){
cell=path[_i];
word +=cell.letter;
}}
return word
};
Cell=(function (){
function Cell(x, y){
this.x=x;
this.y=y;
this.solvedColorClasses=[];
this.isSelected=false;
this.onPath=false;
this.onCorrectPath=false;
}
Cell.prototype.willFitLetter=function (letter){
return (this.letter==null)||this.letter===letter;
};
Cell.prototype.randomFill=function (){
if(this.letter==null){
return this.letter=_.sample(ALPHABET);
}};
return Cell;
})();
LetterGrid=(function (){
function LetterGrid(width, height, maxWords, wordlist){
var cell, i, row, word, x, y, _i, _j, _k, _l, _len, _len1, _len2, _ref;
this.width=width!=null ? width:8;
this.height=height!=null ? height:8;
if(maxWords==null){
maxWords=20;
}
if(wordlist==null){
wordlist=defaultWordlist;
}
this.cells=(function (){
var _i, _ref, _results;
_results=[];
for (y=_i=0, _ref=this.height - 1; 0 <=_ref ? _i <=_ref:_i >=_ref; y=0 <=_ref ? ++_i:--_i){
_results.push((function (){
var _j, _ref1, _results1;
_results1=[];
for (x=_j=0, _ref1=this.width - 1; 0 <=_ref1 ? _j <=_ref1:_j >=_ref1; x=0 <=_ref1 ? ++_j:--_j){
_results1.push(new Cell(x, y));
}
return _results1;
}).call(this));
}
return _results;
}).call(this);
this.words=[];
wordlist=_.sortBy(_.shuffle(wordlist), function (word){
return -1 * word.length;
});
for (i=_i=1; 1 <=maxWords ? _i <=maxWords:_i >=maxWords; i=1 <=maxWords ? ++_i:--_i){
for (_j=0, _len=wordlist.length; _j < _len; _j++){
word=wordlist[_j].replace(/([\s-'])/g, '');
if(__indexOf.call(this.words, word) < 0){
if(this._tryPutWord(word)){
break;
}}
}}
_ref=this.cells;
for (_k=0, _len1=_ref.length; _k < _len1; _k++){
row=_ref[_k];
for (_l=0, _len2=row.length; _l < _len2; _l++){
cell=row[_l];
cell.randomFill();
}}
this.words=_.sortBy(this.words, function (word){
return -1 * word.length;
});
}
LetterGrid.prototype._tryPutWord=function (word){
var cell, dirX, dirY, endX, endY, i, path, startX, startY, _i, _j, _len, _len1, _ref;
_ref=DIRECTIONS[this.words.length % DIRECTIONS.length], dirX=_ref[0], dirY=_ref[1];
if(dirX!==0&&word.length > this.width||dirY!==0&&word.length > this.height){
return false;
}
startX=_.random((dirX===-1 ? word.length - 1:0), (dirX===1 ? this.width - word.length:this.width - 1));
startY=_.random((dirY===-1 ? word.length - 1:0), (dirY===1 ? this.height - word.length:this.height - 1));
endX=startX + dirX * (word.length - 1);
endY=startY + dirY * (word.length - 1);
path=this._getPath([startX, startY], [endX, endY]);
for (i=_i=0, _len=path.length; _i < _len; i=++_i){
cell=path[i];
if(!cell.willFitLetter(word[i])){
return false;
}}
for (i=_j=0, _len1=path.length; _j < _len1; i=++_j){
cell=path[i];
cell.letter=word[i];
}
this.words.push(word);
return true;
};
LetterGrid.prototype._getPath=function (start, end){
var cellList, diffX, diffY, endX, endY, stepX, stepY, x, y;
x=start[0], y=start[1];
endX=end[0], endY=end[1];
diffX=endX - x;
diffY=endY - y;
stepX=diffX===0 ? 0:diffX / Math.abs(diffX);
stepY=diffY===0 ? 0:diffY / Math.abs(diffY);
cellList=[];
while (x >=0&&y >=0&&x < this.width&&y < this.height){
cellList.push(this.cells[y][x]);
if(x===endX&&y===endY){
return cellList;
}
x +=stepX;
y +=stepY;
}
return null;
};
LetterGrid.prototype.getPathFromCells=function (start, end){
return this._getPath([start.x, start.y], [end.x, end.y]);
};
return LetterGrid;
})();
angular.module('wordsearchApp', []).controller('WordsearchCtrl', [
'$scope', function ($scope){
if(use_global_options=="yes"){
$scope.levels=[
{
width: 8,
height: 8
}, {
width: 9,
height: 9
}, {
width: 10,
height: 10
}, {
width: 11,
height: 11
}, {
width: 12,
height: 12
}, {
width: 13,
height: 13
}, {
width: 14,
height: 14
}, {
width: 15,
height: 15
}, {
width: 16,
height: 16
}, {
width: 17,
height: 17
}, {
width: 18,
height: 18
}, {
width: 19,
height: 19
}, {
width: 20,
height: 20
}
];
}else if(level_difficulty_val!=""||level_difficulty_val!=null){
$scope.levels=[
{
width: level_difficulty_val,
height: level_difficulty_val
}
];
}
$scope.loadLevel=function (level){
$scope.currentLevel=level;
$scope.grid=new LetterGrid(level.width, level.height);
$scope.words=$scope.grid.words;
$scope.testwords=defaultWordlist;
$scope.foundWords=[];
$scope.enableInput=true;
$scope.colorIndex=1;
return $scope.colorClass='wha-color1';
};
$scope.loadLevel($scope.levels[0]);
$scope.cellClicked=function (cell){
var path;
if(!$scope.enableInput){
return;
}
if($scope.selectedCell==null){
cell.isSelected=true;
return $scope.selectedCell=cell;
}else{
path=$scope.grid.getPathFromCells($scope.selectedCell, cell);
$scope.selectedCell.isSelected=false;
$scope.selectedCell=null;
$scope._submitPath(path);
return $scope.clearPath();
}};
$scope.updatePath=function (cell){
var path, _i, _len, _ref, _ref2, _results;
if($scope.selectedCell!=null){
path=$scope.grid.getPathFromCells($scope.selectedCell, cell);
if(path!=null){
_results=[];
for (_i=0, _len=path.length; _i < _len; _i++){
cell=path[_i];
cell.onPath=true;
_ref=wordFromPath(path);
_ref2=wordFromPath(path).split("").reverse().join("");
if(__indexOf.call($scope.words, _ref) >=0||__indexOf.call($scope.words, _ref2) >=0){
_results.push(cell.onCorrectPath=true);
}else{
_results.push(void 0);
}}
return _results;
}}
};
$scope.clearPath=function (){
var cell, row, _i, _len, _ref, _results;
_ref=$scope.grid.cells;
_results=[];
for (_i=0, _len=_ref.length; _i < _len; _i++){
row=_ref[_i];
_results.push((function (){
var _j, _len1, _results1;
_results1=[];
for (_j=0, _len1=row.length; _j < _len1; _j++){
cell=row[_j];
cell.onPath=false;
_results1.push(cell.onCorrectPath=false);
}
return _results1;
})());
}
return _results;
};
$scope._submitPath=function (path){
var alertCongrats, cell, foundWord, foundWord2, mywords, _i, _len;
foundWord=wordFromPath(path);
foundWord2=wordFromPath(path);
mywords=defaultWordlist;
if(__indexOf.call($scope.words, foundWord) >=0||__indexOf.call($scope.words, foundWord2.split("").reverse().join("")) >=0){
if(__indexOf.call($scope.words, foundWord2.split("").reverse().join("")) >=0){
foundWord=foundWord.split("").reverse().join("")
}
$scope.words.splice($scope.words.indexOf(foundWord), 1);
for (var j=0; j < mywords.length; j++){
if(mywords[j].replace(/([\s-'])/g, '')==foundWord){
jQuery(".wha-word-list button").each(function (){
var button_text=jQuery(this).text().replace(/([\s-'])/g, '');
if(foundWord==button_text){
jQuery(this).addClass('wha-solved ' + $scope.colorClass + '');
}});
}}
for (_i=0, _len=path.length; _i < _len; _i++){
cell=path[_i];
cell.solvedColorClasses.push($scope.colorClass);
}
$scope.nextColor();
if($scope.words.length===0){
$scope.enableInput=false;
alertCongrats=function (){
var event=new CustomEvent("wordsearch-finish", { "detail": $scope.foundWords.length });
document.dispatchEvent(event);
jQuery('.wha-wordsearch-app .wha-modal-wordsearch .wha-scope-foundWords').text($scope.foundWords.length);
jQuery('.wha-wordsearch-app .wha-modal-wordsearch').first().addClass('opened');
};
return setTimeout(alertCongrats, 400);
}}
};
/* hide words if they don't fit in to grid */
var gridwords=$scope.words
jQuery(document).ready(function ($){
jQuery(".wha-word-list button").hide();
for (var j=0; j < gridwords.length; j++){
jQuery(".wha-word-list button").each(function (){
var word_item=jQuery(this).text().replace(/([\s-'])/g, '');
if(word_item==gridwords[j]){
if(jQuery(this).text().replace(/([\s-'])/g, '').match(word_item)){
jQuery(this).show();
}}
});
}
jQuery("#wha-level-select-dropdown li").click(function (){
jQuery(".wha-word-list button").hide();
var gridwords=$scope.words;
for (var j=0; j < gridwords.length; j++){
jQuery(".wha-word-list button").each(function (){
var word_item=jQuery(this).text().replace(/([\s-'])/g, '');
if(word_item==gridwords[j]){
if(jQuery(this).text().replace(/([\s-'])/g, '').match(word_item)){
jQuery(this).show();
}}
});
}
jQuery('.wha-word-list button').removeClass('wha-solved');
});
});
return $scope.nextColor=function (){
$scope.colorIndex=$scope.colorIndex % NUM_COLORS + 1;
return $scope.colorClass="wha-color" + $scope.colorIndex;
};}
]);
}).call(this);
}).call(this, typeof self!=="undefined" ? self:typeof window!=="undefined" ? window:{})
}, {"./wordlist": 2}], 2: [function (require, module, exports){
(function (){
var words=[];
jQuery.each(jQuery('.wha-wordsearch-word'), function (i, val){
words.push(jQuery(this).val());
});
if(jQuery('#whaws_alphabet_option').length > 0){
var whaws_alphabet_option=jQuery('#whaws_alphabet_option').val();
if(whaws_alphabet_option.trim().length==0&&words.length==0){
module.exports=['ARCHAEOPTERYX', 'CARBONIFEROUS', 'TYRANNOSAURUS', 'BRACHIOSAURUS', 'ICHTHYOSAURUS', 'BRONTOSAURUS', 'PLESIOSAURUS', 'ANKYLOSAURUS', 'STEGOSAURUS', 'PLEISTOCENE', 'PTERODACTYL', 'ECHINODERM', 'EXTINCTION', 'CRETACEOUS', 'ALLOSAURUS', 'BAROSAURUS', 'ALLOSAURUS', 'PALAEOCENE', 'CEPHALOPOD', 'CRUSTACEAN', 'BELEMNITE', 'CROCODILE', 'OLIGOCENE', 'TRILOBITE', 'VERTEBRAE', 'CARNIVORE', 'IGUANODON', 'DINOSAUR', 'GASTONIA', 'DRACONYX', 'AMMONITE', 'TENTACLE', 'JURASSIC', 'TRIASSIC', 'DEINODON', 'CIONODON', 'CERATOPS', 'ASTEROID', 'BARYONYX', 'MOLLUSCS', 'MESOZOIC', 'RAPTOREX', 'HOLOCENE', 'OZRAPTOR', 'STARFISH', 'KILESKUS', 'ASTRODON', 'NAUTILUS', 'SAUROPOD', 'ECHINOID', 'FLIPPER', 'REPTILE', 'PERMIAN', 'MIOCENE', 'CALCITE', 'AETONYX', 'CRINOID', 'CRYSTAL', 'EXTINCT', 'SPECIES', 'BIVALVE', 'PACIFIC', 'CHISEL', 'FOSSIL', 'PERIOD', 'HAMMER', 'ISLAND', 'MAMMAL', 'EOCENE', 'INSECT', 'LIZARD', 'PEBBLE', 'PLANT', 'CORAL', 'STONE', 'AMBER', 'TOOTH', 'CLIFF', 'SHELL', 'OCEAN', 'SQUID', 'COAST', 'SHARK', 'SKULL', 'SPINE', 'CLAW', 'CAVE', 'TIDE', 'BIRD', 'LEAF', 'FISH', 'BONE', 'ROCK', 'PREY', 'COAL', 'FERN', 'LEAF', 'TAIL'];
}else{
module.exports=words;
}}
}).call(this);
}, {}]
}, {}, [1]);
jQuery(document).ready(function ($){
function DropDown(el){
this.dd=el;
this.placeholder=this.dd.children('span');
this.opts=this.dd.find('ul.wha-drop li');
this.val='';
this.index=-1;
this.initEvents();
}
DropDown.prototype={
initEvents: function (){
var obj=this;
obj.dd.on('click', function (e){
e.preventDefault();
e.stopPropagation();
$(this).toggleClass('active');
});
obj.opts.on('click', function (){
var opt=$(this);
obj.val=opt.text();
obj.index=opt.index();
obj.placeholder.text(obj.val);
opt.siblings().removeClass('selected');
opt.filter(':contains("' + obj.val + '")').addClass('selected');
}).change();
},
getValue: function (){
return this.val;
},
getIndex: function (){
return this.index;
}};
$(function (){
var dd1=new DropDown($('#noble-gases'));
$(document).click(function (){
$('.wha-wrap-drop').removeClass('active');
});
});
$('.wha-closemodale').click(function (e){
e.preventDefault();
$('.wha-modale').removeClass('opened');
if(jQuery("#wha-level-select-dropdown li").hasClass('selected')){
setTimeout(function (){
$("#wha-level-select-dropdown li.selected a").trigger("click");
$(".wha-wrap-drop").removeClass("active");
}, 100);
}else{
setTimeout(function (){
$("#wha-level-select-dropdown li:first-child a").trigger("click");
$(".wha-wrap-drop").removeClass("active");
}, 100);
}
jQuery('.wha-word-list button').removeClass('wha-solved wha-color')
});
window.addEventListener("keydown", function (e){
if(e.keyCode===114||(e.ctrlKey&&e.keyCode===70)){
e.preventDefault();
}})
var difficulty=optional_wordsearch_vars.whaws_level_difficulty;
var global_diff=jQuery('#wha-level-select-dropdown li:first-child a').val().replace(/x([0-9])/g, '');
jQuery(".wha-word-list button").each(function (){
var button_text=jQuery(this).text().replace(/\s/g, '').length;
if(button_text > difficulty||button_text > global_diff){
jQuery(this).hide();
}});
var grid_height=jQuery('.wha-ws-grid').height();
jQuery('.wha-word-list').css('max-height', grid_height + 80);
jQuery("#wha-level-select-dropdown li").click(function (){
var grid_height=jQuery('.wha-ws-grid').height();
jQuery('.wha-word-list').css('max-height', grid_height + 80);
})
var wha_ws_grid_width=jQuery('.wha-ws-grid').width();
jQuery('.wha-dir-bottom .wha-word-list').css('max-width', wha_ws_grid_width+'px');
jQuery('.wha-dir-top .wha-word-list').css('max-width', wha_ws_grid_width+'px');
});