// Simple Waitcursor
Button1.onclick = function() {
NSB.WaitCursor(true);
Button1.disabled = true;
Button2.disabled = false;
};
Button2.onclick = function() {
NSB.WaitCursor(false);
Button1.disabled = false;
Button2.disabled = true;
};
// Cursor Example with Delay
sleep=function(ms) {
//used for delay to avoid loop that uses up CPU
var caller = sleep.caller;
if (caller.sleepTimer) {
delete caller.sleepTimer;
return true;
}
caller.sleepTimer = window.setTimeout (function () {
caller.apply ([]);
},ms);
return false;
}
delayPostProcessing=function(ms) {
/* if you need a delayed response, put all post processing in this function
* anything outside this function will execute prior to the delay even if it
* comes after calling this function */
document.body.style.cursor = 'wait'; //busy style cursor during delay
NSB.Print("Cursor changed to busy");
if (!sleep (ms)) return;
document.body.style.cursor = ''; //normal cursor
NSB.Print("Cursor restored to normal");
NSB.Print("Continue processing inside the wrapper after delay");
NSB.Print("... and continue processing inside the wrapper");
}
preProcessing=function() {
//do your pre-processing before delay here
var delayMS=5000; //5000 ms equates to 5 seconds
NSB.Print("After processing this line, cause delay of " + (delayMS/1000).toString() + " seconds");
delayPostProcessing(delayMS); //force delay now
NSB.Print("This line ignores the delay");
}
preProcessing(); //this runs all code prior to the delay
NSB.Print("This line ignores the delay also");