Merge pull request #2501 from phl0/satTimers

Add forgotten files in PR 2500
This commit is contained in:
Peter Goodhall 2023-09-19 13:12:45 +01:00 committed by GitHub
commit 154dd0d72a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 83 additions and 0 deletions

36
assets/css/sattimers.css Normal file
View 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;
}

View 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 = "&#x274C;";
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 = "&#x2705;";
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);
}