summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2012-02-02 22:39:09 -0800
committerPatrick Davison <snapwilliam@gmail.com>2012-02-02 22:39:09 -0800
commit1eeb95fcde8e23ea9493d74232f9e38d3fad6d02 (patch)
treea5643675b0c5a6926238307846661c1b64c203d5
parent7257ddcadc19f119c97d1ab8996ffafc8f863fd5 (diff)
downloadpathery-1eeb95fcde8e23ea9493d74232f9e38d3fad6d02.tar.xz
Fix for JSON "MapData" div issue for search engines.
-rw-r--r--includes/maps.php19
-rw-r--r--js/mapspecs.js9
2 files changed, 18 insertions, 10 deletions
diff --git a/includes/maps.php b/includes/maps.php
index 6a8512c..a6787a7 100644
--- a/includes/maps.php
+++ b/includes/maps.php
@@ -104,12 +104,9 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
$i -= 1;
$height = (($i * 35) + -1).'px';
//$height = (($i * 22) + 2).'px';
-
- $jsonmap = json_encode($mapdata);
-
-
-
+ $jsonmap = str_replace("'", "\'", json_encode($mapdata));
+
//This works in chrome, not sure about others.
$preloaddiv .= "
<div style='visibility:hidden;display:none'>
@@ -122,9 +119,15 @@ function DisplayMap($mapMatrix, $idprefix = 1, $style = 'normal', $speed = NULL)
<img src='images/OverlayTileFaceted10.png' alt=''>
</div>";
- $mapdatadiv .= "<div id='$idprefix,mapdata' style='visibility:hidden;display:none'>";
- $mapdatadiv .= $jsonmap;
- $mapdatadiv .= '</div>';
+ //$mapdatadiv .= "<div id='$idprefix,mapdata' style='visibility:hidden;display:none'>";
+ //$mapdatadiv .= $jsonmap;
+ //$mapdatadiv .= '</div>';
+
+ //JSON Fix for search-engine cache.
+ $mapdatadiv = "<script>
+ jsonmapdata['$idprefix'] = '$jsonmap';
+ </script>";
+
$maptable = "$preloaddiv
<table style='width:$width;height:$height;' class='grid_table'>
diff --git a/js/mapspecs.js b/js/mapspecs.js
index 68be78c..5361d9d 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -27,6 +27,8 @@ var count = new Array();
var mapdata = new Array();
var mapjson = new Array();
var htmlscores = '';
+var jsonmapdata = new Object;
+
function loadSol(sol) {
if (sol == null)
@@ -113,12 +115,15 @@ function updateDsp(mapid, element, data) {
}
function getmapdata(mapid) {
+ var rawjson = jsonmapdata[mapid];
if (typeof(JSON) == 'undefined') {
- text = document.getElementById(mapid+',mapdata').innerHTML;
+ //text = document.getElementById(mapid+',mapdata').innerHTML;
+ text = rawjson;
mapdata[mapid] = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')');
//mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML);
} else {
- mapdata[mapid] = JSON.parse(document.getElementById(mapid+',mapdata').innerHTML);
+ //mapdata[mapid] = JSON.parse(document.getElementById(mapid+',mapdata').innerHTML);
+ mapdata[mapid] = JSON.parse(rawjson);
}
blocks[mapid] = mapdata[mapid].walls;