This gadget is a simple resumable timer with a digital clock face. It also includes a textbox to allow users to add text that could describe what is being timed. The Vista gadget competition and the desire to find how gadgets work were the main motivations for this article.
To install the gadget, all you need to do is to unzip Timer.zip and open the Timer.gadget file. Timer.gadget is a simple ZIP file containing the gadget files, with the extension renamed from .zip to .gadget. Vista takes care of putting the gadgets in the correct directory (%USERPROFILE%/AppData/Local/Microsoft/Windows Sidebar/Gadgets) automatically. Really simple installation mechanism indeed!
How it works
hours to store the time elapsed so far, with the hours variable rolling over to zero when going from 99 to 100. The actual timer is created via
window.setInterval and is stopped using
window.clearInterval by passing the
images). The following piece of code takes an integer value and generates the corresponding HTML necessary to display it in the image format.
var digit = 0;
var htmlText = "";
var index = 0;
while (param != 0)
digit = param % 10;
param = Math.floor(param/10);
htmlText = "<img src=\"" + images[digit] + "\" /> " + htmlText;
htmlText = "<img src=\"" + images + "\" /> " + htmlText;
How to use it
To start the timer, hit the Start button. Before starting, you can optionally enter some text in the textbox above the buttons, describing the task you are timing. Once started, the timer starts ticking. To pause the timer, hit the Pause button. If you want to reset the timer back to zero, hit the Reset button. Note that the Reset button also stops the timer.
- 20:57 23-01-2007 - Initial submission