[setup] make niceurl testing more accurate, see #1024

This commit is contained in:
Shish
2024-02-07 20:44:39 +00:00
parent e9c8e852a5
commit 9f9ee49e02
2 changed files with 24 additions and 25 deletions

23
ext/setup/script.js Normal file
View File

@ -0,0 +1,23 @@
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 => {
if(response.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)';
});
}
});