PageSourceSearch

https://www.rvhotlinecanada.com/assets/js/initial.js

js rvhotlinecanada.com collected 2026-10-02 13:50:58 UTC 10,224 bytes, 345 lines download raw bytes

1// Google Analytics 4 Tag Manager Script
vendor: 130 bytes, lines 2-5
2window.dataLayer = window.dataLayer || [];
3function gtag(){dataLayer.push(arguments);}
4gtag('js', new Date());
5gtag('config', '
5G-Q6GG1CTD8P
vendor: 9 bytes, lines 5-7
5');
6
7
8// Record Out Bound Link Function
9//assumes it is set on an onclick attribute of an a-tag, 
10//e.g.: onclick=recordOutboundLink(this, ...)
11function recordOutboundLink(a_el, category, action) {
12	const eventParameters = {
13		'event_category': category, 
14		'event_action': action,     
15		'clicked_url': a_el.href,
16		'event_callback': function() {
17			console.log('gtag legacy_outbound_click fired');
18			document.location = a_el.href;
19		}
20	};
21
22	// Then, send the event using gtag.js
23	gtag('event', 'legacy_outbound_click', eventParameters);
24}
25
26//own implementation of Google UA's ga(...) so that legacy event tracking goes to GA4
27function ga(command, hitType, eventCategory, eventAction, eventLabel, eventValue) {
28    if (command === 'send' && hitType === 'event') {
29        //prefix with "legacy_" to differentiate old Analytics stuff from new
30        gtag('event', 'legacy_' + eventAction, {
31            'event_category': eventCategory,
32            'event_label': eventLabel,
33            'value': eventValue
34        });
35    } else {
36        console.log('Unsupported ga() call');
37    }
38}
39
40// Image Error Placeholder Function
41function imgError(image){
42	image.onerror = "";
43	img.src = "/assets/img/placeholder-no-photo-large.png";
44	return true;
45}
46
47
48// Global DOM ready script
49$(document).ready(function(){
50
51	
52	//Make the navigation stick on every page!
53	function sticky_nav() {
54    	var top_gap = $('header .container').outerHeight();
55    	var nav_height = $('nav').outerHeight();
56
57        if( $(window).scrollTop() > top_gap ) {
58                $('nav').css({position: 'fixed', top: '0px', width: '100%', 'z-index': '1001'});
59                $('header').css({'margin-bottom': nav_height+'px'}); //accounts for the little gap the menu creates when going fixed
60        } else {
61                $('nav').css({position: 'relative'});
62                $('header').css({'margin-bottom': '0px'}); //accounts for the little gap the menu creates when going fixed
63        }		
64
65	}
66
67	//Run this function on page load, and then everytime the window is scrolled
68	sticky_nav();
69
70    $(window).scroll(function(){
71    	sticky_nav();		           
72    });	
73
74
75    // Lock the manufacturer search if brand search has value
76    if($("#brand-search").val() != null){
77    	$("#man-search").attr('readonly',true);
78    }
79
80    
81    $('#man-search').change(function(){
82    	console.log("Manufacturer entered.");
83
84    	var $entered_manufacturer = $(this).val();
85
86    	$.ajax({
87    		url : '/snippets/find-brands.php',
88    		method : 'post',
89    		dataType : 'json',
90    		data : {
91    			"selected_manufacturer" : $entered_manufacturer
92    		},
93    		success: function(data){
94
95    			if(data.status == 0){
96    				$("#brand-search").html(data.html);
97    				$("#brand-search").attr("disabled",true);
98    			} else {
99    				$("#brand-search").html(data.html);
100    				$("#brand-search").attr("disabled",false);
101    			}
102    			
103    		},
104    		error: function(data){
105    			console.log(data);
106    		}
107    	});
108
109    });
110
111    // When a brand is selected, we should try to find the brand's manufacturer and fill the manufacturer input box with the information
112    $('#brand-search').change(function(){
113    	var $selected_brand;
114
115    	$(this).find(":selected").each(function(){
116    		$selected_brand = $(this).val();
117    	});
118
119    	$.ajax({
120    		url : '/snippets/find-manufacturer.php',
121    		method : 'post',
122    		dataType : 'json',
123    		data : {
124    			"selected_brand" : $selected_brand
125    		},
126    		success: function(data){
127    			console.log(data.debug_message);
128
129    			if(data.status == '0'){
130    				$("#man-search").val(data.manufacturer);
131    				$("#man-search").attr("readonly",false);
132    			} else if (data.status == '-1') {
133    				$("#man-search").attr("readonly",true);
134    			} else {
135    				$("#man-search").val(data.manufacturer);
136    				$("#man-search").attr("readonly",true);
137    			}
138    			
139
140    		},
141    		error: function(data){
142    			console.log(data.debug_message);
143    		}
144    	});
145    })
146
147
148	
149	// Vehicle Search Form Reset
150	$('#vehicle-search-reset').click(function(e){
151		e.preventDefault();
152		
153		$('#vehicle-search-form input[type=text]').val("");
154		$('#vehicle-search-form input[type=text]').attr("readonly",false);
155		$('#vehicle-search-form #status-both').prop("checked",true);
156		$('#vehicle-search-form select').prop('selectedIndex',0);
157		
158		return false;
159	});
160	
161	// Dealer Search Form Reset
162	$('#dealer-search-reset').click(function(e){
163		e.preventDefault();
164		
165		$('#dealer-search-form input[type=text]').val("");
166		$('#dealer-search-form select').prop('selectedIndex',0);
167		
168		return false;
169	});
170
171	// Rental Search Form Reset
172	$('#vehicle-rental-reset').click(function(e){
173		e.preventDefault();
174		
175		$('#rental-search-form select').prop('selectedIndex',0);
176		
177		return false;
178	});
179	
180	
181	// Featured Units Slider
182	$('#featured-units-slider > .feature-units').bxSlider({
183		slideWidth: 192,
184		minSlides: 5,
185		maxSlides: 5,
186		slideMargin: 2,
187		pager: false,
188		nextSelector: '.slider-next',
189		prevSelector: '.slider-prev',
190		nextText: '<img src="/assets/img/controls/control-slider-next.png" alt="Next Featured Unit" id="bx-next" />',
191		prevText: '<img src="/assets/img/controls/control-slider-prev.png" alt="Previous Featured Unit" id="bx-prev" />',
192		auto: true,
193		autoHover: true,
194		onSliderLoad: function() {
195			//Make sure any duplicate bindings are unbound
196			$(".feature-unit .link").unbind('mouseenter mouseleave');
197			//Bind a hover effect onto the feature unit ads
198			$(".feature-unit .link").hover(									
199				function() {	
200					$(this).closest("div").find('.hover').css("display", "block");
201					$(this).closest("div").find('.information').css("background", "#323232");
202					$(this).closest("div").find('.price').css("background", "#323232");
203				}, function() {
204					$(this).closest("div").find('.hover').css("display", "none");
205					$(this).closest("div").find('.information').css("background", "#709c1f");
206					$(this).closest("div").find('.price').css("background", "#709c1f");
207				}					
208			);					  
209		}
210	});
211	
212	//Fade in the featured-ads when the bxSlider is done loading
213	if ($('#featured-units-slider').css("visibility") == "hidden") {
214		$('#featured-units-slider').css('visibility','visible').hide().fadeIn('slow');
215	}
216	
217	
218	// RV Search Form Modification
219	$('#vehicle-search-form').submit(function(e){
220
221		e.preventDefault();
222		
223		// Loop through the form, disable all input fields without a value
224		$('#vehicle-search-form input[type=text]').each(function(){
225			if($(this).val() == "" || $(this).val() == "-1"){
226				$(this).attr("disabled",true);	
227			}
228		});
229
230		$('#vehicle-search-form select').each(function(){
231			if($(this).val() == "" || $(this).val() == "-1"){
232				$(this).attr("disabled",true);
233			}
234		});
235
236		var form_action = $(this).attr("action");
237		
238		var vehicle_type_selected = $('#vehicle-search-form #stype').find(':selected').val();
239		var vehicle_province_selected = $('#vehicle-search-form #sprovince').find(':selected').val();
240		var vehicle_type, vehicle_status, vehicle_province;
241		
242		
243		if(vehicle_type_selected != ''){
244			vehicle_type = "/" + vehicle_type_selected;
245		} else {
246			vehicle_type = '';	
247		}
248		
249		if(vehicle_province_selected != ''){
250			vehicle_province = "/" + vehicle_province_selected;
251		} else {
252			vehicle_province = '';
253		}
254		
255		if($('#vehicle-search-form #status-preowned').is(":checked")){
256			vehicle_status = '/used';
257		} else if($('#vehicle-search-form #status-new').is(":checked")){
258			vehicle_status = '/new';
259		} else {
260			vehicle_status = '';	
261		}
262
263		var formData = $('input[name!=sstatus],select[name!=stype][name!=sprovince]',this).serialize();
264		
265		if(formData != ''){
266			window.location = form_action + vehicle_province + vehicle_status + vehicle_type + "/?" + formData;
267		} else {
268			window.location = form_action + vehicle_province + vehicle_status + vehicle_type + "/";
269		}
270	});
271
272
273	// RV Rental Search Form Modification
274	$('#rental-search-form').submit(function(e){
275
276		e.preventDefault();
277
278		var form_action = $(this).attr("action");
279		
280		var vehicle_type_selected = $('#rental-search-form #stype').find(':selected').val();
281		var vehicle_province_selected = $('#rental-search-form #sprovince').find(':selected').val();
282		var vehicle_type, vehicle_province;
283		
284		
285		if(vehicle_type_selected != ''){
286			vehicle_type = "/" + vehicle_type_selected;
287		} else {
288			vehicle_type = '';	
289		}
290		
291		if(vehicle_province_selected != ''){
292			vehicle_province = "/" + vehicle_province_selected;
293		} else {
294			vehicle_province = '';
295		}
296		
297
298		var formData = $('select[name!=stype][name!=sprovince]',this).serialize();
299		
300		if(formData != ''){
301			window.location = form_action + vehicle_province + vehicle_type + "/?" + formData;
302		} else {
303			window.location = form_action + vehicle_province + vehicle_type + "/";
304		}
305	});
306	
307	
308	// RV Search Form Modification
309	$('#dealer-search-form').submit(function(e){
310
311		e.preventDefault();
312		
313		// Loop through the form, disable all input fields without a value
314		$('#dealer-search-form input[type=text]').each(function(){
315			if($(this).val() == ""){
316				$(this).attr("disabled",true);	
317			}
318		});
319
320		var form_action = $(this).attr("action");
321		
322		var province_selected = $('#dealer-search-form #dealer-by-state').find(':selected').val();
323		var province;
324		
325		if(province_selected != ''){
326			province = "/" + province_selected;
327		} else {
328			province = '';	
329		}
330
331		var formData = $('input[name!=prov]',this).serialize();
332		
333		if(formData != ''){
334			window.location = form_action + province + "/?" + formData;
335			//alert(form_action + province + "/?" + formData);
336		} else {
337			window.location = form_action + province + "/";
338			//alert(form_action + province + "/");
339		}
340		
341		return false;
342	});
343	
344
345});

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.