Assignment2365

Assignment2365 - intLastClicked=-1; drawPuzzle(); } }...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
<!Assignment #6:> <html> <head> <title>Assignment6</title> <b> Assignment #6: One-dimensional Jigsaw Puzzle </b> <script> var intLastClicked=-1; var arrImageSource = new Array(5); var arrImageSequence = new Array(5); function initPuzzle() { arrImageSource = ['Scrambled Images Here']; arrImageSequence = [4,0,5,3,2,1]; drawPuzzle(); } function lastClick(intClicked) { if (intLastClicked==-1) { intLastClicked=intClicked; document.getElementById("img"+intClicked).border="2"; } else { strTemp=arrImageSource[intLastClicked]; intTemp=arrImageSequence[intLastClicked]; arrImageSource[intLastClicked]=arrImageSource[intClicked]; arrImageSequence[intLastClicked]=arrImageSequence[intClicked]; arrImageSource[intClicked]=strTemp; arrImageSequence[intClicked]=intTemp; document.getElementById("img"+intLastClicked).border="0";
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: intLastClicked=-1; drawPuzzle(); } } function drawPuzzle() { for(t=0;t&amp;lt;=5;t++) { document.getElementById(&amp;quot;img&amp;quot;+t).src=arrImageSource[t]; } if(arrImageSequence == &amp;quot;0,1,2,3,4,5&amp;quot;) { alert(&amp;quot;You solved the puzzle in '+n+' clicks!&amp;quot;); initPuzzle(); } } &amp;lt;/script&amp;gt; &amp;lt;/head&amp;gt; &amp;lt;body onLoad=&amp;quot;initPuzzle();&amp;quot;&amp;gt; &amp;lt;form name = &amp;quot;form&amp;quot;&amp;gt; &amp;lt;table border='1' cellpadding='0' cellspacing='0'&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td&amp;gt;&amp;lt;img id = &amp;quot;img0&amp;quot; onclick = &amp;quot;lastClick(0);&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;img id = &amp;quot;img1&amp;quot; onclick = &amp;quot;lastClick(1);&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;img id = &amp;quot;img2&amp;quot; onclick = &amp;quot;lastClick(2);&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;img id = &amp;quot;img3&amp;quot; onclick = &amp;quot;lastClick(3);&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;img id = &amp;quot;img4&amp;quot; onclick = &amp;quot;lastClick(4);&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td&amp;gt;&amp;lt;img id = &amp;quot;img5&amp;quot; onclick = &amp;quot;lastClick(5);&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt; &amp;lt;/table&amp;gt; &amp;lt;/form&amp;gt; &amp;lt;/body&amp;gt; &amp;lt;/html&amp;gt;...
View Full Document

Ask a homework question - tutors are online