From 9922ce00ffe28bbf5372a31c58f0bbd61fcba407 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Sko=C5=99epa?= <jakub@skorepa.info>
Date: Sat, 19 Mar 2016 16:45:49 +0100
Subject: [PATCH] Fix search results opening in new tab

fixes #17
---
 theme/templates/partials/search.html.nunj | 25 +++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/theme/templates/partials/search.html.nunj b/theme/templates/partials/search.html.nunj
index 47b68e74..e8a08208 100644
--- a/theme/templates/partials/search.html.nunj
+++ b/theme/templates/partials/search.html.nunj
@@ -31,18 +31,25 @@
     };
   };
 
+  var csc;
+
   var myCallback = function() {
     var doRender = function() {
-      var csc = new google.search.CustomSearchControl;
-      .setLinkTarget (google.search.Search.LINK_TARGET_SELF);
-      google.search.cse.element.render({
-                div: "searchresults",
-                tag: 'searchresults-only',
-                gname: 'searchresults'
-              });
+      var options = {};
+      options[google.search.Search.RESTRICT_EXTENDED_ARGS] = {
+        'as_sitesearch': 'nove.ok1kvk.cz'
+      };
+
+      csc = new google.search.CustomSearchControl('003089460452505374651:q5prtsadbio', options);
+      csc.setLinkTarget (google.search.Search.LINK_TARGET_SELF);
+
+      var drawOptions = new google.search.DrawOptions();
+      drawOptions.enableSearchResultsOnly();
+      csc.draw("searchresults", drawOptions);
+
       var s = $("#searchbox input").val()
       if(s != "")
-        google.search.cse.element.getElement('searchresults').execute(s);
+        csc.execute(s);
     }
     if (document.readyState == 'complete') {
       doRender();
@@ -74,7 +81,7 @@
       $("#searchresults").html("");
       myCallback();
     } else
-      google.search.cse.element.getElement('searchresults').execute(s);
+      csc.execute(s);
   },250));
 
   (function() {
-- 
GitLab