You can use setTimeout
to "delay" an action:
setTimeout(function() { console.log('I'm 10 secs later'); }, 1000*10);
With clearTimeout
you can abort such a timer:
var timer = setTimeout(/* .... */);
clearTimeout(timer)
In your example you could start a timeout which executes the logic for button.g == 1
and cancel the timer if any button is clicked:
Setting the timer to 10s:
var timer = setTimeout(1000*10, function() {
AutoJoin.instance.screen = new AutoJoinScreen(parent, info);
f.a(AutoJoin.instance.screen);
})
Click routine:
clearTimeout(timer);
if(button.g == 0) {
f.a(parent);
AutoJoin.instance.resetCache();
}
else if if(button.g == 1) {
AutoJoin.instance.screen = new AutoJoinScreen(parent, info);
f.a(AutoJoin.instance.screen);
}
else if(button.g == 2) {
f.a(new PropertiesScreen(this, info.ip));
}