1
0
em.0x45.cz/templates/posts.html

38 lines
961 B
HTML
Raw Normal View History

2021-12-04 21:34:47 +01:00
{% extends "index.html" %}
{% block title %}
{{ section.title }} — {{ config.title }}
{% endblock %}
{% block content %}
<h1>{{ section.title }}</h1>
2021-12-04 22:05:33 +01:00
<input id="search" class="search" type="text" placeholder="Search titles" oninput="filter_name(this.value)">
2021-12-04 21:34:47 +01:00
{{ macros::list_posts() }}
{% endblock content %}
2021-12-04 22:05:33 +01:00
{% block script %}
<script>
function filter_name(str)
{
str = str.toLowerCase();
if (str.length == 0) {
for (let i = 0; i < articles.length; i++) {
articles[i].style.display = "block";
}
} else {
for (let i = 0; i < articles.length; i++) {
let name = articles[i].getElementsByTagName("h2")[0].innerHTML.toLowerCase();
if (!name.includes(str)) {
articles[i].style.display = "none";
} else {
articles[i].style.display = "block";
}
}
}
}
let articles = document.getElementsByTagName("article");
let search = document.getElementById("search");
search.style.display = "inline-block";
</script>
{% endblock %}