Previous Tip  |  Next Tip  |  Design Tips   | [Bill's Home]

138. Reusing content

I've said it before, and I'll say it again: 'You must always design for reuse'. In the previous design tips I've shown how a wireless access point emulator can be constructed. Now let's take it one step forward to use it to assess skills. For this the emulator is setup with a challenge, and the user must complete the challenge within a given time. The help window is now used to show the challenge:

The help window is set with:

 

h._visible=true;
tab02._alpha=50;
help_flag=true;

 

 

and an interrupt function is used to check the number of correct answers, and update the time:

 

myInterrupt2 = function () {
time.text=getuptime();
nocorrect=0;
if (ipaddress=="140.10.11.12") nocorrect++;
if (subnetmask=="255.255.255.0") nocorrect++;
if (gateway=="140.10.11.1") nocorrect++;
if (ssid=="mynetwork") nocorrect++;
if (sysname=="fred") nocorrect++;
if (wepkey=="fredkey") nocorrect++;
correct.text=nocorrect;
if (getuptime()=="0:5:0")
{
h._visible=true;
h.window.htmltext="Timeout " + getuptime() + "<BR>Please refresh the page to restart" ;
clearInterval(id2);
}
if (nocorrect==6)
{
h._visible=true;
h.window.htmltext="Well done!<BR>That took you " + getuptime();
clearInterval(id2);

}
}


function getuptime()
{
dat= new Date();

sec_now=dat.getTime();

dat.setTime(sec_now-sec_start);

hr=dat.getHours();
min=dat.getMinutes();
sec=dat.getSeconds();
return(hr.toString() + ":" + min.toString() + ":" + sec.toString());
}

 

 

and then the function getuptime() is called every time that the uptime is required: