diff --git a/SudokuSolver.css b/SudokuSolver.css index 2e4a4ca..bed0d62 100644 --- a/SudokuSolver.css +++ b/SudokuSolver.css @@ -18,6 +18,10 @@ table.sudoku td.tborder { border-top: 2px solid black; } +table.sudoku td.original { + background-color: #ccc; +} + table.sudoku td.changed { background-color: #fdd; border: 2px solid red; diff --git a/coffee/SudokuBoard.class.coffee b/coffee/SudokuBoard.class.coffee index 484144a..4d2d9bd 100644 --- a/coffee/SudokuBoard.class.coffee +++ b/coffee/SudokuBoard.class.coffee @@ -27,6 +27,7 @@ class @SudokuBoard r = Math.floor(i / @dim2) c = i % @dim2 @board[r][c].setValue(boardString.charAt(i)) + @board[r][c].setOriginal(true) unless boardString.charAt(i) is '.' @board[r][c].resetChangeFlag() @setCheckDiags(alsoCheckDiags) console.log('Board loaded.') @@ -57,6 +58,7 @@ class @SudokuBoard cssclasses.push('tborder') if r % @dim is 0 cssclasses.push('lborder') if c % @dim is 0 cssclasses.push('changed') if @cellAt(r, c).hasChanged() + cssclasses.push('original') if @cellAt(r, c).isOriginal() value = @cellAt(r, c).getValue() if value is '.' value = '' diff --git a/coffee/SudokuCell.class.coffee b/coffee/SudokuCell.class.coffee index 55d3938..e088f86 100644 --- a/coffee/SudokuCell.class.coffee +++ b/coffee/SudokuCell.class.coffee @@ -2,6 +2,7 @@ class @SudokuCell constructor: (initVal, boardObj) -> @boardObj = boardObj @changed = false + @original = false @value = 0 @set = (1 << @boardObj.dim2) - 1 # all @setValue(initVal) # init cell @@ -46,3 +47,10 @@ class @SudokuCell resetChangeFlag: -> @changed = false + + setOriginal: (newValue) -> + @original = newValue + + isOriginal: -> + return @original + diff --git a/js/SudokuBoard.class.js b/js/SudokuBoard.class.js index a646880..299cba4 100644 --- a/js/SudokuBoard.class.js +++ b/js/SudokuBoard.class.js @@ -37,6 +37,9 @@ r = Math.floor(i / this.dim2); c = i % this.dim2; this.board[r][c].setValue(boardString.charAt(i)); + if (boardString.charAt(i) !== '.') { + this.board[r][c].setOriginal(true); + } this.board[r][c].resetChangeFlag(); } this.setCheckDiags(alsoCheckDiags); @@ -83,6 +86,9 @@ if (this.cellAt(r, c).hasChanged()) { cssclasses.push('changed'); } + if (this.cellAt(r, c).isOriginal()) { + cssclasses.push('original'); + } value = this.cellAt(r, c).getValue(); if (value === '.') { value = ''; diff --git a/js/SudokuCell.class.js b/js/SudokuCell.class.js index 7632740..16670c1 100644 --- a/js/SudokuCell.class.js +++ b/js/SudokuCell.class.js @@ -4,6 +4,7 @@ function SudokuCell(initVal, boardObj) { this.boardObj = boardObj; this.changed = false; + this.original = false; this.value = 0; this.set = (1 << this.boardObj.dim2) - 1; this.setValue(initVal); @@ -68,6 +69,14 @@ return this.changed = false; }; + SudokuCell.prototype.setOriginal = function(newValue) { + return this.original = newValue; + }; + + SudokuCell.prototype.isOriginal = function() { + return this.original; + }; + return SudokuCell; })(); diff --git a/js/SudokuSolver.class.js b/js/SudokuSolver.class.js index 4815657..5a45d88 100644 --- a/js/SudokuSolver.class.js +++ b/js/SudokuSolver.class.js @@ -295,8 +295,8 @@ 'twoValPlacesColumn': 'Only two possible places for pair in column.', 'twoValPlacesDiag': 'Only two possible places for pair in diagonale.', 'oneUnknownAll': 'Only one possible value left.', - 'oneColumnForValue': 'Only one possible column for value.', - 'oneRowForValue': 'Only one possible row for value.' + 'oneColumnForValue': 'Only one possible column in block for value.', + 'oneRowForValue': 'Only one possible row in block for value.' }; i = 1; while (true) {