Permalink
Browse files

Add podium mode.

  • Loading branch information...
ShaneMcC committed Dec 7, 2018
1 parent 860c344 commit 6ffad663172465bcb4fc8a42367e2f871fc31b65
Showing with 32 additions and 6 deletions.
  1. +1 −0 config.php
  2. +3 −3 www/functions.php
  3. +11 −3 www/index.php
  4. +17 −0 www/style.css
@@ -7,6 +7,7 @@
$leaderboardID = '';
$leaderboardYear = '';
$podium = false;
$repeatCount = 20;
$longTimeout = 10;
@@ -17,7 +17,7 @@
}
}
function getDayBestTime($day, $method) {
function getDayBestTimes($day, $method) {
global $data;
$times = [];
@@ -26,10 +26,10 @@ function getDayBestTime($day, $method) {
$times[] = getParticipantTime($pdata['days'][$day]['times'], $method);
}
}
if (empty($times)) { return NULL; }
sort($times);
return $times[0];
array_unique($times);
return $times;
}
function getParticipantTime($times, $method) {
@@ -47,8 +47,11 @@
echo '<tbody>';
for ($day = 1; $day <= 25; $day++) {
$best = getDayBestTime($day, $method);
if ($best === NULL) { continue; }
$best = getDayBestTimes($day, $method);
if (empty($best)) { continue; }
$first = array_shift($best);
$second = array_shift($best);
$third = array_shift($best);
echo '<tr>';
echo '<th class="day">Day ', $day, '</th>';
@@ -64,7 +67,12 @@
$tooltip = 'Min: ' . formatTime($min) . '<br>' . 'Max: ' . formatTime($max);
echo '<td class="participant time ', ($time == $best ? 'table-success' : ''), '" data-ms="', $time ,'" data-toggle="tooltip" data-placement="bottom" data-html="true" title="', htmlspecialchars($tooltip), '">';
$classes = ['participant', 'time'];
if ($time == $first) { $classes[] = $podium ? 'table-first' : 'table-best'; }
if ($podium && $time == $second) { $classes[] = 'table-second'; }
if ($podium && $time == $third) { $classes[] = 'table-third'; }
echo '<td class="', implode(' ', $classes), '" data-ms="', $time ,'" data-toggle="tooltip" data-placement="bottom" data-html="true" title="', htmlspecialchars($tooltip), '">';
echo formatTime($time);
echo '</td>';
} else {
@@ -34,3 +34,20 @@ main {
td.day, th.day {
width: 100px;
}


.table-best, .table-best>td, .table-best>th {
background-color: #c3e6cb;
}

.table-first, .table-first>td, .table-first>th {
background-color: gold;
}

.table-second, .table-second>td, .table-second>th {
background-color: silver;
}

.table-third, .table-third>td, .table-third>th {
background-color: #996633;
}

0 comments on commit 6ffad66

Please sign in to comment.