1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
Alex Kotov da5d97fbc2
Rewrite templates 2023-03-25 21:12:17 +04:00
Alex Kotov e681533b0b
Move title change out of a template function 2023-03-25 21:05:34 +04:00
2 changed files with 20 additions and 50 deletions

View File

@ -14,7 +14,10 @@ window.leqsikoni = {
$.getJSON( $.getJSON(
'http://localhost:4567/words/' + word_id, 'http://localhost:4567/words/' + word_id,
window.leqsikoni.words_xxxxx_template, function(data) {
document.title = window.leqsikoni.maybe_text(data.primary_form) || ''
$('#words-xxxxx').html(window.leqsikoni.words_xxxxx_template(data))
},
) )
}, },
@ -34,39 +37,29 @@ window.leqsikoni = {
var examples = var examples =
window.leqsikoni.words_xxxxx_examples_template(options.examples) window.leqsikoni.words_xxxxx_examples_template(options.examples)
document.title = primary_form || '' var html = ''
$('#primary-form').text(primary_form || '') if (primary_form) {
$('#part-of-speech').text(part_of_speech || '') html += '<h1>' + primary_form + '</h1>'
$('#commentary-data').text(commentary || '') }
if (part_of_speech) {
$('#translations-data').html(translations || '') html += '<p>' + part_of_speech + '</p>'
$('#inflections-data').html(inflections || '')
$('#examples-data').html(examples || '')
if (commentary) {
$('#commentary').removeClass('invisible')
} else {
$('#commentary').addClass('invisible')
} }
if (translations) { if (translations) {
$('#translations').removeClass('invisible') html += '<div><h2>Значения</h2><div>' + translations + '</div></div>'
} else { }
$('#translations').addClass('invisible') if (commentary) {
html += '<div><h2>Комментарий</h2><p>' + commentary + '</p></div>'
} }
if (inflections) { if (inflections) {
$('#inflections').removeClass('invisible') html += '<div><h2>Inflectioons</h2><div>' + inflections + '</div></div>'
} else { }
$('#inflections').addClass('invisible') if (examples) {
html +=
'<div><h2>Примеры употребления</h2><div>' + examples + '</div></div>'
} }
if (examples) { return html
$('#examples').removeClass('invisible')
} else {
$('#examples').addClass('invisible')
}
}, },
words_xxxxx_translations_template: function(translations) { words_xxxxx_translations_template: function(translations) {

View File

@ -8,29 +8,6 @@
<body> <body>
<div id="words-xxxxx"></div> <div id="words-xxxxx"></div>
<h1 id="primary-form"></h1>
<p id="part-of-speech"></p>
<div id="translations" class="invisible">
<h2>Значения</h2>
<div id="translations-data"></div>
</div>
<div id="commentary" class="invisible">
<h2>Комментарий</h2>
<p id="commentary-data"></p>
</div>
<div id="inflections" class="invisible">
<h2>Inflections</h2>
<div id="inflections-data"></div>
</div>
<div id="examples" class="invisible">
<h2>Примеры употребления</h2>
<div id="examples-data"></div>
</div>
<script <script
src="https://code.jquery.com/jquery-3.6.3.min.js" src="https://code.jquery.com/jquery-3.6.3.min.js"
integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU="