SMF For Free Support Forum
Signup For Free Forum
October 06, 2008, 08:40:43 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to SMF For Free. The best free SMF Host
 
   Home   Help Search Arcade Gallery Login Register  

Pages: [1]
  Print  
Author Topic: [Code] Carousel slideshow  (Read 271 times)
0 Members and 1 Guest are viewing this topic.
mattmilla1
SMF For Free Member
*
Offline Offline

Posts: 52


crazydog10


View Profile WWW
« on: June 13, 2008, 02:03:40 pm »

Forum Url: http://mattmilla1.smfforfree4.com
Preview: Crazy Platoon

To see the preview scroll down to the rotating images in the home page!!

Put the following code into your headers!!

Code:
<script type='text/javascript'>

/***********************************************
* Carousel Slideshow II- By Harry Armadillo (http://www.codingforums.com/showthread.php?t=58814)
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* Please keep this notice intact
***********************************************/

function carousel(params){
  if(!(params.width>0 && isFinite(params.width)))params.width=100;
  if(!(params.height>0 && isFinite(params.height)))params.height=100;
  if(!(params.sides>2 && isFinite(params.sides)))params.sides=4;
  if(!(params.steps>0 && params.steps<100 && isFinite(params.steps)))params.steps=20;
  if(!(params.speed>0 && isFinite(params.speed)))params.speed=8;
  if(!(params.image_border_width>=0 && isFinite(params.image_border_width)))params.image_border_width=0;
  if(isFinite(params.id)||!params.id)params.id='bad_id_given_'+Math.random();
 
  document.write("<div style='position:relative;overflow:hidden;' id='"+params.id.replace(/[^a-zA-Z0-9]+/g,'_')+"'></div>");
  var cdiv=document.getElementById(params.id.replace(/[^a-zA-Z0-9]+/g,'_'))
  cdiv.style.width=params.width+'px';
  cdiv.style.height=params.height+'px';
  cdiv.style.border=params.border;
  cdiv.style.position='relative';
  cdiv.style.overflow='hidden';
  cdiv.title=params.id;
   
  var counter=0,spinning=true,interval=Math.floor(60000/params.sides/params.steps/params.speed)-5;
  interval=isNaN(interval)?200:interval;
  var img_position=[],images=[],img_dimension=[];
  var img_index=params.images.length+1,img_index_cap=2*params.images.length;
  var faces=Math.ceil(params.sides/2), dimension, direction, targ, attr, faraway;

  function init(){
    if(params.direction=="left" || params.direction=="right"){
      direction=params.direction;
      dimension="width";
      }
    else if(params.direction=="top" || params.direction=="bottom"){
      direction=params.direction;
      dimension="height";
      }
    else {
      direction="left";
      dimension="width";
      }     
    faraway=(direction=="left"||direction=="top")?'-20000px':'20000px';
    cdiv.style[dimension]=params[dimension]/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)+'px';
    var img=new Image();
    img.style.position='absolute';
    img.style[direction]=faraway;
    img.style.width=params.width-2*params.image_border_width+'px';
    img.style.height=params.height-2*params.image_border_width+'px';
    img.style.border=(params.image_border_width||0)+'px solid '+params.image_border_color;
 
    for(var i=0;i<params.images.length;i++){
      images[i]=img.cloneNode(true);
      images[i].src=params.images[i];
      if(params.links && params.links[i] && params.links[i]!=''){
        targ=params.lnk_targets && params.lnk_targets[i]||params.lnk_base||'new';
        if(targ=="_blank"){
          attr=(params.lnk_attr && params.lnk_attr[i])?",'"+params.lnk_attr[i]+"'":"";
          images[i].onclick=new Function("window.open('"+params.links[i]+"','"+targ+"'"+attr+")");
          }
        else if(targ.substr(0,1)=="_"){
          images[i].onclick=new Function(targ.substr(1)+".location='"+params.links[i]+"'");
          }
        else{
          attr=(params.lnk_attr && params.lnk_attr[i])?",'"+params.lnk_attr[i]+"'":"";
          images[i].onclick=new Function("var t='"+targ+"';if(window[t]){try{window[t].close()}catch(z){}}window[t]=window.open('"+params.links[i]+"',t"+attr+");window[t].focus()");
          }
        images[i].style.cursor=document.all?'hand':'pointer';
        }

      if(params.titles && params.titles[i] && params.titles[i]!='')
        images[i].title=params.titles[i];
      if(document.all)
        images[i].alt=images[i].title;
      images[i+params.images.length]=images[i];
      if(params.images.length==faces)
        images[i+2*params.images.length]=images[i];
      cdiv.appendChild(images[i]);
      }
 
    var face_size=params.size_mode=='image'?params[dimension]:params[dimension]*Math.sin(Math.PI/params.sides);
    var face_offset=params[dimension]*Math.cos(Math.PI/params.sides)/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)/2-.5;
    var pi_piece=2*Math.PI/params.steps/params.sides;
    for(i=0;i<=params.steps*faces;i++){
      img_dimension[i]=face_size*Math.sin(pi_piece*i);
      img_position[i]=(i<params.steps*params.sides/2)?Math.floor(params[dimension]/2/(params.size_mode=='image'?Math.sin(Math.PI/params.sides):1)-face_offset*Math.cos(pi_piece*i)-img_dimension[i]/2)+'px':faraway;
      img_dimension[i]=img_dimension[i]-2*params.image_border_width>1?Math.ceil(img_dimension[i])-2*params.image_border_width+'px':'1px';
      }
    }
  init();

  cdiv.rotate = function(){
    setTimeout('document.getElementById("'+cdiv.id+'").rotate()',interval);
    if(!spinning) return;
    if(++counter>=params.steps){
      counter=0;
      if(++img_index>=img_index_cap)
        img_index=params.images.length;
      }
    images[img_index-faces].style[direction]=faraway;
    for(var i=faces-1;i>=0;i--){
      images[img_index-i].style[direction]=img_position[counter+i*params.steps];
      images[img_index-i].style[dimension]=img_dimension[counter+i*params.steps];
      }
    }
  cdiv.onmouseover=function(){
    spinning=false;
    }
  cdiv.onmouseout=function(){
    spinning=true;
    }
  setTimeout('document.getElementById("'+cdiv.id+'").rotate()',100);
  }
</script>
-------------------------------------------------------------------------------------------------------

Next go to your portal and make a new portal board. Name it what ever you want and make sure that you change it to a html board. After you have done that go to the html code and edit it, set the following code in there.

Code:
<script type='text/javascript'>
carousel({id:'Amazon Books', //Enter arbitrary but unique ID of this slideshow instance
          border:'',
          size_mode:'image', //Enter "carousel" or "image". Affects the width and height parameters below.
          width:107, //Enter width of image or entire carousel, depending on above value
          height:140, //Enter height of image or entire carousel, depending on above value
          sides:6, //# of sides of the carousel. What's shown = sides/2. Even integer with sides/2< total images is best
          steps:23, //# of animation steps. More = smoother, but more CPU intensive
          speed:5, //Speed of slideshow. Larger = faster.
          direction:'left', //Direction of slideshow. Enter "top", "bottom", "left", or "right"
          images:['http://tbn0.google.com/images?q=tbn:nschTDPAVDPZeM:http://www.gameogre.com/battlefield2.jpg',
                  ''http://tbn0.google.com/images?q=tbn:AJXLpbpgI1FTAM:http://www2.fileplanet.com/images/150000/157236ss_sm2.jpg,
                  ''http://tbn0.google.com/images?q=tbn:jvZuqFTOz2R69M:http://www.42bytes.com/wp-content/uploads/2008/03/bf-heroes.jpg,
'http://tbn0.google.com/images?q=tbn:ccjT_8kVw_Wp1M:http://www.maj.com/gallery/EliteMangudai/GAMES/gameVSgame/half-life_vs_halo.jpg'],
          links: ['http://www.dynamicdrive.com', //enter link URLs, or for no links, empty array instead (links :[])
'http://www.javascriptkit.com',
'http://www.codingforums.com',
'http://www.cssdrive.com'],
          titles:['Book #1',
'Book #2',
'Book #3',
'Book #4'],
          image_border_width:1,
          image_border_color:'blue'
          });
</script>



<script type='text/javascript'>
carousel({id:'Amazon Books 2',
          border:'',
          size_mode:'image',
          width:250,
          height:250,
          sides:6,
          steps:23,
          speed:5,
          direction:'left',
          images:['http://tbn0.google.com/images?q=tbn:nschTDPAVDPZeM:http://www.gameogre.com/battlefield2.jpg',
                 'http://tbn0.google.com/images
q=tbn:Zalmdaxhd5fZKM:http://www.rhinorage.co.uk/cutenews/data/upimages/5/4.jpg',
                  'http://tbn0.google.com/images?q=tbn:kktxmFwRqzgV-M:http://www.rockpapershotgun.com/images/feb08/bf3.jpg',
'http://tbn0.google.com/images?q=tbn:ccjT_8kVw_Wp1M:http://www.maj.com/gallery/EliteMangudai/GAMES/gameVSgame/half-life_vs_halo.jpg'],
          links: ['http://www.dynamicdrive.com',
'http://www.javascriptkit.com',
'http://www.codingforums.com',
'http://www.cssdrive.com'],
lnk_base:'google', //Link target for all links (see: http://www.codingforums.com/showthread.php?t=58814&page=2)
          titles:['Book #1',
'Book #2',
'Book #3',
'Book #4'],
          image_border_width:1,
          image_border_color:'blue'
          });
</script>

<div style="margin-top: 1em; font-weight: bold;">

---------------------------------------------------------------------------------------------------------------
You can edit the width and the image urls to your prefered!!....

If you want to add more images you add more of these lines!!!
Code:
''http://tbn0.google.com/images?q=tbn:jvZuqFTOz2R69M:url of your image here,
If that doesnt work than you cant add the images....
« Last Edit: June 16, 2008, 02:29:41 pm by mattmilla1 » Logged

<CRAZYDOG10>
     
=crazydog10=
<br />
=That cat is a bigfoot bounty hunter lol=
clairebear
SMF For Free Hero
*
Offline Offline

Posts: 522


View Profile
« Reply #1 on: June 14, 2008, 05:22:23 pm »

i dont get anything on the preview
Logged


simply sibyl
Global Moderator
*
Online Online

Posts: 8406



View Profile WWW
« Reply #2 on: June 14, 2008, 05:26:30 pm »

typo in his url.. fixed it
Logged

mattmilla1
SMF For Free Member
*
Offline Offline

Posts: 52


crazydog10


View Profile WWW
« Reply #3 on: June 16, 2008, 02:26:36 pm »

o sorry about the typo...here is the real page... http://mattmilla1.smfforfree4.com

Its the rotating carousel at the bottom of the page Wink
Logged

<CRAZYDOG10>
     
=crazydog10=
<br />
=That cat is a bigfoot bounty hunter lol=


Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.6 | SMF © 2006-2008, Simple Machines LLC
ServerBeach Coupon
Page created in 1.845 seconds with 16 queries.