PageSourceSearch

https://www.a-contresens.net/wp-content/themes/blackmag/inc/instant-search/instant-search.js?ver=1.6.13

js a-contresens.net collected 2026-10-02 06:00:20 UTC 3,386 bytes, 120 lines download raw bytes

1;(function( $, window, document, undefined ){
2
3	var INSTANT_SEARCH = {
4		is_on_request: false,
5		delay_search: null,
6		keywords: '',
7		form_template: '<form class="vw-instant-search-panel" method="get" autocomplete="off"> <input type="text" id="s" name="s" value="" placeholder="'+instant_search.placeholder+'"> <div class="vw-loading-icon vw-preloader-bg"></div> <ul class="vw-instant-search-result-panel"></ul> </form>',
8		defaults: {
9			search_delay: 350,
10		},
11
12		init: function( el, options ) {
13			this.options = $.extend({}, this.defaults, options);
14
15			this.startSearch = $.proxy( this.startSearch, this );
16			this.onClickIcon = $.proxy( this.onClickIcon, this );
17			this.onClickOutside = $.proxy( this.onClickOutside, this );
18			this.onTyping = $.proxy( this.onTyping, this );
19			this.onRequestCompleted = $.proxy( this.onRequestCompleted, this );
20
21			this.$form = $( this.form_template );
22			this.$searchbox = $( '#s', this.$form );
23			this.$loading = $( '.vw-loading-icon', this.$form );
24			this.$result_panel = $( '.vw-instant-search-result-panel', this.$form );
25
26			this.$icon = $( el );
27			this.$icon.click( this.onClickIcon );
28			this.$icon.after( this.$form );
29			this.initForm();
30
31			$(document).mousedown( this.onClickOutside );
32		},
33
34		initForm: function() {
35			this.$form.hide();
36			this.$form.attr( 'action', instant_search.blog_url );
37			this.$searchbox.keyup( this.onTyping );
38		},
39
40		startSearch: function() {
41			this.$loading.show();
42			if ( this.is_on_request ) {
43				this.request.abort();
44			}
45
46			this.is_on_request = true;
47
48			this.request = $.ajax({
49				url: instant_search.ajax_url,
50				data: { s: this.keywords, action: 'vw_instant_search' },
51				success: this.onRequestCompleted,
52			});
53		},
54
55		showPanel: function() {
56			this.$form.css( 'opacity', '0' ).show();
57			this.$form.animate( { opacity: 1, marginTop: '0px' }, { duration: 150 } );
58		},
59
60		hidePanel: function() {
61			this.$form.animate( { opacity: 0, marginTop: '-10px' }, { duration: 150, complete: function() {
62				$(this).hide();
63			} } );
64		},
65
66		onClickIcon: function( e ) {
67			if ( ! this.$form.is( ':visible' ) ) {
68				this.showPanel();
69				this.$searchbox.focus();
70			} else {
71				this.hidePanel();
72			}
73
74			return false;
75		},
76
77		onClickOutside: function( e ) {
78			if ( ( ! this.$form.is(e.target) && this.$form.has(e.target).length === 0 )
79			  && ( ! this.$icon.is(e.target) && this.$icon.has(e.target).length === 0)
80			) {
81				this.hidePanel();
82			}
83		},
84
85		onRequestCompleted: function( data ) {
86			this.$result_panel.empty();
87			this.$result_panel.append( data );
88
89			this.is_on_request = false;
90			this.$loading.hide();
91		},
92
93		onTyping: function( e ) {
94			var keywords = this.$searchbox.val();
95
96			if ( keywords == this.keywords ) return;
97			if ( keywords.length < 3 ) {
98				clearTimeout( this.delay_search );
99				this.$loading.hide();
100				return;
101			}
102
103			if ( this.delay_search ) {
104				clearTimeout( this.delay_search );
105			}
106
107			this.keywords = keywords;
108			this.delay_search = setTimeout( this.startSearch , this.options.search_delay );
109		},
110	}
111
112	$.fn.instant_search = function( arg1 ) {
113		return this.each(function() {
114			var instant_search = $.extend( {}, INSTANT_SEARCH );
115
116			instant_search.init( this, arg1 );
117		});
118	};
119
120})( jQuery, window , document );

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.