1function LiveSearch(searchprompt) { 2 var self = this; 3 4 jQuery('#search-form-wrap').addClass('livesearch'); 5 6 this.searchPrompt = searchprompt; 7 this.searchform = jQuery('#searchform'); 8 this.searchField = jQuery('#s'); 9 this.reset = jQuery('#searchreset'); 10 this.loading = jQuery('#searchload'); 11 this.searchLabel = jQuery('#search-label'); 12 13 // Hide the submit button 14 jQuery('#searchsubmit').addClass('hidden'); 15 16 // Inlinize label 17 this.searchLabel.empty().text(searchprompt).addClass('overlabel-apply'); 18 19 // Bind events to the search input 20 this.searchField 21 .focus(function(){ 22 self.searchLabel.addClass('fade'); 23 }) 24 .blur(function(){ 25 if (self.searchField.val() == '') { 26 self.searchLabel.show().removeClass('fade'); 27 28 if (self.prevSearch != '') { 29 self.resetSearch(self); 30 } 31 } 32 }) 33 .keydown(function(event) { 34 if (self.searchField.val() == '') { 35 self.searchLabel.show(); 36 37 if (self.prevSearch != '') { 38 self.resetSearch(self); 39 } 40 } 41 42 var code = event.keyCode; 43 44 if (code == 27) { // Escape 45 self.resetSearch(self); 46 47 } else if (code != 13 && code != 9) { // Not Enter or TAB 48 self.searchLabel.addClass('hide') 49 50 if (self.timer) { 51 clearTimeout(self.timer); 52 } 53 self.timer = setTimeout(function(){ self.doSearch(self); }, 500); 54 } 55 }) 56 .keyup(function(event) { 57 var code = event.keyCode; 58 59 if (code != 13) { // Not Enter 60 if (self.searchField.val() == '') { 61 self.resetSearch(self); 62 clearTimeout(self.timer); 63 } else { 64 self.reset.fadeTo('fast', 0); 65 self.loading.fadeTo('fast', 1); 66 } 67 } 68 }); 69 70 if (this.searchField.val() != '') { // If searchfield isn't empty when page is loaded. 71 this.doSearch(self); 72 this.searchLabel.addClass('hide'); 73 } 74 75 self.loading.fadeTo('fast', 0); 76 self.reset.fadeTo('fast', 0); 77}; 78 79 80LiveSearch.prototype.doSearch = function(self) { 81 if (self.searchField.val() == self.prevSearch) return; 82 83 if (!self.active) { 84 self.active = true; 85 86 if (typeof K2.RollingArchives != 'undefined' && K2.RollingArchives.saveState) { 87 K2.RollingArchives.saveState(); 88 } 89 } 90 91 self.prevSearch = self.searchField.val(); 92 93 K2.ajaxGet(self.searchform.serialize() + '&k2dynamic=init', 94 function(data) { 95 jQuery('#current-content').hide(); 96 jQuery('#dynamic-content').html(data).show(); 97 98 self.loading.fadeTo('fast', 0); 99 100 self.reset.click(function(){ 101 self.resetSearch(self); 102 }).fadeTo('fast', 1.0).css('cursor', 'pointer'); 103 } 104 ); 105}; 106 107LiveSearch.prototype.resetSearch = function(self) { 108 self.active = false; 109 self.prevSearch = ''; 110 111 self.searchField.val(''); 112 self.searchLabel.removeClass('hide'); 113 self.loading.fadeTo('fast', 0); 114 115 self.reset.unbind('click').fadeTo('fast', 0).css('cursor', 'default'); 116 117 if ( jQuery('#current-content').length ) { 118 jQuery('#dynamic-content').hide().html(''); 119 jQuery('#current-content').show(); 120 } 121 122 if (typeof K2.RollingArchives != 'undefined' && K2.RollingArchives.restoreState) { 123 K2.RollingArchives.restoreState(); 124 } 125};
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.