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

fix autorefresh

parent 128d20f3
Branches
No related tags found
No related merge requests found
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment