summaryrefslogtreecommitdiffstats
path: root/pages/scores.php
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-02-28 16:27:08 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-02-28 16:27:08 -0800
commit303a0b1bcda0550c74dce2cc0f4ba58aa88673fb (patch)
treecc3dbce8e2599c0e44d72081f331ec42140dd250 /pages/scores.php
parentac84429dd17bce9720a1e04c5249a640ccf76e4d (diff)
downloadpathery-303a0b1bcda0550c74dce2cc0f4ba58aa88673fb.tar.xz
Fixed Challenges
Diffstat (limited to 'pages/scores.php')
-rw-r--r--pages/scores.php76
1 files changed, 30 insertions, 46 deletions
diff --git a/pages/scores.php b/pages/scores.php
index 70acbaa..8797c36 100644
--- a/pages/scores.php
+++ b/pages/scores.php
@@ -213,7 +213,7 @@ function addMapToNav(mapID) {
var $newdiv1 = $("<div style='float:left;min-width:120px;' id='thumb_"+mapID+"'/>");
$("#mapNavigation").prepend($newdiv1);
-
+
var URLString = 'a/map/'+mapID+'.js';
$.ajax({
type: "GET",
@@ -222,12 +222,40 @@ function addMapToNav(mapID) {
data: '',
fail: function() { alert("error"); },
complete: function(data) {
- $("#thumb_"+mapID).html(mapThumbnailHTML(decryptJSON(data.responseText), 120)).show();
+ var map = decryptJSON(data.responseText);
+ var mapDate = new Date(map.dateExpires*1000);
+ isActive = mapDate.getTime() > serverToday.getTime();
+
+
+ $("#thumb_"+mapID).html(formatMapThumbForNav(data.responseText)).show();
+ //$("#thumb_"+mapID).html(mapThumbnailHTML(map, 120, isActive)).show();
}
});
mapsInNav.unshift(mapID);
}
+function formatMapThumbForNav(json) {
+ var map = decryptJSON(json);
+ var mapDate = new Date(map.dateExpires*1000);
+ var mapClass = '';
+ var toolTip = 'Inactive map';
+
+ var isActive = mapDate.getTime() > serverToday.getTime();
+
+ if (isActive) {
+ mapClass = ' current';
+ toolTip = 'This map can still be played.';
+ }
+
+ var r = '';
+ r += "<div class='mapThumbnail"+mapClass+"' title='"+toolTip+"'; onclick='displayMapScores("+map.ID+")'>";
+ r += mapThumbnailHTML(map, 120, isActive);
+ r += '</div>';
+
+ return r;
+
+}
+
function removeMapFromNav(mapID) {
//console.log("remove map:", mapID, mapsInNav.indexOf(mapID));
$("#thumb_"+mapID).hide('fast', function(){ $("#thumb_"+mapID).remove(); });
@@ -244,50 +272,6 @@ var Tile = {"Wall" : "w",
"Unbuildable" : "o",
"SinglePath" : "o"};
-function mapThumbnailHTML(map, targetWidth) {
- 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 mapClass = '';
- var toolTip = 'Inactive map';
- var mapDate = new Date(map.dateExpires*1000);
- if (mapDate.getTime() > serverToday.getTime()) {
- mapClass = ' current';
- toolTip = 'This map can still be played.';
- }
-
- var r = '';
- r += "<div class='mapThumbnail"+mapClass+"' title='"+toolTip+"'; onclick='displayMapScores("+map.ID+")'>";
- 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;
- r += '</div>';
-
- return r;
-}
-
</script>
<body>