PageSourceSearch

https://zes.net/js/campaign.js?v=RLY048qbv5XzQlU-hNpApmX-hRuXVaOCT6gWw__JrLo

js zes.net collected 2026-10-02 10:29:55 UTC 5,344 bytes, 165 lines download raw bytes

1const pageSize = 8; // backend'de dataCount olarak gönderilecek
2let currentPage = 1;
3let totalPages = 1;
4let currentFilter = 'all'; // 'all', 'active', 'passive', 'announcement'
5
6const CAMPAIGN_TYPE = 1;
7const ANNOUNCEMENT_TYPE = 2;
8
9function getRequestBodyForFilter(page, filter) {
10    if (filter === 'announcement') {
11        return {
12            Page: page,
13            DataCount: pageSize,
14            GetAll: true,
15            IsEnabled: false,
16            Type: ANNOUNCEMENT_TYPE
17        };
18    }
19
20    return {
21        Page: page,
22        DataCount: pageSize,
23        GetAll: filter === 'all',
24        IsEnabled: filter === 'active',
25        Type: CAMPAIGN_TYPE
26    };
27}
28
29async function loadCampaigns(page = 1, filter = currentFilter) {
30    currentPage = page;
31    currentFilter = filter;
32
33    try {
34        const requestBody = getRequestBodyForFilter(page, filter);
35
36        const response = await fetch('/Campaign/GetCampaigns', {
37            method: 'POST',
38            headers: {
39                'Content-Type': 'application/json',
40            },
41            body: JSON.stringify(requestBody)
42        });
43
44        if (!response.ok) {
45            return;
46        }
47
48        const html = await response.text();
49        document.getElementById("campaign-search-result").innerHTML = html;
50
51        totalPages = parseInt(document.getElementById("total-pages")?.value || "1");
52
53        updatePaginationUI();
54        updateTabUI();
55    } catch (error) {
56    }
57}
58
59function updatePaginationUI() {
60    const pagination = document.getElementById("pagination");
61    if (!pagination) return; // Boş durumda pagination render edilmez
62    pagination.innerHTML = "";
63
64    const prevButton = document.createElement("button");
65    prevButton.innerHTML = `<svg width="24" height="24" fill="none"><path d="M15 18L9 12L15 6" stroke="#56708C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
66    prevButton.className = "p-2 rounded-lg hover:bg-[#E6EAEE] transition-all";
67    prevButton.disabled = currentPage === 1;
68    prevButton.onclick = () => loadCampaigns(currentPage - 1, currentFilter);
69    pagination.appendChild(prevButton);
70
71    const pageButtons = getPageNumbersToDisplay(currentPage, totalPages);
72    pageButtons.forEach(p => {
73        const btn = document.createElement("button");
74        btn.textContent = p;
75        btn.className = "w-10 h-10 flex items-center justify-center rounded-lg font-medium text-sm transition-all";
76        if (p === "...") {
77            btn.disabled = true;
78            btn.classList.add("text-[#56708C]");
79        } else {
80            if (p === currentPage) {
81                btn.classList.add("bg-[#E6EAEE]", "text-[#021D3C]");
82            } else {
83                btn.classList.add("hover:bg-[#E6EAEE]", "text-[#56708C]");
84            }
85
86            btn.onclick = () => loadCampaigns(Number(p), currentFilter);
87        }
88        pagination.appendChild(btn);
89    });
90
91    const nextButton = document.createElement("button");
92    nextButton.innerHTML = `<svg width="24" height="24" fill="none"><path d="M9 6L15 12L9 18" stroke="#56708C" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
93    nextButton.className = "p-2 rounded-lg hover:bg-[#E6EAEE] transition-all";
94    nextButton.disabled = currentPage === totalPages;
95    nextButton.onclick = () => loadCampaigns(currentPage + 1, currentFilter);
96    pagination.appendChild(nextButton);
97}
98
99function updateTabUI() {
100    const tabs = document.querySelectorAll('.campaign-tabs button');
101    tabs.forEach((tab) => {
102        tab.classList.remove('active', 'bg-white', 'text-zes-navy-nav-10');
103        tab.classList.add('text-zes-navy-nav-3');
104
105        if (tab.dataset.filter === currentFilter) {
106            tab.classList.add('active', 'bg-white', 'text-zes-navy-nav-10');
107            tab.classList.remove('text-zes-navy-nav-3');
108        }
109    });
110}
111
112function handleTabClick(filter) {
113    loadCampaigns(1, filter);
114}
115
116function getPageNumbersToDisplay(current, total) {
117    const delta = 2;
118    const range = [];
119    const rangeWithDots = [];
120    let l;
121
122    for (let i = 1; i <= total; i++) {
123        if (i === 1 || i === total || (i >= current - delta && i <= current + delta)) {
124            range.push(i);
125        }
126    }
127
128    for (let i of range) {
129        if (l) {
130            if (i - l === 2) {
131                rangeWithDots.push(l + 1);
132            } else if (i - l > 2) {
133                rangeWithDots.push("...");
134            }
135        }
136        rangeWithDots.push(i);
137        l = i;
138    }
139
140    return rangeWithDots;
141}
142
143// Duyuru slug'ı altında açıldıysa varsayılan tab "Duyurular" olur.
144function getInitialFilter() {
145    const path = (window.location.pathname || '').toLowerCase();
146    if (path.includes('/duyurular') || path.includes('/announcements')) {
147        return 'announcement';
148    }
149    return 'all';
150}
151
152// Sayfa yüklendiğinde ilk içerikleri yükle
153document.addEventListener("DOMContentLoaded", function () {
154    const initialFilter = getInitialFilter();
155    loadCampaigns(1, initialFilter);
156
157    // Tab event listeners
158    const tabs = document.querySelectorAll('.campaign-tabs button');
159    tabs.forEach((tab) => {
160        tab.addEventListener('click', function () {
161            const filter = tab.dataset.filter || 'all';
162            handleTabClick(filter);
163        });
164    });
165});

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.