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;
|
border-top: 2px solid black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table.sudoku td.original {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
table.sudoku td.changed {
|
table.sudoku td.changed {
|
||||||
background-color: #fdd;
|
background-color: #fdd;
|
||||||
border: 2px solid red;
|
border: 2px solid red;
|
||||||
|
@ -27,6 +27,7 @@ class @SudokuBoard
|
|||||||
r = Math.floor(i / @dim2)
|
r = Math.floor(i / @dim2)
|
||||||
c = i % @dim2
|
c = i % @dim2
|
||||||
@board[r][c].setValue(boardString.charAt(i))
|
@board[r][c].setValue(boardString.charAt(i))
|
||||||
|
@board[r][c].setOriginal(true) unless boardString.charAt(i) is '.'
|
||||||
@board[r][c].resetChangeFlag()
|
@board[r][c].resetChangeFlag()
|
||||||
@setCheckDiags(alsoCheckDiags)
|
@setCheckDiags(alsoCheckDiags)
|
||||||
console.log('Board loaded.')
|
console.log('Board loaded.')
|
||||||
@ -57,6 +58,7 @@ class @SudokuBoard
|
|||||||
cssclasses.push('tborder') if r % @dim is 0
|
cssclasses.push('tborder') if r % @dim is 0
|
||||||
cssclasses.push('lborder') if c % @dim is 0
|
cssclasses.push('lborder') if c % @dim is 0
|
||||||
cssclasses.push('changed') if @cellAt(r, c).hasChanged()
|
cssclasses.push('changed') if @cellAt(r, c).hasChanged()
|
||||||
|
cssclasses.push('original') if @cellAt(r, c).isOriginal()
|
||||||
value = @cellAt(r, c).getValue()
|
value = @cellAt(r, c).getValue()
|
||||||
if value is '.'
|
if value is '.'
|
||||||
value = ''
|
value = ''
|
||||||
|
@ -2,6 +2,7 @@ class @SudokuCell
|
|||||||
constructor: (initVal, boardObj) ->
|
constructor: (initVal, boardObj) ->
|
||||||
@boardObj = boardObj
|
@boardObj = boardObj
|
||||||
@changed = false
|
@changed = false
|
||||||
|
@original = false
|
||||||
@value = 0
|
@value = 0
|
||||||
@set = (1 << @boardObj.dim2) - 1 # all
|
@set = (1 << @boardObj.dim2) - 1 # all
|
||||||
@setValue(initVal) # init cell
|
@setValue(initVal) # init cell
|
||||||
@ -46,3 +47,10 @@ class @SudokuCell
|
|||||||
|
|
||||||
resetChangeFlag: ->
|
resetChangeFlag: ->
|
||||||
@changed = false
|
@changed = false
|
||||||
|
|
||||||
|
setOriginal: (newValue) ->
|
||||||
|
@original = newValue
|
||||||
|
|
||||||
|
isOriginal: ->
|
||||||
|
return @original
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
r = Math.floor(i / this.dim2);
|
r = Math.floor(i / this.dim2);
|
||||||
c = i % this.dim2;
|
c = i % this.dim2;
|
||||||
this.board[r][c].setValue(boardString.charAt(i));
|
this.board[r][c].setValue(boardString.charAt(i));
|
||||||
|
if (boardString.charAt(i) !== '.') {
|
||||||
|
this.board[r][c].setOriginal(true);
|
||||||
|
}
|
||||||
this.board[r][c].resetChangeFlag();
|
this.board[r][c].resetChangeFlag();
|
||||||
}
|
}
|
||||||
this.setCheckDiags(alsoCheckDiags);
|
this.setCheckDiags(alsoCheckDiags);
|
||||||
@ -83,6 +86,9 @@
|
|||||||
if (this.cellAt(r, c).hasChanged()) {
|
if (this.cellAt(r, c).hasChanged()) {
|
||||||
cssclasses.push('changed');
|
cssclasses.push('changed');
|
||||||
}
|
}
|
||||||
|
if (this.cellAt(r, c).isOriginal()) {
|
||||||
|
cssclasses.push('original');
|
||||||
|
}
|
||||||
value = this.cellAt(r, c).getValue();
|
value = this.cellAt(r, c).getValue();
|
||||||
if (value === '.') {
|
if (value === '.') {
|
||||||
value = '';
|
value = '';
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
function SudokuCell(initVal, boardObj) {
|
function SudokuCell(initVal, boardObj) {
|
||||||
this.boardObj = boardObj;
|
this.boardObj = boardObj;
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
|
this.original = false;
|
||||||
this.value = 0;
|
this.value = 0;
|
||||||
this.set = (1 << this.boardObj.dim2) - 1;
|
this.set = (1 << this.boardObj.dim2) - 1;
|
||||||
this.setValue(initVal);
|
this.setValue(initVal);
|
||||||
@ -68,6 +69,14 @@
|
|||||||
return this.changed = false;
|
return this.changed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SudokuCell.prototype.setOriginal = function(newValue) {
|
||||||
|
return this.original = newValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
SudokuCell.prototype.isOriginal = function() {
|
||||||
|
return this.original;
|
||||||
|
};
|
||||||
|
|
||||||
return SudokuCell;
|
return SudokuCell;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -295,8 +295,8 @@
|
|||||||
'twoValPlacesColumn': 'Only two possible places for pair in column.',
|
'twoValPlacesColumn': 'Only two possible places for pair in column.',
|
||||||
'twoValPlacesDiag': 'Only two possible places for pair in diagonale.',
|
'twoValPlacesDiag': 'Only two possible places for pair in diagonale.',
|
||||||
'oneUnknownAll': 'Only one possible value left.',
|
'oneUnknownAll': 'Only one possible value left.',
|
||||||
'oneColumnForValue': 'Only one possible column for value.',
|
'oneColumnForValue': 'Only one possible column in block for value.',
|
||||||
'oneRowForValue': 'Only one possible row for value.'
|
'oneRowForValue': 'Only one possible row in block for value.'
|
||||||
};
|
};
|
||||||
i = 1;
|
i = 1;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
Reference in New Issue
Block a user