Skip to content
Snippets Groups Projects
Commit a6c8143d authored by Nico's avatar Nico
Browse files

fix autorefresh

parent 128d20f3
No related branches found
No related tags found
No related merge requests found
...@@ -12,16 +12,20 @@ ...@@ -12,16 +12,20 @@
table td, table th { border: 1px solid #000; border-left:0; border-right:0 } table td, table th { border: 1px solid #000; border-left:0; border-right:0 }
</style> </style>
<script> <script>
function formatTime(time) {
return time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds()
}
function refreshUpdates() { function refreshUpdates() {
$.getJSON("/update_checker/data.json", function(data) { $.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 downloadedOffline = $("#downloadedOffline")
var downloaded = $("#downloaded") var downloaded = $("#downloaded")
downloadedOffline.empty() downloadedOffline.empty()
downloaded.empty() downloaded.empty()
$.each(data["update_events"], function(k, upd) { $.each(data["update_events"], function(k, upd) {
var line = $("<tr/>") var line = $("<tr/>")
console.log(upd)
var maplink = "https://map.freifunk-stuttgart.de/#!/en/map/" + upd.mac.replace(/:/g, "").toLowerCase() 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/>").append($("<a/>").text(upd.hostname).attr("href", maplink)).appendTo(line)
$("<td/>").text(upd.mac).appendTo(line) $("<td/>").text(upd.mac).appendTo(line)
...@@ -38,7 +42,6 @@ ...@@ -38,7 +42,6 @@
$("<td/>").text(upd.download_count).appendTo(line) $("<td/>").text(upd.download_count).appendTo(line)
$("<td/>").text(upd.last_date).appendTo(line) $("<td/>").text(upd.last_date).appendTo(line)
console.log(line)
if (upd.status) { if (upd.status) {
downloaded.append(line) downloaded.append(line)
} else { } else {
...@@ -49,7 +52,7 @@ ...@@ -49,7 +52,7 @@
} }
$(document).ready(function() { $(document).ready(function() {
refreshUpdates() refreshUpdates()
//window.setInterval(refreshUpdates, 60*1000); window.setInterval(refreshUpdates, 60*1000);
}) })
</script> </script>
</head> </head>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment