DHTML Jigsaw Puzzle: NN4; The Control Panel | WebReference

DHTML Jigsaw Puzzle: NN4; The Control Panel

Logo

The DHTML Lab Jigsaw Puzzle, Part III: NN4
the control panel


The discussion on this page is more or less repetition, as the functions covered are exactly like the IE versions. Only the third SELECT menu has a change made necessary by Navigator.

The Hint Button

The Hint button calls the giveHint() function. If the puzzle is broken, a single piece solve is performed by calling solve() with an argument of false.

    function giveHint() { if (isBroken) { solve(false) }; }

The Grid ON/OFF Button

The Grid ON/OFF button calls the gridToggle() function. If the grid is presently visible, it is made hidden, and the button value is changed to reflect the change. If the grid is not visible, the setGrid() function is called to initialize it and make it visible. In both cases, the value of isGrid, which tracks grid visibility, is toggled.

    function gridToggle() { if (isGrid) { elGrid.visibility = "hide"; gridBut.value = "Grid OFF"; } else { setGrid() }; isGrid = !isGrid; }

The Drag ON/OFF Button

The Drag ON/OFF button calls the dragToggle() function, to enable or disable full puzzle draggability. The value of isPuzzDraggable is toggled. If the puzzle is not broken, elPuzzle's draggable property is toggled as well. Finally the button display is changed to conform.

    function dragToggle() { isPuzzDraggable = !isPuzzDraggable; if (!isBroken) { elPuzzle.draggable = !elPuzzle.draggable }; if (isPuzzDraggable) { dragBut.value = "Drag ON"; } else { dragBut.value = "Drag OFF"; } }

The SELECT Menus

Let's take a brief look at what the three SELECT drop-down menus do. If the user changes the Across or Down menus, the puzzAcross or puzzDown variables are updated to store the new value. Since changing the piece count calls for a new puzzle to be created, isNewPuzz becomes true and isCreated becomes false. The user can continue playing. The new settings will take effect when the user calls for a Break or loads a new puzzle image.

    <B STYLE="font:bold 9pt sans-serif;">Across:</B> <SELECT onChange="puzzAcross = options[selectedIndex].value; isNewPuzz = true; isCreated = false;"> <OPTION VALUE=2>2 . . . <OPTION VALUE=9>9 </SELECT> . . . <B STYLE="font:bold 9pt sans-serif;">Down:</B> <SELECT onChange="puzzDown = options[selectedIndex].value; isNewPuzz = true; isCreated = false;"> <OPTION VALUE=2>2 . . . <OPTION VALUE=9>9 </SELECT> . . . <B STYLE="font:bold 9pt sans-serif;">Puzzle:</B> <SELECT onChange="initPuzz(options[selectedIndex].value);"> <OPTION VALUE="selfPort.jpg">Self Portrait . . . <OPTION VALUE="guernica.jpg">Guernica </SELECT>

The image SELECT menu brings about instant changes by calling the initPuzz() function with the selected new image src as an argument. It doesn't swap the image like the IE version does, since we need to reload the image by writing new HTML.

Now, let's look at that puzzle again, and sum up.


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Nov. 27, 1997
Revised: Jan. 18, 1998

URL: https://www.webreference.com/dhtml/column10/puzzNSmisc.html