<?php
/*
* buzzword
* Copyright (c) 2003 Jon Tai
*
* $Id: slideshow.php,v 1.24 2004/02/16 20:19:45 jon Exp $
*
* This file is part of buzzword.
*
* buzzword is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* buzzword is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with buzzword; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once './config.inc';
$gallery = new gallery_gallery(import_gallery_gallery_key());
if (!$gallery->exists())
display_error('gallery does not exist');
$images = get_gallery_images($gallery->gallery_key);
header('Content-Type: text/html; charset=ISO-8859-1');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Slideshow of <?php echo $gallery->get_display_title(); ?></title>
<link rel="stylesheet" type="text/css" href="../style.css">
<?php echo stylesheet_hook(); ?>
</head>
<body>
<center>
<br>
<img name="gss_img" src="display.php?i=<?php echo $images[0]->image_key; ?>">
<br>
<div align="center" class="content-container" id="gss_cap">
<?php echo $images[0]->get_display_description(); ?></div>
<br>
<a href="" onClick="gss_stop(); gss_prev(); return false;"><img
src="images/toolbar-slideshow-prev.gif" alt="Previous" title="Previous"
border="0" width="22" height="21"></a>
<a href="" onClick="gss_play(); return false;"><img
src="images/toolbar-slideshow-play.gif" alt="Play" title="Play"
border="0" width="22" height="21"></a>
<a href="" onClick="gss_stop(); return false;"><img
src="images/toolbar-slideshow-stop.gif" alt="Stop" title="Stop"
border="0" width="22" height="21"></a>
<a href="" onClick="gss_stop(); gss_next(); return false;"><img
src="images/toolbar-slideshow-next.gif" alt="Next" title="Next"
border="0" width="22" height="21"></a>
<script language="JavaScript" type="text/javascript">
<!--
gss_speed = <?php echo get_pref('gallery_slideshow_speed'); ?>;
gss_imgs = new Array();
gss_caps = new Array();
<?php
foreach ($images as $key => $image) {
// escape single quotes and newlines for javascript
$image_desc = $image->get_display_description();
$image_desc = str_replace("\n", '', $image_desc);
$image_desc = str_replace('"', '"', $image_desc);
$image_desc = str_replace("\\", "\\\\", $image_desc);
echo "gss_imgs[$key] = '{$image->image_key}';\n";
echo "gss_caps[$key] = \"$image_desc\";\n";
}
?>
gss_current_index = 0;
gss_loaded_imgs = new Array();
function gss_play() {
gss_stopped = false;
setTimeout('gss_playing()', gss_speed);
}
function gss_stop() {
gss_stopped = true;
}
function gss_playing() {
if (!gss_stopped) {
gss_next();
setTimeout('gss_playing()', gss_speed);
}
}
function gss_next() {
// determine the next image to show
gss_next_index = (gss_current_index + 1);
if (gss_next_index == gss_imgs.length)
gss_next_index = 0;
// see if the next image is loaded
if ( (gss_loaded_imgs[gss_next_index]) && (gss_loaded_imgs[gss_next_index].complete) ) {
// it's loaded, so display it
gss_current_index = gss_next_index;
gss_swap();
} else {
// it's not loaded yet, so load it, wait a bit, and try again
gss_loaded_imgs[gss_next_index] = new Image;
gss_loaded_imgs[gss_next_index].src = 'display.php?i=' + gss_imgs[gss_next_index];
setTimeout('gss_next()', (gss_speed * 500));
}
}
function gss_prev() {
// determine the next image to show
gss_prev_index = (gss_current_index - 1);
if (gss_prev_index == -1)
gss_prev_index = (gss_imgs.length - 1);
// see if the next image is loaded
if ( (gss_loaded_imgs[gss_prev_index]) && (gss_loaded_imgs[gss_prev_index].complete) ) {
// it's loaded, so display it
gss_current_index = gss_prev_index;
gss_swap();
} else {
// it's not loaded yet, so load it, wait a bit, and try again
gss_loaded_imgs[gss_prev_index] = new Image;
gss_loaded_imgs[gss_prev_index].src = 'display.php?i=' + gss_imgs[gss_prev_index];
setTimeout('gss_prev()', (gss_speed * 500));
}
}
function gss_swap() {
document.images.gss_img.src = 'display.php?i=' + gss_imgs[gss_current_index];
if (document.getElementById) {
document.getElementById('gss_cap').innerHTML = gss_caps[gss_current_index];
} else if (document.all) {
document.all['gss_cap'].innerHTML = gss_caps[gss_current_index];
}
}
// automatically start the show
gss_play();
// -->
</script>
</center>
</body>
</html>