Commit 213cd4b6 authored by JackV's avatar JackV

Merge branch 'master' into python3

parents 892c6595 1688d49d
......@@ -5,6 +5,7 @@ module("browser_handler", function (require, exports) {
debug = require("debug"),
query = require("peppy").query,
Raphael = require("Raphael"),
moment = require("moment"),
sede,
sedeValue,
......@@ -51,7 +52,12 @@ module("browser_handler", function (require, exports) {
// Show a DOM hidden element
function show(elem) {
debug.log("Showing", elem.id);
elem.setAttribute("style", "display: block");
$(elem).fadeIn();
}
function hide(elem) {
debug.log("Hiding", elem.id);
$(elem).fadeOut();
}
// Return a new string capitalized
......@@ -71,6 +77,16 @@ module("browser_handler", function (require, exports) {
favicon = link;
}
function changeFAB(status) {
debug.log("Changing floating action button", status);
$("#hq-status-fab button")
.removeClass("btn-gialla")
.removeClass("btn-open")
.removeClass("btn-closed")
.addClass("btn-" + status);
}
// the Trend object contains an old state off the value defined
// - newValue
// add a new state to the _oldValue_ state and
......@@ -107,79 +123,65 @@ module("browser_handler", function (require, exports) {
}
};
function swith(elem, callback) {
if (elem !== undefined) {
debug.log(elem, "selected");
if (callback !== undefined) {
callback();
}
} else {
debug.error(elem, "not selectable");
}
}
/* END HELPERS */
/* DOM Selecting initialization */
main(function () {
sede = doc.getElementById("sede");
swith(sede, function () {
sedeValue = query(".value", sede)[0];
sedeTimestamp = query(".timestamp", sede)[0];
sedeModifiedBy = query(".modified_by", sede)[0];
});
moment.locale('it');
temp = doc.getElementById("temp");
swith(temp, function () {
tempValue = query(".value", temp)[0];
tempTrend = query(".trend", temp)[0];
});
sede = $("#sede")[0];
sedeValue = $("#sede .value")[0];
sedeTimestamp = $("#sede .timestamp")[0];
sedeModifiedBy = $("#sede .modified_by")[0];
msg = query("#last.msg")[0];
swith(msg, function () {
msgUser = query(".user", msg)[0];
msgTimestamp = query(".timestamp", msg)[0];
msgValue = query(".value", msg)[0];
});
temp = $("#temp")[0];
tempValue = $("#temp .value")[0];
tempTrend = $("#temp .trend")[0];
title = doc.title;
swith(title);
msg = $("#last.msg")[0];
msgUser = $("#last.msg .user")[0];
msgTimestamp = $("#last.msg .timestamp")[0];
msgValue = $("#last.msg .value")[0];
title = doc.title;
favicon = query('[rel="icon"]')[0];
swith(favicon);
head = doc.head || doc.getElementsByTagName('head')[0];
swith(head);
if ($("#temperature_graph").length > 0)
tempGraph = Raphael("temperature_graph", tempGraphWidth, tempGraphHeight);
trend = new Trend();
});
/* Handler functions definition */
// Handle BITS status change.
function statusHandler(status, first) {
debug.log("browserHandler handling status");
if (first) {
show(sede);
}
var value = status.value === "open" ? "open" : "close";
var value = status.value === "open" ? "open" : "closed";
changeIcon(value);
changeFAB(value);
doc.title = capitalize(value) + " " + title;
sedeValue.setAttribute("class", value + " value");
sedeTimestamp.innerHTML = status.timestamp;
sedeTimestamp.innerHTML = moment(status.timestamp).startOf('hour').fromNow();
sedeModifiedBy.innerHTML = status.modifiedby;
}
// Handle MSGs arrival
function msgHandler(message, first) {
debug.log("Displaying message");
if(first) {
if (message.value.length > 0) {
show(msg);
} else if (message.value.length === 0) {
hide(msg);
}
msgUser.innerHTML = message.user;
msgTimestamp.innerHTML = message.timestamp;
msgTimestamp.innerHTML = moment(message.timestamp).startOf('hour').fromNow();
msgValue.innerHTML = message.value;
}
......@@ -190,6 +192,7 @@ module("browser_handler", function (require, exports) {
if (first) {
show(temp);
}
tempValue.innerHTML = tempInt.value.toPrecision() + "°C";
if (lastTimestamp !== tempInt.timestamp) {
......@@ -198,7 +201,11 @@ module("browser_handler", function (require, exports) {
//TODO tempGraph.addTemp(tempInt);
}
}
temp.setAttribute("class", tempInt.value > 20 ? "high" : "low");
$(temp)
.removeClass("high")
.removeClass("low")
.addClass(tempInt.value > 20 ? "high" : "low");
}
......@@ -229,5 +236,6 @@ module("browser_handler", function (require, exports) {
exports.msg = msgHandler;
exports.tempInt = tempIntHandler;
exports.tempIntHist = tempIntHistHandler;
});
}
);
......@@ -7,8 +7,9 @@ main(function (require) {
location = require("location"),
query = require("peppy").query,
debug = require("debug"),
protocol = /https/.test(location.protocol)? "wss": "ws",
protocol = /https/.test(location.protocol) ? "wss" : "ws",
ws = new WebSocket(protocol + "://" + location.hostname + ":" + location.port + "/ws"),
// ws = new WebSocket("wss://bits.poul.org/ws"),
handler = new Handler(browserHandler);
var debugMeta = query("meta[name='mode']")[0];
......@@ -26,3 +27,29 @@ main(function (require) {
debug.error("WS Error", event);
};
});
let _sticky = false;
const setFABsticky = function (sticky) {
if (sticky === _sticky)
return;
if (sticky)
$("#hq-status-fab").addClass("stick-to-bar");
else
$("#hq-status-fab").removeClass("stick-to-bar");
_sticky = sticky;
};
$(document).ready(function () {
const navbar = $("nav.navbar");
const mainTop = $("#hq-status-fab").parent().offset().top;
$(window).scroll(function () {
const windowScroll = $(this).scrollTop();
const barBottom = navbar.outerHeight();
setFABsticky(windowScroll + barBottom > mainTop);
});
});
\ No newline at end of file
This diff is collapsed.
#poul-logo-top {
width: 65%;
}
.bg-very-dark {
background-color: #010101 !important;
}
.bg-a-bit-less-dark {
background-color: #1b1b1b !important;
}
.bg-kinda-dark {
background-color: #232323 !important;
}
.bg-black {
background-color: black !important;
}
.page-header {
height: 400px;
z-index: -1;
}
a {
color: #ffc500;
}
a:hover {
color: #ac8300;
}
strong {
font-weight: bold;
color: #ffc500;
}
footer ul li a {
color: #ffc500;
}
#hq-status-fab {
z-index: 2000;
text-align: center;
position: absolute;
top: -33px;
width: 100%;
}
#hq-status-fab button {
top: 0;
font-weight: bold;
}
.no-z-index {
z-index: unset !important;
}
.btn.btn-gialla {
color: #fff;
background-color: #ffc500;
border-color: #ffc500;
box-shadow: 0 2px 2px 0 rgba(255, 152, 0, 0.14), 0 3px 1px -2px rgba(255, 152, 0, 0.2), 0 1px 5px 0 rgba(255, 152, 0, 0.12);
}
.btn.btn-gialla:hover {
color: #fff;
background-color: #ffc500;
border-color: #7f6200;
}
.btn-gialla {
color: #212529;
background-color: #ffc500;
border-color: #ffc500;
box-shadow: none;
}
.btn.btn-gialla:after {
content: 'Sede gialla';
}
.btn-gialla:focus,
.btn-gialla.focus {
box-shadow: none, 0 0 0 0.2rem rgba(127, 98, 0, 1);
}
.btn-gialla.disabled,
.btn-gialla:disabled {
color: #212529;
background-color: #ffc500;
border-color: #ffc500;
}
.btn.btn-open {
color: #fff;
background-color: #387002;
border-color: #387002;
box-shadow: 0 2px 2px 0 rgba(28, 56, 1, 0.14), 0 3px 1px -2px rgba(28, 56, 1, 0.2), 0 1px 5px 0 rgba(28, 56, 1, 0.12);
}
.btn.btn-open:hover {
color: #fff;
background-color: #387002;
border-color: #1c3801;
}
.btn.btn-open:after {
content: 'Sede aperta';
}
.btn-open {
color: #212529;
background-color: #387002;
border-color: #387002;
box-shadow: none;
}
.btn-open:focus,
.btn-open.focus {
box-shadow: none, 0 0 0 0.2rem rgb(28, 56, 1);
}
.btn-open.disabled,
.btn-open:disabled {
color: #212529;
background-color: #387002;
border-color: #1c3801;
}
.btn.btn-closed {
color: #fff;
background-color: #d32f2f;
border-color: #d32f2f;
box-shadow: 0 2px 2px 0 rgba(105, 23, 23, 0.14), 0 3px 1px -2px rgba(105, 23, 23, 0.2), 0 1px 5px 0 rgba(105, 23, 23, 0.12);
}
.btn.btn-closed:hover {
color: #fff;
background-color: #d32f2f;
border-color: #691717;
}
.btn.btn-closed:after {
content: 'Sede chiusa';
}
.btn-closed {
color: #212529;
background-color: #d32f2f;
border-color: #d32f2f;
box-shadow: none;
}
.btn-closed:focus,
.btn-closed.focus {
box-shadow: none, 0 0 0 0.2rem rgb(105, 23, 23);
}
.btn-closed.disabled,
.btn-closed:disabled {
color: #212529;
background-color: #d32f2f;
border-color: #691717;
}
.stick-to-bar {
position: fixed !important;
left: 0 !important;
top: 38px !important;
}
.closed.value:after {
content: 'Chiusa';
}
.open.value:after {
content: 'Aperta';
}
.msg .msg-inner {
font-style: italic;
}
#temp .card-body p {
font-size: 15pt;
}
#presence_graph {
width: 100%;
}
.card {
margin-top: 7px;
margin-bottom: 7px;
}
.card p {
margin-bottom: 0;
}
#sede, #temp, #last.msg {
display: none;
}
.md-content p {
font-size: 1.125rem;
line-height: 1.5em;
}
ul#log-status {
list-style: none;
}
#log-status .closed .fa-auto:before {
content: "\f023";
}
#log-status .open .fa-auto:before {
content: "\f09c";
}
#log-status .closed .fa-auto:after {
font-family: 'Open Sans', sans-serif;
content: " Chiusa, ";
}
#log-status .open .fa-auto:after {
font-family: 'Open Sans', sans-serif;
content: " Aperta, ";
}
#paginator {
text-align: center;
}
.btn.btn-transparent {
background-color: transparent;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
#admin .card {
margin-top: 50px;
margin-bottom: 50px;
}
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
/*!
=========================================================
* Material Kit - v2.0.5
=========================================================
* Product Page: https://www.creative-tim.com/product/material-kit
* Copyright 2018 Creative Tim (http://www.creative-tim.com)
* Designed by www.invisionapp.com Coded by www.creative-tim.com
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/
var big_image;
$(document).ready(function() {
BrowserDetect.init();
// Init Material scripts for buttons ripples, inputs animations etc, more info on the next link https://github.com/FezVrasta/bootstrap-material-design#materialjs
$('body').bootstrapMaterialDesign();
window_width = $(window).width();
$navbar = $('.navbar[color-on-scroll]');
scroll_distance = $navbar.attr('color-on-scroll') || 500;
$navbar_collapse = $('.navbar').find('.navbar-collapse');
// Activate the Tooltips
$('[data-toggle="tooltip"], [rel="tooltip"]').tooltip();
// Activate Popovers
$('[data-toggle="popover"]').popover();
if ($('.navbar-color-on-scroll').length != 0) {
$(window).on('scroll', materialKit.checkScrollForTransparentNavbar);
}
materialKit.checkScrollForTransparentNavbar();
if (window_width >= 768) {
big_image = $('.page-header[data-parallax="true"]');
if (big_image.length != 0) {
$(window).on('scroll', materialKit.checkScrollForParallax);
}
}
});
$(document).on('click', '.navbar-toggler', function() {
$toggle = $(this);
if (materialKit.misc.navbar_menu_visible == 1) {
$('html').removeClass('nav-open');
materialKit.misc.navbar_menu_visible = 0;
$('#bodyClick').remove();
setTimeout(function() {
$toggle.removeClass('toggled');
}, 550);
$('html').removeClass('nav-open-absolute');
} else {
setTimeout(function() {
$toggle.addClass('toggled');
}, 580);
div = '<div id="bodyClick"></div>';
$(div).appendTo("body").click(function() {
$('html').removeClass('nav-open');
if ($('nav').hasClass('navbar-absolute')) {
$('html').removeClass('nav-open-absolute');
}
materialKit.misc.navbar_menu_visible = 0;
$('#bodyClick').remove();
setTimeout(function() {
$toggle.removeClass('toggled');
}, 550);
});
if ($('nav').hasClass('navbar-absolute')) {
$('html').addClass('nav-open-absolute');
}
$('html').addClass('nav-open');
materialKit.misc.navbar_menu_visible = 1;
}
});
materialKit = {
misc: {
navbar_menu_visible: 0,
window_width: 0,
transparent: true,
fixedTop: false,
navbar_initialized: false,
isWindow: document.documentMode || /Edge/.test(navigator.userAgent)
},
initFormExtendedDatetimepickers: function() {
$('.datetimepicker').datetimepicker({
icons: {
time: "fa fa-clock-o",
date: "fa fa-calendar",
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',