diff options
-rw-r--r-- | ajax/scores.ajax.php | 61 | ||||
-rw-r--r-- | js/scores.js | 8 |
2 files changed, 61 insertions, 8 deletions
diff --git a/ajax/scores.ajax.php b/ajax/scores.ajax.php index 2b27ca2..b95d22e 100644 --- a/ajax/scores.ajax.php +++ b/ajax/scores.ajax.php @@ -1,20 +1,71 @@ <?
+// Session as read-only to not lock the file.
session_start();
session_write_close();
-//Just doing this as evidence that $_SESSION as read-only is still available.
+
$userID = $_SESSION['userID'];
require('../includes/maps.php');
require('../includes/mapclass.php');
require('../includes/datas.php');
+if ($_GET['getmap'] == 'true') {
+ $mapID = $_GET['mapID'];
+ $code = getMapCode($mapID);
+ $map = GenerateMapByCode($code);
+ echo displaymap($map, $mapID);
+}
+
+
+if ($_GET['getscores'] == 'true') {
+
+}
+
+if ($_GET['getmaplist'] == 'true') {
+ $daysAgo = $_GET['daysago'];
+ //echo "$daysAgo";
+ $todaysScoreMaps = getMapsPlayed($daysAgo);
+ echo getMapNavigation($todaysScoreMaps);
+}
+
+
+function getMapsPlayed($daysAgo) {
+ $sql = "
+ SELECT `mapID`, `code`, `mapType`
+ FROM `mapOfTheDay`
+ INNER JOIN `maps` ON `mapID` = maps.ID
+ WHERE DATE_ADD(CURDATE(), INTERVAL -$daysAgo DAY) =
+ mapDate AND
+ `mapType` IN (1, 2, 3, 4)
+ ";
+ $result = mysql_query($sql) or die(mysql_error());
+ if (mysql_num_rows($result) == 0)
+ return -1;
+ global $mapNamesByType;
+ $r = array();
+ while($data = mysql_fetch_array($result)) {
+ $code = $data['code'];
+ $mapID = $data['mapID'];
+ $mapType = $data['mapType'];
+ $map = new map($code);
+ if ($map->name == '')
+ $map->name = $mapNamesByType[$mapType];
+ $r[$mapID] = $map;
-$mapID = $_GET['mapID'];
+ }
+ return $r;
+}
-$code = getMapCode($mapID);
-$map = GenerateMapByCode($code);
-echo displaymap($map, $mapID);
+function getMapNavigation(&$maps) {
+ foreach ($maps as $mapID => &$map) {
+ $r .= "<div class='mapThumbnail' onclick='displayMap($mapID)'>";
+ $r .= $map->name;
+ $r .= DisplayMapThumbnail($map);
+ $r .= "</div>";;
+ }
+ return $r;
+}
diff --git a/js/scores.js b/js/scores.js index b8ca366..72b2cd6 100644 --- a/js/scores.js +++ b/js/scores.js @@ -124,7 +124,8 @@ function scoresFormatPage(JO) { var x = 0;
var previousI = 0;
- var isWeeklyMap = (document.getElementById("dl-5").className.indexOf('selected') >= 0);
+ //TODO !!
+ //var isWeeklyMap = (document.getElementById("dl-5").className.indexOf('selected') >= 0);
for (var i in JO.users) {
var u = JO.users[i];
@@ -136,8 +137,9 @@ function scoresFormatPage(JO) { if (previousI != i + 1)
if (previousI < i - 1 && previousI != 0)
styleClass = 'border-top: 6px solid #777799;';
-
- var scoredTimeFormat = (isWeeklyMap ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
+ //TODO:
+ //var scoredTimeFormat = (isWeeklyMap ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
+ var scoredTimeFormat = (false ? "mmm d, h:MM:ss TT" : "h:MM:ss TT");
var scoredTimeStr = scoredLocalTime.format(scoredTimeFormat);
p = p+ "<tr style='"+styleClass+" background-color: "+u.background+"; color:"+u.displayColor+";' title='Scored "+scoredTimeStr+"'>";
|