2018-05-15 20:42:10 +02:00
|
|
|
<script>
|
2018-05-15 20:46:03 +02:00
|
|
|
(function () {
|
|
|
|
var cx = '{{ site.google.search_engine_id }}';
|
|
|
|
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);
|
|
|
|
})();
|
2018-05-15 20:42:10 +02:00
|
|
|
|
2018-05-15 20:46:03 +02:00
|
|
|
function googleCustomSearchExecute() {
|
|
|
|
var input = document.getElementById('cse-search-input-box-id');
|
|
|
|
var element = google.search.cse.element.getElement('searchresults-only0');
|
|
|
|
if (input.value == '') {
|
|
|
|
element.clearAllResults();
|
|
|
|
} else {
|
|
|
|
element.execute(input.value);
|
2018-05-15 20:42:10 +02:00
|
|
|
}
|
2018-05-15 20:46:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
2018-05-15 20:42:10 +02:00
|
|
|
|
2018-05-15 20:46:03 +02:00
|
|
|
{% if site.google.instant_search %}
|
2018-05-15 20:42:10 +02:00
|
|
|
$(document).ready(function () {
|
2018-05-15 20:46:03 +02:00
|
|
|
$('input#cse-search-input-box-id').on('keyup', function () {
|
|
|
|
googleCustomSearchExecute();
|
|
|
|
});
|
2018-05-15 20:42:10 +02:00
|
|
|
});
|
2018-05-15 20:46:03 +02:00
|
|
|
{% endif %}
|
|
|
|
</script>
|