PageSourceSearch

https://spacecitygolfcarts.com/wp-content/plugins/motors-car-deale…/assets/js/frontend/app-ajax.js?ver=1.4.125

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