1/*! Accodinator.js Copyright 2014 Clayton Huthwaite @claytuna */ 2 3(function($) { 4 $.fn.siteSearch = function(options) { 5 // Default settings 6 var settings = { 7 searchText: '.js-searchText', 8 searchSubmit: '.js-searchSubmit' 9 }; 10 11 // Extend functionality 12 var opts = $.extend(settings, options); 13 14 return this.each(function() { 15 // Private 16 var $$ = $(this); 17 var searchText = $$.find(settings.searchText); 18 var searchSubmit = $$.find(settings.searchSubmit); 19 20 function HtmlEncode(s) { 21 var el = document.createElement("div"); 22 el.innerText = el.textContent = s; 23 s = el.innerHTML; 24 return s; 25 } 26 27 function bindSearchText() { 28 searchText.bind('click', function(e){ 29 e.stopPropagation(); 30 }); 31 searchText.bind('keydown', function(e){ 32 var st = HtmlEncode($(this).val()); 33 st = encodeURIComponent(st); 34 if(e.keyCode == 13 && st != ''){ 35 window.location.href = '/index.php/search/?query=' + st; 36 } 37 }); 38 } 39 40 function bindSearchSubmit() { 41 searchSubmit.bind('click', function(e){ 42 var st = HtmlEncode(searchText.val()); 43 st = encodeURIComponent(st); 44 if(st != ''){ 45 window.location.href = '/index.php/search/?query=' + st; 46 } else { 47 e.preventDefault(); 48 } 49 }); 50 } 51 52 // Initialize Settings 53 function init() { 54 bindSearchText(); 55 bindSearchSubmit(); 56 } 57 58 init(); 59 }); 60 }; 61})(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.