PageSourceSearch

https://invierteenhuaraz.com.pe/wp-content/plugins/motors-car-deal…/assets/js/frontend/app-ajax.js?ver=1.4.92

js invierteenhuaraz.com.pe collected 2026-10-02 13:58:22 UTC 7,899 bytes, 278 lines download raw bytes

1(function($) {
2    $(document).on('click', '#buy-car-online', function(e) {
3        e.preventDefault();
4
5        var thisBtn = $(this);
6
7        var carId = $(this).data('id');
8        var price = $(this).data('price');
9
10        $.ajax({
11            url: ajaxurl,
12            type: "POST",
13            dataType: 'json',
14            context: this,
15            data: 'car_id=' + carId + '&price=' + price + '&action=stm_ajax_buy_car_online&security=' + stm_security_nonce,
16            beforeSend: function () {
17                thisBtn.addClass('buy-online-load');
18            },
19            success: function (data) {
20
21                thisBtn.removeClass('buy-online-load');
22
23                if (data.status == 'success') {
24                    window.location = data.redirect_url;
25                }
26            }
27        });
28    });
29
30	function sortByListingType() {
31		$( 'body' ).on(
32			'change',
33			'.select-listing-type select',
34			function () {
35				let $select       = $( this );
36				let listingType   = $select.val();
37				let viewType      = $( '#stm_user_dealer_view_type' ).val();
38				let listingsView  = $( '#stm-dealer-view-type' ).val();
39				let userId        = $select.data( 'user' );
40				let popular       = listingsView === 'popular' ? 'yes' : 'no';
41				let userPublic    = $select.data( 'user-public' );
42				let userPrivate   = $select.data( 'user-private' );
43				let userFavourite = $select.data( 'user-favourite' );
44				let postsPerPage  = $select.data( 'posts-per-page' );
45				let offset        = $select.data( 'offset' );
46				if ( offset === 0 ) {
47					offset = postsPerPage;
48				}
49
50				$.ajax(
51					{
52						url: ajaxurl,
53						data: {
54							action: 'mvl_ajax_dealer_load_listings_by_type',
55							listing_type: listingType,
56							user_id: userId,
57							popular: popular,
58							view_type: viewType,
59							user_public: userPublic,
60							user_private: userPrivate,
61							user_favourite: userFavourite,
62							posts_per_page: postsPerPage,
63							offset: offset,
64							security: stm_security_nonce
65						},
66						method: 'POST',
67						dataType: 'json',
68						beforeSend: function () {
69							$( '.select-listing-type select' ).prop( "disabled", true );
70						},
71						success: function (data) {
72							$( '.select-listing-type select' ).prop( "disabled", false );
73							if (data) {
74								const $target = userPublic || userPrivate ? $( '.archive-listing-page' ) :
75								userFavourite ? $( '.archive-listing-page .car-listing-row' ) :
76								$( '#' + listingsView ).find( '.car-listing-row' );
77								$target.html( data.html );
78							}
79
80							const $loadMoreButton = $( '#' + listingsView ).find( '.stm-load-more-dealer-cars' );
81							$loadMoreButton.find('a').attr('data-listing-type', listingType);
82							$loadMoreButton.find('a').attr('data-offset', offset);
83
84							if (data.button === 'show') {
85								$loadMoreButton.show();
86							} else {
87								$loadMoreButton.hide();
88							}
89
90							$( 'img.lazy' ).lazyload(
91								{
92									effect: "fadeIn",
93									failure_limit: Math.max( $( 'img' ).length - 1, 0 )
94								}
95							);
96
97						}
98					}
99				);
100			}
101		);
102	}
103
104
105    function loadMoreDealerCars() {
106		$('body').on('click', '.stm-load-more-dealer-cars a', function (e) {
107			e.preventDefault()
108
109			if (
110				$(this)
111					.closest('.stm-load-more-dealer-cars')
112					.hasClass('not-clickable')
113			) {
114				return false
115			}
116
117			var offset = $(this).attr('data-offset')
118			var user_id = $(this).data('user')
119			var popular = $(this).data('popular')
120			var profile_page = $(this).data('profile');
121			var view_type = $('#stm_user_dealer_view_type').val()
122			var listing_type = $(this).attr('data-listing-type');
123
124			$.ajax({
125				url: ajaxurl,
126				data: {
127					action: 'mvl_ajax_dealer_load_cars',
128					offset: offset,
129					user_id: user_id,
130					popular: popular,
131					view_type: view_type,
132					profile_page: profile_page,
133					security: stm_security_nonce,
134					listing_type: listing_type,
135				},
136				method: 'POST',
137				dataType: 'json',
138				context: this,
139				beforeSend: function () {
140					$(this)
141						.closest('.stm-load-more-dealer-cars')
142						.addClass('not-clickable')
143				},
144				success: function (data) {
145					$(this)
146						.closest('.stm-load-more-dealer-cars')
147						.removeClass('not-clickable')
148					if (data.html) {
149						$(this)
150							.closest('.tab-pane')
151							.find('.car-listing-row')
152							.append(data.html)
153						$(this)
154							.closest('.stm-user-public-listing')
155							.find('.car-listing-row')
156							.append(data.html)
157						$(this)
158							.closest('.stm-user-private-main')
159							.find('.car-listing-row')
160							.append(data.html)
161					}
162					if (data.new_offset) {
163						$(this).attr('data-offset', data.new_offset)
164					}
165					if (data.button == 'hide') {
166						$(this).closest('.stm-load-more-dealer-cars').slideUp()
167						$(this)
168							.closest('.tab-pane')
169							.find('.row-no-border-last')
170							.removeClass('row-no-border-last')
171					}
172				},
173			})
174		})
175	}
176	loadMoreDealerCars();
177	sortByListingType();
178    if (window.location.search.includes('add-to-cart')) {
179        var newUrl = window.location.origin + window.location.pathname;
180        window.history.replaceState({}, document.title, newUrl);
181    }
182
183	$('#sort_by_select').on('change', function () {
184		var sortBy = $(this).val()
185		var user_id = $(this).data('user')
186		var posts_per_page = $(this).data('posts-per-page')
187		var data = {
188			action: 'stm_sort_listings',
189			sort_by: sortBy,
190			user_id: user_id,
191			security: stm_security_nonce,
192			page: 1,
193			posts_per_page: posts_per_page,
194		}
195		$.ajax({
196			url: ajaxurl,
197			type: 'POST',
198			data: data,
199			success: function (response) {
200				if (response.success) {
201					$('.car-listing-row').html(response.data.listings_html)
202					$('.pagination-container').html(response.data.pagination_html)
203					$('#sort_by_select').data('page', 1)
204
205					if (response.data.show_more_button) {
206						$('.stm-load-more-dealer-cars').show()
207					} else {
208						$('.stm-load-more-dealer-cars').hide()
209					}
210				}
211			},
212		})
213	})
214
215	$(document).on('click', '.pagination-container a', function (e) {
216		e.preventDefault()
217		var page = $(this).attr('href').split('page=')[1]
218		var sortBy = $('#sort_by_select').val()
219		var user_id = $('#sort_by_select').data('user')
220		var posts_per_page = $('#sort_by_select').data('posts-per-page')
221		var data = {
222			action: 'stm_sort_listings',
223			sort_by: sortBy,
224			user_id: user_id,
225			page: page,
226			posts_per_page: posts_per_page,
227			security: stm_security_nonce,
228		}
229		$.ajax({
230			url: ajaxurl,
231			type: 'POST',
232			data: data,
233			success: function (response) {
234				if (response.success) {
235					$('.car-listing-row').html(response.data.listings_html)
236					$('.pagination-container').html(response.data.pagination_html)
237					$('#sort_by_select').data('page', page)
238				}
239			},
240		})
241	})
242
243    $(document).on('submit', '#stm_new_password', function() {
244        var password = $(this).val();
245        var messageDiv = $(this).closest('.form-group').find('.stm-validation-message');
246        
247        $.ajax({
248            url: ajaxurl,
249            type: 'POST',
250            data: {
251                action: 'stm_validate_password',
252                password: password,
253                security: stm_security_nonce
254            },
255            success: function(response) {
256                if (!response.valid) {
257                    messageDiv.text(response.message).show();
258                } else {
259                    messageDiv.hide();
260                }
261            }
262        });
263    });
264
265    $(document).on('submit', '.stm_password_recovery', function(e) {
266        var password = $('#stm_new_password').val();
267		var messageDiv = $(this).find('.stm-validation-message');
268        
269        if (password.length < 8) {
270            e.preventDefault();
271            messageDiv.text(stm_i18n.mvl_password_validation).show();
272            return false;
273        }
274        
275        return true;
276    });
277
278})(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.