site-accueil-insa/stats.php

172 lines
6.1 KiB
PHP
Raw Normal View History

2018-05-24 13:17:51 +02:00
<?php
2018-06-15 09:33:29 +02:00
require_once 'classes/dao.php';
2018-05-24 13:17:51 +02:00
ob_start(); // Start reading html
2018-06-15 09:33:29 +02:00
function get_stats($team)
{
2019-05-16 07:28:02 +02:00
$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
}
2018-05-24 14:01:44 +02:00
}
2018-05-24 13:17:51 +02:00
2018-05-24 14:01:44 +02:00
?>
2018-08-27 08:39:38 +02:00
2018-06-15 09:33:29 +02:00
<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 !
2018-08-27 08:39:38 +02:00
<br><br>
<strong>Clique sur une équipe pour voir le détail de son score</strong>
2018-06-15 09:33:29 +02:00
</p>
<div id="stats-container">
2018-08-27 08:39:38 +02:00
<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> Glissefondor <i class="fas fa-arrow-down"></i>
2018-08-27 08:39:38 +02:00
</div>
<table class="stats-table stats-usa" id="usa-table" style="display: none">
2018-06-15 09:33:29 +02:00
<tr>
<td class="stat-log">Log</td>
<td class="stat-points">Points</td>
</tr>
<?php get_stats('usa') ?>
</table>
2018-08-27 08:39:38 +02:00
<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> Peksentard <i class="fas fa-arrow-down"></i>
2018-08-27 08:39:38 +02:00
</div>
<table class="stats-table stats-urss" id="urss-table" style="display: none">
2018-06-15 09:33:29 +02:00
<tr>
<td class="stat-log">Log</td>
<td class="stat-points">Points</td>
</tr>
<?php get_stats('urss') ?>
</table>
2018-08-27 08:39:38 +02:00
<div id="latest-score-urss"></div>
<div id="oldest-score-usa"></div>
<div class="edit-button-container">
<a href="edit_score/usa/edit.php" class="edit-button" id="button-boomsouffle">
Éditer les scores
</a>
</div>
<div class="stats-toggle stats-boomsouffle" onclick="toggleTable(this)" id="toggle-boomsouffle">
<i class="fas fa-arrow-down"></i> Boomsouffle <i class="fas fa-arrow-down"></i>
</div>
<table class="stats-table stats-boomsouffle" id="boomsouffle-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-usa"></div>
<div class="edit-button-container">
<a href="edit_score/usa/edit.php" class="edit-button" id="button-verredaigle">
Éditer les scores
</a>
</div>
<div class="stats-toggle stats-verredaigle" onclick="toggleTable(this)" id="toggle-verredaigle">
<i class="fas fa-arrow-down"></i> Verredaigle <i class="fas fa-arrow-down"></i>
</div>
<table class="stats-table stats-verredaigle" id="verredaigle-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>
2018-06-15 09:33:29 +02:00
</div>
2018-08-27 08:39:38 +02:00
<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> Glissefondor <i class=\"fas fa-arrow-up\"></i>";
2018-08-27 08:39:38 +02:00
// scrolltoNew('usa');
}
else {
$("#usa-table").hide(300);
// scrolltoOld('usa');
elem.innerHTML = "<i class=\"fas fa-arrow-down\"></i> Glissefondor <i class=\"fas fa-arrow-down\"></i>";
2018-08-27 08:39:38 +02:00
}
}
else {
if ($("#urss-table").css("display") === "none") {
$("#urss-table").show(300);
elem.innerHTML = "<i class=\"fas fa-arrow-up\"></i> Peksentard <i class=\"fas fa-arrow-up\"></i>";
2018-08-27 08:39:38 +02:00
// scrolltoNew('urss');
}
else {
$("#urss-table").hide(300);
// scrolltoOld('urss');
elem.innerHTML = "<i class=\"fas fa-arrow-down\"></i> Peksentard <i class=\"fas fa-arrow-down\"></i>";
2018-08-27 08:39:38 +02:00
}
}
}
</script>
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/stats.css">
2018-05-24 13:17:51 +02:00
<?php
$pageContent = ob_get_clean(); // Store html content in variable
2018-06-05 20:03:33 +02:00
$pageTitle = "Stats";
2018-05-24 13:17:51 +02:00
include("template.php"); // Display template with variable content