From 2d290b23c402561ef30c1de665895c120dd79483 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 31 Jul 2012 22:34:08 -0700 Subject: Everything related to the scoreboard. New feedback page. Changed the speed of the pauses on checkpoints during a path animation. Changed how notifications are recieved. --- css/stats.css | 44 ++++++++++ do.php | 39 +++++++-- globe.php | 14 ++-- includes/datas.php | 136 +++++++++++++++++++++++++++++- includes/header.php | 9 +- index.php | 6 +- js/dateformat.js | 125 ++++++++++++++++++++++++++++ js/globe.js | 35 ++++++++ js/mapspecs.js | 76 +++-------------- js/scores.js | 221 +++++++++++++++++++++++++++++++++++++++++++++++++ pages/about.php | 3 + pages/achievements.php | 6 +- pages/feedback.php | 71 ++++++++++++++++ pages/home.php | 43 ++++++---- 14 files changed, 727 insertions(+), 101 deletions(-) create mode 100644 js/dateformat.js create mode 100644 js/globe.js create mode 100644 js/scores.js create mode 100644 pages/feedback.php diff --git a/css/stats.css b/css/stats.css index 8774ea7..8211711 100644 --- a/css/stats.css +++ b/css/stats.css @@ -55,3 +55,47 @@ td, th { -moz-transition:color 0s; } +.leftBtn { + left:0px; +} +.rightBtn { + right:0px; +} +.leftBtn, .rightBtn, rightBtn a { + text-align:center; + text-decoration: none; + position:absolute; + top:65px; + width:50px; + background-color: #262631; + font-size:200%; + height:290px; + line-height:270px; + border-radius: 5px; + border: 1px solid #333; +} +.scoreActive:hover { + background-color: #343c57; +} +.scoreDisabled { + background-color: #222223; +} +.scoreContainer2 { + width:390px; + height:500px; + margin-left:auto; + margin-right:auto; + position:relative; +} +.scoreMedal { + text-align:right; + vertical-align:bottom; + background-repeat:no-repeat; +} +.scoreGold { + background-image: url(../images/MedalGoldCAb.png); +} +.scoreSilver { + background-image: url(../images/MedalSilverCAb.png); +} + diff --git a/do.php b/do.php index 2bf6bb9..2a83751 100644 --- a/do.php +++ b/do.php @@ -5,6 +5,8 @@ include "includes/maps.php"; include "includes/db.inc.php"; include "includes/datas.php"; +$note = false; + //Auto login; include_once("globe.php"); if (!isset($_SESSION['accepted']) || $_SESSION['accepted'] <> 1) @@ -29,18 +31,39 @@ if (isset($_GET['act']) && $_GET['act'] == "getmap") { } } +// !! Depreciate? if (isset($_GET['checkachieve']) && $_GET['checkachieve'] == 'true' && $_SESSION['accepted'] == 1) { $json['notification'] = true; - $userID = $_SESSION['userID']; - //Located in includes/datas.php $note = getNotified($userID); - if ($note !== false) $json['notificationtext'] = $note; } +if ($_GET['r'] == 'reqScorePage') { + $mapID = $_GET['mapid'] + 0; + $page = $_GET['reqPage'] + 0; + if (!is_int($mapID) OR !is_int($page)) + return; + + //Include the notification text + $json = getScores($mapID, $page, 3); + $json['mapid'] = $mapID; + $json['page'] = $page; + + if ($_SESSION['accepted'] == 1) { + $userID = $_SESSION['userID']; + $note = getNotified($userID); + if ($note !== false) + $json['notificationtext'] = $note; + } + + $encoded = json_encode($json); + die($encoded); +} + + if ($_GET['r'] == 'getscores') { $mapID = $_GET['mapid'] + 0; if (!is_int($mapID)) @@ -59,12 +82,18 @@ if ($_GET['r'] == 'getsol') { $userID = $_SESSION['userID']; - if ($_SESSION['accepted'] == 1) +///// !! FIX FIX FIX FIX FIX FIX ////// + if ($_SESSION['accepted'] == 1) { $json = getSolution($userID, $mapID); - if (isset($_SESSION[$mapID.'sol']) AND $mysolution == '') { + if ($tmp['moves'] > $_SESSION[$mapID.'sol']) { + $json = $tmp; + } + } + if (isset($_SESSION[$mapID.'sol'])) { $json['solution'] = $_SESSION[$mapID.'sol']; $json['moves'] = $_SESSION[$mapID.'moves']; } + $json['mapid'] = $mapID; $encoded = json_encode($json); diff --git a/globe.php b/globe.php index 3470e78..22e455f 100644 --- a/globe.php +++ b/globe.php @@ -1,5 +1,5 @@ \n"; $headers .= "Reply-To: $mycompany <$replyemail>\n"; $headers .= "MIME-Version: 1.0\n"; @@ -183,4 +187,4 @@ function EmailError($data) { Return $mail_sent; } -?> +?> \ No newline at end of file diff --git a/includes/datas.php b/includes/datas.php index c445ca1..8c0309c 100644 --- a/includes/datas.php +++ b/includes/datas.php @@ -49,7 +49,8 @@ function topScores($mapid, $top = 5, $bottom = 0) { if ($wallEmblem == '') $wallEmblem = 'blank.png'; - $cdate = date("g:i A (T)", strtotime($cdate)); + //$cdate = date("g:i A (T)", strtotime($cdate)); + $cdate = relativeTime(strtotime($cdate)); $background = '#262631'; if ($i % 2 == 1) @@ -588,6 +589,139 @@ function trackMOTDstats($mapType) { +//Select Stats/Scores. +function getScores($mapid, $pageNumber = 1, $pageDivide = 10) { + $top = $pageNumber * $pageDivide; + $bottom = $top - $pageDivide; + + $pageRequest = 'all'; + + if ($pageRequest == 'all') { + $pageReqStart = 1; + $pageReqEnd = 1000; + } elseif (is_int($pageRequest)) { + $pageReqStart = $pageRequest; + $pageReqEnd = $pageRequest; + } else { + $tmp = explode($pageRequest, "-"); + $pageReqStart = $tmp[0]; + $pageReqEnd = $tmp[1]; + } + + $sql = " + SELECT + timediff(solutions.dateModified, TIMESTAMP(CURDATE())) as diff, + users.displayName as display, + solutions.moves as moves, + users.ID as ID, + IfNull(userData.displayColor, '#cccccc') as displayColor, + IfNull(userData.wallColor, '#666666') as wallColor, + IfNull(userData.wallEmblem, 'blank.png') as wallEmblem, + solutions.dateModified as cdate + FROM + `users` + JOIN `solutions` + ON users.ID = solutions.userID + LEFT JOIN `userData` + ON users.ID = userData.userID + WHERE solutions.mapID = '$mapid' + ORDER BY solutions.moves DESC, solutions.dateModified ASC + "; + $result = mysql_query($sql); + //$utime = date("g:i A (T)"); + + $output['updateTime'] = date("g:i A (T)"); + + $i = 0; + $foundUser = false; + while ($row = mysql_fetch_assoc($result)) { + $i++; + + $moves = $row['moves']; + $userID = $row['ID']; + if ($i == 1) { + $bestMoves = $moves; + $output['bestMoves'] = $bestMoves; + $output['bestBy'] = $row['display']; + } + + if ($_SESSION['userID'] == $userID) { + $userPosition = $i; + } else { + if ($i > $top) + continue; + if ($i <= $bottom) + continue; + } + + if ($wallEmblem == '') + $wallEmblem = 'blank.png'; + + $cdate = $row['cdate']; + $cdate = date("g:i A (T)", strtotime($cdate)); + + $scoredDate = strtotime($row['cdate']); + $secondsSinceScored = strtotime("now") - $scoredDate ; + + //Alternate background colors + $background = '#262631'; + if ($i % 2 == 1) + $background = '#20202a'; + + if ($userPosition == $i) { + $background = '#343c57'; + $foundUser = true; + } + + $medal = 'none'; + if ($moves == $bestMoves) + $medal = 'silver'; + if ($i == 1) + $medal = 'gold'; + + $output['users'][$i] = $row; + $output['users'][$i]['scoredDate'] = $cdate; + $output['users'][$i]['secondsSinceScored'] = $secondsSinceScored; + $output['users'][$i]['background'] = $background; + $output['users'][$i]['medal'] = $medal; + $output['users'][$i]['isUser'] = $userPosition == $i; + $output['users'][$i]['debug'] = "Bestmoves: $bestMoves moves: $moves"; + } // END WHILE + + if ($foundUser) { + $userPage = ceil(($userPosition / $pageDivide)); + $output['userPage'] = $userPage; + $output['userPosition'] = $userPosition; + } + + $output['pageCount'] = ceil(($i / $pageDivide)); + + if ($prevPage > 0) { + $navi .= " << "; + $navi .= " < "; + } else { + $navi .= " << "; + $navi .= " <"; + } + for ($x = 1; $x <= $pageCount; $x++) { + if ($x < $pageNumber - 3 OR $x > $pageNumber + 3) + continue; + if ($x == $pageNumber) + $navi .= " $x "; + elseif ($userPage == $x) + $navi .= " $x "; + else + $navi .= " $x "; + } + if ($nextPage <= $pageCount) { + $navi .= " > "; + $navi .= " >> "; + } + + return $output; +} + + diff --git a/includes/header.php b/includes/header.php index 887aa41..4e19fad 100644 --- a/includes/header.php +++ b/includes/header.php @@ -1,6 +1,6 @@ @@ -17,9 +17,12 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '') { } if ($desc !== '') echo " "; + + foreach ($scripts as $s) + echo ""; ?> - - + + + "; $mysolution = ''; $mymoves = ''; @@ -174,16 +190,7 @@ function displayMaze($motd, $mapType) { $r = "
"; $r .= "
"; - - // if ($width <= 16) { - // $r .= '
'; - // $r .= $topscorediv; - // $r .= '
'; - - // $r .= '
'; - // $r .= "Load your best solution
"; - // $r .= DisplayMap($map, $mapID); - // $r .= '
'; + $r .= "
"; $r .= "
"; $r .= " Load your best solution
"; @@ -210,7 +217,7 @@ function displayMaze($motd, $mapType) { $timerem = strtotime("tomorrow") - strtotime("now"); ?> -
+
New maps in: 00:00:00
-