The Essential Guide to HTML5
MAZES Our application uses a JavaScript alert box to show a message. The user needs to click the OK button to remove the alert b ...
CHAPTER 7 The command localStorage.setItem("lastdate",olddate) sets up a new key/value pair or replaces any previous one with th ...
MAZES alert("Stored: "+olddate); } catch(e) { alert("Error with use of local storage: "+e);} } If you removed the if (typeof(loc ...
CHAPTER 7 Code Explanation try { Set up try clause olddate = new Date(); Define new Date localStorage.setItem("lastdate",olddate ...
MAZES Code Explanation } Close clause return false; Return false to prevent page refresh. } Close function function fetch() { Fe ...
CHAPTER 7 Code Explanation </body> Closing body tag </html> Closing html tag Combining the Date function with localS ...
MAZES catch (e) { alert("data not saved, error given: "+e); } This is a general technique that will try something, suppress any ...
CHAPTER 7 Notice that all three input elements have the same name. This is what defines the group of buttons of which only one m ...
MAZES Function Invoked By / Called By Calls drawtoken drawall using draw method for the token object in the everything array mov ...
CHAPTER 7 Code Explanation var everything = []; To hold everything var curwall; For wall in progress var wallwidth = 5; Fixed wa ...
MAZES Code Explanation ctx.beginPath(); Begin path ctx.moveTo(this.sx+radMath.cos (-.5this.angle),this.sy+radMath.sin (-.5this ...
CHAPTER 7 Code Explanation } Close if true clause } Close for loop } Close function function Wall(sx,sy,fx,fy,width,stylestring) ...
MAZES Code Explanation function init(){ Function header init ctx = document.getElementById ('canvas').getContext('2d'); Define ...
CHAPTER 7 Code Explanation } Close clause curwall = new Wall(mx,my,mx+1,my+1,wallwidth,wallstyle); Create new wall. It is small ...
MAZES Code Explanation drawall(); Draw everything (will show growing wall) } Close if inmotion } Close function function finish( ...
CHAPTER 7 Code Explanation keyCode = event.keyCode; Get keyCode from event event.preventDefault(); Stop default action } Close c ...
MAZES Code Explanation } Close function Function intersect(sx,sy,fx,fy,cx,cy,rad) { Function header intersect var dx; For interm ...
CHAPTER 7 Code Explanation Return false;} Return false } Close function function savewalls() { Function savewalls header var w = ...
MAZES Code Explanation } End try catch (e) { If a catchable error alert("data not saved, error given: "+e); Display message } E ...
CHAPTER 7 Code Explanation sw = wallstgs[i].split("+"); Split individual item sx = Number(sw[0]); Extract 0th value and convert ...
«
8
9
10
11
12
13
14
15
16
17
»
Free download pdf