From a6c8143d466d73cea9c2c9739fc1401301888d3c Mon Sep 17 00:00:00 2001
From: nrb <freifunk@nicoboehr.de>
Date: Sun, 3 Jan 2021 12:53:04 +0100
Subject: [PATCH] fix autorefresh

---
 update_checker.html | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/update_checker.html b/update_checker.html
index 591ca4b..b36d72c 100644
--- a/update_checker.html
+++ b/update_checker.html
@@ -12,16 +12,20 @@
 		table td, table th { border: 1px solid #000; border-left:0; border-right:0 }
 	</style>
 	<script>
+		function formatTime(time) {
+			return time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
+		}
 		function refreshUpdates() {
 			$.getJSON("/update_checker/data.json", function(data) {
-				$("#lastUpdate").text(data.timestamp)
+				var lastUpdate = new Date(data.timestamp * 1000)
+				var lastFetch = new Date()
+				$("#lastUpdate").text(formatTime(lastUpdate) + " (fetch: " + formatTime(lastFetch) + ")")
 				var downloadedOffline = $("#downloadedOffline")
 				var downloaded = $("#downloaded")
 				downloadedOffline.empty()
 				downloaded.empty()
 				$.each(data["update_events"], function(k, upd) {
 					var line = $("<tr/>")
-					console.log(upd)
 					var maplink = "https://map.freifunk-stuttgart.de/#!/en/map/" + upd.mac.replace(/:/g, "").toLowerCase()
 					$("<td/>").append($("<a/>").text(upd.hostname).attr("href", maplink)).appendTo(line)
 					$("<td/>").text(upd.mac).appendTo(line)
@@ -38,7 +42,6 @@
 					$("<td/>").text(upd.download_count).appendTo(line)
 					$("<td/>").text(upd.last_date).appendTo(line)
 
-					console.log(line)
 					if (upd.status) {
 						downloaded.append(line)
 					} else {
@@ -49,7 +52,7 @@
 		}
 		$(document).ready(function() {
 			refreshUpdates()
-			//window.setInterval(refreshUpdates, 60*1000);
+			window.setInterval(refreshUpdates, 60*1000);
 		})
 	</script>
 </head>
-- 
GitLab