PageSourceSearch

https://seikoclub.hu/cache-buster-1774622387/js/topicsubscription_handler.js

js seikoclub.hu collected 2026-09-24 14:22:16 UTC 2,921 bytes, 67 lines download raw bytes

1document.addEventListener('DOMContentLoaded', () => {
2    const topicsMarkAllButtons = document.querySelectorAll(".topicsmarkall_button");
3    const topicsubscriberbuttons = document.querySelectorAll(".topicsubscriber_button");
4
5    const endpoint = "/customer/subscriptions/topics";
6
7    if (topicsMarkAllButtons instanceof NodeList && topicsubscriberbuttons instanceof NodeList) {
8        [...topicsMarkAllButtons].map(
9            topicsMarkAllButton => topicsMarkAllButton.addEventListener("click", async (event) => {
10                event.preventDefault();
11                const action = event.currentTarget?.value || null;
12                if (action) {
13                    const responseData = await topicSubscriber({action});
14                    showTopicSibscribedMessage(responseData?.message);
15                    if (responseData.success) {
16                        [...topicsubscriberbuttons].map(topicsubscriberbutton => {
17                            topicsubscriberbutton.checked = action === "subscribe";
18                        })
19                    }
20                }
21            }));
22
23        [...topicsubscriberbuttons].map(
24            topicsubscriberbutton => topicsubscriberbutton.addEventListener("click", async (event) => {
25                const topic = event.currentTarget?.value || null;
26                const subscribed = event.currentTarget?.checked;
27                if (topic) {
28                    const responseData = await topicSubscriber({topic, subscribed});
29                    showTopicSibscribedMessage(responseData?.message);
30                }
31            }))
32    }
33
34    async function topicSubscriber({action = null, topic = "", subscribed = true}) {
35        const bodyObject = action ? {action} : {topic, subscribed};
36
37        const options = {
38            method: "POST",
39            headers: {
40                "Content-Type": "application/json"
41            },
42            body: JSON.stringify(bodyObject)
43        }
44
45        try {
46            const response = await fetch(endpoint, options);
47            const data = await response?.json();
48            return data || {success: false, message: "No data"}
49        } catch (e) {
50            return {success: false, message: "ServerError", error: e}
51        }
52    }
53
54    function showTopicSibscribedMessage(message) {
55        const topicSubscriptionModal = document.querySelector("#topicsubscription-modal");
56        if (topicSubscriptionModal instanceof HTMLElement) {
57            topicSubscriptionModal.classList.toggle("popup-modal-opened");
58            if (message) {
59                const topicSubscriptionModalChildren = topicSubscriptionModal.children[0];
60                if (topicSubscriptionModalChildren instanceof HTMLElement) {
61                    topicSubscriptionModalChildren.innerHTML = message
62                }
63                setTimeout(() => showTopicSibscribedMessage(), 3000);
64            }
65        }
66    }
67});

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.