1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-26 16:45:52 +00:00

Insert branches into <select> in template

This commit is contained in:
Unrud 2021-12-05 13:26:36 +01:00
parent f3508e4947
commit 664ddc6737
3 changed files with 46 additions and 53 deletions

View file

@ -1,15 +1,16 @@
window.addEventListener("load", function() {
let select = document.querySelector("header .documentBranch select");
while (select.length > 0) {
select.remove(0);
}
for (let branch of documentBranches) {
select.add(new Option(branch, branch, branch === documentBranch, branch === documentBranch), 0);
}
select.addEventListener("change", function() {
if (select.value !== documentBranch) {
location.assign(encodeURIComponent(select.value + ".html"));
select.value = documentBranch;
function resetSelect(select) {
for (let option of select.options) {
option.selected = option.defaultSelected;
}
}
let select = document.querySelector("header .documentBranch select");
resetSelect(select);
select.addEventListener("change", function() {
let option = select.selectedOptions.item(0);
if (option && !option.defaultSelected) {
location.assign(option.value);
}
resetSelect(select);
});
});