summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/mapspecs.js55
-rw-r--r--pages/challengelist.php16
-rw-r--r--pages/scores.php76
3 files changed, 89 insertions, 58 deletions
diff --git a/js/mapspecs.js b/js/mapspecs.js
index 3f2d3f6..0ea99db 100644
--- a/js/mapspecs.js
+++ b/js/mapspecs.js
@@ -801,7 +801,7 @@ 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 = 'a/map/'+mapid+".js";
if (challengeMap == true) stringURL = 'a/challenge/'+mapid+".js";
@@ -814,18 +814,21 @@ function displayMap(mapid, divID, goalSize, solution, moves, challengeMap) {
//TODO: Better fail option?
fail: (function() { console.log("FAIL Map Download"); }),
complete: function(data) {
- $("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).fadeIn('fast');
- //$("#"+divID).html(mapAsHTML(decryptJSON(data.responseText), goalSize)).show();
- 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);
+ }
}
});
}
//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);
+
map.mapid = map.ID;
//console.log("MapID:", map.mapid);
//console.log("MapObj", map);
@@ -916,6 +919,44 @@ 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 += "<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;
+}
+
+
+
var ignoreMuteChecks = false;
function setMute(value)
{
diff --git a/pages/challengelist.php b/pages/challengelist.php
index ade47b6..51c8f69 100644
--- a/pages/challengelist.php
+++ b/pages/challengelist.php
@@ -82,14 +82,20 @@ function getChallengeListHtml($challengeListResultset) {
$challengeMapID = $firstChallenge['challengeMapID'];
//$mapCode = getMapCode($mapid);
- $mapCode = $firstChallenge['mapCode'];
- $map = new map($mapCode);
- $thumbnail = DisplayMapThumbnail($map);
+ //$mapCode = $firstChallenge['mapCode'];
+ //$map = new map($mapCode);
+ //$thumbnail = DisplayMapThumbnail($map);
$r .= "<div class='challengelist_map' onclick='document.location.href=\"challenge?challengeMapID=$challengeMapID\"'>";
- $r .= "$map->name";
- $r .= $thumbnail;
+ //$r .= "$map->name";
+ //$r .= $thumbnail;
+ $r .= "<div id='innerChallengeMapDspThumb_$challengeMapID'>\n";
+ $r .= "</div>\n";
+ $r .= "<script>";
+ $r .= " displayMap($challengeMapID, 'innerChallengeMapDspThumb_$challengeMapID', 170, '', '', true, true);";
+ $r .= "</script>";
+
foreach ($challenge as $ordering => $content) {
//Each challenge gets its own star
if($content["dateSolved"] !== NULL)
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>