diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2012-03-19 19:24:31 -0700 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2012-03-19 19:24:31 -0700 |
commit | 638ff8a06aae2b1bc9fcbb9406a7a1a30b741ef3 (patch) | |
tree | 5ca60c22a645aef62a951060e87a13fc0d99d22f /js/mapspecs.js | |
parent | 81ae4cb1eb3eb3dc859b38d00c7c9d7700216e95 (diff) | |
download | pathery-638ff8a06aae2b1bc9fcbb9406a7a1a30b741ef3.tar.xz |
achievements.php debug data and some fixes.
Diffstat (limited to 'js/mapspecs.js')
-rw-r--r-- | js/mapspecs.js | 47 |
1 files changed, 36 insertions, 11 deletions
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 = '<div class="notification" align="center">';
- var suff = '<button onclick="this.parentNode.parentNode.removeChild(this.parentNode);">'
- suff += 'Close</button></div>';
+ pref += '<div class="notification_close"><a href="javascript:" onclick="this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);">[Close]</a> </div> ';
+ pref += '<div style="overflow:auto;height:295px;">';
+ var suff = '</div></div>';
+ //var suff = '<button onclick="">'
+ //suff += 'Close</button></div>';
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<ARRcookies.length;i++)
+{
+ x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
+ y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
+ x=x.replace(/^\s+|\s+$/g,"");
+ if (x==c_name)
+ {
+ return unescape(y);
+ }
+ }
+}
|