Skip to content

Commit 01fdeef

Browse files
committed
fixed error with newlines in fields
1 parent 254d485 commit 01fdeef

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

PrettyYomitanCardsDemo.apkg

13.7 KB
Binary file not shown.

backTemplate.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@
376376

377377
///////////////////// Side Tab Logic ////////////////////////////////////////////////////////////////////
378378
// disable the Sentence Tab. if it doesn't differ from the expression or no sentence has been provided
379-
if('{{Expression}}'==='{{Sentence}}' || sentence.textContent === '')
379+
if(sentence.textContent.trim() === '' || `{{Expression}}`.trim() === sentence.textContent.trim())
380380
{
381381
document.getElementById('ex-tab').classList.add('disabled');
382382
}
@@ -393,7 +393,7 @@
393393
}
394394

395395
// disable the Furigana Tab for Sentences, that don't contain any
396-
if(sentence.textContent === sentenceFurigana.textContent || sentenceFurigana.textContent === '') {
396+
if(sentence.textContent.trim() === sentenceFurigana.textContent.trim() || sentenceFurigana.textContent.trim() === '') {
397397
document.getElementById('ex-furi-tab').classList.add('disabled');
398398
}
399399

@@ -463,9 +463,9 @@
463463
for(let k=0; k<meaning.childNodes.length; k++) {
464464
let id = meaning.childNodes[k].id;
465465
ids.push(id);
466-
document.getElementById(id+'-tab').addEventListener('click', () => { switchHiddenContent(ids, k) }); // todo: find a way to pass value not reference
466+
document.getElementById(id+'-tab').addEventListener('click', () => { switchHiddenContent(ids, k) });
467467
}
468-
switchHiddenContent(ids, 0);
468+
switchHiddenContent(ids, 0);
469469
}
470470

471471
setupHideFunctionality('pitch-tab', 'pitch-content', null, show_pitch_by_default);

frontTemplate.html

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
<div class="main" lang="ja">
2626
<div id="expr-field" class="expression-field content bottom">
27-
<span class="expression fill-flex">
27+
<span id="expr" class="expression fill-flex">
2828
{{Expression}}
2929
</span>
3030
<aside class="tab corner-offset">
@@ -43,6 +43,11 @@
4343

4444

4545
<script>
46+
47+
var expression = document.getElementById('expr');
48+
49+
var sentence = document.getElementById('ex-plain');
50+
4651
// clip rgb values to fit [0, 255] range
4752
for(var i=0; i<colorRGB.length; i++)
4853
colorRGB[i] = (colorRGB[i]>255) ? 255 : ((colorRGB[i]<0) ? 0 : colorRGB[i]);
@@ -99,7 +104,7 @@
99104
}
100105

101106
// because yomitan/-chan also adds one-word sentences
102-
if("{{Expression}}"=="{{Sentence}}")
107+
if(sentence.textContent.trim() === '' || expression.textContent.trim() === sentence.textContent.trim())
103108
{
104109
document.getElementById('ex-tab').classList.add('disabled');
105110
}

0 commit comments

Comments
 (0)