PageSourceSearch

https://amarkets.ng/wp-content/plugins/amarkets-partials/browser_language_popup/js/index.js?ver=403.1175

js amarkets.ng collected 2026-10-04 21:33:01 UTC 6,085 bytes, 148 lines download raw bytes

1jQuery(function($) {
2
3    function getCookie(name) {
4        let matches = document.cookie.match(new RegExp(
5            "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
6        ));
7        return matches ? decodeURIComponent(matches[1]) : undefined;
8    }
9    let browser_language_popup_cookie = getCookie('browser-language-popup');
10    var is_disabled = $('body').hasClass('domain-overwrite-active') || $('body').hasClass('disable-browser-language-popup');
11
12    if (browser_language_popup_cookie === undefined && !is_disabled) {
13        function setCookie(name, value, options) {
14            options = options || {};
15
16            var expires = options.expires;
17
18            if (typeof expires == "number" && expires) {
19                var d = new Date();
20                d.setTime(d.getTime() + expires * 1000);
21                expires = options.expires = d;
22            }
23            if (expires && expires.toUTCString) {
24                options.expires = expires.toUTCString();
25            }
26
27            value = encodeURIComponent(value);
28
29            var updatedCookie = name + "=" + value;
30
31            for (var propName in options) {
32                updatedCookie += "; " + propName;
33                var propValue = options[propName];
34                if (propValue !== true) {
35                    updatedCookie += "=" + propValue;
36                }
37            }
38
39            document.cookie = updatedCookie;
40        }
41        function cookieInit() {
42            let domain_reverse = location.hostname.split('.').reverse();
43            let global_domain = '.' + domain_reverse[1] + '.' + domain_reverse[0];
44
45            setCookie('browser-language-popup', '1', {expires: 60 * 60 * 24 * 365, domain: global_domain, path: '/'});
46        }
47
48        let popup  = $("#browser-language-popup");
49
50        let pll_languages = JSON.parse(popup.attr('data-raw'));
51        let browser_language = navigator.language;
52
53        let browser_language_flag_url = null;
54        let current_language_flag_url = null;
55        let browser_language_href = null;
56        let browser_slug = null;
57        let current_slug = null;
58
59        $.each(pll_languages, function () {
60            if (this.locale === browser_language || this.slug === browser_language) {
61                browser_language_flag_url = this.flag;
62                browser_language_href = this.url;
63                browser_slug = this.slug;
64            }
65            if (this.current_lang) {
66                current_language_flag_url = this.flag;
67                current_slug = this.slug;
68            }
69        });
70
71        let rtl_class = '';
72        if (popup.attr('data-rtl') === '1') {
73            rtl_class = 'is-rtl';
74        }
75
76        if (browser_slug != null &&
77            current_slug != null &&
78            browser_slug != current_slug) {
79            let popup_html_template =
80                '<svg id="blp-close" viewBox="0 0 20 20" fill="none">' +
81                '<path fill-rule="evenodd" clip-rule="evenodd" d="M8.52685 10L4.78508 6.25823C4.6549 6.12805 4.6549 5.917 4.78508 5.78682L5.78681 4.78509C5.91699 4.65491 6.12804 4.65491 6.25822 4.78509L9.99999 8.52686L13.7418 4.78509C13.8719 4.65491 14.083 4.65491 14.2132 4.78509L15.2149 5.78682C15.3451 5.917 15.3451 6.12805 15.2149 6.25823L11.4731 10L15.2149 13.7418C15.3451 13.8719 15.3451 14.083 15.2149 14.2132L14.2132 15.2149C14.083 15.3451 13.8719 15.3451 13.7418 15.2149L9.99999 11.4731L6.25822 15.2149C6.12804 15.3451 5.91699 15.3451 5.78681 15.2149L4.78508 14.2132C4.6549 14.083 4.6549 13.8719 4.78508 13.7418L8.52685 10Z"/>' +
82                '</svg>' +
83                '<div class="blp-text">' +
84                '<span id="blp-notice"></span>' +
85                '</div>' +
86                '<div class="blp-text">' +
87                '<strong id="blp-question"></strong>' +
88                '</div>' +
89                '<div class="blp-buttons ' + rtl_class + '">' +
90                '<a id="blp-url" class="blp-button ' + rtl_class + '" href="">' +
91                '<span class="blp-lang-code">' + browser_slug + '</span>' +
92                '<span id="blp-first-button" class="blp-button-text"></span>' +
93                '</a>' +
94                '<a id="blp-disable" class="blp-button ' + rtl_class + '" href="">' +
95                '<span class="blp-lang-code">' + current_slug + '</span>' +
96                '<span id="blp-second-button" class="blp-button-text"></span>' +
97                '</a>' +
98                '</div>';
99
100            popup.html(popup_html_template);
101
102            $('#blp-disable').on('click', function(){
103                cookieInit();
104            });
105            popup.on('click', '.fancybox-close-small',function () {
106                cookieInit();
107            });
108
109            let text_notice = popup.attr('data-notice');
110            let text_question = popup.attr('data-question');
111            let text_first_button = popup.attr('data-first-button');
112            let text_second_button = popup.attr('data-second-button');
113
114            $("#blp-notice").html(text_notice);
115            $("#blp-question").html(text_question);
116            $("#blp-first-button").html(text_first_button);
117            $("#blp-second-button").html(text_second_button);
118
119            $("#blp-browser-flag").attr('src', browser_language_flag_url);
120            $("#blp-url").attr('href', browser_language_href);
121            $("#blp-current-flag").attr('src', current_language_flag_url);
122
123            let modal = $("#browser-language-popup-modal");
124
125            modal.fadeIn(500);
126
127            modal.on('click', function () {
128                modal.fadeOut(300);
129            });
130
131            $("#browser-language-popup-modal div").on('click', function (e) {
132                e.stopPropagation();
133            });
134
135            $('#blp-disable').on('click', function(e){
136                e.preventDefault();
137                modal.fadeOut(300);
138                cookieInit();
139            });
140
141            $('#blp-close').on('click', function(){
142                modal.fadeOut(300);
143                cookieInit();
144            });
145        }
146    }
147
148});

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.