Thursday, February 15, 2007

Code for SlideShow Widget

<b:widget id='PictureSlideShow' locked='false' title='Pictures' type='TextList'>
<b:includable id='main'>

<b:if cond='data:title'><h2><data:title/></h2></b:if>
<div class='widget-content'>

<a onclick='pickSwap.gotoshow();'><img border='0' name='slide' onmouseover=' if (picSwap.slideshowspeed == 0) picSwap.slideit();'/></a>


<script type='text/javascript'>
/*<![CDATA[*/
function PicObject() {

this.slideshowspeed=0;

this.slideimages=new Array();
this.slidelinks=new Array();

this.whichimage=0;
this.whichlink=this.whichimage;


}


PicObject.prototype.addImage = function (imageURL)
{
var currLength = this.slideimages.length;
this.slideimages[currLength] = new Image();
this.slideimages[currLength].src = imageURL;
this.whichimage=Math.round((this.slideimages.length-1)*Math.random());
}

PicObject.prototype.addLink = function (linkURL)
{
var currLength = this.slidelinks.length;
this.slidelinks[currLength]=linkURL;
}

PicObject.prototype.addImageAndLink = function (imageURL)
{
this.addImage(imageURL);
this.addLink(imageURL);
}

PicObject.prototype.gotoshow = function ()
{
if (!window.winslide||winslide.closed)
winslide=window.open(this.slidelinks[this.whichlink]);
else
winslide.location=this.slidelinks[this.whichlink];
winslide.focus();
}

PicObject.prototype.slideit = function()
{
if (!document.images)
return;

document.images.slide.src=this.slideimages[this.whichimage].src;

this.whichlink=this.whichimage;
if (this.whichimage<this.slideimages.length-1)
this.whichimage++;
else
this.whichimage=0;

var thisobj = this;
if (this.slideshowspeed != 0) setTimeout(function() {thisobj.slideit();},this.slideshowspeed);
}

var picSwap = new PicObject();

/*]]>*/
<b:loop values='data:items' var='item'>
picSwap.addImageAndLink("<data:item/>");
</b:loop>
/*<![CDATA[*/

picSwap.slideit();

/*]]>*/
</script>
<b:include name='quickedit'/>
</div>
</b:includable>
</b:widget>

No comments: