Next/Prev button works without captcha

This commit is contained in:
Simon 2018-11-15 12:54:31 -05:00
parent db26e851a4
commit fc3de06c35

59
templates/search.html Normal file → Executable file
View File

@ -18,7 +18,8 @@
<div class="input-group-prepend"> <div class="input-group-prepend">
<div class="input-group-text"> <div class="input-group-text">
<label for="matchAll" style="margin-bottom: 0">Match any word&nbsp</label> <label for="matchAll" style="margin-bottom: 0">Match any word&nbsp</label>
<input title="Toggle between 'match all words' and 'match any word'" type="checkbox" id="matchAll" name="all" {{ "checked" if match_all }}> <input title="Toggle between 'match all words' and 'match any word'" type="checkbox"
id="matchAll" name="all" {{ "checked" if match_all }}>
</div> </div>
</div> </div>
<input class="form-control" name="q" id="q" placeholder="Query" value="{{ q }}"> <input class="form-control" name="q" id="q" placeholder="Query" value="{{ q }}">
@ -52,15 +53,18 @@
<div class="col-md-5" style="margin-left: 1em"> <div class="col-md-5" style="margin-left: 1em">
<div class="text-muted">Search in</div> <div class="text-muted">Search in</div>
<div class="form-group form-check form-check-inline"> <div class="form-group form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="field_name" name="field_name"{{ "checked" if field_name else ""}}> <input class="form-check-input" type="checkbox" id="field_name"
name="field_name"{{ "checked" if field_name else "" }}>
<label class="form-check-label" for="field_name">name</label> <label class="form-check-label" for="field_name">name</label>
</div> </div>
<div class="form-group form-check form-check-inline"> <div class="form-group form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="field_trigram" name="field_trigram"{{ "checked" if field_trigram else ""}}> <input class="form-check-input" type="checkbox" id="field_trigram"
name="field_trigram"{{ "checked" if field_trigram else "" }}>
<label class="form-check-label" for="field_trigram">name.trigram</label> <label class="form-check-label" for="field_trigram">name.trigram</label>
</div> </div>
<div class="form-group form-check form-check-inline"> <div class="form-group form-check form-check-inline">
<input class="form-check-input" type="checkbox" id="field_path" name="field_path" {{ "checked" if field_path else ""}}> <input class="form-check-input" type="checkbox" id="field_path"
name="field_path" {{ "checked" if field_path else "" }}>
<label class="form-check-label" for="field_path">path</label> <label class="form-check-label" for="field_path">path</label>
</div> </div>
</div> </div>
@ -73,12 +77,23 @@
{# Sort order #} {# Sort order #}
<select class="form-control" name="sort_order" title="Sort order"> <select class="form-control" name="sort_order" title="Sort order">
<option disabled>Sort order</option> <option disabled>Sort order</option>
<option value="score" {{ "selected" if sort_order == "score" else "" }}>Relevance </option> <option value="score" {{ "selected" if sort_order == "score" else "" }}>Relevance
<option value="size_asc" {{ "selected" if sort_order == "size_asc" else "" }}>Size ascending </option> </option>
<option value="size_dsc" {{ "selected" if sort_order == "size_dsc" else "" }}>Size descending</option> <option value="size_asc" {{ "selected" if sort_order == "size_asc" else "" }}>Size
<option value="date_asc" {{ "selected" if sort_order == "date_asc" else "" }}>Date ascending</option> ascending
<option value="date_dsc" {{ "selected" if sort_order == "date_dsc" else "" }}>Date descending</option> </option>
<option value="none" {{ "selected" if sort_order == "none" else "" }}>No order (faster)</option> <option value="size_dsc" {{ "selected" if sort_order == "size_dsc" else "" }}>Size
descending
</option>
<option value="date_asc" {{ "selected" if sort_order == "date_asc" else "" }}>Date
ascending
</option>
<option value="date_dsc" {{ "selected" if sort_order == "date_dsc" else "" }}>Date
descending
</option>
<option value="none" {{ "selected" if sort_order == "none" else "" }}>No order
(faster)
</option>
</select> </select>
</div> </div>
{# Results per page #} {# Results per page #}
@ -100,9 +115,13 @@
document.getElementById("sfrm").submit(); document.getElementById("sfrm").submit();
}</script> }</script>
<script src="https://www.google.com/recaptcha/api.js" async defer></script> <script src="https://www.google.com/recaptcha/api.js" async defer></script>
<button id="s" class="g-recaptcha btn btn-primary btn-shadow" data-sitekey="6LcCXWkUAAAAAJo2NR9_m09Obn5YmDrI97sGrr2f" data-callback="f" style="float: right" onclick="document.getElementById('page').value = 0">Search</button> <button id="s" class="g-recaptcha btn btn-primary btn-shadow"
data-sitekey="6LcCXWkUAAAAAJo2NR9_m09Obn5YmDrI97sGrr2f" data-callback="f"
style="float: right" onclick="document.getElementById('page').value = 0">Search
</button>
{% else %} {% else %}
<input id="s" class="btn btn-primary btn-shadow" type="submit" value="Search" style="float: right"> <input id="s" class="btn btn-primary btn-shadow" type="submit" value="Search"
style="float: right">
{% endif %} {% endif %}
</div> </div>
</div> </div>
@ -182,8 +201,11 @@
<p>For better results:</p> <p>For better results:</p>
<ul> <ul>
<li>Try checking the 'Match any word' box for a broader search.</li> <li>Try checking the 'Match any word' box for a broader search.</li>
<li>Make sure you don't include the file extension in your query (Use the appropriate field to filter file types)</li> <li>Make sure you don't include the file extension in your query (Use the appropriate field to
<li>If you're searching for files in a particular website, use the <a href="/website">website search page</a></li> filter file types)
</li>
<li>If you're searching for files in a particular website, use the <a href="/website">website
search page</a></li>
</ul> </ul>
</div> </div>
@ -258,11 +280,20 @@
//Next button //Next button
function nextPage() { function nextPage() {
document.getElementById("page").value = parseInt(document.getElementById("page").value) + 1; document.getElementById("page").value = parseInt(document.getElementById("page").value) + 1;
{% if show_captcha %}
grecaptcha.execute(); grecaptcha.execute();
{% else %}
document.getElementById("sfrm").submit()
{% endif %}
} }
function prevPage() { function prevPage() {
document.getElementById("page").value = parseInt(document.getElementById("page").value) - 1; document.getElementById("page").value = parseInt(document.getElementById("page").value) - 1;
{% if show_captcha %}
grecaptcha.execute(); grecaptcha.execute();
{% else %}
document.getElementById("sfrm").submit()
{% endif %}
} }
</script> </script>