summaryrefslogtreecommitdiff
path: root/docsite/_themes/srtd/searchbox.html
blob: b0310cff989b526db92c6b10a7d156445bcdd62a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!-- <form class="wy-form" action="{{ pathto('search') }}" method="get">
  <input type="text" name="q" placeholder="Search docs" />
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form> -->

<script>
  (function() {
    var cx = '006019874985968165468:eu5pbnxp4po';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
        '//www.google.com/cse/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>

<form id="search-form-id" action="">
  <input type="text" name="query" id="search-box-id" />
  <a class="search-reset-start" id="search-reset"><i class="fa fa-times"></i></a>
  <a class="search-reset-start" id="search-start"><i class="fa fa-search"></i></a>
</form>

<script type="text/javascript" src="http://www.google.com/cse/brand?form=search-form-id&inputbox=search-box-id"></script>

<script>
  function executeQuery() {
      var input = document.getElementById('search-box-id');
      var element = google.search.cse.element.getElement('searchresults-only0');
      element.resultsUrl = '/htmlout/search.html'
      if (input.value == '') {
          element.clearAllResults();
          $('#page-content, .rst-footer-buttons, #search-start').show();
          $('#search-results, #search-reset').hide();
      } else {
          $('#page-content, .rst-footer-buttons, #search-start').hide();
          $('#search-results, #search-reset').show();
          element.execute(input.value);
      }
      return false;
      }

  $('#search-reset').hide();

  $('#search-box-id').css('background-position', '1em center');

  $('#search-box-id').on('blur', function() {
    $('#search-box-id').css('background-position', '1em center');
  });

  $('#search-start').click(function(e) { executeQuery(); });
  $('#search-reset').click(function(e) { $('#search-box-id').val(''); executeQuery(); });

  $('#search-form-id').submit(function(e) {
      console.log('submitting!');
      executeQuery();
      e.preventDefault();
      });
</script>