HTML and CSS Reference
In-Depth Information
Figure 13-24
Highlighting incorrect cells
cells incorrectly darkened
cells incorrectly
identified as empty
initial markin g of
the puzzle cells
c ell incorrectly
identified as empty
Rebecca wants the hints to appear only for a brief time, after which the puzzle should
be returned to its previous state. To do this, you'll create the unpeek() function, which
will restore all red data cells in the puzzle table back to gray and all pink cells back to
white. The form of the unpeek() function will closely resemble that of the peek() function.
You'll run the function half a second after the peek() function is run.
To create the unpeek() function:
1. Return to the hanjie.js file in your text editor.
2. Directly after the peek() function, insert the following unpeek() function as shown
in Figure 13-25:
function unpeek() {
/* Create collection of all puzzle data cells */
var allCells = document.querySelectorAll(“#hanjieGrid td”);
/* Change all pink cells back to white and
change all red cells back to dark gray */
for (var i = 0; i < allCells.length; i++) {
var cell = allCells[i];
if ( == “rgb(255, 192, 192)”) = “white”;
if ( == “red”) = “rgb(101, 101, 101)”;
Figure 13-25
creating the unpeek() function
Search WWH ::

Custom Search