PageSourceSearch

https://projectr.tv/js/cadmorepagination.js?v00134

js projectr.tv collected 2026-09-24 19:05:34 UTC 3,909 bytes, 150 lines download raw bytes

1"use strict";
2
3class CadmorePagination {
4    constructor(model)
5    {
6        this.WidgetId = model.widgetId;
7        this.ContainerId = model.containerId;
8        this.Page = model.page;
9        this.PageSize = model.pageSize;
10        this.RecordCount = model.recordCount;
11    }
12
13    Reset(widgetId, containerId, page, pageSize, recordCount)
14    {
15        let obj = this;
16
17        obj.WidgetId = widgetId;
18        obj.ContainerId = containerId;
19        obj.Page = page;
20        obj.PageSize = pageSize;
21        obj.RecordCount = recordCount;
22
23        obj.DrawControls();
24    }
25
26    SafeId()
27    {
28        let obj = this;
29        return obj.WidgetId.replaceAll("-", "_");
30    }
31
32    SetRecordCount(recordCount)
33    {
34        let obj = this;
35        obj.RecordCount = recordCount;
36    }
37
38    NavToPreviousPage()
39    {
40        let obj = this;
41        obj.Page = obj.Page - 1;
42        if (obj.Page < 1) {obj.Page = 1}
43
44        _pageManager.TriggerWidgetEvent(obj.WidgetId, "pagingnav", null);
45
46        obj.DrawControls();
47    }
48
49    NavToNextPage()
50    {
51        let obj = this;
52        obj.Page = obj.Page + 1;
53
54        var maxPage = obj.CalcMaxPage();
55        if (obj.Page > maxPage) {obj.Page = maxPage}
56
57        _pageManager.TriggerWidgetEvent(obj.WidgetId, "pagingnav", null);
58
59        obj.DrawControls();
60    }
61
62    NavToPage(pageString)
63    {
64        let obj = this;
65        let page = Number(pageString);
66        if (page > 0) {obj.Page = page}
67        var maxPage = obj.CalcMaxPage();
68        if (obj.Page > maxPage) { obj.Page = maxPage }
69
70        _pageManager.TriggerWidgetEvent(obj.WidgetId, "pagingnav", null);
71
72        obj.DrawControls();
73    }
74
75    NavToLastPage()
76    {
77        let obj = this;
78        obj.Page = obj.CalcMaxPage();
79
80        _pageManager.TriggerWidgetEvent(obj.WidgetId, "pagingnav", null);
81
82        obj.DrawControls();
83    }
84
85    CalcMaxPage()
86    {
87        let obj = this;
88        let maxPage = 0;
89
90        if (obj.RecordCount > 0 && obj.PageSize > 0)
91        {
92            maxPage = (obj.RecordCount / obj.PageSize).toFixed(0);
93            if (maxPage < (obj.RecordCount / obj.PageSize)) { maxPage += 1; }
94        }
95
96        return Number(maxPage);
97    }
98
99    CalcSkip()
100    {
101        let obj = this;
102
103        var skip = (obj.Page - 1) * obj.PageSize;
104
105        return skip;
106    }
107
108    DrawControls()
109    {
110        let obj = this;
111        var $container = $("#" + obj.ContainerId);
112        var safeId = obj.SafeId();
113        $container.empty();
114
115        var template = $("#templatePaging").html();
116
117        var pageList = "";
118
119        var maxPage = obj.CalcMaxPage();
120
121        if (obj.RecordCount > 0) {
122            //Have data
123            pageList = "<select class='cadmore-pagination-pagelist' onchange='_pagination" + safeId + ".NavToPage($(this).val());'>"
124
125            for(var i = 1; i <= maxPage; i++)
126            {
127                var selected = (i == obj.Page) ? " selected" : "";
128
129                pageList += "<option value='" + i + "'" + selected + ">Page " + i + " of " + maxPage + "</option>";
130            } 
131
132            pageList += "</select>";
133        }
134        else
135        {
136            //No data
137            pageList = "<span class='cadmore-pagination-noresults'>No results</span>";
138        }
139
140        var $markup = template.replaceAll('{{pagelist}}', pageList).replaceAll('{{safeId}}', safeId)
141
142        $container.append($markup);
143
144        //Enable/Disable nav buttons as required;
145        $(".cadmore-pagination-firstpage").prop('disabled', (obj.Page <= 1));
146        $(".cadmore-pagination-prevpage").prop('disabled', (obj.Page <= 1));
147        $(".cadmore-pagination-nextpage").prop('disabled', (obj.Page >= maxPage));
148        $(".cadmore-pagination-lastpage").prop('disabled', (obj.Page >= maxPage));
149    }
150}

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.