mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-11 21:40:17 +02:00
Merge branch 'evetime-js-update' into 'master'
Evetime js update See merge request allianceauth/allianceauth!1395
This commit is contained in:
commit
26017056c7
@ -1,58 +1,20 @@
|
||||
$(document).ready(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* check time
|
||||
* @param i
|
||||
* @returns {string}
|
||||
*/
|
||||
let checkTime = function (i) {
|
||||
if (i < 10) {
|
||||
i = '0' + i;
|
||||
}
|
||||
|
||||
return i;
|
||||
};
|
||||
|
||||
/**
|
||||
* render a JS clock for Eve Time
|
||||
* @param element
|
||||
* @param utcOffset
|
||||
*/
|
||||
let renderClock = function (element, utcOffset) {
|
||||
let today = new Date();
|
||||
let h = today.getUTCHours();
|
||||
let m = today.getUTCMinutes();
|
||||
|
||||
h = h + utcOffset;
|
||||
|
||||
if (h > 24) {
|
||||
h = h - 24;
|
||||
}
|
||||
|
||||
if (h < 0) {
|
||||
h = h + 24;
|
||||
}
|
||||
|
||||
h = checkTime(h);
|
||||
m = checkTime(m);
|
||||
const renderClock = function (element) {
|
||||
const datetimeNow = new Date();
|
||||
const h = String(datetimeNow.getUTCHours()).padStart(2, '0');
|
||||
const m = String(datetimeNow.getUTCMinutes()).padStart(2, '0');
|
||||
|
||||
element.html(h + ':' + m);
|
||||
|
||||
setTimeout(function () {
|
||||
renderClock(element, 0);
|
||||
}, 500);
|
||||
};
|
||||
|
||||
/**
|
||||
* functions that need to be executed on load
|
||||
*/
|
||||
let init = function () {
|
||||
renderClock($('.eve-time-wrapper .eve-time-clock'), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* start the show
|
||||
*/
|
||||
init();
|
||||
// Start the Eve time clock in the top menu bar
|
||||
setInterval(function () {
|
||||
renderClock($('.eve-time-wrapper .eve-time-clock'));
|
||||
}, 500);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user