From 1f56b15fb263547598ab22e3df093b98d49d60db Mon Sep 17 00:00:00 2001 From: gth001 Date: Sun, 15 Oct 2023 22:06:26 -0700 Subject: [PATCH] This fixes the issue of a "stale" CGM value displaying indefinately. It displays "Internet offline." until internet is restored. This fix addresses the issue that with a lost internet connection, clock view continues to display a stale CGM values forever, with no clue that internet connectivity is lost. This fix shows "Internet offline." for the duration that is it lost, then returns to normal when internet is restored. --- views/clockviews/clock.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/views/clockviews/clock.html b/views/clockviews/clock.html index 2893aec3612..ea83f93164d 100644 --- a/views/clockviews/clock.html +++ b/views/clockviews/clock.html @@ -92,6 +92,25 @@ window.addEventListener('click', function() { showClose(); }); + + // This fixes the issue of a "stale" CGM value displaying indefinately. + // It displays "Internet offline." until internet is restored. + function uOffline() { + document.body.innerHTML = + 'Internet offline.' + } + // Return to normal as soon as internet connectivity is restored. + function uOnline() { + location.reload() + } + if(window.addEventListener) { + window.addEventListener('offline', uOffline); + window.addEventListener('online', uOnline); + } else { + document.body.attachEvent('onoffline', uOffline); + document.body.attachEvent('ononline', uOnline); + } + <% } %> <%if (face == 'config') { %>