2021-11-27 14:58:45 +00:00
|
|
|
<!--
|
2022-10-14 21:22:13 +00:00
|
|
|
mpvacious cards, version 14.0
|
|
|
|
Thu Oct 20 02:37:35 PM UTC 2022
|
2021-11-27 14:58:45 +00:00
|
|
|
-->
|
|
|
|
|
|
|
|
<div class="wrap">
|
2021-12-25 03:19:58 +00:00
|
|
|
<header>
|
2022-10-24 15:41:56 +00:00
|
|
|
{{#Focus}}
|
|
|
|
<div class="tags">{{Focus}}</div>
|
|
|
|
{{/Focus}}
|
2021-12-25 03:19:58 +00:00
|
|
|
{{#Tags}}
|
|
|
|
<div class="tags">{{Tags}}</div>
|
|
|
|
{{/Tags}}
|
|
|
|
</header>
|
2021-11-27 14:58:45 +00:00
|
|
|
|
2021-12-25 03:19:58 +00:00
|
|
|
<div class="sent-center">
|
|
|
|
<div class="jpsentence" lang="ja">
|
2022-11-02 19:01:21 +00:00
|
|
|
{{edit:furigana:SentKanji}}
|
2021-12-25 03:19:58 +00:00
|
|
|
{{^SentKanji}}
|
|
|
|
<nokana>{{edit:kanji:SentFurigana}}</nokana>
|
|
|
|
{{/SentKanji}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-09-12 16:58:13 +00:00
|
|
|
|
2022-10-24 16:46:37 +00:00
|
|
|
{{#Image}}<div class="images on-front">{{Image}}</div>{{/Image}}
|
2021-11-27 14:58:45 +00:00
|
|
|
</div> <!-- /wrap -->
|
|
|
|
|
|
|
|
<div style="display:none;">
|
|
|
|
<div id="pitchnum_hidden">{{VocabPitchNum}}</div>
|
|
|
|
<div id="kanaword_hidden">{{kana:VocabFurigana}}</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
/* Paints the question word according to its Pitch Accent number.
|
|
|
|
* blue for 平板
|
|
|
|
* red for 頭高
|
|
|
|
* orange for 中高
|
|
|
|
* green for 尾高
|
|
|
|
*/
|
|
|
|
function markPitch() {
|
|
|
|
let pitchNumber = document.getElementById("pitchnum_hidden");
|
|
|
|
if (pitchNumber === null) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
pitchNumber = pitchNumber.innerHTML.match(/\d/);
|
|
|
|
}
|
|
|
|
if (pitchNumber === null) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
pitchNumber = Number(pitchNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Then decide what color to use and change font color accordingly. */
|
|
|
|
if (pitchNumber == 0) {
|
|
|
|
// use blue for 平板
|
|
|
|
paintTargetWord("#3366CC");
|
|
|
|
} else if (pitchNumber == 1) {
|
|
|
|
// use red for 頭高
|
|
|
|
paintTargetWord("red");
|
|
|
|
} else if (pitchNumber > 1) {
|
|
|
|
if (odaka(pitchNumber)) {
|
|
|
|
// use green for 尾高
|
|
|
|
paintTargetWord("green");
|
|
|
|
} else {
|
|
|
|
// use orange for 中高
|
|
|
|
paintTargetWord("#ff6207");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function paintTargetWord(color) {
|
2022-04-18 18:21:56 +00:00
|
|
|
for (const word of document.querySelectorAll(".jpsentence b, .jpsentence strong")) {
|
2022-04-17 14:37:06 +00:00
|
|
|
word.style.color = color;
|
2021-11-27 14:58:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function odaka(pitch_num) {
|
|
|
|
// word is odaka if number of moras is equal to pitch accent position
|
|
|
|
const vocab_kana = document.getElementById("kanaword_hidden");
|
|
|
|
if (vocab_kana === null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// small っ is one mora; ゃゅょ are parts of single mora
|
2021-12-25 03:19:58 +00:00
|
|
|
const n_moras = vocab_kana.innerHTML.replace(/[ャュョゃゅょ]/g, "").length;
|
2021-11-27 14:58:45 +00:00
|
|
|
if (n_moras == pitch_num) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Splits tags into separate divs */
|
|
|
|
function splitTagDiv() {
|
|
|
|
const header = document.querySelector("header");
|
|
|
|
if (!header) return;
|
2022-10-24 15:41:56 +00:00
|
|
|
const split = `{{Focus}} {{Tags}}`.split(" ");
|
2021-11-27 14:58:45 +00:00
|
|
|
|
|
|
|
header.innerHTML = "";
|
|
|
|
|
|
|
|
for (const tag of split) {
|
2021-12-25 03:19:58 +00:00
|
|
|
if (tag.length < 1) continue;
|
2021-11-27 14:58:45 +00:00
|
|
|
const tag_elem = document.createElement("div");
|
|
|
|
tag_elem.className = "tags";
|
2022-09-12 16:58:13 +00:00
|
|
|
tag_elem.innerText = tag;
|
2021-11-27 14:58:45 +00:00
|
|
|
header.appendChild(tag_elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-12 16:58:13 +00:00
|
|
|
function setImageOnFront() {
|
|
|
|
const tags = `{{Tags}}`.split(" ");
|
|
|
|
const front_img = document.querySelector("div.images.on-front");
|
|
|
|
if (front_img && tags.includes("imageonfront")) {
|
|
|
|
front_img.classList.toggle("on-front");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-25 03:19:58 +00:00
|
|
|
markPitch();
|
|
|
|
splitTagDiv();
|
2022-09-12 16:58:13 +00:00
|
|
|
setImageOnFront();
|
2021-12-25 03:19:58 +00:00
|
|
|
</script>
|