PageSourceSearch

https://www.zariadim.sk/scripts/global.js?v=1.6

js zariadim.sk collected 2026-10-08 03:36:48 UTC 14,028 bytes, 590 lines download raw bytes

1accentMap = {
2	"á": "a",
3	"ä": "a",
4	"č": "c",
5	"ć": "c",
6	"ď": "d",
7	"é": "e",
8	"ě": "e",
9	"í": "i",
10	"ľ": "l",
11	"ĺ": "l",
12	"ň": "n",
13	"ó": "o",
14	"ô": "o",
15	"ö": "o",
16	"ř": "r",
17	"ŕ": "r",
18	"Å¡": "s",
19	"Å¥": "t",
20	"ú": "u",
21	"ů": "u",
22	"ý": "y",
23	"ž": "z",
24	"Á": "A",
25	"Ä": "A",
26	"Č": "C",
27	"Ć": "C",
28	"Ď": "D",
29	"É": "E",
30	"Ě": "E",
31	"Í": "I",
32	"Ľ": "L",
33	"Ĺ": "L",
34	"Ň": "N",
35	"Ó": "O",
36	"Ô": "O",
37	"Ö": "O",
38	"Ř": "R",
39	"Ŕ": "R",
40	"Å ": "S",
41	"Ť": "T",
42	"Ú": "U",
43	"Å®": "U",
44	"Ý": "Y",
45	"Ž": "Z"
46};
47
48function normalize(term) {
49	var ret = "";
50	for ( var i = 0; i < term.length; i++ ) {
51		ret += accentMap[ term.charAt(i) ] || term.charAt(i);
52	}
53	return ret;
54}
55
56$(function () {
57	var spinner = $('<div id="ajax-spinner"></div>');
58	spinner.appendTo('body').hide(0);
59
60	$(document).ajaxStop(function () {
61		spinner.hide().css({
62			position: "fixed",
63			left: "50%",
64			top: "50%",
65			"z-index": 10000
66		});
67	});
68
69	$(document).on('click', 'a.ajax', function (event) {
70		event.preventDefault();
71
72		$.post(this.href);
73
74		$("#ajax-spinner").show().css({
75			position: "absolute",
76			left: event.pageX + 20,
77			top: event.pageY + 40
78		});
79	});
80
81
82	var addWidgetTimeout;
83	$(document).on('click', 'a.set-widget', function (e) {
84		e.preventDefault();
85		$("#ajax-spinner").show().css({
86			position: "absolute",
87			left: e.pageX + 20,
88			top: e.pageY + 40
89		});
90
91		$.ajax({
92			url: this.href
93		}).done(function (data) {
94			if (data.redirect) {
95				window.location.href = data.redirect;
96				return;
97			}
98
99			$('#add-widget-error').hide();
100			$('#add-widget-success').html(data.message).fadeIn();
101			clearTimeout(addWidgetTimeout);
102			addWidgetTimeout = setTimeout(function() {
103				$('#add-widget-success').fadeOut();
104			}, 3000);
105		}).fail(function (data) {
106			if (data.responseJSON.redirect) {
107				window.location.href = data.responseJSON.redirect;
108				return;
109			}
110
111			$('#add-widget-success').hide();
112			$('#add-widget-error').html(data.responseJSON.error).fadeIn();
113			clearTimeout(addWidgetTimeout);
114			addWidgetTimeout = setTimeout(function() {
115				$('#add-widget-error').fadeOut();
116			}, 3000);
117		});
118	});
119
120	$(document).on('click', 'form.ajax :submit:not(.no-ajax)', function (event) {
121		var form = $(this).parents('form');
122
123		// if valid show spinner and send with ajax
124		if (Nette.validateForm(form[0])) {
125			$("#ajax-spinner").show().css({
126				position: "absolute",
127				left: event.pageX + 20,
128				top: event.pageY + 40
129			});
130
131			form.ajaxSubmit();
132		}
133
134		return false;
135	});
136
137	$(document).on("keyup", "textarea", function() {
138		var txt = $(this);
139		if (!txt.data("rows")) {
140			txt.data("rows", txt.attr("rows"));
141		}
142		txt.attr("rows", Math.max(txt.data("rows"), txt.val().split("\n").length));
143	});
144
145
146	// Set slovak localizations
147	$.datepicker.regional['sk'] = {
148		closeText: 'Zavrieť',
149		prevText: '&#x3c;Predchádzajúci',
150		nextText: 'Nasledujúci&#x3e;',
151		currentText: 'Dnes',
152		monthNames: ['Január','Február','Marec','Apríl','Máj','Jún',
153		'Júl','August','September','Október','November','December'],
154		monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún',
155		'Júl','Aug','Sep','Okt','Nov','Dec'],
156		dayNames: ['Nedel\'a','Pondelok','Utorok','Streda','Å tvrtok','Piatok','Sobota'],
157		dayNamesShort: ['Ned','Pon','Uto','Str','Å tv','Pia','Sob'],
158		dayNamesMin: ['Ne','Po','Ut','St','Å t','Pia','So'],
159		weekHeader: 'Ty',
160		dateFormat: 'dd.mm.yy',
161		firstDay: 1,
162		isRTL: false,
163		showMonthAfterYear: false,
164		yearSuffix: ''
165	};
166
167	$.timepicker.regional['sk'] = {
168			timeOnlyTitle: 'Zvoľte čas',
169			timeText: 'Čas',
170			hourText: 'Hodiny',
171			minuteText: 'Minúty',
172			secondText: 'Sekundy',
173			timezoneText: 'Časové pásmo',
174			currentText: 'Teraz',
175			closeText: 'Zavrieť',
176			timeFormat: 'h:m',
177			ampm: false
178		};
179
180	// Set js to date-time inputs
181	$('.date').datepicker($.datepicker.regional[ "sk" ]);
182	$.timepicker.setDefaults($.timepicker.regional['sk']);
183	$('.time').timepicker({
184		timeFormat: 'hh:mm'
185	});
186	$('.datetime').datetimepicker({
187		dateFormat: 'dd.mm.yy',
188		timeFormat: 'hh:mm'
189	});
190
191	$(document).on('focusin', '.offer-time-to input', function(e) {
192		$(this).data('touched', true);
193	});
194
195	$(document).on('change', '.offer-time-from input', function (e) {
196		var from = $(this).val();
197		var to = $(this).closest('table').find('.offer-time-to input');
198
199		if (from == '' || !from.includes(':')) {
200			return;
201		}
202
203		if ($(to).data('touched')) {
204			return;
205		}
206
207		from = from.split(':');
208		to.val((parseInt(from[0])+1) + ':' + from[1]);
209	});
210
211	// ** AUTOCOMPLETE CITIES **
212	var key = 'autocomplete-cities';
213	var input = $('input[data-key="'+key+'"]');
214	if (input.exists()) {
215		var result = typeof Storage !== 'undefined' ? window.localStorage.getItem(key) : null;
216		var cities;
217
218		if (result == null) {
219			$.get(input.data('url'), function(data) {
220				if (typeof Storage !== 'undefined') {
221					window.localStorage.setItem(key, JSON.stringify(data));
222				}
223				cities = data.cities;
224			});
225		} else {
226			var data = JSON.parse(result);
227			var now = new Date();
228			var expiration = data.hasOwnProperty('expiry') ? new Date(data.expiry.date) : null;
229
230			if (expiration == null || now > expiration) {
231				$.ajax({
232					url: input.data('url'),
233					type: 'GET',
234					async: false
235				}).done(function (data) {
236					if (typeof Storage !== 'undefined') {
237						window.localStorage.setItem(key, JSON.stringify(data));
238					}
239					cities = data.cities;
240				});
241			} else {
242				cities = data.cities;
243			}
244		}
245
246		input.autocomplete({
247			minLength: 2,
248			source: function( request, response ) {
249				var matcher = new RegExp( $.ui.autocomplete.escapeRegex( request.term ), "i" );
250				response( $.grep(cities, function(value) {
251					return matcher.test( value ) || matcher.test( normalize( value ) );
252				}));
253			}
254		});
255	}
256
257	$(document).ready(function() {
258		var key = "autocomplete-categories";
259
260		var categoryInputs = $('input[data-key=' + key + ']');
261		if (categoryInputs.length > 0) {
262			var url = $(categoryInputs).first().data('url');
263
264			var result = typeof Storage !== 'undefined' ? window.localStorage.getItem(key) : null;
265			var categories;
266
267			if (result == null) {
268				$.ajax({
269					url: url,
270					type: 'GET',
271					async: false
272				}).done(function (data) {
273					if (typeof Storage !== 'undefined') {
274						window.localStorage.setItem(key, JSON.stringify(data));
275					}
276					categories = data.categories;
277				});
278			} else {
279				var data = JSON.parse(result);
280				var now = new Date();
281				var expiration = data.hasOwnProperty('expiry') ? new Date(data.expiry.date) : null;
282
283				if (expiration == null || now > expiration) {
284					$.ajax({
285						url: url,
286						type: 'GET',
287						async: false
288					}).done(function (data) {
289						if (typeof Storage !== 'undefined') {
290							window.localStorage.setItem(key, JSON.stringify(data));
291						}
292						categories = data.categories;
293					});
294				} else {
295					categories = data.categories;
296				}
297			}
298
299			categoryInputs.each(function (index, element) {
300				$(element).autocomplete({
301					minLength: 1,
302					source: function (request, response) {
303						var unique = [];
304
305						var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
306						var matches = $.grep(categories, function (value) {
307							value = value.key || value.value || value;
308							return matcher.test(value) || matcher.test(normalize(value));
309						});
310
311						for (var i = 0; i < matches.length; i++) {
312							if ($.inArray(matches[i], unique) == -1) {
313								unique.push(matches[i].key);
314							}
315						}
316
317						response(unique);
318					}
319				});
320			});
321		}
322	});
323
324	// Fileupload
325	$('body').delegate('.upload-control', 'uploadControl', function () {
326		if (window.File && window.FileList && window.FileReader) {
327			$(this).each(function() {
328				var fileInput = $(this).find('input[type=file]');
329
330				// enable uploading multiple files
331				fileInput.attr('multiple', 'multiple');
332
333				// after change save attachments
334				fileInput.change(function(e) {
335					e.stopPropagation();
336					e.preventDefault();
337
338					// fetch FileList object
339					var files = e.target.files || e.dataTransfer.files;
340					var fd = new FormData;
341
342					// process all File objects
343					for (var i = 0, f; f = files[i]; i++) {
344						if (f.size > (1024 * 1024 * 5)) {
345							alert('Maximálna veľkosť súboru je 5MB.');
346							return;
347						}
348						fd.append(i, f);
349					}
350
351					if (files.length) {
352						$('#ajax-spinner').show();
353						uploadFiles(fd);
354					}
355
356					$(this).replaceWith($(this).val('').clone(true));
357				});
358			});
359		}
360	});
361	$('.upload-control').trigger('uploadControl');
362
363	// global login handler
364	var parent = $('.global-sign');
365	var loginForm = parent.find('.login-form');
366
367	$(document).on('click', '.login-button', function (e) {
368		e.preventDefault();
369		showGlobalSignIn();
370	});
371
372	parent.find('.jq-login-close').click(function (e) {
373		e.preventDefault();
374		loginForm.hide().css('top', '-20px').removeClass('job-post');
375		$('.lightbox-overlay').remove();
376	});
377
378
379	// function to save lightbox image with CTRL + S
380	$(window).keydown(function(e) {
381		if (!(e.which == 83 && e.ctrlKey) && !(e.which == 19)) {
382			return true;
383		}
384		var image = $('.mfp-img');
385		if (image.size() > 0) {
386			var title = $('.mfp-title');
387			var imageSrc = image.prop('src');
388			var a = document.createElement('a');
389			a.download = title ? title.text() : 'fotka.jpg';
390			a.href = imageSrc;
391			a.click();
392
393			e.preventDefault();
394			return false;
395		}
396	});
397});
398
399
400
401/**** functions ****/
402
403function showGlobalSignIn() {
404	var parent = $('.global-sign');
405	var loginForm = parent.find('.login-form');
406
407	loginForm.show();
408	if (loginForm.is(':visible')) {
409		var body = $('body');
410		body.append('<div class="lightbox-overlay"></div>');
411		$('.lightbox-overlay').css({
412			'width': function() {
413				return $('body').width();
414			},
415			'height': function() {
416				return ($(window).height() > body.height()) ? $(window).height() : body.height();
417			}
418		});
419	} else {
420		$('.lightbox-overlay').remove();
421	}
422}
423
424
425// Asynchronous files uploading
426function uploadFiles(formData) {
427	$.ajax({
428		url: $('.upload-control').data('upload-url'),
429		type: 'POST',
430		data: formData,
431		processData: false,
432		contentType: false,
433		success: jQuery.nette.success
434	});
435}
436
437
438// get form values
439function getFormValues(form) {
440	var values = {};
441
442	for (var i = 0; i < form.elements.length; i++) {
443		var elem = form.elements[i];
444		if (!(elem.nodeName.toLowerCase() in { input:1, select:1, textarea:1 }) || (elem.type in { hidden:1, submit:1, image:1, reset: 1 }) || elem.disabled || elem.readonly) {
445			continue;
446		}
447		values[elem.id] = Nette.getValue(elem);
448	}
449
450	return values;
451}
452
453// set values to form
454function setFormValues(values) {
455	for (var id in values) {
456		var value = values[id];
457		var elem = $('#' + id);
458
459		if (elem.is(':radio')) {
460			if (elem.val() == value) {
461				elem.prop('checked', true).change();
462			}
463
464		} else if (value) {
465			elem.val(value).change();
466		}
467
468		// show invitation if filled
469		if (elem.prop('name') == 'invitation' && value) {
470			$('.jp-invitation').show();
471		}
472	}
473}
474
475
476function padLeft (str, max) {
477	str = str.toString();
478	return str.length < max ? padLeft("0" + str, max) : str;
479}
480
481
482jQuery.extend({
483	googleMap : function (mapId, detectPosition, defaultLatitude, defaulLongitude) {
484		if (!defaultLatitude) {
485			defaultLatitude = 48.4;
486		}
487		if (!defaulLongitude) {
488			defaulLongitude = 19.3;
489		}
490
491		var map = new google.maps.Map(document.getElementById(mapId), {
492			// essentials
493			zoom      : 7,
494			center    : new google.maps.LatLng(defaultLatitude, defaulLongitude),
495			mapTypeId : google.maps.MapTypeId.ROADMAP,
496
497			// controls
498			scrollwheel : false,
499
500			// user interface
501			scaleControl : true,
502			scaleControlOptions : {
503				position : google.maps.ControlPosition.RIGHT_BOTTOM
504			},
505			mapTypeControl : true,
506			mapTypeControlOptions : {
507				style : google.maps.MapTypeControlStyle.DROPDOWN_MENU,
508				position : google.maps.ControlPosition.TOP_RIGHT
509			},
510			navigationControl : true,
511			navigationControlOptions : {
512				style : google.maps.NavigationControlStyle.SMALL,
513				position : google.maps.ControlPosition.TOP_LEFT
514			}
515		});
516
517		if (detectPosition) {
518			if (navigator.geolocation) {
519				navigator.geolocation.getCurrentPosition(function (position) {
520					map.setCenter(new google.maps.LatLng(position.coords.latitude, position.coords.longitude));
521					map.setZoom(14);
522				});
523
524			} else if (google.gears) {
525				var geo = google.gears.factory.create("beta.geolocation");
526				geo.getCurrentPosition(function(position) {
527					map.setCenter(new google.maps.LatLng(position.latitude, position.longitude));
528					map.setZoom(14);
529				});
530			}
531		}
532
533		return map;
534	}
535});
536
537jQuery.fn.exists = function() {
538	return this.length > 0;
539};
540
541function removeAccent(string) {
542    var withoutAccent = '';
543    for (var i = 0; i < string.length; i++) {
544        withoutAccent += accentMap.hasOwnProperty(string.charAt(i)) ? accentMap[string.charAt(i)] : string.charAt(i);
545    }
546    return withoutAccent;
547}
548
549jQuery(function ($) {
550	$('body').on('click', 'a[data-delete-confirm]', function (e) {
551		var result = confirm($(this).data('delete-confirm'));
552		if (!result) {
553			e.preventDefault();
554			return false;
555		}
556	});
557});
558
559
560function initializeMPGallery() {
561	$('.mp-gallery').each(function () {
562		$(this).magnificPopup({
563			delegate: 'a.mp-link',
564			type: 'image',
565			tLoading: 'Načítavam obrázok #%curr%...',
566			gallery: {
567				enabled: true,
568				preload: [0, 2],
569				tPrev: 'Predchádzajúci (šípka doľava)',
570				tNext: 'Ďalší (šípka doprava)',
571				tCounter: '%curr% z %total%'
572			},
573			image: {
574				tError: '<a href="%url%">Obrázok #%curr%</a> sa nepodarilo načítať.',
575				titleSrc: function (item) {
576					var title = item.el.attr('title');
577					var referenceLink = item.el.attr('data-reference-link');
578					if (referenceLink != undefined) {
579						title = '<a href="' + referenceLink + '" style="color: #FFF;" onclick="$(\'.mfp-close\').click();">' + title + '</a>';
580					}
581					return title;
582				}
583			}
584		});
585	});
586}
587
588$(document).ready(function() {
589	initializeMPGallery();
590});

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.