Status added on home page

This commit is contained in:
Qwann 2017-03-07 17:01:37 +01:00
parent f8e09cf257
commit ce96bc4b67
3 changed files with 40 additions and 4 deletions

View file

@ -52,3 +52,12 @@ li.carte-line {
.unbreakable.carte-inverted {
background: #FFDBC7;
}
#open_status {
color: white;
}
#open_status_parent {
padding-left:0px;
padding-right:0px;
}

View file

@ -1,19 +1,28 @@
function kfet_open(init_date, init_satus) {
// VARIABLES
var kfet_open_bullet = $('#kfet-open');
var open_status = $('#open_status');
// bullet
var open_color = "#73C252";
var closed_color = "#B42B26";
var unknown_color = "#ECD03E";
// status bar
var open_color_status = "#73C252";
var closed_color_status = "#B42B26";
var unknown_color_status = "#D4BE4C";
var kfet_open_date = init_date;
var kfet_open = init_status;
// INITIALISAITION
update_open_bullet();
update_open_status();
// On recherge toute les 30sec
// (dans le cas où le statut deviendrait inconn)
setInterval(function() {
update_open_bullet();
update_open_status();
}, 30 * 1000); // 60 * 1000 milsec
// FONCTIONS
@ -32,9 +41,9 @@ function kfet_open(init_date, init_satus) {
}
function update_open_bullet() {
nb_min = nb_min_diff();
console.log("K-Fêt ouverte : " + kfet_open);
console.log("BULLET | K-Fêt ouverte : " + kfet_open);
console.log(nb_min + " minute(s) depuis la dernière mise à jour");
if (nb_min > 5) {
if (nb_min > 15) {
kfet_open_bullet.css({'background-color': unknown_color});
} else if (kfet_open){
kfet_open_bullet.css({'background-color': open_color});
@ -42,6 +51,21 @@ function kfet_open(init_date, init_satus) {
kfet_open_bullet.css({'background-color': closed_color});
}
}
function update_open_status() {
nb_min = nb_min_diff();
console.log("STATUS | K-Fêt ouverte : " + kfet_open);
console.log(nb_min + " minute(s) depuis la dernière mise à jour");
if (nb_min > 15) {
open_status.parent().css({'background-color': unknown_color});
open_status.html("?????");
} else if (kfet_open){
open_status.parent().css({'background-color': open_color});
open_status.html("OUVERTE");
} else {
open_status.parent().css({'background-color': closed_color});
open_status.html("FERMÉE");
}
}
// SYNCHRONIZATION
websocket_msg_default = {'last_op': 0}
@ -58,5 +82,6 @@ function kfet_open(init_date, init_satus) {
kfet_open = data['kfet_open'];
update_open_bullet();
update_open_status();
}
}

View file

@ -15,11 +15,13 @@
<div class="content-left">
<div class="content-left-top">
<div class="line line-bigsub">La K-Fêt est</div>
<div class="line line-big">Fermée</div>
</div>
<div class="content-left-top" id="open_status_parent">
<div class="line line-big" id="open_status">?????</div>
</div>
<div class="buttons">
<a class="btn btn-primary btn-lg" href="#TODO">
Ouvrir manuelement
Ouvrir manuellement
</a>
</div>
</div>