PageSourceSearch

https://www.tataplay.com/dth/core/misc/autocomplete.js?v=9.5.11

js tataplay.com collected 2026-10-01 10:25:32 UTC 4,197 bytes, 137 lines download raw bytes

1/**
2* DO NOT EDIT THIS FILE.
3* See the following change record for more information,
4* https://www.drupal.org/node/2815083
5* @preserve
6**/
7(function ($, Drupal) {
8  var autocomplete;
9  function autocompleteSplitValues(value) {
10    var result = [];
11    var quote = false;
12    var current = '';
13    var valueLength = value.length;
14    var character;
15    for (var i = 0; i < valueLength; i++) {
16      character = value.charAt(i);
17      if (character === '"') {
18        current += character;
19        quote = !quote;
20      } else if (character === ',' && !quote) {
21        result.push(current.trim());
22        current = '';
23      } else {
24        current += character;
25      }
26    }
27    if (value.length > 0) {
28      result.push(current.trim());
29    }
30    return result;
31  }
32  function extractLastTerm(terms) {
33    return autocomplete.splitValues(terms).pop();
34  }
35  function searchHandler(event) {
36    var options = autocomplete.options;
37    if (options.isComposing) {
38      return false;
39    }
40    var term = autocomplete.extractLastTerm(event.target.value);
41    if (term.length > 0 && options.firstCharacterBlacklist.indexOf(term[0]) !== -1) {
42      return false;
43    }
44    return term.length >= options.minLength;
45  }
46  function sourceData(request, response) {
47    var elementId = this.element.attr('id');
48    if (!(elementId in autocomplete.cache)) {
49      autocomplete.cache[elementId] = {};
50    }
51    function showSuggestions(suggestions) {
52      var tagged = autocomplete.splitValues(request.term);
53      var il = tagged.length;
54      for (var i = 0; i < il; i++) {
55        var index = suggestions.indexOf(tagged[i]);
56        if (index >= 0) {
57          suggestions.splice(index, 1);
58        }
59      }
60      response(suggestions);
61    }
62    var term = autocomplete.extractLastTerm(request.term);
63    function sourceCallbackHandler(data) {
64      autocomplete.cache[elementId][term] = data;
65      showSuggestions(data);
66    }
67    if (autocomplete.cache[elementId].hasOwnProperty(term)) {
68      showSuggestions(autocomplete.cache[elementId][term]);
69    } else {
70      var options = $.extend({
71        success: sourceCallbackHandler,
72        data: {
73          q: term
74        }
75      }, autocomplete.ajax);
76      $.ajax(this.element.attr('data-autocomplete-path'), options);
77    }
78  }
79  function focusHandler() {
80    return false;
81  }
82  function selectHandler(event, ui) {
83    var terms = autocomplete.splitValues(event.target.value);
84    terms.pop();
85    terms.push(ui.item.value);
86    event.target.value = terms.join(', ');
87    return false;
88  }
89  function renderItem(ul, item) {
90    return $('<li>').append($('<a>').html(item.label)).appendTo(ul);
91  }
92  Drupal.behaviors.autocomplete = {
93    attach: function attach(context) {
94      var $autocomplete = $(once('autocomplete', 'input.form-autocomplete', context));
95      if ($autocomplete.length) {
96        var blacklist = $autocomplete.attr('data-autocomplete-first-character-blacklist');
97        $.extend(autocomplete.options, {
98          firstCharacterBlacklist: blacklist || ''
99        });
100        $autocomplete.autocomplete(autocomplete.options).each(function () {
101          $(this).data('ui-autocomplete')._renderItem = autocomplete.options.renderItem;
102        });
103        $autocomplete.on('compositionstart.autocomplete', function () {
104          autocomplete.options.isComposing = true;
105        });
106        $autocomplete.on('compositionend.autocomplete', function () {
107          autocomplete.options.isComposing = false;
108        });
109      }
110    },
111    detach: function detach(context, settings, trigger) {
112      if (trigger === 'unload') {
113        $(once.remove('autocomplete', 'input.form-autocomplete', context)).autocomplete('destroy');
114      }
115    }
116  };
117  autocomplete = {
118    cache: {},
119    splitValues: autocompleteSplitValues,
120    extractLastTerm: extractLastTerm,
121    options: {
122      source: sourceData,
123      focus: focusHandler,
124      search: searchHandler,
125      select: selectHandler,
126      renderItem: renderItem,
127      minLength: 1,
128      firstCharacterBlacklist: '',
129      isComposing: false
130    },
131    ajax: {
132      dataType: 'json',
133      jsonp: false
134    }
135  };
136  Drupal.autocomplete = autocomplete;
137})(jQuery, Drupal);

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.