woodburn/assets/js/status.js

50 lines
2.2 KiB
JavaScript
Raw Normal View History

2023-12-13 12:56:10 +11:00
function checkStatus(url, callback) {
fetch(url, {
method: 'GET',
mode: 'no-cors'
}).then(function(response) {
callback('up');
}
).catch(function(error) {
callback('down');
}
);
}
// Check every 5 seconds
setInterval(function() {
checkStatuses();
}, 5000);
function checkStatuses(){
checkStatus('https://nathan.woodburn.au', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('nathan-woodburn-au').style.color = '#00ff00';
else document.getElementById('nathan-woodburn-au').style.color = '#ff0000';
});
checkStatus('https://nathan3dprinting.au', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('nathan3dprinting-au').style.color = '#00ff00';
else document.getElementById('nathan3dprinting-au').style.color = '#ff0000';
});
checkStatus('https://podcast.woodburn.au', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('podcast-woodburn-au').style.color = '#00ff00';
else document.getElementById('podcast-woodburn-au').style.color = '#ff0000';
});
checkStatus('https://uptime.woodburn.au', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('uptime-woodburn-au').style.color = '#00ff00';
else document.getElementById('uptime-woodburn-au').style.color = '#ff0000';
});
checkStatus('https://reg.woodburn.au', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('reg-woodburn-au').style.color = '#00ff00';
else document.getElementById('reg-woodburn-au').style.color = '#ff0000';
});
checkStatus('https://hnscall', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('hnscall').style.color = '#00ff00';
else document.getElementById('hnscall').style.color = '#ff0000';
});
checkStatus('https://hnshosting', function(updateStatus) {
if (updateStatus == 'up') document.getElementById('hnshosting').style.color = '#00ff00';
else document.getElementById('hnshosting').style.color = '#ff0000';
});
}
// Check on load
2023-07-28 14:17:53 +10:00
checkStatuses();