PageSourceSearch

https://hbvcdn.hacibayram.edu.tr/ortakJs/cerez.js

js hacibayram.edu.tr collected 2026-10-02 06:58:08 UTC 13,477 bytes, 486 lines download raw bytes

1(function () {
2
3    /* ============================
4       CONFIG (Dynamic GA Support)
5    ============================ */
6
7    const scriptTag = document.currentScript;
8
9    const CONFIG = {
10        storageKey: "hbv_cookie_consent",
11        cookieName: "hbv_cookie_consent",
12        consentVersion: 1,
13        ttlDays: 180,
14        delay: 1000,
15        gaId: scriptTag ? scriptTag.getAttribute("data-ga") : null,
16        submitUrl: "https://cerez.hacibayram.edu.tr/submit",
17        defaultState: {
18            necessary: true,
19            analytics: true
20        }
21    };
22
23    /* ============================
24       HELPERS
25    ============================ */
26
27    function setCookie(name, value, days) {
28        const d = new Date();
29        d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
30        document.cookie =
31            name + "=" + encodeURIComponent(value) +
32            "; expires=" + d.toUTCString() +
33            "; path=/; SameSite=Lax";
34    }
35
36    function getCookie(name) {
37        const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
38        return match ? decodeURIComponent(match[2]) : null;
39    }
40
41    function loadState() {
42        const ls = localStorage.getItem(CONFIG.storageKey);
43        if (ls) {
44            const parsed = JSON.parse(ls);
45            if (parsed && parsed.consentVersion === CONFIG.consentVersion) {
46                return parsed;
47            }
48        }
49
50        const ck = getCookie(CONFIG.cookieName);
51        if (ck) {
52            const parsed = JSON.parse(ck);
53            if (parsed && parsed.consentVersion === CONFIG.consentVersion) {
54                return parsed;
55            }
56        }
57
58        return null;
59    }
60
61    function saveState(state) {
62        const payload = JSON.stringify({
63            ...state,
64            consentVersion: CONFIG.consentVersion,
65            updatedAt: new Date().toISOString()
66        });
67
68        localStorage.setItem(CONFIG.storageKey, payload);
69        setCookie(CONFIG.cookieName, payload, CONFIG.ttlDays);
70    }
71
72    function submitState(state, action) {
73        const payload = {
74            action: action,
75            consentVersion: CONFIG.consentVersion,
76            necessary: !!state.necessary,
77            analytics: !!state.analytics,
78            hostname: window.location.hostname,
79            pageUrl: window.location.href,
80            submittedAt: new Date().toISOString()
81        };
82
83        if (typeof fetch !== "function") return;
84
85        try {
86            fetch(CONFIG.submitUrl, {
87                method: "POST",
88                headers: {
89                    "Content-Type": "application/json"
90                },
91                body: JSON.stringify(payload),
92                keepalive: true
93            }).catch(() => {});
94        } catch (_) {}
95    }
96
97    function expireCookie(name) {
98        document.cookie =
99            name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; SameSite=Lax";
100    }
101
102    function clearGACookies() {
103        const cookies = document.cookie.split(";");
104        cookies.forEach(c => {
105            const name = c.split("=")[0].trim();
106            if (name.startsWith("_ga") || name === "_gid" || name === "_gat") {
107                expireCookie(name);
108            }
109        });
110    }
111
112    /* ============================
113       GA CONTROL
114    ============================ */
115
116    function loadGA() {
117        if (!CONFIG.gaId) return;
118        if (window.__hbvGaLoaded) return;
119        window.__hbvGaLoaded = true;
120
121        const s = document.createElement("script");
122        s.async = true;
123        s.src = "https://www.googletagmanager.com/gtag/js?id=" + CONFIG.gaId;
124        document.head.appendChild(s);
125
126        window.dataLayer = window.dataLayer || [];
127        function gtag(){ dataLayer.push(arguments); }
128        window.gtag = gtag;
129
130        gtag("js", new Date());
131        gtag("config", CONFIG.gaId, { anonymize_ip: true });
132    }
133
134    function applyState(state) {
135        if (state.analytics) {
136            loadGA();
137        } else {
138            clearGACookies();
139        }
140    }
141
142    /* ============================
143       STYLE INJECTION
144    ============================ */
145
146    function injectStyles() {
147
148        // duplicate style engeli
149        if (document.getElementById("hbv-cookie-style")) return;
150
151        const style = document.createElement("style");
152        style.id = "hbv-cookie-style";
153
154        style.innerHTML = `
155    .hbv-cookie-wrap{
156      position:fixed;
157      left:0;
158      bottom:0;
159      z-index:9999;
160      pointer-events:none;
161      padding:16px;
162    }
163
164    .hbv-cookie-card{
165      pointer-events:auto;
166      max-width:540px;
167      width:100%;
168      margin:0 auto;
169      background:#fff;
170      border-radius:8px;
171      box-shadow:0 25px 60px rgba(0,0,0,.25);
172      overflow:hidden;  
173      transform:translateY(140%);
174      opacity:0;
175      transition:transform .45s ease, opacity .45s ease;
176      font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
177    }
178
179    .hbv-cookie-card.active{
180      transform:translateY(0);
181      opacity:1;
182    }
183
184    .hbv-cookie-header{
185      background:#161a1c;
186      color:#fff;
187      padding:14px 16px;
188      display:flex;
189      align-items:center;
190      gap:10px;
191      height:56px;
192    }
193
194    .hbv-ico{
195      width:22px;
196      height:22px;
197      flex:0 0 22px;
198    }
199
200    .hbv-cookie-title{
201      font-weight:700;
202      font-size:16px;
203      margin:0;
204      color:#fff;
205    }
206
207    .hbv-cookie-body{
208      padding:16px;
209    }
210
211    .hbv-cookie-desc{
212      margin:0 0 12px 0;
213      color:#374151;
214      font-size:12px;
215      line-height:1.6;
216    }
217
218    .hbv-cookie-section{
219      border:1px solid #e5e7eb;
220      border-radius:8px;
221      padding:12px 14px;
222      margin-bottom:10px;
223      display:flex;
224      justify-content:space-between;
225      align-items:center;
226      font-size:14px;
227      background:#fafafa;
228    }
229
230    .hbv-badge{
231      font-size:9px;
232      background:#e5e7eb;
233      padding:0 12px;
234      border-radius:4px;
235      font-weight:600;
236    }
237
238    .hbv-toggle{
239      position:relative;
240      width:40px;
241      height:22px;
242    }
243
244    .hbv-toggle input{
245      display:none;
246    }
247
248    .hbv-slider{
249      position:absolute;
250      inset:0;
251      background:#d1d5db;
252      border-radius:20px;
253      cursor:pointer;
254      transition:.3s;
255    }
256
257    .hbv-slider:before{
258      content:"";
259      position:absolute;
260      width:18px;
261      height:18px;
262      left:2px;
263      top:2px;
264      background:white;
265      border-radius:50%;
266      transition:.3s;
267    }
268
269    .hbv-toggle input:checked + .hbv-slider{
270      background:#1b84ff;
271    }
272
273    .hbv-toggle input:checked + .hbv-slider:before{
274      transform:translateX(18px);
275    }
276
277    .hbv-cookie-footer{
278      padding:14px 16px 16px 16px;
279      background:#f9fafb;
280      border-top:1px solid rgba(0,0,0,.06);
281    }
282
283    .hbv-cookie-actions{
284      display:flex;
285      gap:10px;
286      justify-content:space-between;
287    }
288
289    .hbv-btn{
290      flex:1;
291      border-radius:8px;
292      padding:11px 12px;
293      font-size:13px;
294      font-weight:600;
295      cursor:pointer;
296      border:none;
297      transition:.15s ease;
298      white-space:nowrap;
299    }
300
301    .hbv-btn-primary{
302      background:#1b84ff;
303      color:#fff;
304      border:1px solid #1b84ff;
305    }
306
307    .hbv-btn-primary:hover{
308      background:#056ee9;
309    }
310
311    .hbv-btn-dark{
312      background:#f1f1f4;
313      color:#161a1c;
314      border:1px solid #d1d5db;
315    }
316
317    .hbv-btn-dark:hover{
318      background:#e4e6eb;
319      border-color:#c4cada;
320    }
321
322    .hbv-btn-danger{
323      background:#fff;
324      border:1px solid #fee2e2;
325      color:#dc2626;
326    }
327
328    .hbv-btn-danger:hover{
329      background:#fee2e2;
330      color:#b91c1c;
331    }
332
333    @media (max-width:600px){
334      .hbv-cookie-actions{
335        flex-direction:column;
336      }
337      .hbv-btn{
338        width:100%;
339      }
340    }
341        `;
342
343        document.head.appendChild(style);
344    }
345
346    /* ============================
347       CREATE BAR
348    ============================ */
349
350    function createBar() {
351        if (!document.body) return;
352        if (document.getElementById("hbvCookieCard")) return;
353
354        const wrap = document.createElement("div");
355        wrap.className = "hbv-cookie-wrap";
356
357        wrap.innerHTML = `
358      <div class="hbv-cookie-card" id="hbvCookieCard">
359        <div class="hbv-cookie-header">
360          <svg class="hbv-ico" viewBox="0 0 24 24" fill="none">
361            <path d="M12 2c5.2 0 9.5 3.9 10 9-1.8.6-3.8.2-5.3-1.1-1.4-1.2-2.1-3-1.8-4.8C13.5 4 12.8 2 12 2Z" fill="rgba(255,255,255,.9)"/>
362            <path d="M4 13.2C4 8.1 8.1 4 13.2 4c.5 0 1 0 1.5.1-.2 2.1.6 4.1 2.2 5.5 1.5 1.3 3.5 1.9 5.5 1.5v.6c0 5.1-4.1 9.2-9.2 9.2S4 18.3 4 13.2Z" fill="rgba(255,255,255,.9)"/>
363            <circle cx="9" cy="13" r="1.2" fill="#161a1c"/>
364            <circle cx="12.2" cy="16" r="1.1" fill="#161a1c"/>
365            <circle cx="14.7" cy="12.4" r="1.0" fill="#161a1c"/>
366          </svg>
367          <h3 class="hbv-cookie-title">Çerez Kullanımı</h3>
368        </div>
369        <div class="hbv-cookie-body">
370          <p class="hbv-cookie-desc">
371            Hacı Bayram Veli Üniversitesi olarak internet sitemizde, 6698 sayılı KVKK kapsamında çerezler kullanmaktayız.
372            Zorunlu çerezler sitenin çalışması için gereklidir. Analitik çerezler yalnızca açık rızanız doğrultusunda kullanılmaktadır.
373            Daha fazla bilgi için <a href="https://hacibayram.edu.tr/web/cerez-politikasi" target="_blank">Çerez Politikası Metni’ni</a> inceleyebilirsiniz.
374          </p>
375          <div class="hbv-cookie-section">
376            <div>Zorunlu Çerezler</div>
377            <span class="hbv-badge">Gerekli</span>
378          </div>
379          <div class="hbv-cookie-section">
380            <div>Analitik Çerezler</div>
381            <label class="hbv-toggle">
382              <input type="checkbox" id="hbvAnalytics">
383              <span class="hbv-slider"></span>
384            </label>
385          </div>
386        </div>
387        <div class="hbv-cookie-footer">
388          <div class="hbv-cookie-actions">
389            <button type="button" class="hbv-btn hbv-btn-primary" id="hbvAcceptAll">Hepsini Kabul Et</button>
390            <button type="button" class="hbv-btn hbv-btn-dark" id="hbvSave">Kaydet</button>
391            <button type="button" class="hbv-btn hbv-btn-danger" id="hbvRejectAll">Reddet</button>
392          </div>
393        </div>
394      </div>`;
395
396        document.body.appendChild(wrap);
397
398        const card = document.getElementById("hbvCookieCard");
399        if (!card) return;
400
401        setTimeout(() => card.classList.add("active"), CONFIG.delay);
402
403        const toggle = document.getElementById("hbvAnalytics");
404        toggle.checked = CONFIG.defaultState.analytics;
405
406        function closeBanner() {
407            document.querySelectorAll(".hbv-cookie-wrap").forEach((node) => {
408                node.remove();
409            });
410        }
411
412        function handleConsent(state, action) {
413            closeBanner();
414
415            try {
416                if (state.analytics && CONFIG.gaId) {
417                    console.log("HBV GA consent accepted:", CONFIG.gaId);
418                }
419
420                saveState(state);
421                submitState(state, action);
422                applyState(state);
423            } catch (_) {
424                // Kullanici aksiyonunu UI tarafinda bloklamayalim.
425            }
426        }
427
428        document.getElementById("hbvAcceptAll").onclick = function (event) {
429            event.preventDefault();
430            handleConsent({ necessary:true, analytics:true }, "accept_all");
431        };
432
433        document.getElementById("hbvRejectAll").onclick = function (event) {
434            event.preventDefault();
435            handleConsent({ necessary:true, analytics:false }, "reject_all");
436        };
437
438        document.getElementById("hbvSave").onclick = function (event) {
439            event.preventDefault();
440            handleConsent({
441                necessary: CONFIG.defaultState.necessary,
442                analytics: toggle.checked
443            }, "save_preferences");
444        };
445    }
446
447    /* ============================
448       GLOBAL API
449    ============================ */
450
451    window.hbvCookie = {
452        reopen: function () {
453
454            // çift banner engeli
455            if (document.getElementById("hbvCookieCard")) return;
456
457            localStorage.removeItem(CONFIG.storageKey);
458            expireCookie(CONFIG.cookieName);
459            clearGACookies();
460            createBar();
461        }
462    };
463
464    /* ============================
465       INIT
466    ============================ */
467
468    function initCookieConsent() {
469        injectStyles();
470
471        const existing = loadState();
472
473        if (existing) {
474            applyState(existing);
475        } else {
476            createBar();
477        }
478    }
479
480    if (document.readyState === "loading") {
481        document.addEventListener("DOMContentLoaded", initCookieConsent, { once: true });
482    } else {
483        initCookieConsent();
484    }
485
486})();

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.