show primitive alert on screen when panic button pressed

This commit is contained in:
BlubbFish 2019-03-28 17:06:46 +01:00
parent 1f8bb79d43
commit 52406de2ba
2 changed files with 16 additions and 0 deletions

View File

@ -51,6 +51,18 @@ function parseAjaxPanic() {
var panics = JSON.parse(this.responseText);
for (var id in panics) {
if (panics.hasOwnProperty(id)) {
var panicitem = panics[id];
if (markers.hasOwnProperty(id)) {
if (typeof markers[id].getPopup() === "undefined") {
markers[id].bindPopup("");
}
if (timeDiffRaw(panicitem["Triggerdtime"]) <= 10 && !markers[id].isPopupOpen()) {
markers[id].setPopupContent("ALERT!");
markers[id].openPopup();
} else if (timeDiffRaw(panicitem["Triggerdtime"]) > 10 && markers[id].isPopupOpen()) {
markers[id].closePopup();
}
}
}
}
}

View File

@ -119,3 +119,7 @@ function timeDiffToText(time) {
}
return Math.floor(diff / (60 * 60 * 24)) + " d";
}
function timeDiffRaw(time) {
return (Date.now() - Date.parse(time)) / 1000;
}