summaryrefslogtreecommitdiffstats
path: root/pages/scores.php
diff options
context:
space:
mode:
authorPatrick Davison <snapwilliam@gmail.com>2013-03-07 21:42:14 -0800
committerPatrick Davison <snapwilliam@gmail.com>2013-03-07 21:42:14 -0800
commitaf0ee456d75304494e3eecfb8a9bd2b232e44fe6 (patch)
treeb11254a8f2c5bdd90806b7547c5bf0ed334790dc /pages/scores.php
parentc230abd1f7ecc1139f9bef92208eced6849b2c78 (diff)
downloadpathery-af0ee456d75304494e3eecfb8a9bd2b232e44fe6.tar.xz
Scoreboard bugfixes and improvments, partial implementation of onhashchange.
Diffstat (limited to 'pages/scores.php')
-rw-r--r--pages/scores.php44
1 files changed, 27 insertions, 17 deletions
diff --git a/pages/scores.php b/pages/scores.php
index 90c87bb..60ce2e8 100644
--- a/pages/scores.php
+++ b/pages/scores.php
@@ -23,6 +23,7 @@ $jsDate = "$jsYear,$jsMonth,$jsDay";
?>
<script type="text/javascript" src="js/jquery.keystrokes.min.js"></script>
+<script type="text/javascript" src="js/jquery.hashchange.min.js"></script>
<script type="text/javascript">
playerWallColor = '<?PHP echo isset($wallColor) ? $wallColor : ''; ?>';
@@ -37,11 +38,20 @@ var serverToday = new Date(<? echo $jsDate; ?>);
var pointerTime = new Date();
pointerTime.setTime(serverToday.getTime())
-setTimeout("start();", 500);
-
var pointerMapID = -1;
var goToPointer = true;
-function start() {
+var goToScorePointer = true;
+
+$(function(){
+ // Bind the event.
+ $(window).hashchange( function(){
+ handleHashChange();
+ })
+ // Trigger the event (useful on page load).
+ $(window).hashchange();
+});
+
+function handleHashChange() {
var hash = window.location.hash.substring(1);
if (hash !== '') {
hashParts = hash.split('_')
@@ -53,7 +63,7 @@ function start() {
pointerPage = hashParts[2];
} else pointerPage = 1;
if (typeof(hashParts[3]) !== 'undefined') {
- pointerUserID = hashParts[3];
+ pointerSolutionID = hashParts[3];
}
//+1 because i'm gonna use prev.
pointerTime = new Date(dateSplit[0],dateSplit[1]-1,dateSplit[2]-0+1);
@@ -61,6 +71,7 @@ function start() {
getMapIDs('prev');
}
+
function addDay(dateObj) {
var d = dateObj;
d.setDate(d.getDate()+1);
@@ -79,6 +90,7 @@ keys: ['arrow up', 'arrow up', 'arrow down', 'arrow down', 'arrow left', 'arrow
alert('You unlocked awesomeness!');
});
+
function displayMapScores(mapID) {
pointerMapID = mapID;
updateHash();
@@ -93,18 +105,17 @@ function displayMapScores(mapID) {
//Set the 'selectedMap' class
$('.selectedMap').removeClass('selectedMap');
- var currentMapDiv = $('#thumb_'+mapID).children();
+ var currentMapDiv = $('#thumb_'+mapID);
currentMapDiv.addClass('selectedMap');
//Hack: display the "current map" div for currently running maps
//Relies on the fact that the #thumb_<mapId> div has a single child with the 'current' class..
- var showCurrentMapMessage = currentMapDiv.hasClass('currentlyRunning');
+ var showCurrentMapMessage = currentMapDiv.children().hasClass('currentlyRunning');
$('#currentlyRunningMessage').toggle(showCurrentMapMessage);
$("#mapDisplay").fadeOut('fast');
displayMap(mapID, "mapDisplay", 682);
scoresShowPage(pointerPage, mapID);
- //console.log(pointerPage, mapID);
}
function updateHash() {
@@ -114,17 +125,17 @@ function updateHash() {
anchorTag += "_"+pointerMapID;
if (pointerPage) anchorTag += "_"+pointerPage;
else anchorTag += "_";
- if (pointerUserID) anchorTag += "_"+pointerUserID;
+ if (pointerSolutionID) anchorTag += "_"+pointerSolutionID;
else anchorTag += "_";
document.location=anchorTag;
}
-var pointerPage = 1, pointerUserID
-function saveScoreLocation(page, userID) {
+var pointerPage = 1, pointerSolutionID
+function saveScoreLocation(page, solutionID) {
pointerPage = page;
- pointerUserID = userID;
+ pointerSolutionID = solutionID;
updateHash();
- console.log("SaveScoreLoc");
+ //console.log("SaveScoreLoc");
}
var pointerDate;
@@ -219,8 +230,10 @@ function getMapIDsResponse(response) {
}
function addMapToNav(mapID) {
- //console.log("adding map to nav:", mapID);
- var $newdiv1 = $("<div style='float:left;min-width:120px;' id='thumb_"+mapID+"'/>");
+
+ var $newdiv1 = $("<div id='thumb_"+mapID+"'/>");
+ if (pointerMapID + '' == mapID + '') $newdiv1.addClass('selectedMap');
+ $newdiv1.addClass('mapThumbnailOuter');
$("#mapNavigation").prepend($newdiv1);
@@ -236,7 +249,6 @@ function addMapToNav(mapID) {
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();
}
@@ -261,9 +273,7 @@ function formatMapThumbForNav(json) {
r += "<div class='mapThumbnail"+mapClass+"' title='"+toolTip+"'; onclick='displayMapScores("+map.ID+")'>";
r += mapThumbnailHTML(map, 120, isActive);
r += '</div>';
-
return r;
-
}
function removeMapFromNav(mapID) {