From 303a0b1bcda0550c74dce2cc0f4ba58aa88673fb Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Thu, 28 Feb 2013 16:27:08 -0800 Subject: Fixed Challenges --- js/mapspecs.js | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) (limited to 'js') 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 += "
"; + r += map.name; + + mapgrid += '
'; + 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 += "
"; + mapgrid += "
"; + } + } + mapgrid += '
'; + + r += mapgrid; + //r += '
'; + return r; +} + + + var ignoreMuteChecks = false; function setMute(value) { -- cgit v1.2.3