word cards: refactor js

This commit is contained in:
Ren Tatsumoto 2022-01-21 12:40:48 +03:00
parent 8c2a2aca6c
commit 52c75cbd06

View file

@ -34,39 +34,23 @@ Thu Feb 4 01:06:07 AM UTC 2021
}
function splitTagDiv() {
const header = document.getElementsByTagName("header")[0];
if (!header) return;
const header = document.querySelector("header");
if (header) {
const tags = `{{Tags}}`.split(" ");
header.innerHTML = "";
for (const tag of tags) {
if (tag.includes("DisableGyousyo")) {
continue;
}
const tag_elem = document.createElement("div");
tag_elem.className = "tags";
tag_elem.innerHTML = tag;
header.appendChild(tag_elem);
}
}
}
splitTagDiv()
highlightNames()
applyQuizFont()
</script>
<script>
// Hides DisableGyousyo from tags.
document.addEventListener('DOMContentLoaded', tagActions(), false);
function hidedisablegyousyo() {
const tags_elems = document.getElementsByClassName("tags");
for (const tag_elem of tags_elems) {
if (tag_elem.innerHTML.includes("DisableGyousyo")) {
tag_elem.style.display = "none";
}
}
}
function tagActions() {
hidedisablegyousyo()
}
</script>