PageSourceSearch

https://economicus.ue.katowice.pl/layout/utils.js

js ue.katowice.pl collected 2026-09-24 09:16:10 UTC 7,883 bytes, 274 lines download raw bytes

1/* google Analytics code */
2function initAnalytics() {
3	if (typeof analytics !== "undefined" && analytics) {
4		(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5					(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6				m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7		})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
8
9		ga('create', analytics, domain);
10		ga('send', 'pageview');
11	}
12}
13
14function gaSendEvent(category, action, label) {
15	if (typeof analytics !== "undefined" && analytics) {
16		ga('send', 'event', category, action, label);
17	}
18}
19/* google Analytics code */
20
21function gaSendDownloadEvent(fileId, nameSizeComment) {
22	gaSendEvent('files', 'download', fileId + ' (' + nameSizeComment + ')');
23}
24
25function initFileDownloadEventHandler(){
26    var eventName = "click.fileDownloadEventHandler";
27    $('[id^=file_download_event_]').off(eventName).on(eventName, function (event) {
28        var fileId = $( this ).attr("id").substring('file_download_event_'.length);
29        var nameSizeComment = $( this ).attr("title") || $( this ).data( "title" ) || ' n/a ';
30        gaSendDownloadEvent(fileId, nameSizeComment);
31    });
32}
33
34function initMessageHelpContainerEventHandler(){
35	$(".messageHelpContainer").keypress(function (e) {
36		if (e.key === ' ' || e.key === 'Spacebar') {
37			e.preventDefault();
38			$(this).click();
39
40		}
41	});
42
43	$(".messageHelpContainer").click(function(e){
44				$(this).attr('aria-expanded', $(this).attr('aria-expanded') === 'true' ? 'false' : 'true');
45			});
46
47	$(".messageHelpOverlayPanel").keyup(function (e) {
48		if(e.key === "Escape") {
49			e.preventDefault();
50			PF($(this).data('widget-war')).hide();
51		}
52	});
53
54	if (typeof(applyWcagFixes) != "undefined"){
55		applyWcagFixes();
56	}
57}
58
59function initRightSidebarEventHandler(){
60
61
62	var $sidebar = $(".right-sidebar-menu");
63	if(!$sidebar.length){
64		return;
65	}
66
67	$(".right-sidebar-menu button.open-close-btn").off('click.sidebar').on('click.sidebar', function(e){
68		var $menu = $(this).closest(".right-sidebar-menu");
69		var prevState = $menu.hasClass("sidebar-menu-opened");
70		$(this).attr('aria-expanded', !prevState);
71		$menu.toggleClass("sidebar-menu-opened");
72	});
73
74	$(".right-sidebar-menu").off('focusout.sidebar').on('focusout.sidebar', function(e){
75		var $menu = $(this);
76		if(e.relatedTarget && $(e.relatedTarget).closest('.right-sidebar-menu').length){
77			return;
78		}
79		$menu.removeClass("sidebar-menu-opened");
80		$menu.find('button.open-close-btn').attr('aria-expanded', "false");
81	});
82
83	var sticky = $sidebar.offset().top;
84
85	$(window).off('scroll.sidebar').on('scroll.sidebar', function(){
86		if (window.pageYOffset >= sticky) {
87			$(".right-sidebar-menu").addClass("sticky")
88		} else {
89			$(".right-sidebar-menu").removeClass("sticky")
90		}
91	})
92
93
94}
95
96$(function () {
97	initAnalytics();
98	initFileDownloadEventHandler();
99	initMessageHelpContainerEventHandler();
100	initRightSidebarEventHandler();
101});
102
103function previousPage(imode, backcnt) {
104	self.history.go(-1);
105}
106
107function highlight(phrase) {
108	// This pattern assumes the IDs are strictly 32 hex chars long after the prefix.
109	const excludeIdRegex = /^[A-Z]{2,3}[0-9a-fA-F]{32}$/;
110
111	$(".rowEntry, .ui-dataview-row, .matchEntry").mark(phrase, {
112		"element": "span",
113		"accuracy": "exactly",
114		"className": "highlight",
115		"ignoreJoiners": true,
116		"ignorePunctuation": ":;.,-–—‒_(){}[]!'\"+=".split(""),
117		"filter": function(textNode, foundPhrase, totalMarks, phraseMarks) {
118			return !excludeIdRegex.test(foundPhrase);
119		}
120	});
121}
122
123function newViewState() {
124	var loc = location.pathname+location.search;
125	var newVal = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 3);
126	if (loc.search('\\?')<0) {
127		self.history.pushState(null, null, loc+'?p='+newVal);
128	} else if (loc.search('\\?p=[a-z][a-z][a-z]')>=0){
129		self.history.pushState(null, null, loc.replace(/\?p=[a-z][a-z][a-z]/,'?p='+newVal));
130	} else if (loc.search('&p=[a-z][a-z][a-z]')>=0){
131		self.history.pushState(null, null, loc.replace(/&p=[a-z][a-z][a-z]/,'&p='+newVal));
132	} else {
133		self.history.pushState(null, null, loc+'&p='+newVal);
134	}
135}
136
137var waitForFinalEvent = (function () {
138	var timers = {};
139	return function (callback, ms, uniqueId) {
140		if (!uniqueId) {
141			uniqueId = "Don't call this twice without a uniqueId";
142		}
143		if (timers[uniqueId]) {
144			clearTimeout (timers[uniqueId]);
145		}
146		timers[uniqueId] = setTimeout(callback, ms);
147	};
148})();
149
150function setFocusOnLoad(selector){
151	var watchTimeLimit = 1000;
152	var watchTick = 100;
153	jQuery(document).ready(function ($) {
154		$(selector).focus();
155		var watchStartTime = new Date().getTime();
156		checkFocusFn();
157		function checkFocusFn(){
158			var continueWatch = false;
159			if(!document.activeElement || document.activeElement.nodeName=='BODY'){
160				$(selector).focus();
161				continueWatch=true;
162			}
163			continueWatch = (new Date().getTime() - watchStartTime < watchTimeLimit) && (continueWatch || $(selector).is(":focus"));
164			if(continueWatch){
165				setTimeout(checkFocusFn,watchTick);
166			}
167		}
168
169	});
170}
171
172function getWidgetVarById(id) {
173	var widgets = PrimeFaces.widgets;
174	for (var propertyName in widgets) {
175		var widget = widgets[propertyName];
176		if (widget && widget.id === id) {
177			return widget;
178		}
179	}
180	return null;
181}
182
183function replaceHistoryStateWithParam(name, value) {
184	replaceHistoryStateWithParams([{
185		name: name,
186		value: value
187	}])
188}
189
190function replaceHistoryStateWithParams(params) {
191	if (window.history.replaceState && URL && params) {
192		var url = new URL(window.location.href);
193
194		params.forEach(function(p){
195			if(p.value === ""){
196				url.searchParams.delete(p.name);
197			}else{
198				url.searchParams.set(p.name, p.value);
199			}
200		})
201
202		url.search = url.searchParams.toString();
203		window.history.replaceState(null, null, url.toString());
204	}
205}
206
207function letterCount(element, message) {
208    if (message === undefined) {
209        message = "";
210    }
211
212    const _ID = element.getAttribute('id').replaceAll(':', '\\:');
213
214    const counterElement = element.parentElement.getElementsByClassName('counter')[0];
215
216    $(counterElement).html($('#' + _ID).val().length + "/" + $('#' + _ID).attr("maxlength") + message);
217}
218
219function initAjaxRequestProgressListeners() {
220    $(document).on("ajaxStart pfAjaxSend", function() {
221        $("html").addClass("progress");
222    }).on("ajaxStop pfAjaxComplete", function() {
223        $("html").removeClass("progress");
224    });
225}
226
227function increaseHeadingLevels(selector, increaseBy = 1) {
228	document.querySelectorAll(selector).forEach(container => {
229		container.querySelectorAll('h1, h2, h3, h4, h5, h6').forEach(heading => {
230			if (!heading.textContent.trim().length) {
231				heading.remove();
232				return;
233			}
234
235			const currentLevel = parseInt(heading.tagName.substring(1), 10);
236			const newLevel = currentLevel + increaseBy;
237
238			const tag = newLevel <= 6 ? `h${newLevel}` : 'h6';
239			const newHeading = document.createElement(tag);
240			newHeading.innerHTML = heading.innerHTML;
241
242			for (const attr of heading.attributes) {
243				newHeading.setAttribute(attr.name, attr.value);
244			}
245
246			if (newLevel > 6) {
247				newHeading.setAttribute('data-level', String(newLevel));
248				newHeading.setAttribute('aria-level', String(newLevel));
249				newHeading.classList.add(`heading-level-${newLevel}`);
250			}
251
252			heading.replaceWith(newHeading);
253		});
254	});
255}
256
257function removeEmptyElements(selector) {
258	const container = document.querySelector(selector);
259	if (!container) {
260		return;
261	}
262	const elements = container.querySelectorAll('p, div, li');
263	elements.forEach(element => {
264		const text = element.textContent.trim();
265		const hasOnlyWhitespace = text === '';
266		const hasNoMeaningfulChildren = element.children.length === 0 ||
267			Array.from(element.children).every(child =>
268				child.textContent.trim() === ''
269			);
270		if (hasOnlyWhitespace && hasNoMeaningfulChildren) {
271			element.remove();
272		}
273	});
274}

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.