Browse Source

Merge remote-tracking branch 'dalf/master'

asciimoo 11 years ago
parent
commit
11fdd8e8ac
3 changed files with 31 additions and 3 deletions
  1. 27 0
      searx/static/js/searx.js
  2. 1 0
      searx/templates/base.html
  3. 3 3
      searx/templates/results.html

+ 27 - 0
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);
+

+ 1 - 0
searx/templates/base.html

@@ -18,6 +18,7 @@
 <div id="container">
 {% block content %}
 {% endblock %}
+<script src="/static/js/searx.js" ></script>
 </div>
 </body>
 </html>

+ 3 - 3
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" />