Hearing Dog Training Tool – setTimeout()
Our new code looks like the following:
// determine time to wait in seconds
wait_secs=52; // for now, just define it
// wait for time to be up & sound alarm
setTimeout(sound_alarm(), (wait_secs * 1000))
This works great, but it is hard to tell, because nothing changes after you press the button until the time is up. However, the DOM can help us with this as well. I added the following 2 lines to the beginning of the do_alarm() function:
// mark alarm as set
This changes the button we pushed to set the alarm to say "Alarm Set" and disables it. If we want to be able to use the alarm again, we'll have to change the button back to it's original state. I added this to the sound_alarm() function. You can view all the code and try out a working example here.
This site needs an editor - click to learn more!
You Should Also Read:
Program Planning – Hearing Dog Alert Training Tool
Iterative Development First Pass – Hearing Dog Training Tool
Editor's Picks Articles
Top Ten Articles
Content copyright © 2022 by Julie L Baumler. All rights reserved.
This content was written by Julie L Baumler. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.