From 1da7929920f4939336931fe0bf5df59342f649fd Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Fri, 13 Apr 2012 17:27:27 -0700 Subject: Score updates --- js/mapspecs.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'js') diff --git a/js/mapspecs.js b/js/mapspecs.js index 1f9702e..f6a1791 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -154,8 +154,8 @@ function grid_click(obj) { } function updateDsp(mapid, element, data) { - if (mapdata[mapid] == undefined) - return; + //if (mapdata[mapid] == undefined) + // return; //if (mapdata[mapid].example != true) { if (document.getElementById(mapid+','+element) != undefined) { handle = document.getElementById(mapid+','+element); @@ -299,6 +299,29 @@ function request_path_done() { ajax.runAJAX();// Do it! } +// Force score update. +function updateScoresReq(mapid) { + //Get score update. + ajax.requestFile = "do.php?checkachieve=true&r=getscores&mapid="+mapid; //prepare strdata + ajax.onCompletion = updateScoresGet; // Specify function to be executed on response. + ajax.runAJAX();// Do it! +} +function updateScoresGet() { + JO = decryptJSON(ajax.response); + updateDsp(JO.mapid, 'dspScore', JO.scores); +} + +function decryptJSON(text) { + if (typeof(JSON) == 'undefined') { + 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); + } + return JO; +} + + function animatePath(path, mapid, start) { tmp = start.split(','); y = tmp[0]; -- cgit v1.2.3