Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamBenes3 committed Dec 1, 2023
1 parent 037b4ef commit b8a2c4e
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,19 @@
.then(data => {
if (data) {
car1 = data.data;
var timestamp = new Date(car1.timestamp);
timestamp.setHours(timestamp.getHours() + 1);
var currentTimestamp = new Date();
var timeDifferenceInSeconds = (currentTimestamp - timestamp) / 1000;
if (timeDifferenceInSeconds < 60) {
timestampBackgroundColor = 'rgba(0, 128, 0, 0.7)';
} else if (timeDifferenceInSeconds >= 60 && timeDifferenceInSeconds <= 300) {
timestampBackgroundColor = 'rgba(255, 165, 0, 0.7)';
} else {
timestampBackgroundColor = 'rgba(255, 0, 0, 0.7)';
}
document.getElementById('car1Panel').textContent = timestamp.toLocaleString('en-US', { hour12: false }) + ", (-" + timeDifferenceInSeconds + "s)";
document.getElementById('car1Panel').style.backgroundColor = timestampBackgroundColor;
} else {
console.log('Received undefined data from the server');
}
Expand All @@ -629,6 +642,19 @@
.then(data => {
if (data) {
car2 = data.data;
var timestamp = new Date(car2.timestamp);
timestamp.setHours(timestamp.getHours() + 1);
var currentTimestamp = new Date();
var timeDifferenceInSeconds = (currentTimestamp - timestamp) / 1000;
if (timeDifferenceInSeconds < 60) {
timestampBackgroundColor = 'rgba(0, 128, 0, 0.7)';
} else if (timeDifferenceInSeconds >= 60 && timeDifferenceInSeconds <= 300) {
timestampBackgroundColor = 'rgba(255, 165, 0, 0.7)';
} else {
timestampBackgroundColor = 'rgba(255, 0, 0, 0.7)';
}
document.getElementById('car2Panel').textContent = timestamp.toLocaleString('en-US', { hour12: false }) + ", (-" + timeDifferenceInSeconds + "s)";
document.getElementById('car2Panel').style.backgroundColor = timestampBackgroundColor;
} else {
console.log('Received undefined data from the server');
}
Expand All @@ -646,6 +672,19 @@
.then(data => {
if (data) {
car3 = data.data;
var timestamp = new Date(car3.timestamp);
timestamp.setHours(timestamp.getHours() + 1);
var currentTimestamp = new Date();
var timeDifferenceInSeconds = (currentTimestamp - timestamp) / 1000;
if (timeDifferenceInSeconds < 60) {
timestampBackgroundColor = 'rgba(0, 128, 0, 0.7)';
} else if (timeDifferenceInSeconds >= 60 && timeDifferenceInSeconds <= 300) {
timestampBackgroundColor = 'rgba(255, 165, 0, 0.7)';
} else {
timestampBackgroundColor = 'rgba(255, 0, 0, 0.7)';
}
document.getElementById('car3Panel').textContent = timestamp.toLocaleString('en-US', { hour12: false }) + ", (-" + timeDifferenceInSeconds + "s)";
document.getElementById('car3Panel').style.backgroundColor = timestampBackgroundColor;
} else {
console.log('Received undefined data from the server');
}
Expand Down

0 comments on commit b8a2c4e

Please sign in to comment.