| |
 |
PHP source code for website interface
(Sorry for the lack of comments)
<h1>Multimedia Tools Projects</h1> - <p></p>
-
- <?php
- $numcols = 28;
- $numrows = 16;
- $size = 560 / $numcols;
-
- $rndinterval = 7000;
- $rndminimum = 3000;
-
- // $ReservedCells[cell/img/link][id]
- $ReservedCells["cell"][0] = "13-17";
- $ReservedCells["img"] [0] = "link1.gif";
- $ReservedCells["link"][0] = "2p1";
- $ReservedCells["cell"][1] = "14-14";
- $ReservedCells["img"] [1] = "link2.gif";
- $ReservedCells["link"][1] = "2p2a";
- $ReservedCells["cell"][4] = "14-15";
- $ReservedCells["img"] [4] = "link2.gif";
- $ReservedCells["link"][4] = "2p2b";
- $ReservedCells["cell"][2] = "13-12";
- $ReservedCells["img"] [2] = "link3.gif";
- $ReservedCells["link"][2] = "2p3";
- $ReservedCells["cell"][3] = "13-10";
- $ReservedCells["img"] [3] = "link4.gif";
- $ReservedCells["link"][3] = "2p4";
-
-
- // cell color distribution
- $cellcolor[] = "blue.gif";
- $cellcolor[] = "blue.gif";
- $cellcolor[] = "blue.gif";
- $cellcolor[] = "blue.gif";
- $cellcolor[] = "green.gif";
- $cellcolor[] = "green.gif";
- $cellcolor[] = "green.gif";
- $cellcolor[] = "green.gif";
- $cellcolor[] = "lgrey.gif";
-
-
- // pull out all "link"s and generate image array
- // for rollover images based on link name (2p1)
-
- // $ImgData[link][cell/img][id]
-
- $path = "img/";
- $file = new File();
- $tmp_array = array();
- $tmp_array = $file->get_files("$path","gif");
-
- foreach( $ReservedCells["link"] as $link ) {
- $cnt = 0;
- while ( list( $key, $filename ) = each( $tmp_array ) ) {
- if( substr($filename,0,strlen($link)) == $link ) {
- $cellid = str_replace($link."_","",$filename);
- $cellid = str_replace(".gif","",$cellid);
- $ImgData[$link][$cnt]["cell"] = $cellid;
- $ImgData[$link][$cnt]["img"] = $filename;
- $cnt++;
- }
- }
- reset($tmp_array);
- }
-
- // now there is an array of all the 20x20 images, still have to
- // transfer it to javascript though
-
- ?>
- <style type="text/css">
- table.grid
- {
- border-spacing: 0px;
- border-collapse: collapse;
- }
- td.grid
- {
- border: 1px #FFFFFF solid;
- padding:0px;
- font-size:10pt;
- }
- </style>
- <script language="javascript" type="text/javascript">
- <!--
-
- Array.prototype.inArray = function (value)
- // Returns true if the passed value is found in the
- // array. Returns false if it is not.
- {
- var i;
- for (i=0; i < this.length; i++) {
- // Matches identical (===), not just similar (==).
- if (this[i] === value) {
- return true;
- }
- }
- return false;
- };
-
- var cellcolor = new Array();
- <?php
- for( $i=0; $i < count($cellcolor); $i++ ) {
- echo "cellcolor[$i] = '".$cellcolor[$i]."';\n";
- }
- ?>
-
- <?php
- // print javascript array for reserved cells for links
- echo "var ReservedCells = new Array();\n";
- for( $i=0; $i < count($ReservedCells["cell"]); $i++ ) {
- echo "ReservedCells[$i] = '".$ReservedCells["cell"][$i]."';\n";
- }
- // end reserved cells
-
- // copy 20x20 image array to javascript array
- echo "var ImgData = new Array();\n";
- $cnt = 0;
- while( list($link, $value) = each($ImgData) ) {
- echo "ImgData['$link'] = new Array();\n";
- $id = 0;
- while( list($null, $value2) = each($ImgData[$link]) ) {
- $linkn = $value2["cell"];
- echo "ImgData['$link'][$id] = new Array();\n";
- echo "ImgData['$link'][$id]['cell'] = '".$linkn."';\n";
- echo "ImgData['$link'][$id]['img'] = '".$value2["img"]."';\n";
- $id++;
- }
- $cnt++;
- }
- // end image data cells
- ?>
-
- var rndinterval = <?php echo $rndinterval; ?>;
- var rndminimum = <?php echo $rndminimum; ?>;
-
- function StartTimers() {
- var rndTime = 0;
- timerPause = 0;
- for(i=1; i<=<?php echo $numrows; ?>; i++) {
- for(j=1; j<=<?php echo $numcols; ?>; j++) {
- rndTime = Math.floor(Math.random()*rndinterval)+rndminimum;
- setTimeout('ChangeBkg("'+i+"-"+j+'")',rndTime);
- }
- }
- }
-
- function ChangeBkg(cellid) {
- if( !ReservedCells.inArray(cellid) ) {
- document.images[cellid].src=cellcolor[Math.floor(Math.random()*cellcolor.length)];
- rndTime = Math.floor(Math.random()*rndinterval)+rndminimum;
- setTimeout("ChangeBkg('"+cellid+"')",rndTime);
- }
- }
-
- function ShowBigPic(link) {
- path = '<?php echo $path; ?>';
- obj = ImgData[link];
- for( var cells in obj ) {
- cellid = ImgData[link][cells]["cell"];
- cellimg = ImgData[link][cells]["img"];
- document.images[cellid].src = path + cellimg;
- }
- }
-
- StartTimers();
- //-->
- </script>
-
- <table class="grid">
- <?php
- for( $row=1; $row<=$numrows; $row++ ) {
- echo "<tr>\n";
- for( $col=1; $col<=$numcols; $col++ ) {
- if( in_array("$row-$col", $ReservedCells["cell"]) ) {
- $index = array_search("$row-$col", $ReservedCells["cell"]);
- $ahref_open = "<a href=\"".$ReservedCells["link"][$index]."\" onMouseOver=\"ShowBigPic('".$ReservedCells["link"][$index]."');\">";
- $ahref_close = "</a>";
- $src = $ReservedCells["img"][$index];
- } else {
- $src = $cellcolor[rand(0,count($cellcolor)-1)];
- $ahref_open = "";
- $ahref_close = "";
- }
- echo "<td class=\"grid\">$ahref_open<img src=\"$src\" width=\"$size\" height=\"$size\" id=\"$row-$col\" name=\"$row-$col\">$ahref_close</td>\n";
- }
- echo "</tr>\n";
- }
- ?>
- </table>
-
|