Skip to content

add search and fix size to filter on page #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,54 @@
{% load i18n %}
<h3>{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}</h3>
<ul class="mulitple-choice">
{% for choice in choices %}
{% if choice.reset %}
<li{% if choice.selected %} class="selected"{% endif %}>
<a href="{{ choice.query_string|iriencode }}" title="{{ choice.display }}">{{ choice.display }}</a>
</li>
{% endif %}
{% endfor %}
{% for choice in choices %}
{% if not choice.reset %}
<li{% if choice.selected %} class="selected"{% endif %}>
<a href="{{ choice.query_string|iriencode }}" title="{{ choice.display }}" style="display:inline">{{ choice.display }}</a>
{% if choice.selected and choice.exclude_query_string %}
<a class="small" href="{{ choice.exclude_query_string|iriencode }}" style="display:inline">(exclude)</a>
{% endif %}
{% if not choice.selected and choice.include_query_string %}
<a class="small" href="{{ choice.include_query_string|iriencode }}" style="display:inline">(include)</a>
{% endif %}
</li>
{% endif %}
{% endfor %}
{% now "u" as id_name %}

<h3 style="margin-top:20px;">{% blocktrans with filter_title=title %} By {{ filter_title }} {% endblocktrans %}</h3>
<script>
function searchFun{{id_name}}() {
// Declare variables
var input, filter, ul, li, a, i, txtValue;
input = document.getElementById('myInput{{id_name}}');
filter = input.value.toUpperCase();
ul = document.getElementById("myUl{{id_name}}");
li = ul.getElementsByTagName('li');

// Loop through all list items, and hide those who don't match the search query
for (i = 0; i < li.length; i++) {
a = li[i].getElementsByTagName("a")[0];
txtValue = a.textContent || a.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
li[i].style.display = "";
} else {
li[i].style.display = "none";
}
}
}
</script>

<input type="text" id="myInput{{ id_name }}" onkeyup="searchFun{{ id_name }}()" placeholder={% trans "Search" %}>
<br>
<ul id="myUl{{ id_name }}" class="mulitple-choice" style="height:200px; overflow:auto;">
{% for choice in choices %}
{% if choice.reset %}
<li{% if choice.selected %} class="selected"{% endif %}>
<a href="{{ choice.query_string|iriencode }}" title="{{ choice.display }}">{{ choice.display }}</a>
</li>
{% endif %}
{% endfor %}
{% for choice in choices %}
{% if not choice.reset %}
<li{% if choice.selected %} class="selected"{% endif %}>
<a href="{{ choice.query_string|iriencode }}" title="{{ choice.display }}"
style="display:inline">{{ choice.display }}</a>
{% if choice.selected and choice.exclude_query_string %}
<a class="small" href="{{ choice.exclude_query_string|iriencode }}" style="display:inline;"><b
style="color:red; font-size:1.3rem;"> -</b></a>
{% endif %}
{% if not choice.selected and choice.include_query_string %}
<a class="small" href="{{ choice.include_query_string|iriencode }}" style="display:inline"><b
style="color:green; font-size:1.3rem;"> +</b></a>
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>