Skip to content

Instantly share code, notes, and snippets.

@Demwunz
Last active October 1, 2015 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demwunz/1949084 to your computer and use it in GitHub Desktop.
Save Demwunz/1949084 to your computer and use it in GitHub Desktop.
Static Template browser
<?php
$directory = '';
$pages = glob($directory . "*.php");
foreach($pages as $page){
$thelist .= '<option value="'.$page.'">'.$page.'</option>';
}
?>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<!-- This page is repurposed from a script I wrote at http://snipplr.com/view/48345/static-template-switcher/ -->
<style>
html body{width:100%;height:100%;padding:0px;margin:0px;overflow:hidden;font-family:arial;font-size:10px;color:#6e6e6e;background-color:#000}
#header-bar{height:40px;background-color:#000;border-bottom:1px solid #191919;z-index:100;line-height:40px;margin-bottom:1px;padding-left:20px;}
#preview-frame{width:100%;background-color:#fff}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<script type="text/javascript">
var calcHeight = function() {
var headerDimensions = $('#header-bar').height();
$('#preview-frame').height($(window).height() - headerDimensions);
}
$(function() {
calcHeight();
var iframe = $('#preview-frame'),
selector = $("#switcher"),
state,
selected = state;
if (location.hash) {
iframe.attr('src', location.hash.split('#')[1]);
}
selector.change(function(e){
state = $(this).val();
iframe.attr('src', state);
location.hash = state;
e.preventDefault();
});
$("#refresh").click(function(e) {
e.preventDefault();
document.getElementById("preview-frame").contentWindow.location.reload(true);
});
});
$(window).resize(function() {
calcHeight();
}).load(function() {
calcHeight();
});
</script>
</head>
<body>
<div id="header-bar">
<div class="switcher">
<select name="switcher" id="switcher">
<?=$thelist?>
</select>
<button type="button" id="refresh">Refresh</button>
</div>
</div>
<iframe id="preview-frame" src="home.php" name="preview-frame" frameborder="0" noresize="noresize"></iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment