view/search.html.haml in inqlude-0.7.3 vs view/search.html.haml in inqlude-0.7.4

- old
+ new

@@ -1,31 +1,15 @@ %h2 Search results -#cse - Loading - +%gcse:searchresults-only + Loading... :javascript - function parseQueryFromUrl () { - var queryParamName = "q"; - var search = window.location.search.substr(1); - var parts = search.split('&'); - for (var i = 0; i < parts.length; i++) { - var keyvaluepair = parts[i].split('='); - if (decodeURIComponent(keyvaluepair[0]) == queryParamName) { - return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' ')); - } - } - return ''; - } - google.load('search', '1', {language : 'en'}); - google.setOnLoadCallback(function() { - var customSearchControl = new google.search.CustomSearchControl('012526638842992167133:g7thmrlp2uw'); - customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET); - var options = new google.search.DrawOptions(); - options.enableSearchResultsOnly(); - customSearchControl.draw('cse',options); - var queryFromUrl = parseQueryFromUrl(); - if (queryFromUrl) { - customSearchControl.execute(queryFromUrl); - } - }, true); + (function() { + var cx = '012526638842992167133:g7thmrlp2uw'; + var gcse = document.createElement('script'); + gcse.type = 'text/javascript'; + gcse.async = true; + gcse.src = 'https://cse.google.com/cse.js?cx=' + cx; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(gcse, s); + })();