serveranzeige/popup.js

26 lines
1008 B
JavaScript

document.addEventListener('DOMContentLoaded', function () {
checkServerStatus("https://example-1.com", "Server-1");
checkServerStatus("https://example-2.com", "Server-2");
checkServerStatus("https://example-3.com", "Server-3");
checkServerStatus("https://example-4.com", "Server-4");
});
function checkServerStatus(url, statusElementId) {
fetch(url)
.then(response => {
var statusElement = document.getElementById(statusElementId);
if (response.status === 200) {
statusElement.textContent = 'Online';
statusElement.style.color = '#00FF00'; // Grün für online
} else {
statusElement.textContent = 'Offline';
statusElement.style.color = '#FF0000'; // Rot für offline
}
})
.catch(error => {
var statusElement = document.getElementById(statusElementId);
statusElement.textContent = 'Offline';
statusElement.style.color = '#FF0000'; // Rot für offline
});
}