website diff libs/js/slideshow.js @ rev 780
ex + id: Code clean-up and new layout (TODO: finish es)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sat Mar 26 22:22:15 2011 +0100 (2011-03-26) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/js/slideshow.js Sat Mar 26 22:22:15 2011 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 + 1.5 +window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init); 1.6 + 1.7 +var d=document, imgs = new Array(), zInterval = null, current=0, pause=false; 1.8 + 1.9 +function so_init() 1.10 +{ 1.11 + if(!d.getElementById || !d.createElement)return; 1.12 + 1.13 + imgs = d.getElementById('slideshow').getElementsByTagName('img'); 1.14 + for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0; 1.15 + imgs[0].style.display = 'block'; 1.16 + imgs[0].xOpacity = .99; 1.17 + 1.18 + setTimeout(so_xfade,4000); 1.19 +} 1.20 + 1.21 +function so_xfade() 1.22 +{ 1.23 + cOpacity = imgs[current].xOpacity; 1.24 + nIndex = imgs[current+1]?current+1:0; 1.25 + nOpacity = imgs[nIndex].xOpacity; 1.26 + 1.27 + cOpacity-=.05; 1.28 + nOpacity+=.05; 1.29 + 1.30 + imgs[nIndex].style.display = 'block'; 1.31 + imgs[current].xOpacity = cOpacity; 1.32 + imgs[nIndex].xOpacity = nOpacity; 1.33 + 1.34 + setOpacity(imgs[current]); 1.35 + setOpacity(imgs[nIndex]); 1.36 + 1.37 + if(cOpacity<=0) 1.38 + { 1.39 + imgs[current].style.display = 'none'; 1.40 + current = nIndex; 1.41 + setTimeout(so_xfade,4000); 1.42 + } 1.43 + else 1.44 + { 1.45 + setTimeout(so_xfade,60); 1.46 + } 1.47 + 1.48 + function setOpacity(obj) 1.49 + { 1.50 + if(obj.xOpacity>.99) 1.51 + { 1.52 + obj.xOpacity = .99; 1.53 + return; 1.54 + } 1.55 + 1.56 + obj.style.opacity = obj.xOpacity; 1.57 + obj.style.MozOpacity = obj.xOpacity; 1.58 + obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')'; 1.59 + } 1.60 +}