diff options
author | Mantas <11616378+mistermantas@users.noreply.github.com> | 2019-01-24 19:23:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-24 19:23:35 +0200 |
commit | 4a968698e45ece04b25f41783298b9b397a191a1 (patch) | |
tree | 57ae06a3d7344f234ba71a12b7962144b8eb5472 /layouts/partials/js.html | |
parent | 8a1aaf4737e90406119bdf5770937eea924729aa (diff) |
cState is now stable on v3.0 - 2019-01-24 (info: #41)
Diffstat (limited to 'layouts/partials/js.html')
-rw-r--r-- | layouts/partials/js.html | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/layouts/partials/js.html b/layouts/partials/js.html index 6282729..af3bb80 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -3,9 +3,8 @@ * Dev toolset */ - console.log('You are using cState v2.0.1: https://github.com/cstate/cstate'); - document.querySelector('html').className = 'js'; - + console.log('cState v3.0.0 - Stable 2019-01-24 - https://github.com/cstate/cstate'); + document.getElementsByTagName('html')[0].className = 'js'; /** * Make theme color pretty @@ -21,13 +20,25 @@ } } + /** + * Admin redirect + */ + + if (window.location.hash.match('access_token')) { + document.location.pathname = '/admin'; + } + + /** + * Timer + */ + function hasClass(element, className) { return (' ' + element.className + ' ').indexOf(' ' + className+ ' ') > -1; } if (hasClass(document.querySelector('body'), 'status-homepage')) { var lastUpdated = document.querySelector('.summary__date'); - lastUpdated.innerHTML = 'Last checked just now'; + lastUpdated.innerHTML = '{{ T "lastChecked" }} {{ T "justNow" }}'; var lastUpdate = new Date(); @@ -37,32 +48,32 @@ var interval = Math.floor(seconds / 31536000); if (interval > 1) { - return interval + ' years'; + return interval + ' {{ T "yearsAgo" }}'; } interval = Math.floor(seconds / 2592000); if (interval > 1) { - return interval + ' months'; + return interval + ' {{ T "monthsAgo" }}'; } interval = Math.floor(seconds / 86400); if (interval > 1) { - return interval + 'd'; + return interval + '{{ T "daysAgo" }}'; } interval = Math.floor(seconds / 3600); if (interval > 1) { - return interval + 'h'; + return interval + '{{ T "hoursAgo" }}'; } interval = Math.floor(seconds / 60); if (interval > 1) { - return interval + ' min'; + return interval + ' {{ T "minsAgo" }}'; } - return Math.floor(seconds) + 's'; + return Math.floor(seconds) + '{{ T "secondsAgo" }}'; } var aDay = 24*60*60*1000; } window.setInterval(function() { if (hasClass(document.querySelector('body'), 'status-homepage')) { - lastUpdated.innerHTML = 'Last checked ' + timeSince(lastUpdate) + ' ago'; + lastUpdated.innerHTML = '{{ T "lastChecked" }} ' + timeSince(lastUpdate) + ' {{ T "someTimeAgo" }}'; // Refresh almost every 5m if (lastUpdate > 290000) { |