PageSourceSearch

https://420medicalstore.com/wp-content/plugins/anant-addons-for-elementor/assets/js/search.js?ver=1.2.8

js 420medicalstore.com collected 2026-09-26 00:38:56 UTC 4,970 bytes, 143 lines download raw bytes

1( function( $ ) {
2	/**
3	* Search widget JS
4	*/
5	var WidgetanantSearchButton = function( $scope, $ ){
6
7		if ( 'undefined' == typeof $scope )
8			return;
9		const wId = $scope.data("id");
10		const wrapper = document.querySelector(`.elementor-element-${wId}`);
11
12		var $input = $scope.find( "input.anant_search_input" );
13		var $clear = $scope.find( "button#clear" );
14		var $clear_with_button = $scope.find( "button#clear-with-button" );
15		var $search_button = $scope.find( ".anant-search-submit" );
16		var $toggle_search = $scope.find( ".anant-search-icon-toggle input" );
17
18		$scope.find( '.search-btn i.fa-search' ).on( 'click', function( ){
19			$scope.find( ".anant-search-wrapper" ).toggleClass( "anant-input-focus" );					
20		});
21
22		$toggle_search.css( 'padding-right', $toggle_search.next().outerWidth() + 'px' );
23
24		$input.on( 'keyup', function(){
25			$clear.style = (this.value.length) ? $clear.css('visibility','visible'): $clear.css('visibility','hidden');
26			$clear_with_button.style = (this.value.length) ? $clear_with_button.css('visibility','visible'): $clear_with_button.css('visibility','hidden');
27			$clear_with_button.css( 'right', $search_button.outerWidth() + 'px' );
28		});
29
30		$clear.on("click",function(){
31			this.style = $clear.css('visibility','hidden');
32			$input.value = "";
33		});
34		$clear_with_button.on("click",function(){
35			this.style = $clear_with_button.css('visibility','hidden');
36			$input.value = "";
37		});
38
39		// var searchRequest;	
40		// $input.autocomplete({
41		// 	source: function(term, suggest){
42		// 		var term1 = $scope.find( "input.anant_search_input" ).val();
43		// 		try { searchRequest.abort(); } catch(e){}
44		// 		searchRequest = $.post(search.ajax, { srch1: term1, action: 'search_site' }, function(res) {
45		// 			var rspns = eval(res.data);
46		// 			var na = [];
47		// 			$.map(rspns, function(item) {
48		// 			let result = item.toLowerCase().includes(term1.toLowerCase());
49		// 				if(result == true){
50		// 					na.push(item);
51		// 				}	
52		// 			});
53		// 				suggest(na);
54		// 		});
55		// 	}
56	  	// });
57  
58		const searchInput = wrapper.querySelector('#ant-search-input');
59		const suggestionsContainer = wrapper.querySelector('#ant-suggestions-container');
60
61		searchInput.addEventListener('input', function() {
62			const inputText = searchInput.value.trim().toLowerCase();
63			console.log(inputText);
64            var thisEl = $(this);
65            var data = {
66				action: 'search_site',
67				search_item: inputText,
68				'anant_search_nonce': search.search_nonce
69			};
70        
71            jQuery.ajax({
72                url: search.ajax,
73                type: "POST",
74                data: data,
75                success: function (response) {
76                    var suggestions = JSON.parse(response.data);
77					if (inputText === '') {
78						suggestionsContainer.innerHTML = "";
79						return;
80					}
81			
82					const filteredSuggestions = suggestions.filter(suggestion =>
83						suggestion.title.toLowerCase().includes(inputText)
84					);
85                    console.log(suggestions);
86
87			
88					displaySuggestions(filteredSuggestions);
89                },
90                error: function(errorThrown){
91                    console.log(errorThrown);
92                    console.log('woo search ajax error');
93                },
94            });
95		});
96
97		function displaySuggestions(suggestionsList) {
98			suggestionsContainer.innerHTML = '';
99	
100			if (suggestionsList.length === 0) {
101				suggestionsContainer.innerHTML = '<div class="ant-no-results"><p>No results found</p></div>';
102				suggestionsContainer.style.display = 'block';
103				return;
104			}
105	
106			suggestionsList.forEach(suggestion => {
107				const suggestionElement = document.createElement('div');
108				suggestionElement.className = 'search-suggestion'; 
109				// Create title anchor tag
110				const titleAnchorElement = document.createElement('a');
111				titleAnchorElement.href = suggestion.url; 
112				titleAnchorElement.target = '_blank'; 
113		
114				// Create title element
115				const titleElement = document.createElement('p');
116				titleAnchorElement.textContent = suggestion.title;
117				titleElement.appendChild(titleAnchorElement);
118				suggestionElement.appendChild(titleElement);
119		
120				suggestionElement.addEventListener('click', function() {
121					searchInput.value = suggestion.title;
122					suggestionsContainer.style.display = 'none';
123				});
124		
125				suggestionsContainer.appendChild(suggestionElement);
126			});
127	
128			suggestionsContainer.style.display = 'block';
129		}
130	
131		document.addEventListener('click', function(event) {
132			if (event.target !== searchInput && event.target !== suggestionsContainer) {
133				suggestionsContainer.style.display = 'none';
134			}
135		});
136
137	}
138
139    $( window ).on( 'elementor/frontend/init', function () {
140
141		elementorFrontend.hooks.addAction( 'frontend/element_ready/anant-search.default', WidgetanantSearchButton );
142	});
143} )( 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.