I'm not sure if this is the right way..
I have created one new widget made from default template
this is the javascript:
............
// handle ui elements events
widget.find('[data-ui-field=on]').bind('click', function(){
_this.statusText.html('ON was clicked!');
_this.iconImage.attr('src', 'pages/control/widgets/homegenie/generic/images/light_on.png');
HG.Control.Modules.ServiceCall("Control.On", module.Domain, module.Address, null, function (data) { });
wait(5000); // -------- I NEED WAIT HERE
_this.statusText.html('OFF was clicked!');
_this.iconImage.attr('src', 'pages/control/widgets/homegenie/generic/images/light_off.png');
HG.Control.Modules.ServiceCall("Control.Off", module.Domain, module.Address, null, function (data) { });
});
......... etc. etc.
i added one new own function in widget javascript:
function wait(ms){
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
}
but when a select the ON button HG wait 5 second then execute all code quikly..
I' m confused.. I'm very dummy with Javascript, could someone help me ?