So you've created your Create your First Yahoo! Widget ! but all didn't seem to go on smoothly. You faced unknown errors and did not know how to debug them ? This blog will tell you how to debug and then package your widget. You can find Part - I and Part - II of this tutorial here : Create your First Yahoo! Widget !.
Part - III : Debugging your Widget
Luckily, for us, the Yahoo! Widget Engine includes a built in debugger, we just have to turn it on ! This is done by including the tag into your code. You can set debug to on when you are developing a widget. However do remember to set it to off once you are ready to publish your widget to the world ! If debug is set to on, a debugger window pops up once you load your widget. The debugger supports the following commands :
/dump object : Dumps all the properties of 'object' on the screen.
/trace function : Prints a message every time 'function' is called
/untrace function : Stops tracing 'function'
/watch object.property : Displays a message when the given 'property' of 'object' changes
/tracethrow [on|off] : Turns on/off messages whenever an exception is thrown (on by default)
(JavaScript Code) : Executes the given JavaScript Code
/clear : Clears the debug console
/help : Prints out this list of commands on the debug console
For e.g. to dump the properties of the system.cpu object, we'll have to type /dump system.cpu at the debug console. Note that we can dump any object that the engine provides or you have defined in the code. A dump of the txtCPUActivity Text object defined to displays its properties. So the debugger is a really powerful tool ! Having ironed out the bugs, lets get ready to convert our widegt to a single file distributable flat widget !
Part - IV : Packaging your Widget
If you remember the The Widget Converter Widget that i had mentioned in my post Create your First Yahoo! Widget !, that's all we need to get your widget packed and ready to be distributed. Fire up the Widget and drag and drop the CPUMon folder on to the widget. Press convert and you are done ! You have shiny new flat widget from your folder structure that you can now freely distribute ! Have fun !