Added enter key submit on results page

Added results type carryover for subsequent searches on results page

Removed redundant header on image search results
main
Ben Busby 2020-05-25 10:53:15 -06:00
parent d1f38cf924
commit 9212f9921a
2 changed files with 11 additions and 1 deletions

View File

@ -133,14 +133,20 @@ def search():
else: else:
formatted_results = content_filter.clean(dirty_soup) formatted_results = content_filter.clean(dirty_soup)
# Set search type to be used in the header template to allow for repeated searches
# in the same category
search_type = request_params.get('tbm') if 'tbm' in request_params else ''
return render_template( return render_template(
'display.html', 'display.html',
query=urlparse.unquote(q), query=urlparse.unquote(q),
search_type=search_type,
response=formatted_results, response=formatted_results,
search_header=render_template( search_header=render_template(
'header.html', 'header.html',
q=urlparse.unquote(q), q=urlparse.unquote(q),
mobile=g.user_request.mobile)) search_type=search_type,
mobile=g.user_request.mobile) if 'isch' not in search_type else '')
@app.route('/config', methods=['GET', 'POST']) @app.route('/config', methods=['GET', 'POST'])

View File

@ -13,6 +13,7 @@
<div class="sbc esbc autocomplete"> <div class="sbc esbc autocomplete">
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q" <input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
spellcheck="false" type="text" value="{{ q }}"> spellcheck="false" type="text" value="{{ q }}">
<input name="tbm" value="{{ search_type }}" style="display: none">
<div class="sc"></div> <div class="sc"></div>
</div> </div>
</div> </div>
@ -34,6 +35,7 @@
<div style="width: 100%; display: flex"> <div style="width: 100%; display: flex">
<input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q" <input id="search-bar" autocapitalize="none" autocomplete="off" class="noHIxc" name="q"
spellcheck="false" type="text" value="{{ q }}"> spellcheck="false" type="text" value="{{ q }}">
<input name="tbm" value="{{ search_type }}" style="display: none">
<div class="sc"></div> <div class="sc"></div>
</div> </div>
</div> </div>
@ -48,6 +50,8 @@
searchBar.addEventListener("keyup", function (event) { searchBar.addEventListener("keyup", function (event) {
if (event.keyCode !== 13) { if (event.keyCode !== 13) {
handleUserInput(searchBar); handleUserInput(searchBar);
} else {
document.getElementById("search-form").submit();
} }
}); });
</script> </script>