PageSourceSearch

https://dai-labor.de/wp-content/plugins/dai-env/lib/paginator/paginator.js?ver=3.2.4

js dai-labor.de collected 2026-10-02 08:16:00 UTC 3,116 bytes, 120 lines download raw bytes

1/**
2 * Paginator - 1.0
3 *
4 * Author: Benjamin Vahl
5 */
6
7function Paginator(selector, options) {
8	options = (options === undefined) ? {} : options;
9	this.selector = selector;
10
11	var defaults = {
12		first: '<i class="fas fa-angle-double-left"></i>',
13		prev: '<i class="fas fa-angle-left"></i>',
14		next: '<i class="fas fa-angle-right"></i>',
15		last: '<i class="fas fa-angle-double-right"></i>'
16	};
17	this.options = Object.assign(defaults, options);
18
19	this.currentPage = null;
20
21	var content = $("<div></div>")
22		.addClass("page-container")
23		.html($(this.selector).html());
24	$(this.selector)
25		.empty()
26		.append(content)
27		.append('<div class="switcher"><ul></ul></div>');
28	var that = this;
29
30	this.updateSize = function() {
31		this.size = 0;
32		$(this.selector+' .page').each(function(i) {
33			that.size = Math.max($(this).outerHeight(), that.size);
34		});
35		$(this.selector+' .page-container').height(this.size);
36	};
37
38	$(window).resize(function () {
39		that.updateSize();
40	});
41
42	this.addToSwitcher = function(label, classes) {
43		classes = (classes === undefined) ? "" : classes;
44		if (! label)
45			return;
46		$(this.selector+' .switcher ul').append(
47			'<li class="'+classes+'">'+label+'</li>'
48		);
49	};
50
51	this.updateSwitcher = function(delta) {
52		delta = (delta === undefined) ? 2 : delta;
53		var amount = 2 * delta + 1;
54		var index = that.active;
55		var length = $(that.selector+' .page').length;
56		var skip = amount <= length;
57		$(this.selector+' .switcher ul').empty();
58
59		if (skip) this.addToSwitcher(this.options.first, "go first");
60		this.addToSwitcher(this.options.prev, "go prev");
61		if (amount >= length) {
62			skip = false;
63			for (var n = 0; n < length; n++) {
64				this.addToSwitcher(n + 1, n === index ? "active" : "");
65			}
66		} else {
67			var low = index - delta;
68			var high = index + delta;
69			if (low < 0) {
70				high -= low;
71				low = 0;
72			}
73			if (high >= length) {
74				high = length - 1;
75				low = high - amount + 1;
76			}
77			for (var n = low; n <= high; n++) {
78				this.addToSwitcher(n + 1, n === index ? "active" : "");
79			}
80		}
81		this.addToSwitcher(this.options.next, "go next");
82		if (skip) this.addToSwitcher(this.options.last, "go last");
83		if (length <= 1)
84			$(this.selector+' .switcher').hide();
85		$(this.selector+' .switcher li').on("click", this.onSwitch);
86	};
87
88	this.select = function(index) {
89		index = (index === undefined) ? 0 : index;
90		this.active = index;
91		this.updateSwitcher();
92		if (this.currentPage !== null)
93			this.currentPage.removeClass('active');
94		this.currentPage = $($(this.selector+' .page').get(index));
95		this.currentPage.addClass("active");
96	};
97
98	this.onSwitch = function(evt) {
99		var index = that.active;
100		var maxIndex = $(that.selector+' .page').length - 1;
101		if ($(this).hasClass("go")) {
102			if ($(this).hasClass("prev")) {
103				index -= 1;
104			}
105			if ($(this).hasClass("next")) {
106				index += 1;
107			}
108			index = Math.max(0, Math.min(maxIndex, index));
109			if ($(this).hasClass("first")) index = 0;
110			if ($(this).hasClass("last")) index = maxIndex;
111		} else {
112			var index = parseInt($(this).text()) - 1;
113		}
114		that.select(index);
115	};
116
117	this.select(0);
118	this.updateSize();
119}
120

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.