js/arrangeTiles.js
// Generates board of given size and adds it to the DOM.
Generates board of given size and adds it to the DOM.
Generates board of given size and adds it to the DOM .
function generateBoard() {
            var rows = $([]),
                gridTiles = grid.getTiles();
            for (var r = 0; r < gridSize; r++) {
                var rowTemp = rowTemplate[0].innerHTML.replace('#', r.toString()),
                    row = $([]).add(rowTemp);
                for (var c = 0; c < gridSize; c++) {
                    var tileNum = gridTiles[r][c],
                        colTemp,
                        col;
                    colTemp = colTemplate[0].innerHTML.replace(/@colNum/g, c.toString())
                                                      .replace(/@tileNum/, tileNum.toString());
                    col =  $([]).add(colTemp);
                    if (tileNum === 0) {
                        col.addClass("blank");
                    }
                    col.data("row", r)
                       .data("col", c);
                    row.first().append(col);
                }
                rows = rows.add(row);
            }
            board.empty()
                 .append(rows);
        }
function generateBoard ( ) { var rows = $ ( [ ] ) , gridTiles = grid . getTiles ( ) ; for ( var r = 0 ; r < gridSize ; r ++ ) { var rowTemp = rowTemplate [ 0 ] . innerHTML . replace ( '#' , r . toString ( ) ) , row = $ ( [ ] ) . add ( rowTemp ) ; for ( var c = 0 ; c < gridSize ; c ++ ) { var tileNum = gridTiles [ r ] [ c ] , colTemp , col ; colTemp = colTemplate [ 0 ] . innerHTML . replace ( / @colNum / g , c . toString ( ) ) . replace ( / @tileNum / , tileNum . toString ( ) ) ; col = $ ( [ ] ) . add ( colTemp ) ; if ( tileNum === 0 ) { col . addClass ( "blank" ) ; } col . data ( "row" , r ) . data ( "col" , c ) ; row . first ( ) . append ( col ) ; } rows = rows . add ( row ) ; } board . empty ( ) . append ( rows ) ; }
Generates board of given size and adds it to the DOM.
Generates board of given size and adds it to the DOM .