function selectedDomain() {
dom = [...document.querySelectorAll('#domain option')].filter((el) => {return el.selected}).at(0).text
return dom.match(/\S+/g)[0]
}
function getDefaultDocroot() {
var hostname;
if (document.querySelector('#hostname').value == '')
hostname = selectedDomain();
else
hostname = document.querySelector('#hostname').value + '.' + selectedDomain();
return hostname + '/htdocs';
}
function useDefaultDocroot( default_docroot ) {
var do_it = document.querySelector('#use_default_docroot').checked;
var inputfield = document.querySelector('#docroot');
inputfield.disabled = do_it;
if (do_it) {
document.querySelector('#docroot').value = getDefaultDocroot();
}
}
function showAppropriateLines() {
type = [...document.querySelectorAll('input[name="vhost_type"]')].filter((el) => {return el.checked}).at(0).value
switch (type) {
case "regular":
document.querySelector('#options_docroot').style.display = '';
document.querySelector('#options_scriptlang').style.display = '';
break;
case "dav":
document.querySelector('#options_docroot').style.display = '';
document.querySelector('#options_scriptlang').style.display = 'none';
break;
case "svn":
document.querySelector('#options_docroot').style.display = 'none';
document.querySelector('#options_scriptlang').style.display = 'none';
break;
}
}
function showhsts( event ) {
ssl = [...document.querySelectorAll('#ssl option')].filter((el) => {return el.selected}).at(0).value
if (ssl == 'forward') {
document.querySelector('#hsts_block').style.display = '';
cert = [...document.querySelectorAll('#cert option')].filter((el) => {return el.selected}).at(0).value
if (cert == '') {
document.querySelector('#cert').value = '-1';