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:
parent
f3508e4947
commit
664ddc6737
3 changed files with 46 additions and 53 deletions
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue