PageSourceSearch

https://nordfront.se/wp-content/plugins/faktabasen/public/js/quote-widget.js?ver=1790007109

js nordfront.se collected 2026-09-24 20:25:57 UTC 2,373 bytes, 68 lines download raw bytes

1/**
2 * Faktabasen — citatwidgetens JS-kopia (vanilla, inga beroenden).
3 * Ordagrann funktionsport av temats sidebar-quotes.js (init_quotes,
4 * prev_quote, next_quote) med två skydd:
5 *  1. Globalerna definieras endast om de saknas — under överlappet
6 *     laddas denna fil inte alls (temats widget renderar), men skulle
7 *     båda finnas vinner temats definitioner.
8 *  2. Egen bootstrap för .quotes_collection[data-onload] med
9 *     idempotensflagga (data-fb-init) — temats generella
10 *     [data-onload]-eval-bootstrap finns duplicerad i en överlevande
11 *     temafil och kan anropa init_quotes före oss; flaggan sätts i
12 *     init_quotes så dubbelinitiering aldrig sker.
13 */
14(function () {
15	'use strict';
16
17	function fill(collection, index) {
18		var quotes = collection.querySelectorAll('blockquote');
19		if (!quotes.length) { return; }
20		collection.setAttribute('data-index', String(index));
21		var area = collection.closest('.sidebar-area');
22		var target = area ? area.querySelector('.content blockquote') : null;
23		if (target) { target.innerHTML = quotes[index].innerHTML; }
24	}
25
26	function step(el, delta) {
27		var area = el.closest('.sidebar-area');
28		if (!area) { return; }
29		var collection = area.querySelector('.quotes_collection');
30		if (!collection) { return; }
31		var count = collection.querySelectorAll('blockquote').length;
32		if (!count) { return; }
33		var index = parseInt(collection.getAttribute('data-index') || '0', 10) + delta;
34		if (index < 0) { index = count - 1; }
35		if (index > count - 1) { index = 0; }
36		fill(collection, index);
37	}
38
39	if (typeof window.init_quotes === 'undefined') {
40		window.init_quotes = function (e) {
41			if (!e || e.getAttribute('data-fb-init')) { return; }
42			e.setAttribute('data-fb-init', '1');
43			var count = e.querySelectorAll('blockquote').length;
44			if (!count) { return; }
45			fill(e, Math.floor(Math.random() * count));
46		};
47	}
48
49	if (typeof window.prev_quote === 'undefined') {
50		window.prev_quote = function (e) { step(e, -1); };
51	}
52
53	if (typeof window.next_quote === 'undefined') {
54		window.next_quote = function (e) { step(e, 1); };
55	}
56
57	function boot() {
58		document.querySelectorAll('.quotes_collection[data-onload]').forEach(function (el) {
59			window.init_quotes(el);
60		});
61	}
62
63	if (document.readyState === 'loading') {
64		document.addEventListener('DOMContentLoaded', boot);
65	} else {
66		boot();
67	}
68})();

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.