From 43a6ffcd4644fb831bd4a7bb47c856e21d3ab5e6 Mon Sep 17 00:00:00 2001
From: dalf <alex@al-f.net>
Date: Thu, 2 Jan 2014 22:57:28 +0100
Subject: [PATCH 1/2] [fix] the search text input gets the focus automatically

---
 searx/templates/search.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/searx/templates/search.html b/searx/templates/search.html
index 64f0d8f73..07df31ef5 100644
--- a/searx/templates/search.html
+++ b/searx/templates/search.html
@@ -1,6 +1,6 @@
 <form method="post" action="/" id="search_form">
 <div id="search_wrapper">
-    <input type="text" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/>
+    <input type="text" id="q" class="q" name="q" tabindex="1" autocomplete="off" {% if q %}value="{{ q }}"{% endif %}/>
     <input type="submit" value="" id="search_submit" />
 </div>
     <div>

From b70b0775f30670e4d2f168a5e81059f59b8732ae Mon Sep 17 00:00:00 2001
From: dalf <alex@al-f.net>
Date: Thu, 2 Jan 2014 23:02:38 +0100
Subject: [PATCH 2/2] [mod] the search text input gets the focus automatically
 only on the index page.

---
 searx/static/js/searx.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/searx/static/js/searx.js b/searx/static/js/searx.js
index 5eb880f65..7b224a17f 100644
--- a/searx/static/js/searx.js
+++ b/searx/static/js/searx.js
@@ -17,7 +17,7 @@
 
     addListener(w, 'load', function () {
         var qinput = d.getElementById('q');
-        if (qinput !== null) {
+        if (qinput !== null && qinput.value === "") {
             addListener(qinput, 'focus', placeCursorAtEnd);
             qinput.focus();
         }