cleaning
This commit is contained in:
parent
c175e7bb86
commit
d7dc145ac1
53
index.php
53
index.php
@ -4,6 +4,14 @@
|
|||||||
* TODO Cache the humongous API data
|
* TODO Cache the humongous API data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Form submit if a filter is active or not */
|
||||||
|
$SEND_BUTTON = [
|
||||||
|
true => [ 'value' => '', 'text' => 'Tout afficher'],
|
||||||
|
false => [ 'value' => 'true', 'text' => 'Afficher la sélection'],
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Fetching velov API in an associative array. This form is easier to use as keys are ids */
|
/* Fetching velov API in an associative array. This form is easier to use as keys are ids */
|
||||||
$data =
|
$data =
|
||||||
json_decode(
|
json_decode(
|
||||||
@ -27,7 +35,7 @@ if(isset($_GET['filter'])){
|
|||||||
if(htmlentities($_GET['filter']))
|
if(htmlentities($_GET['filter']))
|
||||||
$filter = true;
|
$filter = true;
|
||||||
else
|
else
|
||||||
$filter = false;
|
;$filter = false;
|
||||||
}else
|
}else
|
||||||
$filter = false;
|
$filter = false;
|
||||||
?>
|
?>
|
||||||
@ -36,38 +44,23 @@ if(isset($_GET['filter'])){
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
|
<link rel="stylesheet" type="text/css" href="style.css">
|
||||||
<title>Because velov map is too heavy</title>
|
<title>Because velov map is too heavy</title>
|
||||||
<style>
|
|
||||||
html{
|
|
||||||
background-color:black;
|
|
||||||
color:white;
|
|
||||||
}
|
|
||||||
.success{
|
|
||||||
color:green;
|
|
||||||
}
|
|
||||||
.danger{
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<form action="" method="get">
|
<form action="" method="get">
|
||||||
<?php if ($filter) { ?>
|
<input type="hidden" name="filter" value="<?php echo $SEND_BUTTON[$filter]['value']; ?>" />
|
||||||
<input type="hidden" name="filter" value="" />
|
<input type="submit" value="<?php echo $SEND_BUTTON[$filter]['text']; ?>" />
|
||||||
<input type="submit" value="Tout afficher" />
|
|
||||||
<?php } else { ?>
|
|
||||||
<input type="hidden" name="filter" value="true" />
|
|
||||||
<input type="submit" value="Afficher uniquement la séléction" />
|
|
||||||
<?php } ?>
|
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Sélectionner</th><th>Nom</th><th>Vélos</th><th>Places Libres</th></tr>
|
<tr><th>Sélectionner</th><th>Nom</th><th>Vélos</th><th>Places Libres</th></tr>
|
||||||
<?php
|
<?php
|
||||||
foreach ($data as $key => $station){
|
foreach ($data as $key => $station){
|
||||||
if ( ! $filter || isset($_GET[$key])){
|
if ( ! $filter || isset($_GET[$key])){
|
||||||
echo
|
echo '<tr>
|
||||||
'<tr>
|
<td>
|
||||||
<td><input type="checkbox" name="',$key,'"/></td>
|
<input type="checkbox" name="',$key,'" ',(isset($_GET[$key]) ? 'checked="checked"' : ''),' />
|
||||||
<td class="', ($station['open'] == 1 && $station['obsolete'] == 0 ? 'success' : 'danger' ) ,'" >'
|
</td>
|
||||||
|
<td class="', ($station['open'] == 1 && $station['obsolete'] == 0 ? 'success' : 'danger' ) ,'" >'
|
||||||
,$station['name'],
|
,$station['name'],
|
||||||
'</td>
|
'</td>
|
||||||
<td>',$station['AB'], '</td>
|
<td>',$station['AB'], '</td>
|
||||||
@ -77,11 +70,7 @@ if(isset($_GET['filter'])){
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
<?php if ($filter) { ?>
|
<input type="submit" value="<?php echo $SEND_BUTTON[$filter]['text']; ?>" />
|
||||||
<input type="submit" value="Tout afficher" />
|
|
||||||
<?php } else { ?>
|
|
||||||
<input type="submit" value="Afficher uniquement la séléction" />
|
|
||||||
<?php } ?>
|
|
||||||
</form>
|
</form>
|
||||||
<p>
|
<p>
|
||||||
<h4>À quoi ça sert ?</h4>
|
<h4>À quoi ça sert ?</h4>
|
||||||
@ -91,5 +80,9 @@ if(isset($_GET['filter'])){
|
|||||||
<h4>Pourquoi cette page est elle lente ?</h4>
|
<h4>Pourquoi cette page est elle lente ?</h4>
|
||||||
Parce qu’il faut télécharger toutes les données relatives aux stations vélov à chaque chargement ! N’hésitez pas à améliorer cette page sur <a href="http://github.com/adrianamaglio/velov">Github</a>
|
Parce qu’il faut télécharger toutes les données relatives aux stations vélov à chaque chargement ! N’hésitez pas à améliorer cette page sur <a href="http://github.com/adrianamaglio/velov">Github</a>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<h4>Pourquoi ces couleurs ?</h4>
|
||||||
|
Le <span class="success">vert</span> est réservé aux stations actives, le <span class="danger">rouge</span> est pour celles inutilisables.
|
||||||
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user