From b2bffd5eb17212b60b62ab86a8559213ed3820af Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Sun, 2 Dec 2012 13:27:12 -0800 Subject: Image updates and mapspecs fixes. Fixed a bug where every checkpoint was called "checkpoint A" Fixed a bug where requesting solution during a path would break it. Fixed a bug regarding tutorial success. --- js/mapspecs.js | 44 +++++++++----------------------------------- 1 file changed, 9 insertions(+), 35 deletions(-) (limited to 'js') diff --git a/js/mapspecs.js b/js/mapspecs.js index 5299b60..5a64d83 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -33,11 +33,6 @@ var mapType; // 1 = simple, 2 = normal, ...; used for mixpanel tracking var pressedGoTime = 0; -// function loadAllSolutions() { - // for(var i in jsonmapdata.solutions) { - // } -// } - function loadSol(sol, moves) { if (sol == null) if (document.getElementById('mapsol') != undefined) @@ -62,7 +57,6 @@ function loadSol(sol, moves) { if (moves && mapid) { updateDsp(mapid, 'dspCount', moves+ " moves"); } - } function showNotification(html) { @@ -163,20 +157,12 @@ function updateDsp(mapid, element, data) { } function getmapdata(mapid) { - var rawjson = jsonmapdata[mapid]; - if (typeof(JSON) == 'undefined') { - //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(rawjson); - } - + + if (typeof(mapdata[mapid]) != 'object') + mapdata[mapid] = decryptJSON(jsonmapdata[mapid]); + blocks[mapid] = mapdata[mapid].walls; solution[mapid] = '.'; - updateDsp(mapid, 'dspWalls', blocks[mapid]+" walls"); } @@ -206,15 +192,10 @@ function requestSol(mapID) { function requestSolDone() { var JO; - if (typeof(JSON) == 'undefined') { - text = ajax.response; - JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')'); - } else { - JO = JSON.parse(ajax.response); - } + JO = decryptJSON(ajax.response); if (JO.solution == 'undefined') return; - clearwalls(JO.mapid); + //clearwalls(JO.mapid); loadSol(JO.mapid + ":" + JO.solution, JO.moves); } @@ -242,7 +223,8 @@ function clearwalls(mapid) { } } solution[mapid] = undefined; - getmapdata(mapid); + //!! + //getmapdata(mapid); } function resetwalls(mapid) { @@ -253,7 +235,6 @@ function resetwalls(mapid) { } function request_path_done() { - var JO = decryptJSON(ajax.response); var mapid = JO.mapid; mapjson[mapid] = JO; @@ -289,7 +270,6 @@ function request_path_done() { mapdata[mapid].restoreTiles = new Array(); mapdata[mapid].pathColor = new Object; - mapdata[mapid].pathsPending = JO.path.length; mapdata[mapid].isMultiPath = (JO.path.length > 1); @@ -299,8 +279,6 @@ function request_path_done() { animatePath(JO.path[i].path, mapid, JO.path[i].start, i); } - - //Mark off challenges //TODO: Temporarly disabled because it breaks the tutorial; if(isChallenge && 2 == 4) @@ -318,9 +296,8 @@ function decryptJSON(text) { var JO; if (typeof(JSON) == 'undefined') { JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')'); - //mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML); } else { - JO = JSON.parse(ajax.response); + JO = JSON.parse(text); } return JO; } @@ -341,9 +318,6 @@ function animatePath(path, mapid, start, pathNumber) { } function animatePathDone(mapid) { - - //console.log('Animate Path Done', mapid); - scoresRequestPage(mapid, currentPage[mapid]); document.getElementById(mapid+',btn').disabled = false; if (isChallenge == true) { -- cgit v1.2.3