diff options
author | Patrick Davison <snapwilliam@gmail.com> | 2013-02-28 16:27:08 -0800 |
---|---|---|
committer | Patrick Davison <snapwilliam@gmail.com> | 2013-02-28 16:27:08 -0800 |
commit | 303a0b1bcda0550c74dce2cc0f4ba58aa88673fb (patch) | |
tree | cc3dbce8e2599c0e44d72081f331ec42140dd250 /js/mapspecs.js | |
parent | ac84429dd17bce9720a1e04c5249a640ccf76e4d (diff) | |
download | pathery-303a0b1bcda0550c74dce2cc0f4ba58aa88673fb.tar.xz |
Fixed Challenges
Diffstat (limited to 'js/mapspecs.js')
-rw-r--r-- | js/mapspecs.js | 55 |
1 files changed, 48 insertions, 7 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)
{
|