src/lib/wordfindgame.js
function (puzzle, words, list, colorHash) {
                var solution = wordfind.solve(puzzle, words).found;
                for (var i = 0, len = solution.length; i < len; i++) {
                    var word = solution[i].word, orientation = solution[i].orientation, x = solution[i].x, y = solution[i].y, next = wordfind.orientations[orientation];
                    if (!$('.' + word).hasClass('wordFound')) {
                        var color = colorHash.hex(word);
                        list.append("<li class=\"" + word + "\"><i style=\"background-color:" + color + ";\"></i>" + word + "</li>");
                        for (var j = 0, size = word.length; j < size; j++) {
                            var nextPos = next(x, y, j);
                            //por cada letra de la palabra
                            //si no tiene bc
                            //se añade bc
                            //si tiene bc
                            //se añade un elemento hijo
                            //se añade el bc
                            var selected = $('[x="' + nextPos.x + '"][y="' + nextPos.y + '"]');
                            for (var selectedIndex = 0, selectedLength = selected.length; selectedIndex < selectedLength; selectedIndex++) {
                                var current = $(selected[selectedIndex]), childrens = current.find(".puzzleSquare"), item = childrens.length == 0 ? current : childrens.last(), style = item.attr("style"), hasBC = style != undefined && style.indexOf("background-color") - 1;
                                if (hasBC) {
                                    var subItem = $("<span class='puzzleSquare'>" + item.text() + "</span>")
                                        .css("background-color", color);
                                    item.text("");
                                    item.append(subItem);
                                }
                                else {
                                    current.css("background-color", color);
                                }
                            }
                            selected.addClass('solved');
                        }
                        $('.' + word).addClass('wordFound');
                    }
                }
                $('.puzzleSquare').off(".spl").trigger("end");
            }
function (puzzle, words, list, colorHash) {
                var solution = wordfind.solve(puzzle, words).found;
                for (var i = 0, len = solution.length; i < len; i++) {
                    var word = solution[i].word, orientation = solution[i].orientation, x = solution[i].x, y = solution[i].y, next = wordfind.orientations[orientation];
                    if (!$('.' + word).hasClass('wordFound')) {
                        var color = colorHash.hex(word);
                        list.append("<li class=\"" + word + "\"><i style=\"background-color:" + color + ";\"></i>" + word + "</li>");
                        for (var j = 0, size = word.length; j < size; j++) {
                            var nextPos = next(x, y, j);
                            //por cada letra de la palabra
                            //si no tiene bc
                            //se añade bc
                            //si tiene bc
                            //se añade un elemento hijo
                            //se añade el bc
                            var selected = $('[x="' + nextPos.x + '"][y="' + nextPos.y + '"]');
                            for (var selectedIndex = 0, selectedLength = selected.length; selectedIndex < selectedLength; selectedIndex++) {
                                var current = $(selected[selectedIndex]), childrens = current.find(".puzzleSquare"), item = childrens.length == 0 ? current : childrens.last(), style = item.attr("style"), hasBC = style != undefined && style.indexOf("background-color") - 1;
                                if (hasBC) {
                                    var subItem = $("<span class='puzzleSquare'>" + item.text() + "</span>")
                                        .css("background-color", color);
                                    item.text("");
                                    item.append(subItem);
                                }
                                else {
                                    current.css("background-color", color);
                                }
                            }
                            selected.addClass('solved');
                        }
                        $('.' + word).addClass('wordFound');
                    }
                }
                $('.puzzleSquare').off(".spl").trigger("end");
            }
function ( puzzle , words , list , colorHash ) { var solution = wordfind . solve ( puzzle , words ) . found ; for ( var i = 0 , len = solution . length ; i < len ; i ++ ) { var word = solution [ i ] . word , orientation = solution [ i ] . orientation , x = solution [ i ] . x , y = solution [ i ] . y , next = wordfind . orientations [ orientation ] ; if ( ! $ ( '.' + word ) . hasClass ( 'wordFound' ) ) { var color = colorHash . hex ( word ) ; list . append ( "<li class=\"" + word + "\"><i style=\"background-color:" + color + ";\"></i>" + word + "</li>" ) ; for ( var j = 0 , size = word . length ; j < size ; j ++ ) { var nextPos = next ( x , y , j ) ; //por cada letra de la palabra //si no tiene bc //se añade bc //si tiene bc //se añade un elemento hijo //se añade el bc var selected = $ ( '[x="' + nextPos . x + '"][y="' + nextPos . y + '"]' ) ; for ( var selectedIndex = 0 , selectedLength = selected . length ; selectedIndex < selectedLength ; selectedIndex ++ ) { var current = $ ( selected [ selectedIndex ] ) , childrens = current . find ( ".puzzleSquare" ) , item = childrens . length == 0 ? current : childrens . last ( ) , style = item . attr ( "style" ) , hasBC = style != undefined && style . indexOf ( "background-color" ) - 1 ; if ( hasBC ) { var subItem = $ ( "<span class='puzzleSquare'>" + item . text ( ) + "</span>" ) . css ( "background-color" , color ) ; item . text ( "" ) ; item . append ( subItem ) ; } else { current . css ( "background-color" , color ) ; } } selected . addClass ( 'solved' ) ; } $ ( '.' + word ) . addClass ( 'wordFound' ) ; } } $ ( '.puzzleSquare' ) . off ( ".spl" ) . trigger ( "end" ) ; }
Solves an existing puzzle.

@param {[[String]]} puzzle: The puzzle to solve
@param {[String]} words: The words to solve for
Solves an existing puzzle .