aboutsummaryrefslogtreecommitdiff
path: root/anki-card-template/card.js
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-01-28 10:22:25 +0100
committerlonkaars <loek@pipeframe.xyz>2023-01-28 10:22:25 +0100
commitc351f01b12a13c149e3946e2393071903dc245ce (patch)
treeae293ac89420e1d28396f729084a9993047e5cbe /anki-card-template/card.js
parent7f752ac3f2165e08ed2041a13488db3a8740722c (diff)
fix onorientationchange handler + opacity for non-highlighted text in sentence instead of hardcoded hex values2.2.2
Diffstat (limited to 'anki-card-template/card.js')
-rw-r--r--anki-card-template/card.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/anki-card-template/card.js b/anki-card-template/card.js
index d110c33..3cc7bee 100644
--- a/anki-card-template/card.js
+++ b/anki-card-template/card.js
@@ -128,8 +128,10 @@ function parseFurigana(nodes) {
var alwaysvisisble = false; // if furigana is always visible (on front of card)
var kanji = ""; // current kanji
var reading = ""; // current kanji reading
+ var normal = ""; // normal text
+ var flush_normal = () => { out += `<span class="normal">${normal}</span>`; normal = ""; };
- for (var i = 0; i < input.length; i++) {
+ for (var i = 0; i < input.length; i++, lastmode = mode) {
// parse [kanji](reading) into ruby text
// [kanji](reading) is only visible on card back
// {kanji}(reading) is always visible
@@ -142,16 +144,18 @@ function parseFurigana(nodes) {
if (mode == "kanji" && kanji.length > 0 && input[i] == "(") // reading open
{ reading = ""; mode = "reading"; continue; }
if (mode == "reading" && input[i] == ")") { // reading close
+ flush_normal();
mode = "normal";
out += `<ruby>${kanji}<rt class="${alwaysvisisble ? 'visible' : 'hidden'}">${reading}</rt></ruby>`;
continue;
}
// add current character to selected mode buffer
- if (mode == "normal") out += input[i];
+ if (mode == "normal") normal += input[i];
if (mode == "kanji") kanji += input[i];
if (mode == "reading") reading += input[i];
}
+ flush_normal();
return out;
});
}
@@ -325,3 +329,5 @@ run();
window.onload = () => run();
window.onresize = () => layout();
window.ondeviceorientation = () => layout();
+window.screen.orientation.onchange = () => layout();
+