PDA

View Full Version : Conveyor Belt slideshow - randomized



d6veteran
08-09-2005, 09:30 PM
Conveyor Belt slideshow script

http://www.dynamicdrive.com/dynamicindex14/leftrightslide.htm

I love this script but I want the images randomized so that each time a user comes to the site they don't see the same first 3 photos before moving on to other sections.

Thanks.

jscheuer1
08-10-2005, 01:42 AM
An excellent array randomizer was written by Mike (mwinter) from these forums. It is still available here (http://www.dynamicdrive.com/forums/showthread.php?p=8442). What you do is place the unit after the array, in this case the 'leftrightslide' array. A good place would be just after this line in the Conveyor Belt slideshow script:

////NO NEED TO EDIT BELOW THIS LINE////////////Then after the unit put this:

leftrightslide.shuffle()Then each time the page loads, a random order will be assigned to the array and thus the order of the images shown.

d6veteran
08-10-2005, 04:35 AM
Nice! That was a snap to implement.

The whole unit is now running great in a core phpnuke block. Randomized now too :)

Thanks!

thenajsays
05-19-2009, 02:22 PM
anyone got a way to continuously randomize the slides? and also to make sure slides dont repeat?

thenajsays
05-19-2009, 04:21 PM
i got something... not completely continuous, but it gets the job done...

/***********************************************
* Conveyor belt slideshow script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/


//Specify the slider's width (in pixels)
var sliderwidth="860px"
//Specify the slider's height
var sliderheight="136px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=2
//configure background color:
slidebgcolor="#F0FFF0"

//Specify the slider's images
var randomslides=new Array()
var finalslide=''
randomslides[0]='<img src="images/slideshow/IMG_0907.jpg">'
randomslides[1]='<img src="images/slideshow/IMG_0916.jpg">'
randomslides[2]='<img src="images/slideshow/IMG_0934.jpg">'
randomslides[3]='<img src="images/slideshow/IMG_0928.jpg">'
randomslides[4]='<img src="images/slideshow/IMG_0989.jpg">'
randomslides[5]='<img src="images/slideshow/IMG_0998.jpg">'


var leftrightslide = new Array();
//MultiRandomizer by AJ Pinto thenajsays@gmail.com
function MultiRandomizer()
{
var p = new Array();

for (i = 0; i < 99; i++)
{
var n = Math.floor(Math.random() * 6);
leftrightslide[i] = randomslides[n];
if(n != p[0] && n != p[1] && n != p[2])
{
leftrightslide[i] = randomslides[n];
p[0] = p[1];
p[1] = p[2];
p[2] = n;
}
else
{
while (n == p[0] || n == p[1] || n == p[2])
{
n = Math.floor(Math.random() * 6);
}
leftrightslide[i] = randomslides[n];
p[0] = p[1];
p[1] = p[2];
p[2] = n;
}

}
}
//End MultiRandomizer

//Specify gap between each image (use HTML):
var imagegap=""

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=0
MultiRandomizer();

////NO NEED TO EDIT BELOW THIS LINE////////////


var copyspeed=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>'
var iedom=document.all || document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide

function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+"px"
}
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}
window.onload=fillup

function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"

}
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshowgap

if (ns_slide2.left>(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
}
}


if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'"')
write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}