diff options
-rw-r--r-- | back-template.m4 | 14 | ||||
-rw-r--r-- | card/card.js | 6 | ||||
-rw-r--r-- | front-template.m4 | 7 |
3 files changed, 16 insertions, 11 deletions
diff --git a/back-template.m4 b/back-template.m4 index 77a8abf..b0b7eda 100644 --- a/back-template.m4 +++ b/back-template.m4 @@ -1,10 +1,3 @@ -<style> -undivert(`card/card.css') -</style> -<script defer> -undivert(`card.min.js') -</script> - <div class="card back"> <span class="sentence">{{Complete sentence}}</span> <hr class="split"> @@ -13,3 +6,10 @@ undivert(`card.min.js') <span class="sentence-translation">{{Complete sentence translation}}</span> </div> +<style> +undivert(`card/card.css') +</style> +<script defer> +undivert(`card.min.js') +</script> + diff --git a/card/card.js b/card/card.js index ad744b7..e31564f 100644 --- a/card/card.js +++ b/card/card.js @@ -30,8 +30,12 @@ function parseSentence(input) { function run() { var sentences = document.getElementsByClassName("sentence"); - for (var sentence of sentences) + for (var sentence of sentences) { + if (sentence.classList.contains("parsed")) continue; sentence.innerHTML = parseSentence(sentence.innerText); + sentence.classList.add("parsed"); + } } run(); +window.onload = () => run(); diff --git a/front-template.m4 b/front-template.m4 index 832069c..534477d 100644 --- a/front-template.m4 +++ b/front-template.m4 @@ -1,3 +1,7 @@ +<div class="card front"> +<span class="sentence">{{Complete sentence}}</span> +</div> + <style> undivert(`card/card.css') </style> @@ -5,6 +9,3 @@ undivert(`card/card.css') undivert(`card.min.js') </script> -<div class="card front"> -<span class="sentence">{{Complete sentence}}</span> -</div> |