forked from vergnet/site-accueil-insa
139 lines
4.7 KiB
PHP
Executable file
139 lines
4.7 KiB
PHP
Executable file
<?php
|
|
require_once 'classes/dao.php';
|
|
|
|
ob_start(); // Start reading html
|
|
|
|
|
|
function get_stats($team)
|
|
{
|
|
$dao = new Dao('');
|
|
foreach ($dao->get_score_team($team) as $row) {
|
|
$text = $row['text'];
|
|
$points = $row['points'];
|
|
if ($points > 0)
|
|
$id = "positive";
|
|
else
|
|
$id = "negative";
|
|
?>
|
|
<tr id="<?= $id ?>">
|
|
<td><?= htmlspecialchars($text) ?></td>
|
|
<td><?= $points ?></td>
|
|
</tr>
|
|
<?php
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
<h1>Stats</h1>
|
|
<p>
|
|
Les stats de la semaine.
|
|
<br>
|
|
Remporte le plus de points possible pour faire gagner ton équipe, mais attention à ne pas lui en faire perdre !
|
|
<br><br>
|
|
<strong>Clique sur une équipe pour voir le détail de son score</strong>
|
|
</p>
|
|
|
|
<div id="stats-container">
|
|
|
|
<div id="oldest-score-usa"></div>
|
|
<div class="edit-button-container">
|
|
<a href="edit_score/usa/edit.php" class="edit-button" id="button-usa">
|
|
Éditer les scores
|
|
</a>
|
|
</div>
|
|
<div class="stats-toggle stats-usa" onclick="toggleTable(this)" id="toggle-usa">
|
|
<i class="fas fa-arrow-down"></i> USA <i class="fas fa-arrow-down"></i>
|
|
</div>
|
|
<table class="stats-table stats-usa" id="usa-table" style="display: none">
|
|
<tr>
|
|
<td class="stat-log">Log</td>
|
|
<td class="stat-points">Points</td>
|
|
</tr>
|
|
<?php get_stats('usa') ?>
|
|
</table>
|
|
<div id="latest-score-usa"></div>
|
|
|
|
<div id="oldest-score-urss"></div>
|
|
<div class="edit-button-container">
|
|
<a href="edit_score/urss/edit.php" class="edit-button" id="button-urss">
|
|
Éditer les scores
|
|
</a>
|
|
</div>
|
|
<div class="stats-toggle" onclick="toggleTable(this)" id="toggle-urss">
|
|
<i class="fas fa-arrow-down"></i> URSS <i class="fas fa-arrow-down"></i>
|
|
</div>
|
|
<table class="stats-table stats-urss" id="urss-table" style="display: none">
|
|
<tr>
|
|
<td class="stat-log">Log</td>
|
|
<td class="stat-points">Points</td>
|
|
</tr>
|
|
<?php get_stats('urss') ?>
|
|
</table>
|
|
<div id="latest-score-urss"></div>
|
|
</div>
|
|
<script>
|
|
function scrolltoOld(team) {
|
|
if (team === 'usa') {
|
|
$('html, body').animate({
|
|
scrollTop: $("#oldest-score-usa").offset().top
|
|
}, 300);
|
|
}
|
|
else {
|
|
$('html, body').animate({
|
|
scrollTop: $("#oldest-score-urss").offset().top
|
|
}, 300);
|
|
}
|
|
}
|
|
|
|
function scrolltoNew(team) {
|
|
if (team === 'usa') {
|
|
$('html, body').animate({
|
|
scrollTop: ($("#latest-score-usa").offset().top - window.innerHeight)
|
|
}, 300);
|
|
}
|
|
else {
|
|
$('html, body').animate({
|
|
scrollTop: ($("#latest-score-urss").offset().top - window.innerHeight)
|
|
}, 300);
|
|
}
|
|
}
|
|
|
|
function toggleTable(elem) {
|
|
if (elem.id === 'toggle-usa') {
|
|
if ($("#usa-table").css("display") === "none") {
|
|
$("#usa-table").show(300);
|
|
elem.innerHTML = "<i class=\"fas fa-arrow-up\"></i> USA <i class=\"fas fa-arrow-up\"></i>";
|
|
// scrolltoNew('usa');
|
|
}
|
|
else {
|
|
$("#usa-table").hide(300);
|
|
// scrolltoOld('usa');
|
|
elem.innerHTML = "<i class=\"fas fa-arrow-down\"></i> USA <i class=\"fas fa-arrow-down\"></i>";
|
|
}
|
|
}
|
|
else {
|
|
if ($("#urss-table").css("display") === "none") {
|
|
$("#urss-table").show(300);
|
|
elem.innerHTML = "<i class=\"fas fa-arrow-up\"></i> URSS <i class=\"fas fa-arrow-up\"></i>";
|
|
// scrolltoNew('urss');
|
|
}
|
|
else {
|
|
$("#urss-table").hide(300);
|
|
// scrolltoOld('urss');
|
|
elem.innerHTML = "<i class=\"fas fa-arrow-down\"></i> URSS <i class=\"fas fa-arrow-down\"></i>";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
<?php
|
|
$pageContent = ob_get_clean(); // Store html content in variable
|
|
$pageTitle = "Stats";
|
|
ob_start(); // Start reading html
|
|
?>
|
|
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/stats.css">
|
|
<?php
|
|
$pageMeta = ob_get_clean(); // Store html content in variable
|
|
include("template.php"); // Display template with variable content
|