From 638ff8a06aae2b1bc9fcbb9406a7a1a30b741ef3 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Mon, 19 Mar 2012 19:24:31 -0700 Subject: achievements.php debug data and some fixes. --- js/mapspecs.js | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/mapspecs.js b/js/mapspecs.js index ff86a28..1f9702e 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -30,9 +30,15 @@ var mapjson = new Array(); var htmlscores = ''; var htmlnotification = ''; var jsonmapdata = new Object; +//var jsonmapdata.solutions = new Array(); -function loadSol(sol) { +// function loadAllSolutions() { + // for(var i in jsonmapdata.solutions) { + // } +// } + +function loadSol(sol, moves) { if (sol == null) if (document.getElementById('mapsol') != undefined) sol = document.getElementById('mapsol').innerHTML; @@ -53,13 +59,20 @@ function loadSol(sol) { } } } + if (moves && mapid) { + updateDsp(mapid, 'dspCount', moves+ " moves"); + } + } function showNotification(html) { var div = document.createElement('div'); var pref = '
'; - var suff = '
'; + pref += '
[Close]
'; + pref += '
'; + var suff = '
'; + //var suff = ''; div.innerHTML = pref+html+suff; document.body.appendChild(div.firstChild); } @@ -197,24 +210,23 @@ function doSend(mapid) { }); } -function requestSol(solid) { - ajax.requestFile = "do.php?r=getsol&solutionid="+solid; //prepare strdata +function requestSol(mapID) { + ajax.requestFile = "do.php?r=getsol&mapID="+mapID; //prepare strdata ajax.onCompletion = requestSolDone; // specify function to be executed on response ajax.runAJAX(); } function requestSolDone() { - if (typeof(JSON) == 'undefined') { text = ajax.response; var JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')'); - //mapdata[mapid] = eval(document.getElementById(mapid+',mapdata').innerHTML); } else { var JO = JSON.parse(ajax.response); } - + if (JO.solution == 'undefined') + return; clearwalls(JO.mapid); - loadSol(JO.mapid + ":" + JO.solution); + loadSol(JO.mapid + ":" + JO.solution, JO.moves); } function clearwalls(mapid) { @@ -691,7 +703,7 @@ function savePref(pref, value) { setCookie('pref_'+pref, value,31); } -//Cookie function from w3schools.com +//Cookie functions from w3schools.com function setCookie(c_name,value,exdays) { var exdate=new Date(); @@ -699,7 +711,20 @@ function setCookie(c_name,value,exdays) var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } - +function getCookie(c_name) +{ +var i,x,y,ARRcookies=document.cookie.split(";"); +for (i=0;i