woodburn/assets/js/status.js
Nathan Woodburn 858610d3a8
Some checks failed
Build Docker / FixFiles (push) Successful in 6s
Build Docker / CheckFiles (push) Failing after 6s
Build Docker / Build Docker (push) Has been skipped
Build Docker / Build ARM Docker (push) Has been skipped
feat: Add analytics
2023-12-13 12:56:10 +11:00

50 lines
2.2 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();