Skip to content

Commit 07c6816

Browse files
committed
Add black option to delete cells marked (color).
1 parent 1b277ef commit 07c6816

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

Sudoku.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ function submitGivens() {
296296

297297
if (currentCell.value !== 0) {
298298
currentCell.element.innerHTML = currentCell.value;
299+
} else {
300+
currentCell.element.classList.add("blank_cell_highlight_black");
299301
}
300302

301303
currentCell.solution = parseInt(cells.solution[i]);
@@ -376,14 +378,13 @@ function setBlankCells(color) {
376378
currentCell = cells[i];
377379

378380
if (currentCell.value === 0) {
381+
currentCell.element.classList.remove("blank_cell_highlight_black");
379382
currentCell.element.classList.remove("blank_cell_highlight_red");
380383
currentCell.element.classList.remove("blank_cell_highlight_blue");
381384
currentCell.element.classList.remove("blank_cell_highlight_green");
382385
currentCell.element.classList.remove("blank_cell_highlight_purple");
383386

384-
if (color !== "black") {
385-
currentCell.element.classList.add("blank_cell_highlight_" + color);
386-
}
387+
currentCell.element.classList.add("blank_cell_highlight_" + color);
387388
}
388389

389390
}
@@ -395,7 +396,7 @@ function deleteColoredCells(element) {
395396
var color = element.value.toLowerCase();
396397
element.value = "Select Color";
397398

398-
if (color === "select color" || !confirm("Are you sure you want to delete all cells marked "+color+"?")) {
399+
if (color === "select color" || !confirm("Are you sure you want to delete all cells marked " + color + "?")) {
399400
return;
400401
}
401402

@@ -404,8 +405,9 @@ function deleteColoredCells(element) {
404405
for (var i = 0; i < 81; i++) {
405406
currentCell = cells[i];
406407

407-
if (currentCell.value !== 0)
408-
console.log(currentCell.element.classList.contains("blank_cell_highlight_" + color));
408+
// if (currentCell.value !== 0) {
409+
// console.log(currentCell.element.classList.contains("blank_cell_highlight_" + color));
410+
// }
409411

410412
if (currentCell.value !== 0 && currentCell.element.classList.contains("blank_cell_highlight_" + color)) {
411413
currentCell.element.firstChild.value = "";
@@ -414,9 +416,7 @@ function deleteColoredCells(element) {
414416

415417
currentCell.element.classList.remove("blank_cell_highlight_" + color);
416418

417-
if (color !== "black") {
418-
currentCell.element.classList.add("blank_cell_highlight_" + cells.blankCellColor);
419-
}
419+
currentCell.element.classList.add("blank_cell_highlight_" + cells.blankCellColor);
420420
}
421421
}
422422

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
Delete cells marked:
9292
<select title="Delete all cells marked a certain color." onchange="deleteColoredCells(this);">
9393
<option selected="selected">Select Color</option>
94+
<option style="color: black;">Black</option>
9495
<option style="color: blue;">Blue</option>
9596
<option style="color: red;">Red</option>
9697
<option style="color: green;">Green</option>

test/keyCode.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<html>
22
<head></head>
33
<body>
4-
The keyCode for the inputted key is: <input onkeydown="this.value = window.event.keyCode || window.event.charCode; return false;" />
4+
<h2>onkeydown</h2>
5+
<p>The keyCode for the inputted key is: <input onkeydown="this.value = window.event.keyCode || window.event.charCode; return false;" /></p>
6+
7+
<h2>onkeypress</h2>
8+
<p>The keyCode for the inputted key is: <input onkeypress="this.value = window.event.keyCode || window.event.charCode; return false;" /></p>
59
</body>
610
</html>

0 commit comments

Comments
 (0)