From c3b59bce5af64d1903c4d5b286d079892dbfb48e Mon Sep 17 00:00:00 2001 From: Dave Behnke <916775+dbehnke@users.noreply.github.com> Date: Sat, 8 Oct 2022 01:59:28 -0400 Subject: [PATCH 1/2] add some date time routines to display times in user's local time. format: under a minute displays seconds ago, under 5 minutes shows minutes ago, same day shows only the time, date and time displayed for previous day --- VERSION | 2 +- templates/index.html | 69 ++++++++++++++++++++++++++++++++++++++++---- templates/links.html | 2 +- templates/peers.html | 2 +- 4 files changed, 66 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 1750564..5a5831a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.6 +0.0.7 diff --git a/templates/index.html b/templates/index.html index 3d4d63c..8888eec 100644 --- a/templates/index.html +++ b/templates/index.html @@ -21,7 +21,7 @@ ${ station.callsignsuffix } ${ station.vianode } ${ station.onmodule } - ${ station.lastheard } + ${ station.lastheardlocal } @@ -67,11 +67,68 @@ } }, methods: { - fetchStationsList () { - $.getJSON('{{ .config.SubPath }}/json/stations', (stationdata) => { - this.stationdata = stationdata - }); - }, + fetchStationsList () { + $.getJSON('{{ .config.SubPath }}/json/stations', (stationdata) => { + stationdata.stations.forEach(function(station, index) { + function getDateString(dt) { + console.log(dt) + const year = dt.getFullYear() + const m = dt.getMonth() + 1 + var month = "" + m + if (m < 10) { + month = "0" + m + } + const d = dt.getDate() + var day = "" + d + if (d < 10) { + day = "0" + d + } + return (day+"."+month+"."+year) + } + function getTimeString(dt) { + const h = dt.getHours() + var hour = "" + h + if (h < 10) { + hour = "0" + h + } + const m = dt.getMinutes() + var min = "" + m + if (m < 10) { + min = "0" + m + } + //const s = dt.getSeconds() + //var sec = "" + s + //if (s < 10) { + // sec = "0" + s + //} + return (hour+":"+min) + } + function diffSeconds(dt2, dt1) { + var diff =(dt2.getTime() - dt1.getTime()) / 1000; + + return Math.abs(Math.round(diff)); + } + function localTimeString(dateTimeString) { + const now = new Date(); + const then = new Date(dateTimeString) + if (now.toLocaleDateString() == then.toLocaleDateString()) { + const dSeconds = diffSeconds(now, then) + if (dSeconds < 60) { + return(dSeconds + " sec ago") + } + if (dSeconds < 60 * 5) { + return(Math.abs(Math.round(dSeconds / 60)) + " min ago") + } + return(getTimeString(then)) + } + return(getDateString(then) + " " + getTimeString(then)) + } + station.lastheardlocal = localTimeString(station.lastheard) + stationdata.stations[index] = station + }); + this.stationdata = stationdata + }); + }, }, mounted() { this.timer = setInterval(this.fetchStationsList, refreshTime) diff --git a/templates/links.html b/templates/links.html index c1632f7..477a1e2 100644 --- a/templates/links.html +++ b/templates/links.html @@ -48,7 +48,7 @@ }); }, }, - mounted() { + created() { this.timer = setInterval(this.fetchLinksList, refreshTime) this.fetchLinksList() }, diff --git a/templates/peers.html b/templates/peers.html index de2fc24..e9be1ff 100644 --- a/templates/peers.html +++ b/templates/peers.html @@ -46,7 +46,7 @@ }); }, }, - mounted() { + created() { this.timer = setInterval(this.fetchPeersList, refreshTime) this.fetchPeersList() }, From d8b6683abd9239c54b84c6a2b247765c5f5ea5d1 Mon Sep 17 00:00:00 2001 From: Steve Miller <43918257+kc1awv@users.noreply.github.com> Date: Sat, 8 Oct 2022 08:11:28 -0400 Subject: [PATCH 2/2] Update VERSION bump version to release --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 5a5831a..6e8bf73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.7 +0.1.0