Jump to content

Upside down Javascrip equalizer


law

Recommended Posts

OK, I found this javascript equalizer. It woks great. I cut it all up with php. I intend to make it easily editable. I am awful with javascript. I can't figure out how to flip this code. I would like the equalizer to operate upside down. The effect would look similar to filter: flipv; except be cross browser compatible.

 

<?php
//Number of Cols
$col = 10;
//0 is the starting number
$cols = $cols - 1;
//Number of Rows
$row = 10;
?>
<html>
<head>
<script language="JavaScript">
<!--
color=new Array();
<?php
for ($i=0;$i<$col;$i++){
?>
color[<?php echo $i;?>]="blue.gif";
<?php
}
?>

h=new Array();
for(var i=0;i<<?php echo $col;?>;i++)
  h[i]=-1;

function d_rand()
{
  for(var i=0;i<<?php echo $col;?>;i++)
  {
    var h_old=h[i];
    var sgn=1;
    var rndm=0;
    if(h[i]==-1)
    {
      h[i]= Math.floor(Math.random()*10)
      h_old=9;
    }
    else
    {
      rndm=Math.floor(Math.random()*3);
      sgn=Math.floor(Math.random()*2);
      if(sgn==0)
      {
        var h_old=h[i]
        h[i]+=rndm;
        if(h[i]>9) 
          h[i]=9;
      }
      else
      {
        var h_old=h[i]
        h[i]-=rndm;
        if(h[i]<0) 
          h[i]=0;
      }
    }
    if(sgn==0)
    {
      for(var j=h_old;j<=h[i];j++)
        document.images[i+j*<?php echo $col;?>].src = "black.gif";          
    }
    else
    {
      for(var j=h_old;j>=h[i];j--)
        document.images[i+j*<?php echo $col;?>].src = color[i];          
    }

  }    
  timerId=setTimeout("d_rand()",270)
}
//-->
</script>
<title>UpsideDown - JavaScript - Equalizer</title>
</head>

<body onload="d_rand()" bgcolor="Black" leftmargin=30 text="White" marginwidth=30 vlink=silver>

<table border="0" cellspacing="0" cellpadding="0">
<?php
for ($i=0;$i<$row;$i++){
?>
	<tr>
	<?php 
	for ($ii=0;$ii<$col;$ii++){
	?>
		<td><img src="black.gif" width="40" height="20"></td>
	<?php
	}
	?>
	</tr>
<?php
}
?>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/150390-upside-down-javascrip-equalizer/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.