list available languages and topics for links, and allow for their dynamic display

This commit is contained in:
2020-02-27 14:29:26 +01:00
parent 5c273ce8c2
commit 7be63977ac
6 changed files with 160 additions and 108 deletions

View File

@@ -0,0 +1,47 @@
/*
* SPDX-FileCopyrightText: 2020 Max Mehl <https://mehl.mx>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
function selectTag(tag) {
let li_tags = document.querySelectorAll('li.link');
for (i = 0; i < li_tags.length; i++) {
tags = li_tags[i].getAttribute('tags');
if (tags.indexOf(tag) !== -1) {
li_tags[i].style.display = "list-item";
} else {
li_tags[i].style.display = "none";
}
}
let a_tags = document.querySelectorAll('a.tag');
for (i = 0; i < a_tags.length; i++) {
tags = a_tags[i].getAttribute('tags');
if (tags.indexOf(tag) !== -1) {
a_tags[i].classList.add("active");
} else {
a_tags[i].classList.remove("active");
}
}
}
function selectAllTags() {
let li_tags = document.querySelectorAll('li.link');
for (i = 0; i < li_tags.length; i++) {
li_tags[i].style.display = "list-item";
}
let a_tags = document.querySelectorAll('a.tag');
for (i = 0; i < a_tags.length; i++) {
tags = a_tags[i].getAttribute('tags');
if (tags == "all") {
a_tags[i].classList.add("active");
} else {
a_tags[i].classList.remove("active");
}
}
}