From ce96bc4b6717b953a34b91ad3bde174fa60d4e03 Mon Sep 17 00:00:00 2001 From: Qwann Date: Tue, 7 Mar 2017 17:01:37 +0100 Subject: [PATCH] Status added on home page --- kfet/static/kfet/css/home.css | 9 +++++++++ kfet/static/kfet/js/kfet_open.js | 29 +++++++++++++++++++++++++++-- kfet/templates/kfet/home.html | 6 ++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/kfet/static/kfet/css/home.css b/kfet/static/kfet/css/home.css index 718159c3..2b831d9b 100644 --- a/kfet/static/kfet/css/home.css +++ b/kfet/static/kfet/css/home.css @@ -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; +} diff --git a/kfet/static/kfet/js/kfet_open.js b/kfet/static/kfet/js/kfet_open.js index fe6e0486..1655b71f 100644 --- a/kfet/static/kfet/js/kfet_open.js +++ b/kfet/static/kfet/js/kfet_open.js @@ -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(); } } diff --git a/kfet/templates/kfet/home.html b/kfet/templates/kfet/home.html index 5df60d91..40a1debd 100644 --- a/kfet/templates/kfet/home.html +++ b/kfet/templates/kfet/home.html @@ -15,11 +15,13 @@
La K-Fêt est
-
Fermée
+
+
+
?????