From e870db2edd560ec36bdc7ce79e23be992cdecba3 Mon Sep 17 00:00:00 2001 From: Mathieu Strypsteen Date: Thu, 26 Oct 2023 15:28:23 +0200 Subject: [PATCH] Add warning on camera feed disconnect --- content/assets/scripts/cammie.js | 13 +++++++++++++ content/cammie.erb | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/content/assets/scripts/cammie.js b/content/assets/scripts/cammie.js index d8442fe5..1a15e382 100644 --- a/content/assets/scripts/cammie.js +++ b/content/assets/scripts/cammie.js @@ -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'); diff --git a/content/cammie.erb b/content/cammie.erb index b75898a5..209e0859 100644 --- a/content/cammie.erb +++ b/content/cammie.erb @@ -16,9 +16,14 @@ socket.on('replymessage', function(obj) { <% end %>
+
- cammie + cammie