Mark original numbers with grey background.
This commit is contained in:
parent
e947dc9eed
commit
0dddd732c9
@ -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;
|
||||
|
@ -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 = ''
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 = '';
|
||||
|
@ -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;
|
||||
|
||||
})();
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user