PageSourceSearch

https://ieb-eib.org/js/archive-listing.js?v=10.59

js ieb-eib.org collected 2026-10-02 06:25:52 UTC 6,924 bytes, 250 lines download raw bytes

1(function () {
2'use strict';
3var list = document.querySelector('[data-archive-list]');
4if (!list) {
5return;
6}
7var pagination = document.querySelector('[data-archive-pagination]');
8var prefetched = {};
9var inFlight = null;
10function currentParams() {
11return new URLSearchParams(window.location.search);
12}
13function urlWith(changes) {
14var params = currentParams();
15Object.keys(changes).forEach(function (key) {
16var value = changes[key];
17if (value === null || value === '') {
18params.delete(key);
19} else {
20params.set(key, value);
21}
22});
23var query = params.toString();
24return query ? '?' + query : window.location.pathname;
25}
26function load(url, push) {
27if (inFlight) {
28inFlight.abort();
29}
30inFlight = new AbortController();
31list.classList.add('loading');
32return fetch(url, {
33headers: { 'X-Requested-With': 'XMLHttpRequest' },
34signal: inFlight.signal
35})
36.then(function (response) {
37if (!response.ok) {
38throw new Error('HTTP ' + response.status);
39}
40return response.json();
41})
42.then(function (data) {
43if (data.html) {
44list.innerHTML = data.html;
45} else {
46var empty = list.dataset.emptyText || '';
47list.innerHTML = empty
48? '<div class="no-results">' + empty + '</div>'
49: '';
50}
51if (pagination) {
52pagination.innerHTML = data.pagination || '';
53}
54var total = document.querySelector('[data-archive-total]');
55if (total && typeof data.total !== 'undefined') {
56total.textContent = data.total;
57}
58list.classList.remove('loading');
59inFlight = null;
60if (push !== false) {
61history.pushState({ archiveList: true }, '', url);
62}
63syncFilters();
64scrollToTitle();
65prefetchNeighbours(data.currentPage, data.totalPages);
66})
67.catch(function (error) {
68if (error.name === 'AbortError') {
69return;
70}
71list.classList.remove('loading');
72inFlight = null;
73window.location.href = url;
74});
75}
76function prefetchNeighbours(currentPage, totalPages) {
77[currentPage - 1, currentPage + 1].forEach(function (page) {
78if (page < 1 || page > totalPages || prefetched[page]) {
79return;
80}
81prefetched[page] = true;
82fetch(urlWith({ page: page }), {
83headers: { 'X-Requested-With': 'XMLHttpRequest' }
84})
85.then(function (response) { return response.json(); })
86.then(function (data) {
87(data.imageUrls || []).forEach(function (url) {
88var link = document.createElement('link');
89link.rel = 'prefetch';
90link.href = url;
91document.head.appendChild(link);
92});
93})
94.catch(function () {
95delete prefetched[page];
96});
97});
98}
99function scrollToTitle() {
100var title = document.querySelector('h1');
101if (!title) {
102window.scrollTo({ top: 0, behavior: 'smooth' });
103return;
104}
105var nav = document.querySelector('nav');
106var navHeight = nav ? nav.offsetHeight : 60;
107var marginTop = parseFloat(window.getComputedStyle(title).marginTop) || 0;
108var position = title.getBoundingClientRect().top + window.pageYOffset;
109window.scrollTo({ top: position - navHeight - marginTop, behavior: 'smooth' });
110}
111var filterButtons = Array.prototype.slice.call(
112document.querySelectorAll('[data-filter-key]')
113);
114function syncFilters() {
115var params = currentParams();
116filterButtons.forEach(function (button) {
117var key = button.dataset.filterKey;
118var value = button.dataset.filterValue || '';
119button.classList.toggle('active', (params.get(key) || '') === value);
120});
121var metatheme = params.get('metatheme') || '';
122document.querySelectorAll('[data-filter-group]').forEach(function (group) {
123var owner = group.dataset.filterGroup;
124group.hidden = owner !== metatheme;
125});
126list.classList.toggle('filtered', metatheme !== '');
127}
128filterButtons.forEach(function (button) {
129button.addEventListener('click', function (event) {
130event.preventDefault();
131var changes = {};
132changes[button.dataset.filterKey] = button.dataset.filterValue || '';
133changes.page = 1;
134(button.dataset.filterResets || '').split(',').forEach(function (key) {
135key = key.trim();
136if (key) {
137changes[key] = '';
138}
139});
140prefetched = {};
141load(urlWith(changes));
142});
143});
144if (pagination) {
145pagination.addEventListener('click', function (event) {
146var link = event.target.closest('.pagination-link');
147if (!link || !pagination.contains(link)) {
148return;
149}
150event.preventDefault();
151load(link.getAttribute('href'));
152});
153}
154window.addEventListener('popstate', function () {
155load(window.location.search || window.location.pathname, false);
156});
157document.querySelectorAll('form[data-filter-form]').forEach(function (form) {
158form.addEventListener('submit', function (event) {
159event.preventDefault();
160var field = form.querySelector('[data-filter-key]');
161if (!field) {
162return;
163}
164var changes = { page: 1 };
165changes[field.dataset.filterKey] = field.value.trim();
166prefetched = {};
167load(urlWith(changes));
168});
169});
170document.querySelectorAll('select[data-filter-key]').forEach(function (select) {
171select.addEventListener('change', function () {
172var changes = { page: 1 };
173changes[select.dataset.filterKey] = select.value;
174prefetched = {};
175load(urlWith(changes));
176});
177});
178function checkedValues(key) {
179return Array.prototype.slice
180.call(document.querySelectorAll('input[data-filter-check][data-filter-key="' + key + '"]:checked'))
181.map(function (cb) { return cb.value; });
182}
183document.querySelectorAll('input[data-filter-check]').forEach(function (cb) {
184cb.addEventListener('change', function () {
185var key = cb.dataset.filterKey;
186var values = checkedValues(key);
187if (values.length === 0 && cb.dataset.filterMin === '1') {
188cb.checked = true;
189return;
190}
191var changes = { page: 1 };
192changes[key] = values.join(',');
193prefetched = {};
194load(urlWith(changes));
195});
196});
197document.querySelectorAll('[data-multi-select]').forEach(function (widget) {
198var display = widget.querySelector('[data-multi-display]');
199var dropdown = widget.querySelector('[data-multi-dropdown]');
200var placeholder = widget.querySelector('[data-multi-placeholder]');
201if (!display || !dropdown) {
202return;
203}
204var boxes = Array.prototype.slice.call(dropdown.querySelectorAll('input[type="checkbox"]'));
205function refresh() {
206var chips = [];
207boxes.forEach(function (cb) {
208if (cb.checked) {
209var label = cb.closest('label');
210var text = label ? label.textContent.trim() : cb.value;
211var chip = document.createElement('span');
212chip.className = 'theme-chip';
213chip.textContent = text;
214chips.push(chip);
215}
216});
217display.innerHTML = '';
218if (chips.length === 0 && placeholder) {
219display.appendChild(placeholder);
220placeholder.style.display = '';
221} else {
222chips.forEach(function (chip) { display.appendChild(chip); });
223}
224}
225display.addEventListener('click', function () {
226dropdown.classList.toggle('open');
227display.classList.toggle('focused');
228});
229document.addEventListener('click', function (event) {
230if (!widget.contains(event.target)) {
231dropdown.classList.remove('open');
232display.classList.remove('focused');
233}
234});
235boxes.forEach(function (cb) {
236cb.addEventListener('change', function () {
237refresh();
238var values = boxes
239.filter(function (b) { return b.checked; })
240.map(function (b) { return b.value; });
241var changes = { page: 1 };
242changes[widget.dataset.filterKey] = values.join(',');
243prefetched = {};
244load(urlWith(changes));
245});
246});
247refresh();
248});
249syncFilters();
250})();

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.