// dialog initialization code
// preload an array of offscreen images
var images = new Array(4);
var imageNames = new Array("up.gif", "right.gif", "down.gif", "left.gif");
var animationFrame = 0;
var animationFunction = null;
for(var i = 0; i < 4; i++) {
images[i] = new Image();
images[i].src = "sampleimages/" + imageNames[i];
}
function Startup() {
var checkbox = ElementByID("remind");
if (checkbox)
checkbox.checked = true;
}
// OK button handler
function DoOK() {
// get checkbox
// (using a document method available on HTML and XUL
// documents, but not on XML documents)
var checkbox = document.getElementById("remind");
if (checkbox) {
// load some hypothetical appcore interested in
// the outcome of this dialog
var donationsCore = XPAppCoresManager.Find("DonationsCore");
if (!donationsCore) {
donationsCore = new DonationsCore();
if (donationsCore)
donationsCore.Init("DonationsCore");
}
// tell the appcore about the new setting
if (donationsCore)
donationsCore.SetRemindFlag(checkbox.checked);
}
}
// find and return the DOM element with the given ID
// the equivalent of document.getElementById(), but also
// works for XML documents (unused in the example)
function ElementByID(id) {
var element;
var ctr;
var taglist = document.getElementsByTagName("*");
element = null;
for (ctr = 0; ctr < taglist.length; ctr++)
if (taglist[ctr].getAttribute("id") == id) {
element = taglist[ctr];
break;
}
return element;
}
function animateButtonImage() {
var button = document.getElementById("animation");
if (button) {
button.src = images[animationFrame].src;
animationFrame = (animationFrame + 1) % 4;
animationFunction = setTimeout("animateButtonImage()", 250);
}
}
function startAnimation() {
if (animationFunction == null)
animateButtonImage();
}
function stopAnimation() {
if (animationFunction)
clearTimeout(animationFunction);
animationFunction = null;
}