diff --git a/explorer.php b/explorer.php index 7b11766bda95080e5042bcd00193c554ee1cc61f..5815f6e55bf6af4bf721799fd59f009d59cc6ef0 100644 --- a/explorer.php +++ b/explorer.php @@ -22,19 +22,6 @@ <!--}}}--> </head> <body> - <div class="hidden" id="planet-file"> - <?php - // get the XML planet descriptor - $search = glob("*.xml") ; - $len = count($search) ; - if($len > 0) { - $file = $search[0] ; - echo $file ; - } else { - echo "" ; - } - ?> - </div> <div class="container"> <!--{{{ top bar--> <div class="navbar navbar-default"> @@ -1274,6 +1261,20 @@ </div> <!--}}}--> <!--}}}--> + <xml id="planet-xml"> + <?php + // get the XML planet descriptor + $search = glob("*.xml") ; + $len = count($search) ; + if($len > 0) { + $file = fopen($search[0], 'r') ; + fgets($file) ; + fpassthru($file) ; + } else { + echo "" ; + } + ?> + </xml> <script type="text/javascript" src="<?php echo $rootpath?>/js/bootstrap-native.js"></script> <script type="text/javascript" src="<?php echo $rootpath?>/js/sortable.js"></script> <script type="text/javascript" src="<?php echo $rootpath?>/js/filesaver.js"></script> diff --git a/js/explorer.js b/js/explorer.js index 53672881f7d5ebca1d5a850ad0015c25ce7501e3..1706e50208893069479dc272bd43234fc544fccf 100644 --- a/js/explorer.js +++ b/js/explorer.js @@ -42,9 +42,9 @@ function Tile(XmlElement) { var children = XmlElement.childNodes ; for(var i=0; i<children.length; i++) { var child = children[i] ; - if(child.nodeName == 'image') { + if(child.nodeName == 'IMG') { this.image = child.getAttribute('name') ; - } else if (child.nodeName == 'edge') { + } else if (child.nodeName == 'EDGE') { var index = parseInt(child.getAttribute('origin_index')) ; var neighbour = child.getAttribute('neighbour') ; if(neighbour != '') { @@ -195,11 +195,11 @@ function load_planet(Xmldoc) { var children = Xmldoc.childNodes ; for(var i=0; i<children.length; i++) { var child = children[i] ; - if(child.nodeName == 'planet') { + if(child.nodeName == 'PLANET') { var tiles = child.childNodes for(var j=0; j<tiles.length; j++) { tileNode = tiles[j] ; - if(tileNode.nodeName == 'tile') { + if(tileNode.nodeName == 'TILE') { var tile = new Tile(tileNode) ; planet[tile.name] = tile ; } @@ -262,6 +262,11 @@ function check_boundary(edge) { Xpl.check_boundary = check_boundary ; function init() { + var planet_sources = document.getElementById('planet-xml') ; + load_planet(planet_sources) ; + load_position() ; + redraw() ; + /* var filename = document.getElementById('planet-file').innerHTML ; openXML(filename, function(response) { if (response.readyState == 4 && response.status == 200) { @@ -270,6 +275,7 @@ function init() { redraw() ; } }) ; + */ } document.addEventListener("DOMContentLoaded", init) ;