logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: 11fdd8e8ac2021d6c72cd82217f1b999f1b788ca
parent: 41dea8ab5388a68a12661f1c8482911840a109aa
Author: asciimoo <asciimoo@gmail.com>
Date:   Wed,  1 Jan 2014 20:56:50 +0100

Merge remote-tracking branch 'dalf/master'

Diffstat:

searx/static/js/searx.js | 27+++++++++++++++++++++++++++
searx/templates/base.html | 1+
searx/templates/results.html | 6+++---
3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/searx/static/js/searx.js b/searx/static/js/searx.js @@ -0,0 +1,27 @@ +(function (w, d) { + 'use strict'; + function addListener(el, type, fn) { + if (el.addEventListener) { + el.addEventListener(type, fn, false); + } else { + el.attachEvent('on' + type, fn); + } + } + + function placeCursorAtEnd() { + if (this.setSelectionRange) { + var len = this.value.length * 2; + this.setSelectionRange(len, len); + } + } + + addListener(w, 'load', function () { + var qinput = d.getElementById('q'); + if (qinput !== null) { + addListener(qinput, 'focus', placeCursorAtEnd); + qinput.focus(); + } + }); + +})(window, document); + diff --git a/searx/templates/base.html b/searx/templates/base.html @@ -18,6 +18,7 @@ <div id="container"> {% block content %} {% endblock %} +<script src="/static/js/searx.js" ></script> </div> </body> </html> diff --git a/searx/templates/results.html b/searx/templates/results.html @@ -6,7 +6,7 @@ </div> <div id="results"> {% if suggestions %} - <div id="suggestions">Suggestions: {% for suggestion in suggestions %}<form method="post" action=""><input type="hidden" name="q" value="{{suggestion}}"><input type="submit" value="{{ suggestion }}" /></form>{% endfor %}</div> + <div id="suggestions">Suggestions: {% for suggestion in suggestions %}<form method="post" action="/"><input type="hidden" name="q" value="{{suggestion}}"><input type="submit" value="{{ suggestion }}" /></form>{% endfor %}</div> {% endif %} <div> Number of results: {{ number_of_results }} @@ -18,14 +18,14 @@ {% include 'result_templates/default.html' %} {% endif %} {% endfor %} - <form method="post" action=""> + <form method="post" action="/"> <div class="left"> <input type="hidden" name="q" value="{{ q }}" /> <input type="hidden" name="format" value="csv" /> <input type="submit" value="download results in csv" /> </div> </form> - <form method="post" action=""> + <form method="post" action="/"> <div class=""> <input type="hidden" name="q" value="{{ q }}" /> <input type="hidden" name="format" value="json" />