PageSourceSearch

https://abo.swp.de/public/cookiemanager/js/cookiemanager.js?3

js swp.de collected 2026-10-01 09:22:49 UTC 3,698 bytes, 142 lines download raw bytes

1document.addEventListener("DOMContentLoaded", () => {
2    init();
3});
4
5function init() {
6    const methods = this;
7
8    let cookie = this.getCookie("ni_cookie_manager");
9    if (typeof cookie === "undefined" || cookie.length == 0) {
10    this.showBar();
11    }
12
13    window.document
14    .querySelector(".cookieManager__save")
15    .addEventListener("click", () => this.save());
16    window.document
17    .querySelectorAll(".cookieManager__panel")
18    .forEach((panel) => {
19        panel.addEventListener("click", function () {
20        methods.showPanel(this);
21        });
22    });
23    window.document.querySelectorAll(".cookieManager__open").forEach((el) => {
24    el.addEventListener("click", () => this.openManager());
25    });
26    window.document.querySelectorAll(".cookieManager__accept").forEach((el) => {
27        el.addEventListener("click", () => this.acceptAll());
28        });
29    window.document
30    .querySelector(".cookieManager__deny")
31    .addEventListener("click", () => this.acceptRequired());
32}
33
34function showPanel(obj) {
35    window.document
36    .querySelectorAll(".cookieManager__panel")
37    .forEach((panel) => {
38        panel.classList.remove("cookieManager__panel--active");
39    });
40    obj.classList.add("cookieManager__panel--active");
41}
42
43function showBar() {
44    window.document
45    .querySelector(".cookieManager__bar")
46    .classList.add("cookieManager__visible");
47}
48
49function hideBar() {
50    window.document
51    .querySelector(".cookieManager__bar")
52    .classList.remove("cookieManager__visible");
53}
54
55function openManager() {
56    this.hideBar();
57    var cookieConsent = this.getCookie("ni_cookie_manager");
58    if (typeof cookieConsent === "undefined" || cookieConsent.length == 0) {
59    cookieConsent = "required";
60    }
61
62    cookieConsent = cookieConsent.split("&");
63    window.document
64    .querySelectorAll(".cookieManager__input")
65    .forEach((el) => {
66        el.removeAttribute("checked");
67    });
68    cookieConsent.forEach((value, i) => {
69    if (i < cookieConsent.length - 1) {
70        const checkbox = window.document.querySelector(
71        "#cookieManager__" + value
72        );
73        checkbox ? (checkbox.checked = true) : window.console.log(value);
74    }
75    });
76
77    window.document.querySelector(".cookieManager__manager").style.display =
78    "block";
79}
80
81function hideManager() {
82    window.document.querySelector(".cookieManager__manager").style.display =
83    "none";
84}
85
86function acceptAll() {
87    this.setCookie("marketing&required", 365);
88    location.reload();
89}
90
91function acceptRequired() {
92    this.setCookie("required", 365);
93    location.reload();
94}
95
96function save() {
97    this.hideManager();
98    let consent = "";
99    window.document
100    .querySelectorAll(".cookieManager__switchCheckbox")
101    .forEach((checkbox) => {
102        if (checkbox.checked === true) {
103        consent += checkbox.getAttribute("name") + "&";
104        }
105    });
106    consent += "required";
107
108    this.setCookie(consent, 365);
109    setTimeout(function () {
110    location.reload();
111    }, 200);
112}
113
114function setCookie(cvalue, exdays) {
115    const d = new Date();
116    d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
117    let expires = "expires=" + d.toUTCString();
118
119    const hostname = window.location.hostname;
120    const domain = "domain=" + hostname;
121
122    document.cookie =
123    "ni_cookie_manager" +
124    "=" +
125    cvalue +
126    "; " +
127    expires +
128    "; " +
129    domain +
130    "; path=/";
131}
132
133function getCookie(cname) {
134    let ca = document.cookie.split(";");
135    for (var i = 0; i < ca.length; i++) {
136    var c = ca[i];
137    while (c.charAt(0) == " ") c = c.substring(1);
138    if (c.indexOf(cname) != -1)
139        return c.substring(cname.length + 1, c.length);
140    }
141    return "";
142}

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.