summaryrefslogtreecommitdiffstats
path: root/pages/test.php
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-01-25 00:26:07 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-01-25 00:26:07 -0800
commitae5c6c5800f39ef169986e59e69b43241ccf3902 (patch)
treeb8428e9376c767176dee427855664fbf6102ca1f /pages/test.php
parent54aac45cafb3df1bd1e31177d4f38750f495e908 (diff)
downloadpathery-ae5c6c5800f39ef169986e59e69b43241ccf3902.tar.xz
Added missing files, deleted some old files.
Diffstat (limited to 'pages/test.php')
-rw-r--r--pages/test.php408
1 files changed, 0 insertions, 408 deletions
diff --git a/pages/test.php b/pages/test.php
deleted file mode 100644
index a5fe882..0000000
--- a/pages/test.php
+++ /dev/null
@@ -1,408 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<!-- iso-8859-1 -->
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <link href="css/mapstyles.css" rel="stylesheet" type="text/css" />
- <title>Maze TowerD</title>
-
-<?PHP
-// <script src="js/mapspecs.js" type="text/javascript"></script>
-
-include('../mazetd/includes/maps.php');
-
-//$mygrid = GenerateMap(20, 8, 4, 3);
-if (isset($_GET[mapcode])) {
- $mygrid = GenerateMapByCode($_GET[mapcode]);
-} else {
- $mygrid = GenerateMap(12, 12, 8);
- $mygrid2 = GenerateMap(rand(12, 18), rand(10, 14), 8);
- //$mygrid = GenerateMap(23, 13, 7, 3);
-}
-$code = GenerateMapCode($mygrid);
-
-
-?>
-
- <script src="js/ajax.js" type="text/javascript"></script>
-
-<script type="text/javascript">
-window.onload = function(){
- document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks+"</b>";
- //doSend();
-}
-
-
-var solution = new Array();
-var blocks = new Array();
-var count = new Array();
-var mapdata = new Array();
-
-function grid_click(obj) {
-
- //Prepare data
- tmp = obj.id.split(',');
- mapid = tmp[0] - 0;
- y = tmp[1];
- x = tmp[2];
-
- if (solution[mapid] == undefined) {
- getmapdata(mapid);
- }
-
- if (obj.cv) {
- obj.cv = false;
-
- //obj.style.backgroundColor = '#ffffff';
- obj.setAttribute("class", "grid_td");
- blocks[mapid]++;
- //alert(obj.id);
- //Remove wall
- solution[mapid] = solution[mapid].replace(y+','+x+'.', '');
- } else {
- if (blocks[mapid] < 1) {
- alert("Outa blocks!");
- return;
- }
- obj.cv = true;
- //obj.style.backgroundColor = '#ff0000';
- obj.setAttribute("class", "grid_td_walls");
- //Add Wall
- solution[mapid] += y+','+x+'.';
- blocks[mapid]--;
- }
- document.getElementById('blocksdisplay').innerHTML = "<b>"+blocks[mapid]+"</b>";
-
- document.getElementById(mapid+',dsptr').innerHTML = " "+blocks[mapid]+" walls remain.";
-
-}
-
-function getmapdata(mapid) {
- mapdata[mapid] = JSON.parse(document.getElementById(mapid+',mapdata').innerHTML);
- blocks[mapid] = mapdata[mapid].walls;
- solution[mapid] = '.';
- document.getElementById(mapid+',dsptr').innerHTML = " "+blocks[mapid]+" walls remain.";
- //document.getElementById(mapid+',dsptr').innerHTML = blocks[mapid];
-}
-
-//==needs mapid
-function doSend(mapid) {
- //mapcode = document.getElementById('mapcode').innerHTML;
- //alert("dosend..");
- //mapid = 1;
- if (solution[mapid] == undefined) {
- getmapdata(mapid);
- }
-
- mapcode = '<? echo $code; ?>';
- reqstr = "";
- reqstr += "&mapcode="+mapdata[mapid].code;
- reqstr += "&mapid="+mapid;
- //alert (mapdata[mapid].code);
- reqstr += "&solution="+solution[mapid];
-
- //alert(reqstr);
- document.getElementById('dispdo').innerHTML = "http://mazetd.4xg.net/do.php?r=getpath"+reqstr
-
- //alert("request string:"+reqstr);
- ajax.requestFile = "do.php?r=getpath"+reqstr; //prepare strdata
- ajax.onCompletion = request_path_done; // Specify function to be executed on response.
- ajax.runAJAX();// Do it!
-}
-function resetwalls(mapid) {
- answer = confirm("Remove walls and start fresh?");
- if (answer) {
- if (solution[mapid] == undefined) return;
- walls = solution[mapid].split('.');
- for(var i in walls) {
- //alert(walls[i]);
- tmp = walls[i].split(',');
- eid = mapid+','+tmp[0]+','+tmp[1];
- //alert('eid:'+eid);
- if (document.getElementById(eid) != undefined) {
- obj = document.getElementById(eid);
- obj.setAttribute("class", "grid_td");
- obj.cv = false;
- //alert("exe");
- }
- }
- solution[mapid] = undefined;
- getmapdata(mapid);
- }
-}
-
-function request_path_done() {
- //document.getElementById('mapdisplay').innerHTML = ajax.response;
- //alert ("resp: "+ajax.response);
- //if (ajax.response == undefined) return;
-
- //alert ("resp: "+ajax.response);
- var JO = JSON.parse(ajax.response);
-
- for(var i in JO.error) {
- alert('\n JO error ' + JO.error[i]);
- }
-
- //document.getElementById('disp').innerHTML = JO.map;
-
- if (JO.blocked) {
- alert("Path is blocked make sure there is a way for it to go!");
- return;
- }
- //document.write(JO.map);
- //alert ("moves: "+JO.moves);
- //alert ("path: "+JO.start);
- document.getElementById('disppath').innerHTML = JO.path;
- document.getElementById('disptotalmoves').innerHTML = JO.moves;
-
- AnimatePath(JO.path, JO.mapid, JO.start);
-
- //document.getElementById('mapdisplay').innerHTML = JO.map;
-
-}
-
-
-//This needs a start location.
-function AnimatePath(path, mapid, start) {
- tmp = start.split(',');
- y = tmp[0];
- x = tmp[1];
-
- p = path;
- //alert("Begin");
- t = p.length;
- //count[mapid] = 0;
- doanimate(x, y, p, t, mapid);
- //setTimeout("doanimate("+x+","+y+",'"+p+"',"+t+")",500);
-}
-
-var snake = new Array();
-
-function doanimate(x, y, p, t, mapid) {
- //Animate current square, and move to next one.
- if (count[mapid] == undefined) {
- count[mapid] = 0;
- }
- //alert("test");
- if (snake[mapid] == undefined) {
- snake[mapid] = new Array();
- snake[mapid]['color'] = '#4444bb';
- }
-
- //==
- // document.getElementById('1count').innerHTML = count[mapid];
- document.getElementById(mapid+',dspbr').innerHTML = count[mapid]+ " moves";
-
- eid = mapid+','+x+','+y;
-
- //Verify.
- if (document.getElementById(eid) == undefined) {
- alert("Path exited field..?");
- return;
- }
- handle = document.getElementById(eid);
-
- //Maintain our original classname, no matter the cost!
- origclass = handle.className;
- if ( origclass == 'grid_td_path1' ||
- origclass == 'grid_td_path2' ||
- origclass == 'grid_td_path3' ||
- origclass == 'grid_td_path4' ||
- origclass == 'grid_td_animate_pre' ) {
- // if (origclass == 'grid_td_animate' || origclass == 'grid_td_animate_pre' ) {
- origclass = handle.classOrigName;
- //setTimeout(handle.setAttribute('class', origclass), 850);
- //alert('ex ' + origclass);
- }
- //handle.style.backgroundColor = snake[mapid]['color'];
- handle.classOrigName = origclass;
-
-
- //Just moves
- switch(t) {
- case '1': //1 - Up
- case '2': //2 - Right
- case '3': //3 - Down
- case '4': //4 - Left
- count[mapid]++;
- handle.setAttribute('class', 'grid_td_path'+t);
- break;
- }
- handle.style.backgroundColor = snake[mapid]['color'];
-
- //setTimeout(handle.setAttribute('class', origclass), 850);
- setTimeout("document.getElementById('"+eid+"').setAttribute('class', '"+origclass+"')", 855);
- setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '';", 855);
-
- //Okay lets make it look cool now.
- //document.getElementById(handle).setAttribute('class', 'grid_td_animate_pre');
- //Needs a delay, or simply wont work.
- //setTimeout("document.getElementById('"+handle+"').setAttribute('class', 'grid_td_animate')", 55);
-
- //document.getElementById('blocksdisplay').innerHTML = "<b>"+origclass+"</b>";
-
- //if (origclass != 'grid_td_animate' && origclass != 'grid_td_animate_pre' ) {
- //document.getElementById('blocksdisplay').innerHTML = "<b>"+origclass+"</b>";
- // setTimeout("document.getElementById('"+handle+"').setAttribute('class', '"+origclass+"')", 850);
- //} else {
- //document.getElementById('blocksdisplay').innerHTML = "<b>HELLO WORLD!?</b>";
- //}
-
- //Moving on:
- speed = 85;
- t = p.substring(0, 1);
- if (t == '') {
- count[mapid] = 0;
- snake[mapid]['color'] = '#4444bb';
- return;
- }
- switch(t) {
- case '1': x--; break; //1 - Up
- case '2': y++; break; //2 - Right
- case '3': x++; break; //3 - Down
- case '4': y--; break; //4 - Left
- //Special codes.
- //Reached Target
- case 'a':
- speed = 800;
- snake[mapid]['color'] = '#F777FF';
- break;
- case 'b':
- speed = 800;
- snake[mapid]['color'] = '#FFFFAA';
- break;
- case 'c':
- speed = 800;
- snake[mapid]['color'] = '#44EE66';
- break;
- case 'd':
- speed = 800;
- snake[mapid]['color'] = '#ff9911';
- break;
- case 'e':
- speed = 800;
- snake[mapid]['color'] = '#44ddee';
- break;
- case 'f':
- speed = 800;
- snake[mapid]['color'] = '#4444bb';
- break;
- //The mighty teleport.
- case 'u':
- //alert(p);
- tmp = p.split('u');
- //alert(tmp[1]);
- //alert(tmp[2]);
- AnimatePath(tmp[2], mapid, tmp[1]);
- //setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",speed);
- return;
- speed = 800;
- break;
- case 'n':
- //alert(p);
- tmp = p.split('n');
- //alert(tmp[1]);
- //alert(tmp[2]);
- AnimatePath(tmp[2], mapid, tmp[1]);
- //setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",speed);
- return;
- speed = 800;
- break;
- }
- //Remove move from p
- p = p.substring(1);
- //speed = (10 * p.length) + 40;
-
- setTimeout("doanimate("+x+","+y+",'"+p+"','"+t+"','"+mapid+"')",speed);
-}
-var de = false;
-function displaymap(obj) {
- if (de == false) {
- obj.setAttribute('class', 'mapdisplay_up');
- }
-}
-function minmap(obj) {
- de = true;
- obj.setAttribute('class', 'mapdisplay');
- setTimeout("de = false;", 1000);
-}
-
-</script>
-</head>
-
-<body>
-<?php
-
-
-echo DisplayMap($mygrid, 1);
-echo DisplayMap($mygrid2, 2);
-
-//Echo Findpath ($mygrid);
-$start[0] = 0;
-$start[1] = 1;
-
-//$p = Findpath ($mygrid, $start, 'a');
-//$pathmap1 = $p['path'];
-
-//echo "<br />BP1:".$p['path']."<br />";
-//echo "<br />yx2:".$p['end']."<br />";
-
-//$p = Findpath ($mygrid, explode(",", $p['end']), 'b');
-//echo "<br />BP:".$p['path']."<br />";
-//echo "<br />yx:".$p['end']."<br />";
-// $pathmap1 .= $p['path'];
-
-// $p = Findpath ($mygrid, explode(",", $p['end']), 'c');
-// $pathmap1 .= $p['path'];
-
-$p = Findpath ($mygrid, "2,4.3,4", 'f');
-$pathmap1 .= $p['path'];
-
-//echo DisplayMap($pathmap);
-
-//==Needs to contain mapid.
-//echo "<br /> <b><a href='javascript:doSend()'>Attempt Solution laaaaaaaaaaaaa laaaaaaaaaaaa CLick on this..</a></b>";
-echo "<br /><div style='font-size:32pt;' id='1count'><b>b</b></div> ";
-echo "<br />";
-var_dump ($p);
-
-
-echo "<br />";
-
- // $time = microtime();
- // $time = explode(' ', $time);
- // $time = $time[1] + $time[0];
- // $begintime = $time;
-
- //for($i = 1; $i <= 500; $i++) {
- //$mygrid = generateMap(13, 8, 4, 3);
- //echo "$i <br />";
- // $pathmap = Findpath ($mygrid, $start, 'a');
- // $pathmap = Findpath ($mygrid, $start, 'b');
- // $pathmap = Findpath ($mygrid, $start, 'c');
- // $pathmap = Findpath ($mygrid, $start, 'f');
- //}
- // $time = microtime();
- // $time = explode(" ", $time);
- // $time = $time[1] + $time[0];
- // $endtime = $time;
- // $totaltime = round($endtime - $begintime, 5);
- // echo "<br /><b>500 paths executed in: $totaltime s</b>";
-
- //Starting result:
- //500 paths executed in: 5.24884 s
- //On a $mygrid = GenerateMap(13, 8, 4, 3); board.
- //Now 1.
-echo "Mapcode: $code";
-?>
-<div id="blocksdisplay"><b>b</b></div>
-
-<div id="disp"><b></b></div>
-<div id="disppath"><b></b></div>
-<br />
-<div id="dispdo"><b></b></div>
-<br />
-<div id="disptotalmoves"><b></b></div>
-</body>
-</html> \ No newline at end of file