PageSourceSearch

https://sprotin.fo/site/templates/default/assets/javascripts/main.js

js sprotin.fo collected 2026-10-02 07:04:03 UTC 12,556 bytes, 374 lines download raw bytes

1$(function() {
2
3	// Browser checking
4	$.reject({
5		reject: {
6			//msie8: true;
7		},
8		closeCookie: false
9	});
10
11	// Searchbox
12	var $site_search__component = $('#site-search--component');
13	var $site_search__toggle = $site_search__component.find('.site-search--toggle');
14	$site_search__toggle.on('click', function () {
15		$site_search__component.toggleClass('site-search--component--visible');
16		if ($site_search__component.hasClass('site-search--component--visible')) {
17			$('#site-search--searchbox-input').focus();
18		}
19	});
20
21	// Searchbox autocomplete
22	var $site_search__searchbox__input = $('#site-search--searchbox-input');
23	$site_search__searchbox__input.autocomplete({
24		item_url: '{Url}',
25		item_param: '{Parameter}',
26		search_url: '',
27		results_class: 'site-search--results',
28		results_item_class: 'site-search--results-item'
29	});
30
31
32	// Initialize Slideshows and AddThis
33	Ease.initializePlugins();
34
35	// Initialize Offcanvas menu
36	Offcanvas.initialize();
37
38	// Initiliaze Dotdotdot's
39	$('.dotdotdot').dotdotdot({
40		watch: 'window'
41	});
42	setTimeout(function () {
43		$('.dotdotdot').trigger('destroy').dotdotdot({
44			watch: 'window'
45		});
46	}, 3000);
47
48	// Alertbox close buttons
49	$('alertbox > .close').on('click', function (e) {
50		e.preventDefault();
51		var $this = $(this);
52		var target = $this.attr('data-target');
53		$(this).closest(target ? target : 'grid').slideUp(function () {
54			$(this).remove();
55		});
56	});
57	
58
59	// Convert all # anchor tags to smooth scrolling
60	$('a[href*="#"]:not([href="#"])').click(function() {
61		if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
62			var target = $(this.hash);
63			target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
64			if (target.length) {
65				$('html, body').animate({
66					scrollTop: target.offset().top
67				}, 1000);
68				return false;
69			}
70		}
71	});
72
73	// Fullscreenator
74	$(window).on('resize load', function () {
75		$('.fullscreenator').css({
76			width: $(window).width(),
77			height: Ease.isLoggedIn ? $(window).height() - 48 : $(window).height()
78		});
79	});
80
81	// Remove loader
82	$(window).on('load', function () {
83		$('#loader_spinner').fadeOut(300, function () {
84			$('#loader_holder').fadeOut(300);
85		});
86	});
87
88	$('.adgroup--lysing iframe').on('load', function() {
89		try {
90			$(this).contents().find("head").append($('<style type="text/css">canvas { width: 100% !important; height: 100% !important; }</style>'));
91		} catch (ex) {
92		}
93	});
94
95	// Iframe lazyloader
96	$('iframe[data-src]').each(function() {
97		var $this = $(this);
98		$this.attr('src', $this.attr('data-src')).removeAttr('data-src');
99	});
100
101	// Bind searchbox reset
102	$('.searchreset').click(function () {
103		$('.searchbox').focus();
104	});
105
106
107	// HTML entity translation functions used in dictionaries
108	Tools.get_html_translation_table = function (table, quote_style) {
109		var entities = {};
110		var hash_map = {};
111		var decimal;
112		var constMappingTable = {};
113		var constMappingQuoteStyle = {};
114		var useTable = {};
115		var useQuoteStyle = {};
116		// Translate arguments
117		constMappingTable[0] = 'HTML_SPECIALCHARS';
118		constMappingTable[1] = 'HTML_ENTITIES';
119		constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
120		constMappingQuoteStyle[2] = 'ENT_COMPAT';
121		constMappingQuoteStyle[3] = 'ENT_QUOTES';
122		useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
123		useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
124		if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
125			throw new Error("Table: " + useTable + ' not supported');
126			// return false;
127		}
128		entities['38'] = '&amp;';
129		if (useTable === 'HTML_ENTITIES') {
130			entities['160'] = '&nbsp;';
131			entities['161'] = '&iexcl;';
132			entities['162'] = '&cent;';
133			entities['163'] = '&pound;';
134			entities['164'] = '&curren;';
135			entities['165'] = '&yen;';
136			entities['166'] = '&brvbar;';
137			entities['167'] = '&sect;';
138			entities['168'] = '&uml;';
139			entities['169'] = '&copy;';
140			entities['170'] = '&ordf;';
141			entities['171'] = '&laquo;';
142			entities['172'] = '&not;';
143			entities['173'] = '&shy;';
144			entities['174'] = '&reg;';
145			entities['175'] = '&macr;';
146			entities['176'] = '&deg;';
147			entities['177'] = '&plusmn;';
148			entities['178'] = '&sup2;';
149			entities['179'] = '&sup3;';
150			entities['180'] = '&acute;';
151			entities['181'] = '&micro;';
152			entities['182'] = '&para;';
153			entities['183'] = '&middot;';
154			entities['184'] = '&cedil;';
155			entities['185'] = '&sup1;';
156			entities['186'] = '&ordm;';
157			entities['187'] = '&raquo;';
158			entities['188'] = '&frac14;';
159			entities['189'] = '&frac12;';
160			entities['190'] = '&frac34;';
161			entities['191'] = '&iquest;';
162			entities['192'] = '&Agrave;';
163			entities['193'] = '&Aacute;';
164			entities['194'] = '&Acirc;';
165			entities['195'] = '&Atilde;';
166			entities['196'] = '&Auml;';
167			entities['197'] = '&Aring;';
168			entities['198'] = '&AElig;';
169			entities['199'] = '&Ccedil;';
170			entities['200'] = '&Egrave;';
171			entities['201'] = '&Eacute;';
172			entities['202'] = '&Ecirc;';
173			entities['203'] = '&Euml;';
174			entities['204'] = '&Igrave;';
175			entities['205'] = '&Iacute;';
176			entities['206'] = '&Icirc;';
177			entities['207'] = '&Iuml;';
178			entities['208'] = '&ETH;';
179			entities['209'] = '&Ntilde;';
180			entities['210'] = '&Ograve;';
181			entities['211'] = '&Oacute;';
182			entities['212'] = '&Ocirc;';
183			entities['213'] = '&Otilde;';
184			entities['214'] = '&Ouml;';
185			entities['215'] = '&times;';
186			entities['216'] = '&Oslash;';
187			entities['217'] = '&Ugrave;';
188			entities['218'] = '&Uacute;';
189			entities['219'] = '&Ucirc;';
190			entities['220'] = '&Uuml;';
191			entities['221'] = '&Yacute;';
192			entities['222'] = '&THORN;';
193			entities['223'] = '&szlig;';
194			entities['224'] = '&agrave;';
195			entities['225'] = '&aacute;';
196			entities['226'] = '&acirc;';
197			entities['227'] = '&atilde;';
198			entities['228'] = '&auml;';
199			entities['229'] = '&aring;';
200			entities['230'] = '&aelig;';
201			entities['231'] = '&ccedil;';
202			entities['232'] = '&egrave;';
203			entities['233'] = '&eacute;';
204			entities['234'] = '&ecirc;';
205			entities['235'] = '&euml;';
206			entities['236'] = '&igrave;';
207			entities['237'] = '&iacute;';
208			entities['238'] = '&icirc;';
209			entities['239'] = '&iuml;';
210			entities['240'] = '&eth;';
211			entities['241'] = '&ntilde;';
212			entities['242'] = '&ograve;';
213			entities['243'] = '&oacute;';
214			entities['244'] = '&ocirc;';
215			entities['245'] = '&otilde;';
216			entities['246'] = '&ouml;';
217			entities['247'] = '&divide;';
218			entities['248'] = '&oslash;';
219			entities['249'] = '&ugrave;';
220			entities['250'] = '&uacute;';
221			entities['251'] = '&ucirc;';
222			entities['252'] = '&uuml;';
223			entities['253'] = '&yacute;';
224			entities['254'] = '&thorn;';
225			entities['255'] = '&yuml;';
226		}
227		if (useQuoteStyle !== 'ENT_NOQUOTES') {
228			entities['34'] = '&quot;';
229		}
230		if (useQuoteStyle === 'ENT_QUOTES') {
231			entities['39'] = '&#39;';
232		}
233		entities['60'] = '&lt;';
234		entities['62'] = '&gt;';
235		// ascii decimals to real symbols
236		for (decimal in entities) {
237			if (entities.hasOwnProperty(decimal)) {
238				hash_map[String.fromCharCode(decimal)] = entities[decimal];
239			}
240		}
241		return hash_map;
242	};
243
244	Tools.htmlentities = function (string, quote_style, charset, double_encode) {
245		var hash_map = Tools.get_html_translation_table('HTML_ENTITIES', quote_style);
246		var symbol = '';
247		string = string === null ? '' : string + '';
248		if (!hash_map) {
249			return false;
250		}
251		if (quote_style && quote_style === 'ENT_QUOTES') {
252			hash_map["'"] = '&#039;';
253		}
254		double_encode = double_encode === null || !!double_encode;
255		var regex = new RegExp("&(?:#\\d+|#x[\\da-f]+|[a-zA-Z][\\da-z]*);|[" +
256			Object.keys(hash_map)
257				.join("")
258				// replace regexp special chars
259				.replace(/([()[\]{}\-.*+?^$|\/\\])/g, "\\$1") + "]",
260			"g");
261		return string.replace(regex, function(ent) {
262			if (ent.length > 1) {
263				return double_encode ? hash_map["&"] + ent.substr(1) : ent;
264			}
265			return hash_map[ent];
266		});
267	};
268
269	// Bookclub payment option input section show/hide
270	/*$("input[name='PaymentType']").change(function() {
271		if ($('#radioAutomaticPayment').is(':checked') === true) {
272			$('#user-profile-bookclub--payment-option-gs').slideDown();
273		}
274		else {
275			$('#user-profile-bookclub--payment-option-gs').slideUp();
276		}
277	});*/
278
279	// Products show and hide 'order by'
280	$('#products-order-by--header').on('click', function () {
281		$('#products-order-by--orders').slideToggle(150);
282		$('.products-order-by--icon--right').toggleClass('products-order-by--icon--down');
283	});
284
285});
286
287
288/**
289 * Initialize a newsgroup lazy loader (for use with multiple newsgroup componenets)
290 * @param limit
291 */
292var lazyLoader2_scrollBusy = false;
293var lazyLoader2 = function (limit) {
294	limit = (typeof limit !== 'undefined' && limit) ? limit : Tools.getQueryVariable('_Limit');
295	var $newsgroup_show_more = $('#newsgroup_show_more');
296	$newsgroup_show_more.on('click', function () {
297		var $newsgroup_show_more = $('#newsgroup_show_more');
298		$newsgroup_show_more.addClass('busy');
299		var newsgroupIds = $newsgroup_show_more.attr('data-ease-newsgroupids');
300		var $ease_newsgroup = $('.newsgroup--self').last();
301		$ease_newsgroup.attr('data-ease-buttonselector', '#newsgroup_show_more');
302		var language = $ease_newsgroup.attr('data-ease-language');
303		var excludenewsarticleid = $ease_newsgroup.attr('data-ease-excludenewsarticleid');
304		var offset = parseInt($ease_newsgroup.attr('data-ease-offset'), 10);
305		var interval = parseInt($ease_newsgroup.attr('data-ease-interval'), 10);
306		var template = $ease_newsgroup.attr('data-ease-template');
307		var search = $ease_newsgroup.attr('data-ease-search');
308		var $ease_newsarticles = $ease_newsgroup.find('.lazyRoot').not('.add');
309		var items = $ease_newsarticles.length;
310		$.get('/page_default.php', {
311			Offset: offset,
312			Limit: items,
313			Interval: interval,
314			NewsgroupIds: newsgroupIds,
315			Search: search,
316			p: 'newsgroup_lazy',
317			t: template,
318			Language:  language,
319			ExcludeNewsarticleId: excludenewsarticleid,
320			Append: true
321		}, function (html) {
322			var $html = $(html).find('.lazyRoot');
323			//$html = $html.length === 0 ? $(html) : $html;
324			var $ease_newsgroup = $('.newsgroup--self');
325			var previousCount = $ease_newsgroup.find('.lazyRoot').length;
326			$ease_newsgroup.find('.lazyRoot').last().after($html);
327			Ease.overlay && Ease.overlay.initialize($ease_newsgroup);
328			Ease.initializePlugins();
329			$ease_newsarticles = $ease_newsgroup.find('.lazyRoot').not('.add');
330			$ease_newsgroup.attr('data-ease-limit', $ease_newsarticles.length);
331			history.replaceState(null, '', '?' + Tools.getQuery('_Limit') + '&_Limit=' + $ease_newsarticles.length);
332			$newsgroup_show_more.removeClass('busy');
333			Revealator.refresh();
334			var currentCount = $ease_newsgroup.find('.lazyRoot').length;
335			if ((previousCount + interval) > currentCount) {
336				$('#newsgroup_show_more').hide();
337				lazyLoader2_scrollBusy = true;
338			} else {
339				lazyLoader2_scrollBusy = false;
340			}
341		});
342	});
343
344
345	// Auto activate lazyLoader2 on scroll to bottom
346	$(window).on('scroll resize load ready', function () {
347		if (!lazyLoader2_scrollBusy) {
348			lazyLoader2_scrollBusy = true;
349			setTimeout(function () {
350				var $newsgroup_show_more = $('#newsgroup_show_more');
351				if ($(window).scrollTop() + $(window).height() > $(document).height() - 400) {
352					$newsgroup_show_more.click();
353				} else {
354					lazyLoader2_scrollBusy = false;
355				}
356			}, 100);
357		}
358	});
359
360	window.onpopstate = function() {
361		var $newsgroup_show_more = $('#newsgroup_show_more');
362		var newsgroupIds = $newsgroup_show_more.attr('data-ease-newsgroupids');
363		var $ease_newsgroup = $('#ease_newsgroup_' + newsgroupIds);
364		var offset = parseInt($ease_newsgroup.attr('data-ease-offset'), 10);
365		var interval = parseInt($ease_newsgroup.attr('data-ease-interval'), 10);
366		$ease_newsgroup.attr('data-ease-limit', Tools.getQueryVariable('_Limit') ? Tools.getQueryVariable('_Limit') : interval);
367		Ease.newsgroups && Ease.newsgroups.onchange();
368	};
369
370	var $ease_newsarticles = $('.newsgroup--component').find('.lazyRoot').not('.add');
371	if ($ease_newsarticles.length < limit) {
372		$newsgroup_show_more.hide();
373	}
374};

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.