Skip to content

Commit

Permalink
Control of root/url base form
Browse files Browse the repository at this point in the history
  • Loading branch information
aunefyren committed Dec 4, 2022
1 parent 29d9f8f commit 469c897
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
21 changes: 21 additions & 0 deletions web/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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';
Expand Down
12 changes: 11 additions & 1 deletion web/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 469c897

Please sign in to comment.