Added stats page

This commit is contained in:
Keplyx 2018-05-24 14:01:44 +02:00
parent 7e5560d517
commit 54cdbeb490
4 changed files with 136 additions and 28 deletions

78
assets/css/stats.css Normal file
View file

@ -0,0 +1,78 @@
#stats_container {
display: inline-flex;
width: 100%;
}
.stats_table {
width: 48%;
border: none;
margin: 1% 1% 1% 1%;
}
.stats_table th{
border-radius: 10px 10px 0 0;
font-family: 'Russo One', sans-serif;
}
.stats_table .stat_log, .stats_table .stat_points {
color: #1c1c1c;
border-radius: 0;
font-weight: bold;
}
#stats_usa th {
background-color: #1a5dad;
border-color: #1a5dad;
}
#stats_usa .stat_log, #stats_usa .stat_points {
background-color: #639fad;
border-color: #639fad;
}
#stats_usa td {
border-color: #639fad;
}
#stats_urss th {
background-color: #d72229;
border-color: #d72229;
}
#stats_urss .stat_log, #stats_urss .stat_points {
background-color: #d75556;
border-color: #d75556;
}
#stats_urss td {
border-color: #d75556;
}
.stat_log {
width: 80%;
}
.stat_points {
width: 20%;
}
#positive{
color: #e9b600;
font-weight: bold;
}
#negative{
color: #cea380;
}
@media screen and (max-width: 480px) {
#stats_container {
display: block;
width: 100%;
}
.stats_table {
width: 100%;
}
}

View file

@ -373,7 +373,7 @@ Full-Width Styles
} }
#score_urss{ #score_urss{
color: #ee293d; color: #d72229;
} }
#score_separator{ #score_separator{
@ -384,7 +384,6 @@ Full-Width Styles
width: 100px; width: 100px;
} }
/******************************************************************************* /*******************************************************************************
Small Device Styles Small Device Styles
*******************************************************************************/ *******************************************************************************/

View file

@ -2,25 +2,21 @@
"usa": [ "usa": [
{ {
"text": "whoa, des points!", "text": "whoa, des points!",
"points": 99, "points": 99
"date": "19/07/2018"
}, },
{ {
"text": "whoa, encore des points!", "text": "whoa, encore des points!",
"points": 2, "points": 2
"date": "19/07/2018"
} }
], ],
"urss":[ "urss":[
{ {
"text": "merde, mes points!", "text": "non ! Mes points!",
"points": -99, "points": -99
"date": "19/07/2018"
}, },
{ {
"text": "yes, des points!", "text": "yes, des points!",
"points": 45, "points": 45
"date": "19/07/2018"
} }
] ]
} }

View file

@ -1,25 +1,60 @@
<?php <?php
ob_start(); // Start reading html ob_start(); // Start reading html
function get_stats($is_urss){
$json_source = file_get_contents('historique.json');
$json_data = json_decode($json_source, true);
$root = "usa";
if ($is_urss)
$root = "urss";
foreach($json_data[$root] as $v){
if ($v['points'] > 0)
echo "<tr id='positive'>";
else
echo "<tr id='negative'>";
echo "<td>".$v['text']."</td>";
echo "<td>".$v['points']."</td>";
echo "</tr>";
}
}
?> ?>
<h1>Stats</h1> <h1>Stats</h1>
<table id="stats_table"> <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 !
</p>
<div id="stats_container">
<table class="stats_table" id="stats_usa">
<tr> <tr>
<th colspan="2">USA</th> <th colspan="2">USA</th>
</tr>
<tr>
<td class="stat_log">Log</td>
<td class="stat_points">Points</td>
</tr>
<?php get_stats(false) ?>
</table>
<table class="stats_table" id="stats_urss">
<tr>
<th colspan="2">URSS</th> <th colspan="2">URSS</th>
</tr> </tr>
<tr> <tr>
<td>Log</td> <td class="stat_log">Log</td>
<td>Points</td> <td class="stat_points">Points</td>
<td>Log</td>
<td>Points</td>
</tr>
<tr>
<td class="horaires">9h30</td>
</tr> </tr>
<?php get_stats(true) ?>
</table> </table>
</div>
<?php <?php
$pageContent = ob_get_clean(); // Store html content in variable $pageContent = ob_get_clean(); // Store html content in variable
?>
<?
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 include("template.php"); // Display template with variable content
?> ?>