PageSourceSearch

https://osannavisconti.com/wp-content/plugins/woocommerce-products-filter/ext/by_sku/js/by_sku.js?ver=3.4.4

js osannavisconti.com collected 2026-10-08 16:27:02 UTC 4,241 bytes, 172 lines download raw bytes

1"use strict";
2var woof_sku_do_submit = false;
3function woof_init_sku() {
4	woof_sku_check_reset();
5	jQuery( '.woof_show_sku_search' ).keyup(
6		function (e) {
7
8			let parent                      = this.parentNode;
9			let woof_sku_autocomplete       = parseInt( parent.dataset.autocomplete );
10			let woof_sku_autocomplete_items = parseInt( parent.dataset.autocomplete_items );
11
12			var val = jQuery( this ).val();
13			val     = val.replace( ' ', '' );
14			var uid = jQuery( this ).data( 'uid' );
15
16			if (e.keyCode == 13) {
17				woof_sku_do_submit = true;
18				woof_sku_direct_search( 'woof_sku', val );
19				return true;
20			}
21
22			// save new word into woof_current_values
23			if (woof_autosubmit) {
24				woof_current_values['woof_sku'] = val;
25			} else {
26				woof_sku_direct_search( 'woof_sku', val );
27			}
28
29			// if (woof_is_mobile == 1) {
30			if (val.length > 0) {
31				jQuery( '.woof_sku_search_go.' + uid ).show( 222 );
32				jQuery( '.woof_sku_search_reset.' + uid ).show( 222 );
33			} else {
34				jQuery( '.woof_sku_search_go.' + uid ).hide();
35				jQuery( '.woof_sku_search_reset.' + uid ).hide();
36			}
37			// }
38
39			// http://easyautocomplete.com/examples
40			if (val.length >= 3 && woof_sku_autocomplete) {
41				var input_id = jQuery( this ).attr( 'id' );
42				var nonce    = jQuery( '.woof_sku_search_nonce' ).val()
43				var options  = {
44					url: function (phrase) {
45						return woof_ajaxurl;
46					},
47					//theme: "square",
48					getValue: function (element) {
49						return element.name;
50					},
51					ajaxSettings: {
52						dataType: "json",
53						method: "POST",
54						data: {
55							action: "woof_sku_autocomplete",
56							dataType: "json",
57							woof_sku_search_nonce: nonce
58						}
59					},
60					preparePostData: function (data) {
61						data.phrase = jQuery( "#" + input_id ).val();
62						return data;
63					},
64					template: {
65						type: "description",
66						fields: {
67
68							description: "type"
69						}
70					},
71					list: {
72						maxNumberOfElements: woof_sku_autocomplete_items,
73						onChooseEvent: function () {
74							woof_sku_do_submit = true;
75							woof_sku_direct_search( 'woof_sku', jQuery( "#" + input_id ).val() );
76							return true;
77						},
78						showAnimation: {
79							type: "fade", // normal|slide|fade
80							time: 333,
81							callback: function () {
82							}
83						},
84						hideAnimation: {
85							type: "slide", // normal|slide|fade
86							time: 333,
87							callback: function () {
88							}
89						}
90
91					},
92					requestDelay: 400
93				};
94				try {
95					jQuery( "#" + input_id ).easyAutocomplete( options );
96				} catch (e) {
97					console.log( e );
98				}
99				jQuery( "#" + input_id ).focus();
100			}
101		}
102	);
103	// +++
104	jQuery( 'body' ).on(
105		'click',
106		'.woof_sku_search_go',
107		function () {
108			var uid            = jQuery( this ).data( 'uid' );
109			woof_sku_do_submit = true;
110			var val            = jQuery( '.woof_show_sku_search.' + uid ).val();
111			val                = val.replace( ' ', '' );
112			woof_sku_direct_search( 'woof_sku', val );
113		}
114	);
115	jQuery( 'body' ).on(
116		'click',
117		'.woof_sku_search_reset',
118		function () {
119			var uid = jQuery( this ).data( 'uid' );
120			jQuery( '.woof_show_sku_search.' + uid ).val( "" );
121			if (typeof woof_current_values['woof_sku'] != 'undefined') {
122				delete woof_current_values['woof_sku'];
123			}
124			woof_sku_check_reset();
125
126			let woof_sku_reset_behavior = parseInt( this.dataset.reset_behavior );
127
128			if (woof_sku_reset_behavior) {
129				woof_submit_link( woof_get_submit_link() );
130			}
131		}
132	);
133}
134
135function woof_sku_check_reset() {
136	var all_sku = jQuery( '.woof_show_sku_search' );
137	jQuery.each(
138		all_sku,
139		function (index, input) {
140			var val = jQuery( input ).val();
141			var uid = jQuery( input ).data( 'uid' );
142			if (val.length > 0) {
143				jQuery( '.woof_sku_search_reset.' + uid ).show( 222 );
144			} else {
145				jQuery( '.woof_sku_search_reset.' + uid ).hide();
146			}
147		}
148	);
149}
150
151function woof_sku_direct_search(name, slug) {
152
153	jQuery.each(
154		woof_current_values,
155		function (index, value) {
156			if (index == name) {
157				delete woof_current_values[name];
158				return;
159			}
160		}
161	);
162
163	if (slug != 0) {
164		woof_current_values[name] = slug;
165	}
166
167	woof_ajax_page_num = 1;
168	if (woof_autosubmit || woof_sku_do_submit) {
169		woof_sku_do_submit = false;
170		woof_submit_link( woof_get_submit_link() );
171	}
172}

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.