PageSourceSearch

https://a-markets.org/wp-content/plugins/amarkets-partials/mobile_app_popup/js/index.js?ver=403.1175

js a-markets.org collected 2026-10-07 16:39:23 UTC 3,597 bytes, 118 lines download raw bytes

1document.addEventListener('DOMContentLoaded', () => {
2    class AppPopup {
3        cookie_name = 'mobile-app-popup';
4        show_class = 'app__popup--show';
5
6        constructor() {
7            this.user_agent = this.get_user_agent();
8
9            if (!this.user_agent) {
10                return;
11            }
12
13            this.app_popup = document.querySelector('.app__popup');
14            const app_popup_cookie = this.get_cookie(this.cookie_name);
15
16            if (!app_popup_cookie) {
17                setTimeout(() => {
18                    this.set_app_badges();
19                    this.show_app_popup();
20                    this.add_event_listeners();
21                }, 500);
22            }
23        }
24
25        get_user_agent() {
26            const user_agent = navigator.userAgent.toLowerCase();
27
28            if (user_agent.includes('android')) {
29                return 'android';
30            }
31
32            if (user_agent.includes('iphone')) {
33                return 'iphone';
34            }
35
36            return null;
37        }
38
39        get_cookie(name) {
40            const cookie_pattern = new RegExp(`(?:^|; )${name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1')}=([^;]*)`);
41            const matches = document.cookie.match(cookie_pattern);
42
43            return matches ? decodeURIComponent(matches[1]) : undefined;
44        }
45
46        set_cookie(name, value, options = {}) {
47            let { expires, path = '/', domain } = options;
48            let cookie_string = `${name}=${encodeURIComponent(value)}`;
49
50            if (expires) {
51                if (typeof expires === 'number') {
52                    const date = new Date();
53                    date.setTime(date.getTime() + expires * 1000);
54                    expires = date;
55                }
56
57                if (expires.toUTCString) {
58                    cookie_string += `; expires=${expires.toUTCString()}`;
59                }
60            }
61
62            if (path) {
63                cookie_string += `; path=${path}`;
64            }
65
66            if (domain) {
67                cookie_string += `; domain=${domain}`;
68            }
69
70            document.cookie = cookie_string;
71        }
72
73        set_app_cookie() {
74            const domain_parts = location.hostname.split('.');
75            const cookie_expires = 60 * 60 * 24; // 24 часа
76            let domain;
77
78            if (domain_parts.length >= 2) {
79                domain = `.${domain_parts.slice(-2).join('.')}`;
80            }
81
82            this.set_cookie(this.cookie_name, '1', {
83                expires: cookie_expires,
84                domain,
85                path: '/'
86            });
87        }
88
89        set_app_badges() {
90            this.app_popup.classList.add(`app__popup--${this.user_agent}`);
91        }
92
93        show_app_popup() {
94            const app_popup = this.app_popup;
95
96            if (!app_popup) return;
97
98            document.body.classList.add(this.show_class);
99            app_popup.classList.add(this.show_class);
100            app_popup.classList.add(`app__popup--${this.user_agent}`);
101        }
102
103        add_event_listeners() {
104            const triggers = this.app_popup.querySelectorAll('.app__popup-close, .app__popup-link');
105            const click_handler = this.hide_app_popup.bind(this);
106
107            triggers.forEach(el => el.addEventListener('click', click_handler, { once: true }));
108        }
109
110        hide_app_popup() {
111            document.body.classList.remove(this.show_class);
112            this.app_popup.classList.remove(this.show_class);
113            this.set_app_cookie();
114        }
115    }
116
117  const app_popup = new AppPopup();
118});

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.