diff --git a/ext/setup/main.php b/ext/setup/main.php index 5c3d76b7..1b185ce9 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -355,30 +355,6 @@ class Setup extends Extension $themes[$human] = $name; } - $test_url = str_replace("/index.php", "/nicetest", $_SERVER["SCRIPT_NAME"]); - - $nicescript = ""; $sb = $event->panel->create_new_block("General"); $sb->position = 0; $sb->add_text_option(SetupConfig::TITLE, "Site title: "); @@ -388,7 +364,7 @@ class Setup extends Extension $sb->add_choice_option(SetupConfig::THEME, $themes, "
Theme: "); //$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "
Test Array: "); $sb->add_bool_option("nice_urls", "
Nice URLs: "); - $sb->add_label("(Javascript inactive, can't test!)$nicescript"); + $sb->add_label("(Javascript inactive, can't test!)"); $sb = $event->panel->create_new_block("Remote API Integration"); $sb->add_label("Akismet"); diff --git a/ext/setup/script.js b/ext/setup/script.js new file mode 100644 index 00000000..2e113b8b --- /dev/null +++ b/ext/setup/script.js @@ -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)'; + }); + } +});