Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Feb 22nd, 2011  |  syntax: JavaScript  |  size: 6.53 KB  |  hits: 291  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>Image Gallery</title>
  6. <link rel="stylesheet" type="text/css" href="include/photostyle.css" />
  7. <img class='hiddenPic' src='back.png' />
  8. <img class='hiddenPic' src='forward.png' />
  9. <script language="text/javascript">
  10. var img=new Array();
  11. var imgL=new Array();
  12. var imgid=new Array();
  13. var imgEXIF=new Array();
  14. <?php
  15.         include 'database.php';
  16.         $maxphoto = 0;
  17.         $id = $_GET['id'];
  18.         $albumid = $_GET['albumid'];
  19.  
  20.         $retid = select_row("SELECT * FROM albums where id = $albumid");
  21.         $folder = $retid["folder"];
  22.         $albumName = $retid['name'];
  23.        
  24.         $index = 0;
  25.         $retid = select("SELECT * FROM photos where albumid = $albumid ORDER BY date");
  26.  
  27.         while ($row = mysql_fetch_array($retid))
  28.         {
  29.                 $exposure = $row['exposure'];
  30.                 $aperture =  $row['aperture'];
  31.                 $iso = $row['iso'];
  32.                 $camera = $row['model'];
  33.                 $lens = $row['lens'];
  34.                 $focalLength = $row['focalLength'];
  35.                 if ($row['id'] == $id)
  36.                 {
  37.                         $curP = $index;
  38.                         $startImage = $row['med'];
  39.                         $startImageL = $row['large'];
  40.                         $exifBegin = "Exposure: $exposure sec<br />Aperture: $aperture<br />ISO: $iso<br />Camera: $camera<br />Lens: $lens<br />Focal Length: $focalLength";
  41.                 }
  42.                 $filename = $row["med"];
  43.                 $large = $row['large'];
  44.                 $imageIDC = $row['id'];
  45.                 echo "img[" . $index . "] = 'albums/" . $folder . "/" . $filename . "';\n";
  46.                 echo "imgL[" . $index . "] = 'albums/" . $folder . "/" . $large . "';\n";
  47.                 echo "imgid[$index] = '$imageIDC';\n";
  48.                 echo "imgEXIF[$index] = 'Exposure: $exposure sec<br />Aperture: $aperture<br />ISO: $iso<br />Camera: $camera<br />Lens: $lens<br />Focal Length: $focalLength';\n";
  49.                 $index += 1;
  50.                 $maxPhoto += 1;
  51.         }
  52.         echo 'var maxPhoto = ' . $maxPhoto . ";\n";
  53. ?>
  54.  
  55. var currentPhoto = <?php echo $curP+1 ?>;
  56. var start = currentPhoto;
  57. window.onload = function() {
  58.   document.onselectstart = function() {return false;} // ie
  59.   document.onmousedown = function() {return false;} // mozilla
  60. }
  61.  
  62. function test() {
  63.         alert("ajsidf");
  64. }
  65. var loadingIndex = currentPhoto;
  66. function loadNext() {
  67.         ///alert("maxphoto="+maxPhoto+"start="+start+"loadingindex"+loadingIndex);
  68.         loadingIndex = nextPhotoToLoad(1, maxPhoto,start, loadingIndex);
  69.         if (loadingIndex != '')
  70.         {
  71.                 document.images['imageLoad'].src = img[loadingIndex-1];
  72.         }
  73. }
  74. function movepic(img_name,img_src)
  75. {
  76.         if (img_src == 'next' && currentPhoto != maxPhoto)
  77.         {
  78.                 currentPhoto = currentPhoto + 1;
  79.         }
  80.         if (img_src == 'previous' && currentPhoto != 1)
  81.         {
  82.                 currentPhoto = currentPhoto - 1;
  83.         }
  84.         document[img_name].src=img[currentPhoto-1];
  85.         document.links["largeLink"].href=imgL[currentPhoto-1];
  86.         document.links["downloadLink"].href="force-download.php?file="+imgL[currentPhoto-1];
  87.         document.links["permalink"].href="photo.php?id="+imgid[currentPhoto-1]+"&albumid=<?php echo "$albumid"; ?>";
  88.         document.getElementById('number').innerHTML = currentPhoto+" of "+maxPhoto;
  89.         document.getElementById('exifData').innerHTML = imgEXIF[currentPhoto-1];
  90. }
  91.  
  92.  
  93.  
  94. function nextPhotoToLoad(start, end, firstphotonumber, previouslyloadedphotonumber)
  95. {
  96.         //alert(Math.abs(previouslyloadedphotonumber - firstphotonumber)*2+firstphotonumber));
  97.         if (previouslyloadedphotonumber - firstphotonumber > 0 && ((previouslyloadedphotonumber - firstphotonumber) % 2) == 1 && previouslyloadedphotonumber != end) //loading above and subtraction is odd, load one more forwards
  98.         {
  99.        
  100.                 return previouslyloadedphotonumber + 1;
  101.         }
  102.         else if (previouslyloadedphotonumber - firstphotonumber > 0 && firstphotonumber - (previouslyloadedphotonumber - firstphotonumber)/2 > start-1 ) //loading above and loading the next below isnt below start
  103.         {
  104.                 // alert("in here 2");
  105.                 return firstphotonumber - (previouslyloadedphotonumber - firstphotonumber)/2;
  106.         }
  107.         else if (previouslyloadedphotonumber - firstphotonumber < 0 && Math.abs(previouslyloadedphotonumber - firstphotonumber)*2+firstphotonumber < end) // loading below and above new-1 is less than end
  108.         {
  109.                 //alert("in here 3");
  110.                 return Math.abs(previouslyloadedphotonumber - firstphotonumber)*2+firstphotonumber+1;
  111.         }
  112.         else if (previouslyloadedphotonumber - firstphotonumber < 0 && Math.abs(previouslyloadedphotonumber - firstphotonumber)*2+firstphotonumber <= end && previouslyloadedphotonumber != start)
  113.         {
  114.                 return previouslyloadedphotonumber-1;
  115.         }
  116.         else if (previouslyloadedphotonumber - firstphotonumber > 0 && firstphotonumber - (previouslyloadedphotonumber - firstphotonumber)/2 <= start-1 && previouslyloadedphotonumber != end)
  117.         {
  118.                 return previouslyloadedphotonumber+1;
  119.         }
  120.         else if (previouslyloadedphotonumber == firstphotonumber)
  121.         {
  122.                 return firstphotonumber+1;
  123.         }
  124. }
  125. function fullscreenLink()
  126. {
  127.         var fullscreenURL = "fullscreen.php?id="+imgid[currentPhoto-1]+"&albumid=<?php echo "$albumid"; ?>&height="+document.body.clientHeight+"&width="+document.body.clientWidth;
  128.         //alert(fullscreenURL);
  129.         window.location.href = fullscreenURL;
  130. }
  131. document.onkeyup=function(e) {
  132.     if(e.which == 39)
  133.     {
  134.     movepic('test','next');
  135.     }
  136.     if(e.which == 37)
  137.     {
  138.     movepic('test','previous');
  139.     }
  140. }
  141. </script>
  142. <img name="imageLoad" class="hiddenPic" src="<?php echo "albums/$folder/$startImage"; ?>" onload="loadNext()" />
  143.  
  144. </head>
  145. <body>
  146. <table width="100%" height="100%" align="center">
  147.         <tr>
  148.                 <td valign="middle" width="50px"><img src="back.png" onclick="movepic('test','previous')" name="back" /></td>
  149.                 <td align="center" valign="middle"><a name="largeLink" href="<?php echo "albums/$folder/$startImageL"; ?>"><img src="<?php echo "albums/$folder/$startImage"; ?>" name="test" border='0' /></a></td>
  150.                 <td valign="middle" width="50px"><img src="forward.png" onclick="movepic('test','next')" name="forward" /></td>
  151.         </tr>
  152. </table>
  153. <div id="backTo"><a href="plist.php?albumid=<?php echo $albumid; ?>">back to <?php echo $albumName; ?></a></div>
  154. <div id="name">
  155. <a href="http://www.sambender.com/">sam bender</a>
  156. </div>
  157. <div id="download">
  158. <a name="permalink" href="photo.php?id=<?php echo "$id"; ?>&albumid=<?php echo "$albumid"; ?>">permalink</a>&nbsp|&nbsp<a name="downloadLink" href="force-download.php?file=<?php echo "albums/$folder/$startImageL"; ?>">download</a>&nbsp|&nbsp<a href="javascript:fullscreenLink()" name="fullscreen" >fullscreen</a>&nbsp|&nbsp<a href="" class="tip">exif<span id="exifData"><?php echo $exifBegin; ?></span></a>
  159. <?php if ($_COOKIE["IsAdmin"] == "yes") { echo "&nbsp|&nbsp<a href='javascript:delete()' name='delete' >delete</a>"; } ?>
  160. </div>
  161. <div id="number" name="numbum"><?php echo $curP+1 . " of " . $maxPhoto; ?></div>
  162. </body>
  163. </html>