CHAPTER 7
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 ScriptFunction Invoked By / Called By Callsinit Invoked by action of onLoad in body tag drawalldrawall Init
startwall
stretchwall
getkeyAndMove
getwallsdraw method for Walls and for
token: drawtoken and
drawAlineToken var statement declaring mypentWall startwalldrawtoken drawall using draw method for the token object in
the everything arraymovetoken getkeyAndMove using the moveit method for
mypentintersectdrawAline drawall using draw method for Wall objects in the
everything arraygetkeyAndMove (^) Invoked by action of an addEventListener call in
init
movetoken using the moveit
method for mypent
getwalls (^) Invoked by action of onSubmit for the gf form drawall
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.