summaryrefslogtreecommitdiffstats
path: root/js/mapspecs.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/mapspecs.js')
-rw-r--r--js/mapspecs.js56
1 files changed, 30 insertions, 26 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js
index 662d47c..6d3e4af 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -33,6 +33,8 @@ var jsonmapdata = new Object;
//var jsonmapdata.solutions = new Array();
var mapType; // 1 = simple, 2 = normal, ...; used for mixpanel tracking
+var pressedGoTime = 0;
+
// function loadAllSolutions() {
// for(var i in jsonmapdata.solutions) {
// }
@@ -180,35 +182,22 @@ function getmapdata(mapid) {
solution[mapid] = '.';
updateDsp(mapid, 'dspWalls', blocks[mapid]+" walls");
-
- //document.getElementById(mapid+',dspWalls').innerHTML = " "+blocks[mapid]+" walls";
- //document.getElementById(mapid+',dspWalls').innerHTML = blocks[mapid];
}
function doSend(mapid) {
if (solution[mapid] == undefined) {
getmapdata(mapid);
}
+
+ pressedGoTime = new Date().getTime();
reqstr = "&mapcode="+mapdata[mapid].code;
reqstr += "&mapid="+mapid;
reqstr += "&solution="+solution[mapid];
- //document.getElementById('dispdo').innerHTML = "http://mazetd.4xg.net/do.php?r=getpath"+reqstr
-
ajax.requestFile = "do.php?challengeID="+challengeID+"&isChallenge="+isChallenge+"&r=getpath"+reqstr; //prepare strdata
ajax.onCompletion = request_path_done; // specify function to be executed on response
ajax.runAJAX();
-
- var speedbox = document.getElementById(mapid+',speed'),
- speed = speedbox.options[speedbox.selectedIndex].text,
- mute = !checkSound(mapid);
- mixpanel.track('click go', {
- 'speed': speed,
- 'mute': mute,
- 'mapid': mapid,
- 'type': mapType
- });
}
function requestSol(mapID) {
@@ -265,19 +254,25 @@ function resetwalls(mapid) {
}
function request_path_done() {
- //document.getElementById('mapdisplay').innerHTML = ajax.response;
- //if (ajax.response == undefined) return;
-
- 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);
- }
+ var JO = decryptJSON(ajax.response);
mapjson[JO.mapid] = JO;
+ var speedbox = document.getElementById(mapid+',speed'),
+ speed = speedbox.options[speedbox.selectedIndex].text,
+ mute = !checkSound(mapid);
+
+ nowTime = new Date().getTime();
+ var responseTime = nowTime - pressedGoTime;
+
+ mixpanel.track('click go', {
+ 'speed': speed,
+ 'mute': mute,
+ 'mapid': JO.mapid,
+ 'type': mapType,
+ 'response time': responseTime
+ });
+
if (JO.scores)
updateDsp(JO.mapid, 'dspScore', JO.scores);
@@ -300,10 +295,11 @@ function request_path_done() {
ajax.runAJAX();// Do it!
}
+// Used at the start
// Force score update.
function updateScoresReq(mapid, type) {
//Get score update.
- ajax.requestFile = "do.php?checkachieve=true&r=getscores&mapid="+mapid; //prepare strdata
+ ajax.requestFile = "do.php?r=getscores&mapid="+mapid; //prepare strdata
ajax.onCompletion = updateScoresGet; // Specify function to be executed on response.
ajax.runAJAX();// Do it!
mapType = type;
@@ -313,6 +309,14 @@ function updateScoresGet() {
updateDsp(JO.mapid, 'dspScore', JO.scores);
}
+function reqScoresDone() {
+
+ var JO = decryptJSON(ajax.response);
+ updateDsp(JO.mapid, 'dspScore', JO.scores);
+}
+//function addscorepage
+
+
function decryptJSON(text) {
if (typeof(JSON) == 'undefined') {
var JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')');