1
0

Mark original numbers with grey background.

This commit is contained in:
Markus Birth 2014-01-26 15:52:13 +01:00
parent e947dc9eed
commit 0dddd732c9
6 changed files with 31 additions and 2 deletions

View File

@ -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;

View File

@ -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 = ''

View File

@ -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

View File

@ -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 = '';

View File

@ -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;
})();

View File

@ -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) {