test01 |
var instance = {
formatNum : function(leng, num,options) { var src = new String(num); var cnt = leng - src.length; if (cnt <= 0) return src; while (cnt-- > 0) src = "0" + src; return src; }, slideshowElm_create : function(options){ var Image_length = Math.floor( Math.random() * options.imglength ), Image_length = Image_length++, imgUri = options.server_url + options.imageHeader + instance.formatNum(3, Image_length) + '.jpg'; var slideshow_ImgElm = document.createElement('img'); slideshow_ImgElm.src = imgUri; slideshow_ImgElm.alt = 'img'; return slideshow_ImgElm; }, slide_show : function(that,options){
that.find('img').eq(0).show(); that.find('img').eq(1).fadeOut(1000,function(){ $(this).remove(); $(instance.slideshowElm_create(options)).prependTo(that); }); } }; $.fn.imageSlideShow = function(options){ this.options = $.extend({ time:1000, imglength:null, server_url:'', imageHeader:'' }, options); return this.each(function(){ $(this).append( instance.slideshowElm_create(options), $(instance.slideshowElm_create(options)).fadeIn(1000) ); setInterval(function(){instance.slide_show($(this),options)},options.time); }); };
$(function(){ $('#image_slide_show').imageSlideShow({ time:5000, imglength:50, server_url:'url', imageHeader:'slideImg' }); });
|
pending… |
test02 |
$.fn.imageSlideShow = function(options){ options = $.extend({ time:2000, imglength:null, server_url:'', imageHeader:'' }, options); function formatNum(leng, num) { var src = new String(num); var cnt = leng - src.length; if (cnt <= 0) return src; while (cnt-- > 0) src = "0" + src; return src; }
return this.each(function(){ that = $(this); function slideshowElm_create(){ var Image_length = Math.floor( Math.random() * options.imglength ), Image_length = Image_length++, imgUri = options.server_url+options.imageHeader+formatNum(3, Image_length)+'.jpg', slideshow_IMGElm = $('<img/>',{src:imgUri,alt:'slideImg',style:'display:none;position:absolute;top:0'}); return slideshow_IMGElm; }; function slide_show(){ that.find('img').eq(0).show(); that.find('img').eq(1).fadeOut(2000,function(){ $(this).remove(); $(slideshowElm_create()).prependTo(that); }); }setInterval(function(){slide_show()},options.time); $(slideshowElm_create()).appendTo(that); $(slideshowElm_create()).appendTo(that).fadeIn(1000); }); }; $(function(){ $('#image_slide_show').imageSlideShow({ time:5000, imglength:50, server_url:'url', imageHeader:'slideImg' }); });
|
pending… |
0 comments