summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/globe.js12
-rw-r--r--js/mapspecs.js131
-rw-r--r--js/scores.js73
3 files changed, 142 insertions, 74 deletions
diff --git a/js/globe.js b/js/globe.js
index 9538d9b..152ad71 100644
--- a/js/globe.js
+++ b/js/globe.js
@@ -1,4 +1,3 @@
-
function showSignin() {
if (document.getElementById('oid_hidden') !== undefined) {
document.getElementById('oid_hidden').id = 'oid_wrapper';
@@ -26,6 +25,11 @@ function createSignin() {
document.body.appendChild(div.firstChild);
}
-
-
-
+//Make unselectable elements unselectable (hack for IE 9.0 and below, which doesn't support our CSS)
+$(document).ready(function()
+{
+ if ($.browser.msie && $.browser.version < 10)
+ {
+ $('.unselectable').find(':not(input)').attr('unselectable', 'on');
+ }
+}); \ No newline at end of file
diff --git a/js/mapspecs.js b/js/mapspecs.js
index 2a5bd1d..6ab7286 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -141,10 +141,7 @@ function grid_click(obj) {
wallEmblem = playerWallEmblem;
}
}
- console.log('using wallcolors:', wallColor, wallEmblem);
-
obj.style.backgroundColor = wallColor;
-
if (wallEmblem !== false) {
obj.style.backgroundImage="url(images/marks/"+wallEmblem+")";
}
@@ -588,14 +585,14 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
rs = 84;
//How fast should we be going?
selectbox = document.getElementById(mapid+',speed');
- selected = selectbox.options[selectbox.selectedIndex].value;
- switch (selected) {
+ var selectedSpeed = selectbox.options[selectbox.selectedIndex].value;
+ switch (selectedSpeed) {
case '1':
- rs =160;
+ rs =180;
break;
case '2':
- rs =84;
+ rs =94;
break;
case '3':
@@ -634,7 +631,8 @@ function doanimate(x, y, p, c, mapid, pathNumber) {
case 'a': case 'b': case 'c':
case 'd': case 'e': case 'f':
- rs = rs + 410;
+ rs = rs + 410;
+ if (selectedSpeed <= 2) rs = rs + 200;
mapdata[mapid].pathColor[pathNumber] = targetColor(t);
break;
@@ -712,7 +710,12 @@ function targetColor(target) {
function flashelement(eid, times, color, speed) {
- if (document.getElementById(eid) == undefined) return;
+
+ if (typeof(document.getElementById(eid)) == 'undefined') return;
+ var elementToFlash = document.getElementById(eid);
+ if (elementToFlash.isBeingFlashed == true) return;
+ elementToFlash.isBeingFlashed = true;
+
if (!color) {
color = "#FFFF44";
}
@@ -720,28 +723,23 @@ function flashelement(eid, times, color, speed) {
speed = 220;
}
speedon = speed * .5;
- //document.getElementById(eid).setAttribute('class', 'no_transition');
- var currentclass = document.getElementById(eid).className;
- if (document.getElementById(eid).classOrigName != undefined)
- currentclass = document.getElementById(eid).classOrigName;
- var currentColor = document.getElementById(eid).style.backgroundColor;
- document.getElementById(eid).className='no_transition '+currentclass;
- document.getElementById(eid).style.backgroundColor = '#000000';
+
+ var currentclass = elementToFlash.className;
+ if (elementToFlash.classOrigName != undefined)
+ currentclass = elementToFlash.classOrigName;
+ var currentColor = elementToFlash.style.backgroundColor;
+ elementToFlash.className='no_transition '+currentclass;
+ elementToFlash.style.backgroundColor = '#000000';
for (var i=0; i<times; i++) {
//Flash bright
setTimeout("document.getElementById('"+eid+"').style.color = '#000000'", i*speed);
setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+color+"'", i*speed);
- // setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = 'bold'", i*200);
//Flash out
setTimeout("document.getElementById('"+eid+"').style.color = ''", (i*speed) + speedon);
setTimeout("document.getElementById('"+eid+"').style.backgroundColor = ''", (i*speed) + speedon);
- // setTimeout("document.getElementById('"+mapid+",dspCount').style.fontWeight = ''", i*200);
}
-
- //setTimeout("document.getElementById('"+eid+"').className = '"+currentclass+"'", (i*220) + 200);
setTimeout("document.getElementById('"+eid+"').style.backgroundColor = '"+currentColor+"'", (i*speed) + 200);
-//document.getElementById(eid).className=currentclass;
-//document.getElementById(eid).style.backgroundColor=currentColor;
+ setTimeout("document.getElementById('"+eid+"').isBeingFlashed = false", (i*speed) + 220);
}
@@ -761,12 +759,14 @@ function useSolution(mapid, inputSolution, moves, tempWallColor, tempWallEmblem)
solution[mapid] = inputSolution;
var animateA = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", \""+tempWallColor+"\", \""+tempWallEmblem+"\");";
var animateB = "showTempSolution(\""+mapid+"\", \""+inputSolution+"\", \""+moves+"\", false, false);";
+ //TODO: Sticky colors for the placed walls by the user would be cool.
+ //var animateC = "wallColor = false; wallEmblem = false;";
setTimeout(animateA, 50);
- setTimeout(animateB, 100);
- setTimeout(animateA, 150);
- setTimeout(animateB, 200);
+ setTimeout(animateB, 150);
setTimeout(animateA, 250);
- setTimeout(animateB, 450);
+ setTimeout(animateB, 350);
+ setTimeout(animateA, 450);
+ setTimeout(animateB, 550);
}
//Shows a solution for temporary use, see 'RestoreSolution'
function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmblem) {
@@ -802,30 +802,45 @@ function restoreSolution(mapid) {
showTempSolution(mapid, mapdata[mapid].savedSolution, 0, false, false);
}
-function displayMap(mapid, divID, goalSize, solution, moves, challengeMap) {
+function displayMap(mapid, divID, goalSize, solution, moves, challengeMap, isThumb) {
- var stringURL = 'map/'+mapid+".js";
- if (challengeMap == true) stringURL = 'challenge/'+mapid+".js";
+ var stringURL = 'a/map/'+mapid+".js";
+ if (challengeMap == true) stringURL = 'a/challenge/'+mapid+".js";
$.ajax({
type: "GET",
- url: 'map/'+mapid+".js",
+ url: stringURL,
dataType: 'json',
cache: true,
data: '',
//TODO: Better fail option?
fail: (function() { console.log("FAIL Map Download"); }),
complete: function(data) {
- $("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).fadeIn('slow');
- mapdata[mapid].savedSolution = solution;
- restoreSolution(mapid);
+ if (isThumb) {
+ $("#"+divID).html(mapThumbnailHTML(decryptJSON(data.responseText), goalSize)).fadeIn('fast');
+ } else {
+ $("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).fadeIn('fast');
+ //$("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).show();
+ mapdata[mapid].savedSolution = solution;
+ restoreSolution(mapid);
+ }
}
});
}
+var Tile = {
+"o" : "Open",
+"s" : "Start",
+"f" : "Finish",
+"c" : "Checkpoint",
+"r" : "Rock",
+"t" : "Teleport In",
+"u" : "Teleport Out",
+"p" : "Unbuildable",
+"x" : "Single-Path-Rock"};
+
//Map as object. If target width is NULL or False, default width is used.
-function mapAsHTML(map, targetWidth, demo) {
-
- //console.log("loading MapHTML for ", map);
+function mapAsHTML(map, targetWidth, mapEditor) {
+
map.mapid = map.ID;
//console.log("MapID:", map.mapid);
//console.log("MapObj", map);
@@ -858,19 +873,24 @@ function mapAsHTML(map, targetWidth, demo) {
// GOAL WOULD BE THIS LINE INSTEAD.. As it's not retarded.
//var idHandle = map.ID+','+x+','+y;
-
+
//oldy is used for Position too... for now
- if (type == 'o') {
+ if (mapEditor == true) {
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onMouseOver='mapEditOver(this)' onMouseDown='mapEditClick(this)' >";
+ mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
+ } else if (type == 'o') {
mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' onClick='grid_click(this)' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
} else {
- mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='Position: "+x+","+oldy+"' id='"+idHandle+"' >";
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"' title='"+Tile[type]+" "+value+" On: "+x+","+oldy+"' id='"+idHandle+"' >";
mapgrid += "<div id='child_"+idHandle+"' class='child'></div></div>";
}
}
}
mapgrid += '</div>';
+ if (mapEditor == true) return mapgrid;
+
var r = '';
//TODO: Track down where that 1 pixel is comingfrom, width-1 is a hack.
@@ -916,6 +936,39 @@ function mapAsHTML(map, targetWidth, demo) {
return r;
}
+function mapThumbnailHTML(map, targetWidth, isActive) {
+ if (!targetWidth) targetWidth = 120;
+ var scale = map.width / targetWidth;
+
+ var width = parseInt(map.width / scale);
+ var height = parseInt(map.height / scale);
+ var tileWidth = parseInt(width / map.width);
+
+ width = tileWidth * map.width;
+ height = tileWidth * map.height;
+
+ var mapgrid = '';
+ var r = '';
+ r += map.name;
+
+ mapgrid += '<div class="map" style="width:'+width+'px; height:'+height+'px">';
+ for (var y in map.tiles) {
+ for (var x in map.tiles[y]) {
+ var type = map.tiles[y][x][0];
+ var value = map.tiles[y][x][1];
+ if (!value) value = '';
+
+ mapgrid += "<div style='float:left; width:"+tileWidth+"px; height:"+tileWidth+"px; ' class='mapcell "+type+value+"'>";
+ mapgrid += "</div>";
+ }
+ }
+ mapgrid += '</div>';
+ r += mapgrid;
+ return r;
+}
+
+
+
var ignoreMuteChecks = false;
function setMute(value)
{
diff --git a/js/scores.js b/js/scores.js
index 3fba599..e384831 100644
--- a/js/scores.js
+++ b/js/scores.js
@@ -20,7 +20,8 @@ function scoresRequestPage(mapid, page) {
//console.log("Requesting Page", mapid, page, ajax.inUse);
// == Additionally, check for achievements.
- ajax.requestFile = "do.php?r=reqScorePage&mapid="+mapid+"&reqPage="+page;
+ //ajax.requestFile = "do.php?r=reqScorePage&mapid="+mapid+"&reqPage="+page;
+ ajax.requestFile = "a/score/"+mapid+"_"+page+".js";
ajax.onCompletion = scoresRequestPageDone; // Specify function to be executed on response.
//ajax.onLoading = '';
//ajax.onLoaded = '';
@@ -113,10 +114,15 @@ function scoresFormatPage(JO) {
//console.log("jo object", JO);
var navi = '';
if (JO.pageCount > 1) {
- navi = "<tr><th colspan='3' style='text-align:center;'>"+formatPageNavi(JO, "scoresShowPage", JO.mapid)+"</th></tr>";
+ navi = "<tr><th class='unselectable' colspan='3' style='text-align:center;'>"+formatPageNavi(JO, "scoresShowPage", JO.mapid)+"</th></tr>";
p = p+navi;
}
- p = p+"<tr title='Updated "+JO.updateTime+"'>";
+
+ var localTime = new Date();
+ var updatedLocalTime = new Date();
+ updatedLocalTime.setTime(JO.updateTime * 1000);
+
+ p = p+"<tr title='Last-Update: "+updatedLocalTime.format("mmm d, h:MM TT")+"'>";
p = p+"<th>Rank</th>";
p = p+"<th style='width:125px; overflow:hidden; text-align:left; padding-left:42px;'>Name</th>";
p = p+"<th>Moves</th>";
@@ -127,9 +133,6 @@ function scoresFormatPage(JO) {
var x = 0;
var previousI = 0;
- //TODO !!
- //var isWeeklyMap = (document.getElementById("dl-5").className.indexOf('selected') >= 0);
-
for (var i in JO.users) {
var u = JO.users[i];
var scoredLocalTime = new Date();
@@ -137,33 +140,37 @@ function scoresFormatPage(JO) {
var styleClass = '';
- if (previousI != i + 1)
- if (previousI < i - 1 && previousI != 0)
- styleClass = 'border-top: 6px solid #777799;';
- //TODO:
- //var scoredTimeFormat = (isWeeklyMap ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
- var scoredTimeFormat = (false ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
+ if (previousI != i + 1 && previousI < i - 1 && previousI != 0) {
+ styleClass = 'border-top: 6px solid #777799;';
+ }
+
+ var wasLongAgo = localTime.getTime() > (scoredLocalTime.getTime() + 43200000); //12*60*60*1000
+ var scoredTimeFormat = (wasLongAgo ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
var scoredTimeStr = scoredLocalTime.format(scoredTimeFormat);
var rowclass = 'scoreRow'+((i % 2)+1);
-
- if (u.isUser) {
+
+ if (u.ID == userObj.ID) {
rowclass = 'scoreRowSelf';
+ }
+ if (typeof(pointerUserID) != 'undefined' && u.ID == pointerUserID) {
+ setTimeout("useSolution(\""+JO.mapid+"\", \""+u.solution+"\", \""+u.moves+"\", \""+u.wallColor+"\", \""+u.wallEmblem+"\");", 400);
+ pointerUserID = '';
}
if (u.solution) {
rowclass += ' scoreRowSolutionAvailable';
p += "<tr class='"+rowclass+"' ";
p += "onmouseover='showTempSolution(\""+JO.mapid+"\", \""+u.solution+"\", \""+u.moves+"\", \""+u.wallColor+"\", \""+u.wallEmblem+"\")'";
- p += "onclick='useSolution(\""+JO.mapid+"\", \""+u.solution+"\", \""+u.moves+"\", \""+u.wallColor+"\", \""+u.wallEmblem+"\")'";
+ p += "onclick='useSolution(\""+JO.mapid+"\", \""+u.solution+"\", \""+u.moves+"\", \""+u.wallColor+"\", \""+u.wallEmblem+"\");saveScoreLocation("+JO.page+", "+u.ID+");'";
p += "onmouseout='restoreSolution(\""+JO.mapid+"\")' ";
- p += " style='"+styleClass+" color:"+u.displayColor+";' title='Scored "+scoredTimeStr+"'>";
+ p += " style='"+styleClass+";' title='Last improved "+scoredTimeStr+"'>";
} else {
- p = p+ "<tr class='"+rowclass+"' style='"+styleClass+" color:"+u.displayColor+";' title='Scored "+scoredTimeStr+"'>";
+ p = p+ "<tr class='"+rowclass+"' style='"+styleClass+"' title='Last improved "+scoredTimeStr+"'>";
}
// background-color: "+u.background+";
- p = p+ "<td class='scoreMedal'>";
+ p = p+ "<td class='scoreMedal' style='color:"+u.displayColor+"'>";
if (u.medal == 'gold') {
p = p+ "<img title='Current Champion' src='../images/MedalGoldCAR.png'>";
@@ -179,9 +186,12 @@ function scoresFormatPage(JO) {
p = p+ "";
p = p+ "<span class='scoreName'><a href='achievements?id="+u.ID+"' style='color:"+u.displayColor+"'>"+u.display+"</a></span>";
p = p+ "</td>";
- p = p+ "<td style='text-align:right;'>"+u.moves+"</td>";
if (u.solution) {
- p += "<td>"+u.points+"</td>";
+ p = p+ "<td style='text-align:right;'><a href='javascript: void(0);'>"+u.moves+"</a></td>";
+ p = p+ "<td style='text-align:right;'>"+u.points+"</td>";
+ } else {
+ p = p+ "<td style='text-align:right;'>"+u.moves+"</td>";
+ p = p+ "<td></td>";
}
p = p+ "</tr>";
@@ -338,11 +348,12 @@ function formatPageNavi(JO, callback) {
if (!showedPrevPage)
r = r + ' ... ';
if (JO.page == i) {
- r = r + " <b style='color:#aaaabb; font-size:150%;'>" + i + "</b>";
+ r = r + " <b class='unselectable' style='color:#aaaabb; font-size:150%;'>" + i + "</b>";
} else if (i == JO.userPage) {
- r = r + " <a href='javascript:"+callback+"("+i+", "+arguments[2]+", "+arguments[3]+")' style='color:#99cc99;' title='You are on this page'><i>" + i + '</i></a>';
+ r = r + " <a class='unselectable' href='javascript:"+callback+"("+i+", "+arguments[2]+", "+arguments[3]
+ + ")' style='color:#99cc99;' title='You are on this page'><i>" + i + '</i></a>';
} else {
- r = r + " <a href='javascript:"+callback+"("+i+", "+arguments[2]+", "+arguments[3]+")'>" + i + '</a>';
+ r = r + " <a class='unselectable' href='javascript:"+callback+"("+i+", "+arguments[2]+", "+arguments[3]+")'>" + i + '</a>';
}
showedPrevPage = true;
} else {
@@ -353,18 +364,18 @@ function formatPageNavi(JO, callback) {
var prevPage = JO.page - 1;
if (JO.pageCount > 1) {
if (JO.page < JO.pageCount) {
- r = r+" <a class='scoreRight' title='Last' href='javascript:"+callback+"("+JO.pageCount+", "+arguments[2]+", "+arguments[3]+")'>&gt;&gt;&gt;</a>";
- r = r+" <a class='scoreRight' title='Next' href='javascript:"+callback+"("+nextPage+", "+arguments[2]+", "+arguments[3]+")'>&gt;</a>";
+ r = r+" <a class='scoreRight unselectable' title='Last' href='javascript:"+callback+"("+JO.pageCount+", "+arguments[2]+", "+arguments[3]+")'>&gt;&gt;&gt;</a>";
+ r = r+" <a class='scoreRight unselectable' title='Next' href='javascript:"+callback+"("+nextPage+", "+arguments[2]+", "+arguments[3]+")'>&gt;</a>";
} else {
- r = r+" <span class='scoreRight'>&gt;&gt;&gt;</span>";
- r = r+" <span class='scoreRight'>&gt;</span>";
+ r = r+" <span class='scoreRight unselectable'>&gt;&gt;&gt;</span>";
+ r = r+" <span class='scoreRight unselectable'>&gt;</span>";
}
if (JO.page > 1) {
- r = " <a class='scoreLeft' title='Previous' href='javascript:"+callback+"("+prevPage+", "+arguments[2]+", "+arguments[3]+")'>&lt;</a>"+r;
- r = " <a class='scoreLeft' title='First' href='javascript:"+callback+"(1, "+arguments[2]+", "+arguments[3]+")'>&lt;&lt;&lt;</a>"+r;
+ r = " <a class='scoreLeft unselectable' title='Previous' href='javascript:"+callback+"("+prevPage+", "+arguments[2]+", "+arguments[3]+")'>&lt;</a>"+r;
+ r = " <a class='scoreLeft unselectable' title='First' href='javascript:"+callback+"(1, "+arguments[2]+", "+arguments[3]+")'>&lt;&lt;&lt;</a>"+r;
} else {
- r = r+" <span class='scoreLeft'>&lt;&lt;&lt;</span>";
- r = r+" <span class='scoreLeft'>&lt;</span>";
+ r = r+" <span class='scoreLeft unselectable'>&lt;&lt;&lt;</span>";
+ r = r+" <span class='scoreLeft unselectable'>&lt;</span>";
}
}