Skip to content

Commit

Permalink
Add warning on camera feed disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
msathieu committed Oct 26, 2023
1 parent 32a8d21 commit 9bba5e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions content/assets/scripts/cammie.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ debounce = function(func, wait, initial) {
function cammie_error() {
$("#cammie-feed").attr("src","/assets/images/cammie_down.svg")
}
var cammieTimeout = null;
function cammie_loaded() {
if (cammieTimeout) {
clearTimeout(cammieTimeout);
}
showWarning = function() {
if (!navigator.onLine) {
document.getElementById("cammieFeedDisconnected").textContent = "Lost connection to the server, reload the page to resume viewing";
}
document.getElementById("cammieFeedDisconnected").classList.remove("is-hidden");
};
cammieTimeout = setTimeout(showWarning, 5000);
}

$("#cammie-ctrls").mousemove(debounce(function() {
return $(this).removeClass('display');
Expand Down
7 changes: 6 additions & 1 deletion content/cammie.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ socket.on('replymessage', function(obj) {
<% end %>

<section id="cammie-section">
<div id="cammieFeedDisconnected" class="notification is-danger is-light is-hidden">
Camera feed automatically disconnected due to inactivity, reload the page to resume viewing
<br>
Cammie is meant for checking if the kelder is busy before coming and shouldn't be left open for longer periods of time
</div>
<div id="cammie-body">
<figure class="image is-16by9">
<img id="cammie-feed" alt="cammie" src="https://kelder.zeus.ugent.be/camera/cammie" onerror="cammie_error()">
<img id="cammie-feed" alt="cammie" src="https://kelder.zeus.ugent.be/camera/cammie" onerror="cammie_error()" onload="cammie_loaded()">
</figure>
<div id="cammie-ctrls">
<div class="columns is-mobile">
Expand Down

0 comments on commit 9bba5e4

Please sign in to comment.