PageSourceSearch

https://gmrpg.ru/assets/baba4571/logout-confirm.js

js gmrpg.ru collected 2026-10-08 13:40:51 UTC 3,968 bytes, 122 lines download raw bytes

1(function () {
2    'use strict';
3
4    function isSiteLogoutForm(form) {
5        if (!(form instanceof HTMLFormElement)) {
6            return false;
7        }
8
9        var action = form.getAttribute('action') || '';
10        var actionUrl;
11        try {
12            actionUrl = new URL(action || window.location.href, window.location.href);
13        } catch (e) {
14            return false;
15        }
16
17        return actionUrl.pathname === '/site/logout';
18    }
19
20    function createDialog(onSelect) {
21        var overlay = document.createElement('div');
22        overlay.style.position = 'fixed';
23        overlay.style.inset = '0';
24        overlay.style.zIndex = '2000';
25        overlay.style.background = 'rgba(0, 0, 0, 0.45)';
26        overlay.style.display = 'flex';
27        overlay.style.alignItems = 'center';
28        overlay.style.justifyContent = 'center';
29        overlay.style.padding = '16px';
30
31        var card = document.createElement('div');
32        card.style.width = '100%';
33        card.style.maxWidth = '460px';
34        card.style.background = '#fff';
35        card.style.borderRadius = '10px';
36        card.style.boxShadow = '0 12px 36px rgba(0, 0, 0, 0.25)';
37        card.style.padding = '18px';
38        card.style.fontFamily = 'inherit';
39        overlay.appendChild(card);
40
41        var title = document.createElement('div');
42        title.textContent = 'Выход из аккаунта';
43        title.style.fontWeight = '600';
44        title.style.fontSize = '1.05rem';
45        title.style.marginBottom = '8px';
46        card.appendChild(title);
47
48        var text = document.createElement('div');
49        text.textContent = 'Хотите так же разлогинется на RPGID?';
50        text.style.marginBottom = '14px';
51        text.style.lineHeight = '1.45';
52        card.appendChild(text);
53
54        var actions = document.createElement('div');
55        actions.style.display = 'flex';
56        actions.style.justifyContent = 'flex-end';
57        actions.style.gap = '8px';
58        card.appendChild(actions);
59
60        var noBtn = document.createElement('button');
61        noBtn.type = 'button';
62        noBtn.className = 'btn btn-outline-secondary';
63        noBtn.textContent = 'Нет';
64        actions.appendChild(noBtn);
65
66        var yesBtn = document.createElement('button');
67        yesBtn.type = 'button';
68        yesBtn.className = 'btn btn-primary';
69        yesBtn.textContent = 'Да';
70        actions.appendChild(yesBtn);
71
72        function close(selectRpgidLogout) {
73            if (overlay.parentNode) {
74                overlay.parentNode.removeChild(overlay);
75            }
76            onSelect(!!selectRpgidLogout);
77        }
78
79        yesBtn.addEventListener('click', function () {
80            close(true);
81        });
82        noBtn.addEventListener('click', function () {
83            close(false);
84        });
85        overlay.addEventListener('click', function (event) {
86            if (event.target === overlay) {
87                close(false);
88            }
89        });
90
91        document.body.appendChild(overlay);
92        yesBtn.focus();
93    }
94
95    document.addEventListener('submit', function (event) {
96        var form = event.target;
97        if (!isSiteLogoutForm(form)) {
98            return;
99        }
100        if (form.dataset.logoutConfirmHandled === '1') {
101            return;
102        }
103
104        event.preventDefault();
105
106        createDialog(function (logoutRpgid) {
107            var existing = form.querySelector('input[name="logout_rpgid"]');
108            if (existing) {
109                existing.value = logoutRpgid ? '1' : '0';
110            } else {
111                var hidden = document.createElement('input');
112                hidden.type = 'hidden';
113                hidden.name = 'logout_rpgid';
114                hidden.value = logoutRpgid ? '1' : '0';
115                form.appendChild(hidden);
116            }
117
118            form.dataset.logoutConfirmHandled = '1';
119            form.submit();
120        });
121    }, true);
122})();

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.