Control of root/url base form

This commit is contained in:
aunefyren 2022-12-04 16:06:16 +01:00
parent 29d9f8f81d
commit 469c897eed
2 changed files with 32 additions and 1 deletions

View file

@ -827,6 +827,8 @@ function set_wrapperr_settings() {
function set_wrapperr_settings_call() {
var wrapperr_root_original = wrapperr_root;
document.getElementById("set_wrapperr_settings_form_button").disabled = true;
document.getElementById("set_wrapperr_settings_form_button").style.opacity = '0.5';
@ -843,6 +845,25 @@ function set_wrapperr_settings_call() {
clear_cache = document.getElementById('clear_cache').checked;
winter_theme = document.getElementById('winter_theme').checked;
if(wrapperr_root_original !== wrapperr_root) {
if(!confirm("You have changed the Wrapperr root/base URL. Wrapperr will attempt to restart and the interface to access this webpage will change. If you are using an URL base you must use a trailing '/' at the end of your new URL.")){
return;
}
}
if(wrapperr_root !== "") {
var wrapperr_root_last_char = wrapperr_root.charAt(wrapperr_root.length-1);
var wrapperr_root_first_char = wrapperr_root.charAt(0);
if(wrapperr_root_last_char == "/" || wrapperr_root_first_char == "/") {
document.getElementById("set_wrapperr_settings_form_button").disabled = false;
document.getElementById("set_wrapperr_settings_form_button").style.opacity = '1';
alert("No trailing or initial '/' needed for URL base.");
document.getElementById('wrapperr_root').focus();
return;
}
}
if(timezone === '') {
document.getElementById("set_wrapperr_settings_form_button").disabled = false;
document.getElementById("set_wrapperr_settings_form_button").style.opacity = '1';

View file

@ -372,7 +372,17 @@ function get_wrapper_version() {
}
};
xhttp.withCredentials = true;
xhttp.open("post", window.location + "api/get/wrapperr-version");
var url_current = window.location.toString();
var last_char = url_current.charAt(window.location.length-1);
if(last_char == "/") {
var init_url = window.location
} else {
var init_url = window.location + "/"
}
xhttp.open("post", init_url + "api/get/wrapperr-version");
xhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhttp.send();
return;