I have finally created my first widget and I must say it was a horrendous experience. The code is available at my code testing blog here. The main trouble with the code was declaring objects in JavaScript. For some reason, over the past two years, numerous sites sprang up each claiming different techniques for declaring objects and their members/methods. After trying out numerous, I finally found one that works.
To understand what it does, move your mouse over my banner on top. That is the default behavior. Modifying this.slideshowspeed=0; to a value greater than zero will set the pictures to swap at different durations, i.e. 2000 for 2 seconds.
The widget is actually a hack of a TextList widget. This is to make use of the same interface provided by blogger to add URLs of pictures to display. This can be seen on the code testing blog mentioned earlier. One drawback of this hack is that for now it does not resize pictures to fit.
The reason behind creating a JavaScript Object, PicObject(), is to encapsulate the variables used in the script. This will allow multiple instances of this widget in a single blog. However two modifications have to be made to allow that:
1. The variable holding the object, "pickSwap" must be renamed throughout the code.
2. The image tag's name attribute, "slide", must be renamed throughout the code.
An example of two of these widgets operating is shown for the time being with some DotA icons on the right.
The widget is actually a hack of a TextList widget. This is to make use of the same interface provided by blogger to add URLs of pictures to display. This can be seen on the code testing blog mentioned earlier. One drawback of this hack is that for now it does not resize pictures to fit.
The reason behind creating a JavaScript Object, PicObject(), is to encapsulate the variables used in the script. This will allow multiple instances of this widget in a single blog. However two modifications have to be made to allow that:
1. The variable holding the object, "pickSwap" must be renamed throughout the code.
2. The image tag's name attribute, "slide", must be renamed throughout the code.
An example of two of these widgets operating is shown for the time being with some DotA icons on the right.
No comments:
Post a Comment