mirror of
https://github.com/magicbug/Cloudlog
synced 2024-11-23 18:24:25 +00:00
Merge pull request #2501 from phl0/satTimers
Add forgotten files in PR 2500
This commit is contained in:
commit
154dd0d72a
36
assets/css/sattimers.css
Normal file
36
assets/css/sattimers.css
Normal file
@ -0,0 +1,36 @@
|
||||
.title {
|
||||
text-align: center;
|
||||
font-family: sans-serif;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.active {
|
||||
font-family: sans-serif;
|
||||
color: #3fb618;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.timedout {
|
||||
font-family: sans-serif;
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.nonfunctional {
|
||||
font-family: sans-serif;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.timeout {
|
||||
font-family: sans-serif;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.expired {
|
||||
font-family: sans-serif;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.emoji {
|
||||
font-size: 1.2em;
|
||||
margin: 0;
|
||||
}
|
47
assets/js/sections/sattimers.js
Normal file
47
assets/js/sections/sattimers.js
Normal file
@ -0,0 +1,47 @@
|
||||
function update(i) {
|
||||
|
||||
var now = new Date();
|
||||
if (dateArray[i] == 0) {
|
||||
var element = document.getElementById("tevel"+i+"Timer");
|
||||
element.innerHTML = "NOT FUNCTIONAL";
|
||||
element.classList.add("nonfunctional");
|
||||
element = document.getElementById("emoji"+i);
|
||||
element.innerHTML = "💀";
|
||||
} else {
|
||||
|
||||
//var distance = dateArray[i] - now.getTime();
|
||||
var distance = parseInt(dateArray[i]) - new Date(now.getTime()+now.getTimezoneOffset()*60*1000);
|
||||
var satDate = new Date(parseInt(dateArray[i]) - now.getTimezoneOffset()*60*1000);
|
||||
|
||||
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
||||
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||||
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||||
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||||
|
||||
if (distance < 0) {
|
||||
clearInterval(x);
|
||||
var element = document.getElementById("tevel"+i+"Timer");
|
||||
element.innerHTML = "TIMED OUT";
|
||||
element.classList.add("timedout");
|
||||
element = document.getElementById("emoji"+i);
|
||||
element.innerHTML = "❌";
|
||||
element = document.getElementById("tevel"+i+"Timeout");
|
||||
element.className = "expired";
|
||||
element.innerHTML = "(timed-out: "+satDate.toLocaleDateString()+" "+satDate.toLocaleTimeString()+")";
|
||||
} else {
|
||||
var element = document.getElementById("tevel"+i+"Timer");
|
||||
element.innerHTML = days + "d " + hours + "h " + minutes.toString().padStart(2, '0') + "m " + seconds.toString().padStart(2, '0') + "s";
|
||||
element.classList.add("active");
|
||||
element = document.getElementById("emoji"+i);
|
||||
element.innerHTML = "✅";
|
||||
element = document.getElementById("tevel"+i+"Timeout");
|
||||
element.innerHTML = "(until: "+satDate.toLocaleDateString()+" "+satDate.toLocaleTimeString()+")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i=1; i<=12; i++) {
|
||||
var x = setInterval(function() {
|
||||
update(i);
|
||||
}, 1000);
|
||||
}
|
Loading…
Reference in New Issue
Block a user