Haiku Zone out of ready script

ihf

Active Member
Could someone please give me an example of a script  to test for whether a zone is out of ready for a specified period of time so that I can take an action based on this condition? If there is a library of examples, I'd appreciate a pointer.
 
Thanks.
 
There are many ways of doing this, but here's one approach using a JavaScript timer:
Code:
var myZoneTimer = null;

function onZoneNotReady(zone) {
    if(zone.number == 5 && myZoneTimer == null) {
        myZoneTimer = setTimeout(doSomething, 60*1000); // Call doSomething after 60 seconds
    }
}

function onZoneSecure(zone) {
    if(zone.number == 5 && myZoneTimer != null) {
        clearTimeout(myZoneTimer);
        myZoneTimer = null;
    }
}

function doSomething() {
    alert("Zone 5 was not ready for 60 seconds!");
}
You may need to tweak this depending on your needs.
 
Back
Top