From 78b3b15525d756c5b522b07e98049dcb9c024a6a Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 17:12:45 -0400 Subject: Add .relative-time class and JS logic --- layouts/partials/index/summary.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'layouts/partials/index/summary.html') diff --git a/layouts/partials/index/summary.html b/layouts/partials/index/summary.html index de6bceb..dcf753c 100644 --- a/layouts/partials/index/summary.html +++ b/layouts/partials/index/summary.html @@ -20,5 +20,5 @@ {{ end }}{{ end }}{{ end }} -
- \ No newline at end of file +
+ -- cgit v1.2.3-70-g09d2 From 656f716ecb87ac563e1566592472a65db7019409 Mon Sep 17 00:00:00 2001 From: Kevin Hamer Date: Sun, 11 Oct 2020 17:18:40 -0400 Subject: fix IE bug; rename 'data-prefix' to 'data-time-prefix' and add unused 'data-time-suffix' --- layouts/partials/index/summary.html | 2 +- layouts/partials/js.html | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) (limited to 'layouts/partials/index/summary.html') diff --git a/layouts/partials/index/summary.html b/layouts/partials/index/summary.html index dcf753c..41f285b 100644 --- a/layouts/partials/index/summary.html +++ b/layouts/partials/index/summary.html @@ -20,5 +20,5 @@ {{ end }}{{ end }}{{ end }} -
+
diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 7971bc5..c4c5a85 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -75,26 +75,30 @@ * moves the timestamp to a title attribute tooltip. */ function updateRelativeTimes() { - document.querySelectorAll('.relative-time') - .forEach(function(element) { - var time = Date.parse(element.getAttribute('title')); - var html = element.getAttribute('data-prefix') || ''; - if (!time) { - time = element.innerText; - element.setAttribute('title', time || new Date); - html += '{{ T "justNow" }}'; - } else { - html += timeSince(time) + ' {{ T "someTimeAgo" }}'; - } - element.innerHTML = html.trim(); - }) + var elements = document.querySelectorAll('.relative-time'); + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + var time = Date.parse(element.getAttribute('title')); + var html = element.getAttribute('data-time-prefix') || ''; + if (!time) { + time = element.innerText; + element.setAttribute('title', time || new Date); + html += '{{ T "justNow" }}'; + } else { + html += timeSince(time) + ' {{ T "someTimeAgo" }}'; + } + html += element.getAttribute('data-time-suffix') || ''; + element.innerHTML = html.trim(); + } } updateRelativeTimes(); setInterval(updateRelativeTimes, 5000); - // Reload homepage eevery 290 seconds + /** + * Reload homepage after 290 seconds. + */ if (document.querySelector('body.status-homepage')) { - setInterval(location.reload, 290000) + setTimeout(location.reload, 290000) } -- cgit v1.2.3-70-g09d2