Skip to content

Commit

Permalink
Merge pull request #606 from ZeusWPI/disconnect-warning
Browse files Browse the repository at this point in the history
Add warning on camera feed disconnect
  • Loading branch information
redfast00 authored Oct 27, 2023
2 parents 08fd8e1 + 81bbcb2 commit 8071e22
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
21 changes: 20 additions & 1 deletion content/assets/scripts/cammie.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,27 @@ debounce = function(func, wait, initial) {
};
};

var cammieError = false;
function cammie_error() {
$("#cammie-feed").attr("src","/assets/images/cammie_down.svg")
cammieError = true;
document.getElementById("cammie-ctrls").remove();
document.getElementById("cammie-ctrls-2").remove();
$("#cammie-feed").attr("src","/assets/images/cammie_down.svg")
}
var cammieTimerStarted = false;
function cammie_loaded() {
if (cammieTimerStarted) {
return;
}
showWarning = function() {
if (!cammieError) {
document.getElementById("cammieFeedDisconnected").classList.remove("is-hidden");
document.getElementById("cammie-ctrls").remove();
document.getElementById("cammie-ctrls-2").remove();
}
};
setTimeout(showWarning, 25000);
cammieTimerStarted = true;
}

$("#cammie-ctrls").mousemove(debounce(function() {
Expand Down
9 changes: 7 additions & 2 deletions 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 Expand Up @@ -59,7 +64,7 @@ socket.on('replymessage', function(obj) {
</div>
</div>

<nav class="columns mt-0">
<nav id="cammie-ctrls-2" class="columns mt-0">
<div class="column">
<button class="button is-primary is-full-width ctrl" data-command="set_pos" data-x="43" data-y="15">
Kleine tafel
Expand Down

0 comments on commit 8071e22

Please sign in to comment.