This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/setup/script.js

30 lines
1.1 KiB
JavaScript
Raw Normal View History

document.addEventListener('DOMContentLoaded', () => {
const checkbox = document.getElementById('nice_urls');
const out_span = document.getElementById('nicetest');
if(checkbox !== null && out_span !== null) {
checkbox.disabled = true;
out_span.innerHTML = '(testing...)';
fetch(document.body.getAttribute('data-base-href') + "/nicetest").then(response => {
2024-02-07 22:27:47 +00:00
if(!response.ok) {
checkbox.disabled = true;
2024-02-07 22:27:47 +00:00
out_span.innerHTML = '(http error)';
} else {
response.text().then(text => {
if(text === 'ok') {
checkbox.disabled = false;
out_span.innerHTML = '(test passed)';
} else {
checkbox.disabled = true;
out_span.innerHTML = '(test failed)';
}
});
}
}).catch(() => {
checkbox.disabled = true;
out_span.innerHTML = '(request failed)';
});
}
});