add status text if no image is shown
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
const images = document.getElementsByClassName('current_webcam_image');
|
||||
const boxes = document.getElementsByClassName('current_webcam_image_box');
|
||||
const reload_interval = setInterval(reloadImages, 60000);
|
||||
|
||||
window.onload = function() {
|
||||
@ -16,9 +16,14 @@ function checkImageSource(image_url) {
|
||||
function reloadImages() {
|
||||
console.log('reload in progress');
|
||||
|
||||
Array.prototype.forEach.call(images, function(image) {
|
||||
Array.prototype.forEach.call(boxes, function(box) {
|
||||
var headline = box.childNodes[1]
|
||||
var image = box.childNodes[3]
|
||||
var status_text = box.childNodes[5]
|
||||
|
||||
if (checkImageSource(image.src) == 200) {
|
||||
status_text.style = "visibility:hidden"
|
||||
image.style="width:100%;visibility:visible"
|
||||
if (!image.src.includes('?')) {
|
||||
image.src = `${image.src}?${Date.now()}`;
|
||||
} else {
|
||||
@ -27,9 +32,12 @@ function reloadImages() {
|
||||
} else {
|
||||
console.log('unable to find image on server');
|
||||
image.alt = "Webcam nicht erreichbar."
|
||||
image.style="width:100%;visibility:hidden"
|
||||
status_text.style = "visibility:visible"
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
console.log('reload finished');
|
||||
}
|
Reference in New Issue
Block a user