jaedb
1/12/2014 - 8:26 PM

Design presentation script

Design presentation script

<?php
	
	$page = '0';
	
	if( isset($_GET['page']) )
		$page = $_GET['page'];
		
	$pages = array();
	
	foreach(scandir('.') as $file) {
		if( $file != '.' && $file != '..' && $file != 'index.php' )
			$pages[] = $file;
	}
	
	$prevLink = null;
	$nextLink = null;
	$currentImage = $pages[ $page ];
	$restartLink = false;
	
	if( $page > 0 )
		$prevLink = '?page=' . ($page-1);
	
	if( $page+1 < count($pages) )
		$nextLink = '?page=' . ($page+1);
	else
		$restartLink = true;
	
	// get the current, absolute URL (for JS navigation)
	function getUrl() {
		$url  = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] :  'https://'.$_SERVER["SERVER_NAME"];
		$url .= $_SERVER["PHP_SELF"];
		return $url;
	}
	
?>
<html>
<head>

	<title>PlasticStudio Design Preview</title>
	
	<style>
	
		html, body {
			background: #eeeeee;}
	
		*, html, body {
			border: 0;
			padding: 0;
			margin: 0;
			color: #000000;
			text-decoration: none;}
		
		#image {
			width: 100%;
			position: relative;
			background-position: 50% 0;
			background-repeat: no-repeat;
			overflow-x: hidden;
			border-top: 40px solid #000000;}
			
		#image img {
			opacity: 0;}
			
		#navigation {
			position: absolute;
			top: 0;
			height: 40px;
			width: 100%;
			display: block;
			z-index: 9;
			background: #000000;}
			
		#navigation .page-counter {
			width: 50%;
			left: 25%;
			top: 12px;
			color: #777777;
			position: absolute;
			font-family: Arial, Helvetica, sans-serif;
			font-size: 12px;
			text-align: center;}
			
		#navigation .link {
			display: block;
			font-size: 14px;
			color: #FFFFFF;
			font-weight: bold;
			font-family: Arial, Helvetica, sans-serif;
			position: absolute;
			top: 0;
			padding: 10px;
			opacity: 0.5;}
			
		#navigation .left {
			left: 0px;
			text-align: left;}
			
		#navigation .right {
			right: 0px;
			text-align: right;}
			
		#navigation .link:hover {
			opacity: 1;}
		
	</style>
	
	<script type="text/javascript">
	
		function navigate(e){
			var evtobj = window.event? event : e //distinguish between IE's explicit event object (window.event) and Firefox's implicit.
			var unicode = evtobj.charCode? evtobj.charCode : evtobj.keyCode
			//var actualkey = String.fromCharCode(unicode)
			
			<?php if($nextLink) : ?>
			if (unicode == "39")
				window.location = "<?php echo getUrl() . $nextLink ?>"
			<?php endif; ?>
				
			<?php if($prevLink) : ?>
			if (unicode == "37")
				window.location = "<?php echo getUrl() . $prevLink ?>"
			<?php endif; ?>
		}
		
		document.onkeypress = navigate
		
	</script>
	
</head>
<body>

	<div id="navigation">
		
		<?php if($prevLink) : ?>
			<a href="<?php echo $prevLink ?>" class="link left">
				&#8249; &nbsp; PREVIOUS
			</a>
		<?php endif; ?>
		
		<div class="page-counter">
			Page <?php echo $page+1 ?> of <?php echo count($pages) ?>
		</div>
		
		<?php if($nextLink) : ?>
			<a href="<?php echo $nextLink ?>" class="link right">
				NEXT &nbsp; &#8250;
			</a>
		<?php elseif($restartLink) : ?>
			<a href="?page=0" class="link right">
				&#8634; &nbsp; RESTART
			</a>
		<?php endif; ?>
		
	</div>
	
	<div id="page">
		
		<div id="image" style="background-image: url('<?php echo $currentImage ?>');">
			<img src="<?php echo $currentImage ?>" />			
		</div>
		
	</div>
	
</body>
</html>