PageSourceSearch

https://dream-hostels.com/wp-content/themes/theme/js/scripts.js?1791292182&ver=1.0

js dream-hostels.com collected 2026-10-06 13:10:01 UTC 12,788 bytes, 473 lines download raw bytes

1(function() {
2	if (getCookie('idlealert') == '') {
3		setCookie('accept-cookie',0,365);
4	}
5	var idleTime = 0;
6	$(document).ready(function () {
7		//Increment the idle time counter every minute.
8		var idleInterval = setInterval(timerIncrement, 5000); // 20 sec
9
10		//Zero the idle timer on mouse movement.
11		$(this).mousemove(function (e) {
12			idleTime = 0;
13		});
14		$(this).keypress(function (e) {
15			idleTime = 0;
16		});
17
18		//cookie bar
19		$('.cookies-button').on('click', function(e) {
20			e.preventDefault();
21			setCookie('accept-cookie',1,365);
22			$('.cookie-bar').remove();
23		});
24
25
26	});
27
28	function timerIncrement() {
29		if (getCookie('idlealert') != 1) {
30			idleTime = idleTime + 1;
31			//console.log(idleTime);
32			if (idleTime > 3) { // 20 minutes
33				$('.idle-popup').show(250, function () {
34					setCookie('idlealert',1,1);
35				});
36
37			}
38		}
39	}
40
41	$(document).on('click','.block-booking', function(e) {
42		e.preventDefault();
43	});
44
45	$(document).mouseup(function(e)
46	{
47		var container = $(".idle-popup-content");
48
49		// if the target of the click isn't the container nor a descendant of the container
50		if (!container.is(e.target) && container.has(e.target).length === 0)
51		{
52			$('.idle-popup').hide();
53		}
54	});
55	$(document).on('click','.idle-popup-close', function() {
56		$('.idle-popup').hide();
57	})
58
59	$(document).on('change','select.lang', function() {
60		var needhref = $(this).find('option:selected').attr('data-href');
61		window.location.href = needhref;
62	});
63
64	function checkEmail(m){
65		var pattern = new RegExp(/^((\"[\w-\s]+\")|([\w-]+(?:\.[\w-]+)*)|(\"[\w-\s]+\")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
66		return pattern.test(m);
67	}
68
69	var waitForFormLoad = false;
70	var lang = $('html').attr('lang');
71	if (lang == 'uk-Ua') {
72		lang = 'uk-UA';
73	}
74	$(document).on('submit','form',function(e) {
75		var form = $(this);
76		if (form.hasClass('bestprice--content')) {
77			// Here we go for sticky form
78			var optionSelected = form.find('.towns option:selected');
79			var bookingCity = form.find('.towns option:selected').val();
80			//detect Kyiv
81			// if (bookingCity == '740' || bookingCity == '734' || bookingCity == '20') {
82			//
83			// 	e.preventDefault();
84			// 	if (waitForFormLoad === true) {} else {
85			// 		waitForFormLoad = true;
86			// 		mewsID = optionSelected.attr('data-mews');
87			// 		mewsID = window.atob(mewsID);
88			// 		Mews.Distributor({
89			// 				configurationIds: [
90			// 					mewsID
91			// 				]},
92			// 			function (distributorKyiv) {
93			// 				e.preventDefault();
94			// 				let dateStart = form.find('.datepicker1').val().split('/');
95			// 				dateStart = new Date(dateStart[2],(parseInt(dateStart[1])-1), dateStart[0]);
96			// 				distributorKyiv.setStartDate(dateStart);
97			// 				let dateEnd = form.find('.datepicker2').val().split('/');
98			// 				dateEnd = new Date(dateEnd[2],(parseInt(dateEnd[1])-1), dateEnd[0]);
99			// 				distributorKyiv.setEndDate(dateEnd);
100			// 				distributorKyiv.setLanguageCode(lang);
101			// 				distributorKyiv.open();
102			// 				waitForFormLoad = false;
103			// 			}
104			// 		);
105			// 	}
106			//
107			// } else if (bookingCity == '210' || bookingCity == '2263' || bookingCity == '2309')  {
108			// 	//detect Lviv
109			// 	e.preventDefault();
110			//
111			// 	if (waitForFormLoad === true) {} else {
112			// 		waitForFormLoad = true;
113			// 		mewsID = optionSelected.attr('data-mews');
114			// 		mewsID = window.atob(mewsID);
115			// 		Mews.Distributor({
116			// 				configurationIds: [
117			// 					mewsID
118			// 				]
119			// 			},
120			// 			function (distributorLviv) {
121			// 				e.preventDefault();
122			// 				let dateStart = form.find('.datepicker1').val().split('/');
123			// 				dateStart = new Date(dateStart[2], (parseInt(dateStart[1]) - 1), dateStart[0]);
124			// 				distributorLviv.setStartDate(dateStart);
125			// 				let dateEnd = form.find('.datepicker2').val().split('/');
126			// 				dateEnd = new Date(dateEnd[2], (parseInt(dateEnd[1]) - 1), dateEnd[0]);
127			// 				distributorLviv.setEndDate(dateEnd);
128			// 				distributorLviv.setLanguageCode(lang);
129			// 				distributorLviv.open();
130			// 				waitForFormLoad = false;
131			// 			}
132			// 		);
133			// 	}
134			// }  else if (bookingCity == '2314' || bookingCity == '2255' || bookingCity == '2309')  {
135			// 	//detect Prague
136			// 	e.preventDefault();
137			// 	if (waitForFormLoad === true) {} else {
138			// 		waitForFormLoad = true;
139			// 		mewsID = optionSelected.attr('data-mews');
140			// 		mewsID = window.atob(mewsID);
141			// 		Mews.Distributor({
142			// 				configurationIds: [
143			// 					mewsID
144			// 				]
145			// 			},
146			// 			function (disrtibutorPrague) {
147			// 				e.preventDefault();
148			// 				let dateStart = form.find('.datepicker1').val().split('/');
149			// 				dateStart = new Date(dateStart[2], (parseInt(dateStart[1]) - 1), dateStart[0]);
150			// 				disrtibutorPrague.setStartDate(dateStart);
151			// 				let dateEnd = form.find('.datepicker2').val().split('/');
152			// 				dateEnd = new Date(dateEnd[2], (parseInt(dateEnd[1]) - 1), dateEnd[0]);
153			// 				disrtibutorPrague.setEndDate(dateEnd);
154			// 				disrtibutorPrague.setLanguageCode(lang);
155			// 				disrtibutorPrague.open();
156			// 				waitForFormLoad = false;
157			// 			}
158			// 		);
159			// 	}
160			// } else {
161			// 	//we do nothing
162			// }
163
164
165			//window.location.href = form.attr('action');
166		} else {
167			e.preventDefault();
168			var fields = validateForm(form);
169			fields.data.rec = $('[data-form='+form.find('[name="form_id"]').val()+']').find('[name="rec"]').val();
170			if (fields.canSend == true) {
171				$.post('/wp-content/themes/theme/ajax/formProagation.php', fields.data, function(data) {
172					if (data == 'success') {
173						form.next('.success').css('display', 'flex');
174						form[0].reset();;
175						$('.modal-body, .modal-content, .modal-dialog, .modal').animate({scrollTop : 0}, 100);
176					} else {
177						alert('Someting went wrong, contact administrator');
178					}
179				});
180			}
181		}
182	})
183
184	$(document).on('click focus','input,textarea,select',function () {
185		$(this).removeClass('error');
186	})
187
188	function validateForm(form) {
189		returnObject = {
190			'canSend' : true,
191			'data' : {}
192		}
193		form.find('input,select,textarea').each(function() { // ,textarea
194			inNom = $(this).attr('name');
195			inVal = $(this).val();
196			inTyp = $(this).attr('type');
197			if (inNom == undefined) {
198				if ($(this).hasClass('datepicker2')) {
199					returnObject['data']['dateRangeTo'] = inVal;
200				}
201			} else {
202				if (inTyp == 'checkbox') {
203					returnObject['data']['details'] = [];
204					$('.checkboxes input:checked').each(function() {
205						returnObject['data']['details'].push($(this).val());
206					});
207
208				} else if (inNom == 'e-mail' && !checkEmail(inVal)) {
209					$(this).addClass('error');
210					returnObject['canSend'] = 'false';
211				} else if (inVal == '') {
212					$(this).addClass('error');
213					returnObject['canSend'] = 'false';
214
215				} else  {
216					returnObject['data'][inNom] = inVal;
217				}
218			}
219		});
220		return returnObject;
221	}
222
223	//quizz
224	$(document).on('click','.answer', function() {
225		$(this).closest('.answers').find('.answer').removeClass('checked');
226		$(this).closest('.answers').removeClass('error');
227		$(this).addClass('checked');
228	});
229
230	$(document).on('click','.submit-quizz', function() {
231		var showResult = true;
232		answersArray = {}
233		$('[name=result]').each(function() {
234			answersArray[$(this).val()] = 0;
235		});
236		$('.answers').each(function() {
237			if ($(this).find('.checked').length < 1) {
238				$(this).addClass('error');
239				showResult = false;
240			} else {
241				answersArray[$(this).find('.checked').attr('data-code')] += 1;
242			}
243		})
244
245		if (showResult) {
246			var arr = Object.values(answersArray);
247			var max = Math.max(...arr);
248			var result = 0;
249			Object.keys(answersArray).forEach(function(key) {
250				if (answersArray[key] == max) {
251					result = key;
252				}
253			});
254
255			window.location.href = '?result='+result;
256		} else {
257			$('html,body').animate({scrollTop : $('.answers.error').first().offset().top - 80}, 500);
258		}
259
260	});
261
262	$(document).on('click','.form-field__label',function() {
263		$(this).closest('.field-input').addClass('focused');
264		$(this).closest('.field-input').find('.form-field__input').removeAttr('focused');
265	});
266
267	//var timer;
268	var lastScrollTop = 0;
269	$(window).bind('scroll',function () {
270		// clearTimeout(timer);
271		// timer = setTimeout( refresh , 200 );
272		var st = $(window).scrollTop();
273		//console.log('st '+st);
274		if (st > 0 && st > lastScrollTop){
275			// downscroll code
276			$('header.navbar').hide();
277
278		} else {
279			// upscroll code
280			$('header.navbar').show();
281		}
282		//console.log('lst '+lastScrollTop);
283		lastScrollTop = st;
284
285	});
286
287	$(document).on('change','.hostel-quick-access', function() {
288		window.location.href = $(this).val();
289	});
290
291	$('.nav-wrapper').on('click', function(e){
292
293		if ($(e.target).hasClass('nav-wrapper')) {
294			//$('.navbar').removeClass('open');
295			$('body').removeClass('navbar-open');
296		}
297
298	});
299
300})();
301
302(function( $ ) {
303
304	/**
305	 * initMap
306	 *
307	 * Renders a Google Map onto the selected jQuery element
308	 *
309	 * @date    22/10/19
310	 * @since   5.8.6
311	 *
312	 * @param   jQuery $el The jQuery element.
313	 * @return  object The map instance.
314	 */
315	function initMap( $el ) {
316
317		// Find marker elements within map.
318		var $markers = $el.find('.map-item');
319
320		// Create gerenic map.
321		var mapArgs = {
322			zoom        : $el.data('zoom') || 16,
323			mapTypeId   : google.maps.MapTypeId.ROADMAP
324		};
325		var map = new google.maps.Map( $el[0], mapArgs );
326
327		// Add markers.
328		map.markers = [];
329		$markers.each(function(){
330			initMarker( $(this), map );
331		});
332
333		// Center map based on markers.
334		centerMap( map );
335
336		// Return map instance.
337		return map;
338	}
339
340	/**
341	 * initMarker
342	 *
343	 * Creates a marker for the given jQuery element and map.
344	 *
345	 * @date    22/10/19
346	 * @since   5.8.6
347	 *
348	 * @param   jQuery $el The jQuery element.
349	 * @param   object The map instance.
350	 * @return  object The marker instance.
351	 */
352	function initMarker( $marker, map ) {
353
354		// Get position from marker.
355		var lat = $marker.data('lat');
356		var lng = $marker.data('lng');
357
358		var latLng = {
359			lat: parseFloat( lat ),
360			lng: parseFloat( lng )
361		};
362
363		// Create marker instance.
364		if ($marker.attr('data-marker') == '') {
365			var marker = new google.maps.Marker({
366				position : latLng,
367				map: map,
368			});
369		} else {
370			var icon = {
371				url: $marker.attr('data-marker'), // url
372				scaledSize: new google.maps.Size(32, 32), // scaled size
373				origin: new google.maps.Point(0,0), // origin
374				anchor: new google.maps.Point(0, 0) // anchor
375			};
376			var marker = new google.maps.Marker({
377				position : latLng,
378				map: map,
379				icon: icon
380			});
381		}
382
383
384		if ($('.map_select li[data-value='+$marker.attr('id')+']').length > 0) {
385			google.maps.event.addDomListener($('.map_select li[data-value='+$marker.attr('id')+']')[0], "click", function(ev) {
386				map.setCenter(marker.getPosition());
387			});
388		}
389
390
391		// Append to reference for later use.
392		map.markers.push( marker );
393
394		// If marker contains HTML, add it to an infoWindow.
395		if( $marker.html() ){
396
397			// Create info window.
398			var infowindow = new google.maps.InfoWindow({
399				content: $marker.html()
400			});
401
402			// Show info window when marker is clicked.
403			google.maps.event.addListener(marker, 'click', function() {
404				infowindow.open( map, marker );
405			});
406		}
407	}
408
409	/**
410	 * centerMap
411	 *
412	 * Centers the map showing all markers in view.
413	 *
414	 * @date    22/10/19
415	 * @since   5.8.6
416	 *
417	 * @param   object The map instance.
418	 * @return  void
419	 */
420	function centerMap( map ) {
421		var bounds = new google.maps.LatLngBounds();
422		if( map.markers.length == 1 ){
423			map.markers.forEach(function( marker ){
424				bounds.extend({
425					lat: marker.position.lat(),
426					lng: marker.position.lng()
427				});
428			});
429			map.setCenter( bounds.getCenter() );
430		} else {
431			var bounds = new google.maps.LatLngBounds({
432				lat: parseFloat($('.map').attr('data-default-lat')),
433				lng: parseFloat($('.map').attr('data-default-lng'))
434			});
435			map.setCenter( bounds.getCenter() )
436		}
437	}
438
439// Render maps on page load.
440	$(document).ready(function(){
441		if ($('.map').length > 0) {
442			$('.map').each(function () {
443				var map = initMap($(this));
444			});
445		}
446
447	});
448
449
450
451})(jQuery);
452
453function setCookie(cname, cvalue, exdays) {
454	var d = new Date();
455	d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
456	var expires = "expires="+d.toUTCString();
457	document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
458}
459
460function getCookie(cname) {
461	var name = cname + "=";
462	var ca = document.cookie.split(';');
463	for(var i = 0; i < ca.length; i++) {
464		var c = ca[i];
465		while (c.charAt(0) == ' ') {
466			c = c.substring(1);
467		}
468		if (c.indexOf(name) == 0) {
469			return c.substring(name.length, c.length);
470		}
471	}
472	return "";
473}

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.