woodburn/assets/js/status.js
Nathan Woodburn be65929ca3
All checks were successful
Build Docker / CheckFiles (push) Successful in 10s
Build Docker / Build Docker (push) Successful in 22s
main: Added status checks on websites
2023-07-28 14:17:53 +10:00

51 lines
2.1 KiB
JavaScript

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
checkStatuses();