From 4a968698e45ece04b25f41783298b9b397a191a1 Mon Sep 17 00:00:00 2001 From: Mantas <11616378+mistermantas@users.noreply.github.com> Date: Thu, 24 Jan 2019 19:23:35 +0200 Subject: cState is now stable on v3.0 - 2019-01-24 (info: #41) --- layouts/partials/js.html | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'layouts/partials/js.html') 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) { -- cgit v1.2.3-70-g09d2