HTML and CSS Reference
In-Depth Information
Creating the second maze application
The localStorage data can be accessed by a different application from the one that created the data, as
long as it is on the same server. This is a security feature, as mentioned previously, restricting readers of
local storage to scripts on the same server.
The second script is based on this feature. Table 7-4 shows the functions calling or being called; it is a
subset of the previous one.
Table 7-4 . Functions in the Travel Maze Script
Function
Invoked By / Called By
Calls
init
drawall
Invoked by action of onLoad in body tag
drawall
Init
startwall
stretchwall
getkeyAndMove
getwalls
draw method for Wall s and for
token: drawtoken and
drawAline
Token
var statement declaring mypent
Wall
startwall
drawtoken
drawall using draw method for the token object in
the everything array
movetoken
getkeyAndMove using the moveit method for
mypent
intersect
drawAline
drawall using draw method for Wall objects in the
everything array
movetoken using the moveit
method for mypent
getkeyAndMove Invoked by action of an addEventListener call in
init
getwalls
drawall
Invoked by action of onSubmit for the gf form
The functions are exactly the same as in the all-in-one script with one exception, the getwalls function,
so Ive only commented the new or changed code. This application also has radio buttons in place of the
form input fields. Table 7-5 shows the complete code for the travelmaze application.
 
Search WWH ::




Custom Search