mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Reset front end values on server select change
This commit is contained in:
parent
ef39564c0a
commit
3c0df76c4a
@ -1201,6 +1201,10 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("#server option").each(function () {
|
||||||
|
$(this).remove()
|
||||||
|
})
|
||||||
|
|
||||||
// create new options ordered by ascending
|
// create new options ordered by ascending
|
||||||
versions.forEach(type => {
|
versions.forEach(type => {
|
||||||
newOption = document.createElement("option");
|
newOption = document.createElement("option");
|
||||||
@ -1231,47 +1235,5 @@
|
|||||||
$('.version-hint').popover("hide");
|
$('.version-hint').popover("hide");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function serverJarChange(selectObj) {
|
|
||||||
const type_select = document.getElementById('server_jar')
|
|
||||||
const tidx = type_select.selectedIndex;
|
|
||||||
const val = type_select.options[tidx].value;
|
|
||||||
let jcSelect = {};
|
|
||||||
if (val == 'None') {
|
|
||||||
jcSelect = document.getElementById("server_type");
|
|
||||||
while (jcSelect.options.length > 0) {
|
|
||||||
jcSelect.remove(0);
|
|
||||||
}
|
|
||||||
serverTypeChange(selectObj);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// get the index of the selected option
|
|
||||||
let jidx = selectObj.selectedIndex;
|
|
||||||
// get the value of the selected option
|
|
||||||
let jwhich = selectObj.options[jidx].value;
|
|
||||||
// use the selected option value to retrieve the list of items from the serverTypesLists array
|
|
||||||
let jcList = Object.keys(serverTypesLists[jwhich]);
|
|
||||||
// get the country select element via its known id
|
|
||||||
jcSelect = document.getElementById("server_type");
|
|
||||||
// remove the current options from the country select
|
|
||||||
while (jcSelect.options.length > 0) {
|
|
||||||
jcSelect.remove(0);
|
|
||||||
}
|
|
||||||
let jnewOption;
|
|
||||||
// create new options ordered by ascending
|
|
||||||
jcList.forEach(type => {
|
|
||||||
jnewOption = document.createElement("option");
|
|
||||||
jnewOption.value = jwhich + "|" + type; // assumes option string and value are the same
|
|
||||||
jnewOption.text = type;
|
|
||||||
// add the new option
|
|
||||||
try {
|
|
||||||
jcSelect.add(jnewOption); // this will fail in DOM browsers but is needed for IE
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
jcSelect.appendChild(jnewOption);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
serverTypeChange(selectObj);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
{% end %}
|
{% end %}
|
Loading…
Reference in New Issue
Block a user