display usb-butter section if the usb-butter directory yields 200

This commit is contained in:
John Hess 2024-01-03 21:18:32 -06:00
parent fbcf287319
commit f3362f56f0
4 changed files with 29 additions and 0 deletions

View file

@ -32,3 +32,15 @@ const btnModal = document.querySelector('.btn-modal');
btnModal.addEventListener('click', (event) => {
event.preventDefault();
});
// If #usb-butter exists and a request to thishost.tld/usb-butter returns status 200
// change display of #usb-butter to inherit
const usbButter = document.querySelector('#usb-butter');
if (usbButter) {
fetch('/usb-butter')
.then(response => {
if (response.status === 200) {
usbButter.style.display = 'inherit';
}
});
}