From 1c65a1a164008e993fba099723fc3039c2332a9c Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Wed, 20 Feb 2013 02:05:02 -0800 Subject: Restyled and fixed some bugs in the scoreboard. --- css/stats.css | 46 ++++++++++++++++++++++++---------------- js/mapspecs.js | 6 ++++-- pages/scores.php | 64 +++++++++++++++++++++++++++++++------------------------- 3 files changed, 68 insertions(+), 48 deletions(-) diff --git a/css/stats.css b/css/stats.css index f2d5d8e..166573d 100644 --- a/css/stats.css +++ b/css/stats.css @@ -30,45 +30,55 @@ height: 0; } -.mapNavBtn:hover { - background-color:#57a; -} .mapNavCon { height:135px; width:900px; margin-bottom:10px; } .mapNavLeft { - float:left; - width:40px; - height:135px; - background-color:#358; - border-radius:5px; + float: left; } .mapNavRight { - float:right; - width:40px; - height:135px; - background-color:#358; - border-radius:5px; + float: right; +} +.mapNavLeft, .mapNavRight{ + width: 38px; + height: 133px; + background-color:#236; + border-radius: 0px 25px 6px 0px; + vertical-align: middle; + text-align:center; + line-height: 130px; + text-decoration: none; + background-color: #262631; + font-size:200%; + border-radius: 5px; + border: 1px solid #333; +} +.mapNavActive:hover { + background-color: #343c57; +} +.mapNavDisabled { + background-color: #222223; } .mapNavCenter { float:left; height:135px; - width:820px; - background-color:#888; + width:780px; + margin-left:20px; + margin-right:20px; + background-color:#222223; + border-radius: 15px; white-space: nowrap; overflow-x:hidden; overflow-y:hidden; } #mapNavigation { + margin-left: 45px; padding:1px; - background-color:#888; - border-radius:10px; white-space: nowrap; overflow-x:hidden; overflow-y:hidden; - } .mapThumbnail { diff --git a/js/mapspecs.js b/js/mapspecs.js index 6bf7185..2a5bd1d 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -307,6 +307,7 @@ function request_path_done() { } function decryptJSON(text) { + if (typeof(text) == 'undefined') return false; var JO; if (typeof(JSON) == 'undefined') { JO = !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')'); @@ -772,6 +773,8 @@ function showTempSolution(mapid, tempSolution, moves, tempWallColor, tempWallEmb //console.log('showTempSolution', mapid, solution, moves, tempWallColor, tempWallEmblem); var savedSolution = ''; + if (typeof tempSolution == 'undefined') tempSolution = ''; + if (typeof solution[mapid] !== 'undefined') { savedSolution = solution[mapid]; } @@ -817,7 +820,6 @@ function displayMap(mapid, divID, goalSize, solution, moves, challengeMap) { restoreSolution(mapid); } }); - console.log("dispMapExt"); } //Map as object. If target width is NULL or False, default width is used. @@ -829,7 +831,7 @@ function mapAsHTML(map, targetWidth, demo) { //console.log("MapObj", map); mapdata[map.ID] = map; - //595 + if ((map.width * 35) <= targetWidth) targetWidth = (map.width * 35); if (!targetWidth) targetWidth = (map.width * 35); var scale = map.width / targetWidth; //alert(scale); diff --git a/pages/scores.php b/pages/scores.php index 933873c..f3ce459 100644 --- a/pages/scores.php +++ b/pages/scores.php @@ -49,7 +49,6 @@ var pointerMapID = -1; var goToPointer = true; function start() { var hash = window.location.hash.substring(1); - console.log("HASH:", hash); if (hash !== '') { hashParts = hash.split('_') dateSplit = hashParts[0].split("-"); @@ -83,7 +82,7 @@ function displayMapScores(mapID) { } scoresShowPage(1, mapID); $("#mapDisplay").fadeOut('fast'); - displayMap(mapID, "mapDisplay", 595); + displayMap(mapID, "mapDisplay", 622); } @@ -96,32 +95,33 @@ function updateHash() { } var pointerDate; -function getMapIDs(request) { +function getMapIDs(request) { switch (request) { case "next": - if (pointerTime.getTime() > serverTime.getTime()) { - alert("Tomorrow hasn't happened yet. Alerts are bad. - TMP!"); - return; - } - pointerTime.setTime(pointerTime.getTime() + (24*60*60*1000)); - pointerDate = pointerTime.format("yyyy-mm-dd"); + if (pointerTime.getTime() + (24*60*60*1000) < serverTime.getTime()) { + pointerTime.setTime(pointerTime.getTime() + (24*60*60*1000)); + pointerDate = pointerTime.format("yyyy-mm-dd"); + } else return; break; case "prev": - - if (pointerTime.getTime() - (24*60*60*1000) > serverTime.getTime()) { - alert("Tomorrow hasn't happened yet. Alerts are bad. - TMP!"); - return; - } - pointerTime.setTime(pointerTime.getTime() - (24*60*60*1000)); - pointerDate = pointerTime.format("yyyy-mm-dd"); + if (pointerTime.getTime() + (24*60*60*1000) > 1) { + pointerTime.setTime(pointerTime.getTime() - (24*60*60*1000)); + pointerDate = pointerTime.format("yyyy-mm-dd"); + } else return; break; } - $('#displayDate').html(pointerTime.format("dddd, mmmm ddS, yyyy")); + $('#displayDate').html(pointerTime.format("dddd, mmmm dS, yyyy")); + if (pointerTime.getTime() + (1*24*60*60*1000) > serverTime.getTime()) { + $('#mapNavRight').removeClass('mapNavActive'); + $('#mapNavRight').addClass('mapNavDisabled'); + } else { + $('#mapNavRight').addClass('mapNavActive'); + $('#mapNavRight').removeClass('mapNavDisabled'); + } - var urlString = "ajax/scores.ajax.php?getmapidsbydate="+pointerDate; + var urlString = "ajax/scores.ajax.php?getmapidsbydate="+pointerDate; updateHash(); - $.ajax({ type: "GET", url: urlString, @@ -136,18 +136,22 @@ var mapsInNav = new Array(); function getMapIDsResponse(response) { var json = decryptJSON(response); + json.reverse(); + //Delete removed maps + $("#mapNavigation").hide(0); //console.log("going through mapsInNav", mapsInNav); mapsInNav = $.grep(mapsInNav, function(mapID, key) { - console.log("del: compare:", key, mapID, json, jQuery.inArray(mapID, json)); + //console.log("del: compare:", key, mapID, json, jQuery.inArray(mapID, json)); if (jQuery.inArray(mapID, json) < 0 && typeof(mapID) != 'undefined') { removeMapFromNav(mapID); - return false + return false; } else return true; }); //Add non-existing maps //console.log("going through json", json); + $.each(json, function(key, mapID) { //console.log("add: compare:", mapID, mapsInNav); if (jQuery.inArray(mapID, mapsInNav) == -1) { @@ -157,6 +161,10 @@ function getMapIDsResponse(response) { } } }); + //Don't queue animations... + if ($('#mapNavigation').is(':animated')) { + $("#mapNavigation").show(0); + } else $("#mapNavigation").fadeIn('300'); if (goToPointer == true) { goToPointer = false; @@ -166,9 +174,10 @@ function getMapIDsResponse(response) { function addMapToNav(mapID) { //console.log("adding map to nav:", mapID); - var $newdiv1 = $("
"); + var $newdiv1 = $("
"); - $("#mapNavigation").append($newdiv1); + //$("#mapNavigation").append($newdiv1); + $("#mapNavigation").prepend($newdiv1); //var URLString = 'map/'+mapID+'.js'; var URLString = 'map/'+mapID; @@ -183,11 +192,11 @@ function addMapToNav(mapID) { $("#thumb_"+mapID).html(mapThumbnailHTML(decryptJSON(data.responseText), 120)).show(); } }); - mapsInNav.push(mapID); + mapsInNav.unshift(mapID); } function removeMapFromNav(mapID) { - console.log("remove map:", mapID, mapsInNav.indexOf(mapID)); + //console.log("remove map:", mapID, mapsInNav.indexOf(mapID)); $("#thumb_"+mapID).hide('fast', function(){ $("#thumb_"+mapID).remove(); }); } @@ -218,7 +227,6 @@ function mapThumbnailHTML(map, targetWidth) { var mapClass = ''; var toolTip = 'Inactive map'; var mapDate = new Date(map.dateExpires*1000); - console.log("Dates: ", map.ID, mapDate, serverTime); if (mapDate.getTime() > serverTime.getTime()) { mapClass = ' current'; toolTip = 'This map can still be played.'; @@ -262,8 +270,8 @@ topbar($Links);
-
<
-
>
+
<
+
>
-- cgit v1.2.3