2021-11-27 15:15:10 +00:00
|
|
|
<!--
|
2023-03-07 02:21:16 +00:00
|
|
|
Simple Word Cards, version 6.0
|
|
|
|
Fri Feb 24 07:22:23 PM UTC 2023
|
2021-11-27 15:15:10 +00:00
|
|
|
-->
|
|
|
|
<div class="wrap">
|
|
|
|
{{#Tags}}
|
|
|
|
<header>
|
|
|
|
<div class="tags">{{Tags}}</div>
|
|
|
|
</header>
|
|
|
|
{{/Tags}}
|
2022-01-21 09:30:01 +00:00
|
|
|
<div class="japanese question" id="question">
|
2021-11-27 15:15:10 +00:00
|
|
|
{{edit:furigana:VocabKanji}}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function highlightNames() {
|
|
|
|
const tags_elems = document.getElementsByClassName("tags");
|
|
|
|
for (const tag_elem of tags_elems) {
|
|
|
|
if (tag_elem.innerHTML.includes("キャラ") || tag_elem.innerHTML.includes("有名人")) {
|
|
|
|
tag_elem.style.backgroundColor = "brown";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function splitTagDiv() {
|
2022-01-21 09:40:48 +00:00
|
|
|
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);
|
|
|
|
}
|
2021-11-27 15:15:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-07 02:21:16 +00:00
|
|
|
function formatNewRuby(kanji, readings) {
|
|
|
|
if (readings.length > 1) {
|
|
|
|
return `<ruby>${formatNewRuby(kanji, readings.slice(0, -1))}</ruby><rt>${readings.slice(-1)}</rt>`
|
|
|
|
} else {
|
|
|
|
return `<rb>${kanji}</rb><rt>${readings.join('')}</rt>`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function reformatMultiFurigana() {
|
|
|
|
const separators = /[\s;,.、・。]+/iu;
|
|
|
|
document.querySelectorAll("ruby").forEach(ruby => {
|
|
|
|
try {
|
|
|
|
const kanji = (ruby.querySelector("rb") || ruby.firstChild).textContent.trim()
|
|
|
|
const readings = ruby.querySelector("rt").textContent
|
|
|
|
.split(separators)
|
|
|
|
.map(str => str.trim())
|
|
|
|
.filter(str => str.length)
|
|
|
|
if (readings.length > 1) {
|
|
|
|
ruby.innerHTML = formatNewRuby(kanji, readings)
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
splitTagDiv();
|
|
|
|
highlightNames();
|
|
|
|
reformatMultiFurigana();
|
2022-01-01 22:05:58 +00:00
|
|
|
</script>
|