From e1c490ffb26acecda6c46b46936ca3b474a738ba Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Tue, 28 Jun 2022 17:14:16 +0200
Subject: [PATCH] fix timer

---
 public_html/javascript/functions.js | 5 +----
 public_html/javascript/ubd.class.js | 8 ++++----
 public_html/main.css                | 2 +-
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/public_html/javascript/functions.js b/public_html/javascript/functions.js
index 69497a1..a2b55a0 100644
--- a/public_html/javascript/functions.js
+++ b/public_html/javascript/functions.js
@@ -289,7 +289,7 @@ var oUbdApps=new ubd(
         'url':       _getUrlWithTags, // remark: this is a function
         'header':    { "headers": oHeaders },
         'renderer':  _getAllAppsStatus,
-        'ttl':       0,
+        'ttl':       REFRESHTIME,
     }
 );
 
@@ -299,8 +299,5 @@ var oUbdApps=new ubd(
 oUbdTag.update();
 oUbdApps.update();
 
-// cyclic updates of the app status view
-window.setInterval("oUbdApps.update();", REFRESHTIME*1000);
-
 
 // ----------------------------------------------------------------------
\ No newline at end of file
diff --git a/public_html/javascript/ubd.class.js b/public_html/javascript/ubd.class.js
index 49f54a4..2d8de80 100644
--- a/public_html/javascript/ubd.class.js
+++ b/public_html/javascript/ubd.class.js
@@ -147,7 +147,7 @@ var ubd = function(){
         // clearInterval(this._oTimer);
         if(this._iTTL) {
             let self = this;
-            self._oTimer=window.setTimeout(self.update, this._iTTL*1000);
+            self._oTimer=window.setTimeout( function(){ self.update() }, this._iTTL*1000);
             // self._oTimer=window.setInterval(self.update, this._iTTL*1000);
         }
     },
@@ -165,9 +165,9 @@ var ubd = function(){
             return 0;
         }
         try{
-            let response = await fetch(url, self._oHeader);
+            let response = await fetch(url, this._oHeader);
             if (response.ok) {
-                self._body=await response.json();
+                this._body=await response.json();
                 
                 this.render();
             } else {
@@ -183,7 +183,7 @@ var ubd = function(){
             +'</div>');
             console.error(e);
         }
-
+        this.resetTimer();
     }
 
     // ----------------------------------------------------------------------
diff --git a/public_html/main.css b/public_html/main.css
index d07dc79..d6fde9d 100644
--- a/public_html/main.css
+++ b/public_html/main.css
@@ -64,7 +64,7 @@ td{vertical-align: top;}
 .app .url{font-size: 80%; font-weight: normal; margin-right: 2em;}
 
 .result0{background:#dfd    !important; background: linear-gradient(#ded,#beb)!important;       color:#383}
-.result1{background:#eee    !important; background: linear-gradient(#eee,#ddd)!important;       color:#666;}
+.result1{background:#eee    !important; background: linear-gradient(#ede,#dbd)!important;       color:#666;}
 .result2{background:#fff8d0 !important; background: linear-gradient(#fff0d0,#ffe0a0)!important; color:#870;}
 .result3{background:#fcd    !important; background: linear-gradient(#fcd,#faa)!important;       color:#800;}
 
-- 
GitLab