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
|
||||
*/
|
||||
|
||||
/* 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 */
|
||||
$data =
|
||||
json_decode(
|
||||
@ -27,7 +35,7 @@ if(isset($_GET['filter'])){
|
||||
if(htmlentities($_GET['filter']))
|
||||
$filter = true;
|
||||
else
|
||||
$filter = false;
|
||||
;$filter = false;
|
||||
}else
|
||||
$filter = false;
|
||||
?>
|
||||
@ -36,38 +44,23 @@ if(isset($_GET['filter'])){
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<title>Because velov map is too heavy</title>
|
||||
<style>
|
||||
html{
|
||||
background-color:black;
|
||||
color:white;
|
||||
}
|
||||
.success{
|
||||
color:green;
|
||||
}
|
||||
.danger{
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form action="" method="get">
|
||||
<?php if ($filter) { ?>
|
||||
<input type="hidden" name="filter" value="" />
|
||||
<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 } ?>
|
||||
<input type="hidden" name="filter" value="<?php echo $SEND_BUTTON[$filter]['value']; ?>" />
|
||||
<input type="submit" value="<?php echo $SEND_BUTTON[$filter]['text']; ?>" />
|
||||
<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
|
||||
foreach ($data as $key => $station){
|
||||
if ( ! $filter || isset($_GET[$key])){
|
||||
echo
|
||||
'<tr>
|
||||
<td><input type="checkbox" name="',$key,'"/></td>
|
||||
<td class="', ($station['open'] == 1 && $station['obsolete'] == 0 ? 'success' : 'danger' ) ,'" >'
|
||||
echo '<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="',$key,'" ',(isset($_GET[$key]) ? 'checked="checked"' : ''),' />
|
||||
</td>
|
||||
<td class="', ($station['open'] == 1 && $station['obsolete'] == 0 ? 'success' : 'danger' ) ,'" >'
|
||||
,$station['name'],
|
||||
'</td>
|
||||
<td>',$station['AB'], '</td>
|
||||
@ -77,11 +70,7 @@ if(isset($_GET['filter'])){
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php if ($filter) { ?>
|
||||
<input type="submit" value="Tout afficher" />
|
||||
<?php } else { ?>
|
||||
<input type="submit" value="Afficher uniquement la séléction" />
|
||||
<?php } ?>
|
||||
<input type="submit" value="<?php echo $SEND_BUTTON[$filter]['text']; ?>" />
|
||||
</form>
|
||||
<p>
|
||||
<h4>À quoi ça sert ?</h4>
|
||||
@ -91,5 +80,9 @@ if(isset($_GET['filter'])){
|
||||
<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>
|
||||
</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>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user