Format challenge #91
This commit is contained in:
parent
969a506cf1
commit
0fd14132ff
3 changed files with 26 additions and 3 deletions
|
@ -11,8 +11,10 @@
|
|||
{{- partial "nav.html" . -}}
|
||||
<div id="challenge">
|
||||
<div>
|
||||
{{ if not .Params.override }}
|
||||
<button id="direction" title="Text direction">↕</button>
|
||||
<button lang="ja" id="highlight" title="Vocab/kanji links">漢字</button>
|
||||
{{ end }}
|
||||
<button lang="ja" id="kyujitai" title="Shinjitai/kyujitai">旧字体</button>
|
||||
{{ if .Params.english }}
|
||||
<button id="english" title="Show/hide translation">Show translation</button>
|
||||
|
@ -22,6 +24,12 @@
|
|||
<h3>Tegaki Tuesday #{{- $current -}}</h3>
|
||||
<small><ruby>手<rp>(</rp><rt>て</rt><rp>)</rp></ruby><ruby>書<rp>(</rp><rt>が</rt><rp>)</rp></ruby>きの<ruby>火<rp>(</rp><rt>か</rt><rp>)</rp></ruby><ruby>曜<rp>(</rp><rt>よう</rt><rp>)</rp></ruby><ruby>日<rp>(</rp><rt>び</rt><rp>)</rp></ruby>#{{- $current -}}・<time datetime="{{- .Date.Format " 2006-01-02T15:04:05Z07:00" -}}">{{- .Date.Format "2006年01月02日" -}}</time></small>
|
||||
</header>
|
||||
{{ if .Params.override }}
|
||||
<div>
|
||||
{{ .Params.override | safeHTML }}
|
||||
</div>
|
||||
{{ else }}
|
||||
|
||||
{{ if .Params.english }}
|
||||
<div id="challenge-english" style="display: none">
|
||||
<!-- English view -->
|
||||
|
@ -101,6 +109,7 @@
|
|||
{{- end -}}
|
||||
{{- end -}}
|
||||
</div>
|
||||
{{ end }}
|
||||
<script src="/js/toggle.js"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,9 +7,11 @@ const defaultHeight = challenge.scrollHeight + "px";
|
|||
let verticalHeight;
|
||||
challenge.style.height = defaultHeight;
|
||||
|
||||
let texts = [];
|
||||
const vocab = document.getElementById("challenge-vocab");
|
||||
if (vocab) texts.push(vocab);
|
||||
const kanji = document.getElementById("challenge-kanji");
|
||||
const texts = [vocab, kanji];
|
||||
if (kanji) texts.push(kanji);
|
||||
|
||||
const rubies = document.getElementsByTagName("ruby");
|
||||
let kyujitaiConvertable = [];
|
||||
|
@ -24,8 +26,8 @@ for (let i = 0; i < rubies.length; i++) {
|
|||
}
|
||||
ruby.shinjitai = pair[0];
|
||||
ruby.kyujitai = pair[1];
|
||||
const encodedURIComponent = encodeURIComponent(pair[0]).toLowerCase();
|
||||
if (ruby.parentNode.nodeName === "A" && ruby.parentNode.href.includes(encodedURIComponent) && ruby.parentNode.href.endsWith("%23kanji")) {
|
||||
const encodedURIComponent = encodeURIComponent(pair[0]);
|
||||
if (ruby.parentNode.nodeName === "A" && ruby.parentNode.href.toUpperCase().includes(encodedURIComponent) && ruby.parentNode.href.endsWith("%23kanji")) {
|
||||
ruby.parentNode.shinjitaiHref = ruby.parentNode.href;
|
||||
ruby.parentNode.kyujitaiHref = ruby.parentNode.href.replace(encodedURIComponent, encodeURIComponent(pair[1]));
|
||||
kyujitaiConvertableLinks.push(ruby.parentNode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue