Skip to content

Commit e874706

Browse files
committed
Changed <select> elements to links.
This guarantees accurate event handling.
1 parent 07c6816 commit e874706

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

Sudoku.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ a:active {
6969
cursor: help;
7070
}
7171

72+
#guessing_tools_table {
73+
border-width: 0px;
74+
border-spacing: 0px;
75+
margin: 10px 0px 10px 40px;
76+
padding: 0px;
77+
}
78+
7279
.cell {
7380
border-bottom-style: none;
7481
border-color: black;
@@ -154,6 +161,10 @@ a:active {
154161
padding: 1px 4px;
155162
}
156163

164+
.blank_cell_highlight_black input {
165+
color: black;
166+
}
167+
157168
.blank_cell_highlight_red input {
158169
color: red;
159170
}

Sudoku.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,16 @@ function setBlankCells(color) {
388388
}
389389

390390
}
391-
391+
392+
// Highlight selected link.
393+
document.getElementById("mark_blank_cells_" + cells.blankCellColor).style.backgroundColor = "";
394+
document.getElementById("mark_blank_cells_" + color).style.backgroundColor = "#FF8";
395+
392396
cells.blankCellColor = color;
393397
}
394398

395-
function deleteColoredCells(element) {
396-
var color = element.value.toLowerCase();
397-
element.value = "Select Color";
398-
399-
if (color === "select color" || !confirm("Are you sure you want to delete all cells marked " + color + "?")) {
399+
function deleteColoredCells(color) {
400+
if (!confirm("Are you sure you want to delete all cells marked " + color + "?")) {
400401
return;
401402
}
402403

@@ -405,10 +406,6 @@ function deleteColoredCells(element) {
405406
for (var i = 0; i < 81; i++) {
406407
currentCell = cells[i];
407408

408-
// if (currentCell.value !== 0) {
409-
// console.log(currentCell.element.classList.contains("blank_cell_highlight_" + color));
410-
// }
411-
412409
if (currentCell.value !== 0 && currentCell.element.classList.contains("blank_cell_highlight_" + color)) {
413410
currentCell.element.firstChild.value = "";
414411
currentCell.setValue(0);

index.html

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
</ul>
7878

7979
<div class="small_header">Guessing tools:</div>
80-
<ul>
80+
<!-- <ul>
8181
<li>
8282
Mark blank cells:
8383
<select title="Mark all blank cells a unique color so they can be deleted easily. This is useful for making guesses." onchange="this.style.color = this.value.toLowerCase(); setBlankCells(this.value.toLowerCase());">
@@ -98,7 +98,26 @@
9898
<option style="color: purple;">Purple</option>
9999
</select>
100100
</li>
101-
</ul>
101+
</ul> -->
102+
<table id="guessing_tools_table">
103+
<tbody>
104+
<tr>
105+
<td>Mark blank cells:</td>
106+
<td><a href="javascript:void(0);" onclick="setBlankCells('black');" style="color: black; background-color: #FF8;" id="mark_blank_cells_black" title="Mark all blank cells black so they can be deleted easily. This is useful for making guesses.">Black</a></td>
107+
<td><a href="javascript:void(0);" onclick="setBlankCells('blue');" style="color: blue;" id="mark_blank_cells_blue" title="Mark all blank cells blue so they can be deleted easily. This is useful for making guesses.">Blue</a></td>
108+
<td><a href="javascript:void(0);" onclick="setBlankCells('red');" style="color: red;" id="mark_blank_cells_red" title="Mark all blank cells red so they can be deleted easily. This is useful for making guesses.">Red</a></td>
109+
<td><a href="javascript:void(0);" onclick="setBlankCells('green');" style="color: green;" id="mark_blank_cells_green" title="Mark all blank cells green so they can be deleted easily. This is useful for making guesses.">Green</a></td>
110+
<td><a href="javascript:void(0);" onclick="setBlankCells('purple');" style="color: purple;" id="mark_blank_cells_purple" title="Mark all blank cells purple so they can be deleted easily. This is useful for making guesses.">Purple</a></td>
111+
</tr><tr>
112+
<td>Delete cells marked:</td>
113+
<td><a href="javascript:void(0);" onclick="deleteColoredCells('black');" style="color: black;" title="Delete all cells marked black.">Black</a></td>
114+
<td><a href="javascript:void(0);" onclick="deleteColoredCells('blue');" style="color: blue;" title="Delete all cells marked blue.">Blue</a></td>
115+
<td><a href="javascript:void(0);" onclick="deleteColoredCells('red');" style="color: red;" title="Delete all cells marked red.">Red</a></td>
116+
<td><a href="javascript:void(0);" onclick="deleteColoredCells('green');" style="color: green;" title="Delete all cells marked green.">Green</a></td>
117+
<td><a href="javascript:void(0);" onclick="deleteColoredCells('purple');" style="color: purple;" title="Delete all cells marked purple.">Purple</a></td>
118+
</tr>
119+
</tbody>
120+
</table>
102121

103122
<div class="small_header">Solution/Hints:</div>
104123
<ul>

0 commit comments

Comments
 (0)