2020-07-20 11:44:57 +00:00
|
|
|
{% macro show_metadata(query_metadata) %}
|
2020-07-16 14:00:38 +00:00
|
|
|
|
2020-07-20 11:44:57 +00:00
|
|
|
<div class="col s12">
|
2020-07-21 11:40:17 +00:00
|
|
|
<table class="highlight">
|
2020-07-20 07:31:27 +00:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-07-22 11:15:55 +00:00
|
|
|
<th style="width: 33%">Metadata Description</th>
|
|
|
|
<th style="width: 66%">Value</th>
|
2020-07-20 07:31:27 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for pair in query_metadata|dictsort %}
|
|
|
|
<tr>
|
2020-07-22 11:15:55 +00:00
|
|
|
<td>{{ pair[0]|replace("_", " ")|upper() }}</td>
|
2020-07-20 11:44:57 +00:00
|
|
|
{% if pair[0] == "corpus_all_texts"
|
|
|
|
or pair[0] == "text_lookup" %}
|
2020-07-20 07:31:27 +00:00
|
|
|
<td>
|
2020-07-22 11:15:55 +00:00
|
|
|
<ul class="collapsible">
|
|
|
|
{% for key, value in pair[1].items() %}
|
|
|
|
<li class="text-metadata"
|
|
|
|
data-metadata-key="{{ pair[0] }}"
|
|
|
|
data-text-key="{{ key }}">
|
|
|
|
<div class="collapsible-header"
|
2020-07-20 07:31:27 +00:00
|
|
|
data-metadata-key="{{ pair[0] }}"
|
2020-07-22 11:15:55 +00:00
|
|
|
data-text-key="{{ key }}">
|
|
|
|
<i class="material-icons"
|
|
|
|
data-metadata-key="{{ pair[0] }}"
|
|
|
|
data-text-key="{{ key }}">info_outline</i>
|
|
|
|
{{ value['author'] }} - {{ value['publishing_year'] }}
|
|
|
|
- {{ value['title'] }}
|
|
|
|
</div>
|
|
|
|
<div class="collapsible-body">
|
|
|
|
<span>
|
|
|
|
<ul id="bibliographic-data-{{ pair[0] }}-{{ key }}"
|
|
|
|
style="column-count: 2;">
|
|
|
|
</ul>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
2020-07-20 07:31:27 +00:00
|
|
|
</td>
|
|
|
|
{% else %}
|
|
|
|
<td>{{ pair[1] }}</td>
|
|
|
|
{% endif %}
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2020-07-20 11:44:57 +00:00
|
|
|
</div>
|
2020-07-16 14:00:38 +00:00
|
|
|
|
|
|
|
<script>
|
2020-07-22 11:15:55 +00:00
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
let elems = document.querySelectorAll('.collapsible');
|
|
|
|
let instances = M.Collapsible.init(elems, {accordion: false});
|
|
|
|
});
|
|
|
|
let collapsibles = document.getElementsByClassName("text-metadata");
|
|
|
|
for (let collapsible of collapsibles) {
|
|
|
|
collapsible.onclick = () => {
|
2020-07-16 14:00:38 +00:00
|
|
|
let metadataKey = event.target.dataset.metadataKey;
|
|
|
|
let textKey = event.target.dataset.textKey;
|
|
|
|
let textData = {{ query_metadata|tojson|safe }}[metadataKey][textKey];
|
2020-07-22 11:15:55 +00:00
|
|
|
let bibliographicData = document.getElementById(`bibliographic-data-${metadataKey}-${textKey}`);
|
2020-07-16 14:00:38 +00:00
|
|
|
bibliographicData.innerHTML = "";
|
|
|
|
for (let [key, value] of Object.entries(textData)) {
|
2020-07-22 11:15:55 +00:00
|
|
|
bibliographicData.insertAdjacentHTML("afterbegin",
|
2020-07-16 14:00:38 +00:00
|
|
|
`
|
2020-07-22 11:15:55 +00:00
|
|
|
<li><span style="text-transform: capitalize;">${key}:</span> ${value}</li>
|
2020-07-16 14:00:38 +00:00
|
|
|
`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-07-20 07:31:27 +00:00
|
|
|
</script>
|
|
|
|
{% endmacro %}
|