PageSourceSearch

https://hotline.org.tw/sites/hotline.org.tw/modules/google_cse/google_cse_results.js?tm8c9t

js hotline.org.tw collected 2026-10-02 04:17:50 UTC 1,770 bytes, 57 lines download raw bytes

1/**
2 * @file
3 * Google CSE JavaScript setup and invocation code.
4 */
5
6// Callback to grab search terms from the URL and feed them to Google.
7window.__gcse = {
8  callback: function () {
9    var keys = [];
10    if (Drupal.settings.googleCSE.keys) {
11      // Get search keys passed by settings.
12      keys[1] = Drupal.settings.googleCSE.keys;
13    } else {
14      // Fallback to get keys from URL, if not set in settings.
15      keys = /.*\/search\/google\/(.+)/.exec(document.location.pathname);
16    }
17    if (keys) {
18      var gcse = google.search.cse.element.getElement("google_cse");
19      if (gcse) {
20        gcse.execute(decodeURIComponent(keys[1]));
21      }
22    }
23  }
24};
25
26// The Google CSE standard code, just changed to pick up the SE if
27// ("cx") from Drupal.settings.
28(function() {
29  var cx = Drupal.settings.googleCSE.cx;
30  var gcse = document.createElement('script');
31  gcse.type = 'text/javascript';
32  gcse.async = true;
33  gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
34    '//cse.google.com/cse.js?cx=' + cx;
35    var s = document.getElementsByTagName('script')[0];
36  s.parentNode.insertBefore(gcse, s);
37}
38)();
39
40// Added to send input from search block to Google endpoint.
41// The Form API AJAX framework should probably be used here.
42(function($) {
43  Drupal.behaviors.form_submit_processor = {
44    attach: function (context, settings) {
45      $("form#google-cse-results-searchbox-form").submit(function (e) {
46        e.preventDefault();
47        keys = $('form#google-cse-results-searchbox-form #edit-query').val();
48        if (keys) {
49          var gcse = google.search.cse.element.getElement("google_cse");
50          if (gcse) {
51            gcse.execute(decodeURIComponent(keys));
52          }
53        }
54      });
55    }
56  }
57})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.