phaser/examples/wip/index.php

114 lines
2.8 KiB
PHP
Raw Normal View History

2013-10-22 02:58:20 +00:00
<?php
// Global
$files = dirToArray(dirname(__FILE__));
$total = 0;
foreach ($files as $key => $value)
{
if (is_array($value) && count($value) > 0)
{
$total += count($value);
}
}
function getFile() {
global $files, $dir, $filename, $title, $code;
if (isset($_GET['d']) && isset($_GET['f']))
{
$dir = urldecode($_GET['d']);
$filename = urldecode($_GET['d']) . '/' . urldecode($_GET['f']);
$title = urldecode($_GET['t']);
if (file_exists($filename))
{
$code = file_get_contents($filename);
$files = dirToArray($dir);
}
}
}
function dirToArray($dir) {
$ignore = array('.', '..', '_site', 'assets', 'states', 'book');
2013-10-22 02:58:20 +00:00
$result = array();
$root = scandir($dir);
$dirs = array_diff($root, $ignore);
foreach ($dirs as $key => $value)
{
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
{
$result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value);
}
else
{
if (substr($value, -3) == '.js')
{
$result[] = $value;
}
}
}
return $result;
}
function printJSLinks($dir, $files) {
2013-10-22 02:58:20 +00:00
$output = "";
foreach ($files as $key => $value)
{
$value2 = substr($value, 0, -3);
$file = urlencode($value);
$output .= "<a href=\"wip/index.php?f=$file\">$value2</a><br />";
}
return $output;
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>phaser</title>
<base href="../"></base>
<?php
require('../../build/config.php');
if (isset($_GET['f']))
2013-10-22 02:58:20 +00:00
{
$f = $_GET['f'];
?>
<script src="wip/<?php echo $f?>" type="text/javascript"></script>
<script src="../filters/SampleFilter.js" type="text/javascript"></script>
<script src="../filters/BinarySerpents.js" type="text/javascript"></script>
<script src="../filters/Tunnel.js" type="text/javascript"></script>
<script src="../filters/ColorBars.js" type="text/javascript"></script>
2013-11-21 12:34:41 +00:00
<script src="../filters/Fire.js" type="text/javascript"></script>
<?php
2013-10-22 02:58:20 +00:00
}
?>
<style>
body {
font-family: Arial;
font-size: 14px;
2013-10-22 02:58:20 +00:00
}
</style>
</head>
<body>
2013-10-22 02:58:20 +00:00
<div id="phaser-example"></div>
2013-10-22 02:58:20 +00:00
<h2>work in progress examples</h2>
2013-10-22 02:58:20 +00:00
<?php
echo printJSLinks('wip', $files);
?>
2013-10-22 02:58:20 +00:00
</body>
</html>