diff options
author | Mantas Vilčinskas <hi@mnts.lt> | 2021-02-24 13:48:14 +0200 |
---|---|---|
committer | Mantas Vilčinskas <hi@mnts.lt> | 2021-02-24 13:48:14 +0200 |
commit | 925027e85b74a77e06448be5baa6053f1222fb78 (patch) | |
tree | b5dc98f1a5828764ec653cd37dc4b70585faf47d /layouts/partials/js.html | |
parent | 867f6a5dc8118d0d6f903eea75484c59e296d37e (diff) |
Doc updates, bugfixes, add rel time to NCMS
Diffstat (limited to 'layouts/partials/js.html')
-rw-r--r-- | layouts/partials/js.html | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 8465483..d966643 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -3,11 +3,11 @@ * Dev toolset */ - console.log('cState v4.4 - https://github.com/cstate/cstate'); + console.log('cState v5 Dev - https://github.com/cstate/cstate'); document.getElementsByTagName('html')[0].className = 'js'; /** - * Make theme color pretty + * Change header color based on status */ if (document.body.className === 'change-header-color') { @@ -43,6 +43,7 @@ /** * Returns a relative date string for the given date. */ + function timeSince(date) { var seconds = Math.floor((new Date() - date) / 1000); @@ -78,6 +79,7 @@ * Changes elements with the class 'relative-time' into relative times and * moves the timestamp to a title attribute tooltip. */ + function updateRelativeTimes() { var elements = document.querySelectorAll('.relative-time'); for (var i = 0; i < elements.length; i++) { @@ -95,21 +97,17 @@ element.innerHTML = html.trim(); } } + updateRelativeTimes(); - setInterval(updateRelativeTimes, 5000); - /** - * Reload homepage after 290 seconds. - */ - if (document.querySelector('body.status-homepage')) { - setTimeout(location.reload, 290000) - } + // Update "time since" feature every 5s + setInterval(updateRelativeTimes, 5000); </script> {{ if ne .Site.Params.googleAnalytics "UA-00000000-1" }} <!-- Global site tag (gtag.js) - Google Analytics --> - <script type="text/javascript" defer src="https://www.googletagmanager.com/gtag/js?id=UA-109775664-1"></script> + <script type="text/javascript" defer src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.googleAnalytics }}"></script> <script type="text/javascript" defer> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} |