PageSourceSearch

https://fsvps.gov.ru/wp-content/themes/fsvps/js/cook.js

js fsvps.gov.ru collected 2026-10-09 04:51:40 UTC 7,420 bytes, 235 lines download raw bytes

1// Получение cookie
2function getCookie(name) {
3    const nameEQ = name + "=";
4    const ca = document.cookie.split(';');
5    for(let i = 0; i < ca.length; i++) {
6        let c = ca[i];
7        while (c.charAt(0) === ' ') c = c.substring(1, c.length);
8        if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
9    }
10    return null;
11}
12
13// Установка обычной cookie (fallback)
14function setRegularCookie(name, value, days) {
15    let expires = "";
16    if (days) {
17        const date = new Date();
18        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
19        expires = "; expires=" + date.toUTCString();
20    }
21    document.cookie = name + "=" + (value || "") + expires + "; path=/";
22}
23
24// AJAX URL прописан напрямую
25var ajaxUrl = '/wp-admin/admin-ajax.php';
26
27// Установка защищенной cookie через AJAX
28async function setSecureCookie(name, value, days) {
29    try {
30        const url = ajaxUrl + '?action=set_secure_cookie&name=' + encodeURIComponent(name) + 
31                    '&value=' + encodeURIComponent(value) + '&days=' + days;
32        
33        const response = await fetch(url, {
34            method: 'GET',
35            credentials: 'same-origin'
36        });
37        
38        const data = await response.json();
39        return data.success === true;
40    } catch(error) {
41        return false;
42    }
43}
44
45// Показать блок cookie
46function showCookieBlock() {
47    const cookieBlock = document.getElementById('cookieConsent');
48    if (!cookieBlock) return;
49    
50    cookieBlock.style.display = 'block';
51    
52    const blokClass = document.getElementById('cookie-add-blok-class');
53    if (blokClass && blokClass.value === 'fix') {
54        if (typeof jQuery !== 'undefined') {
55            jQuery('#blok').addClass('fix');
56            jQuery('body').addClass('fix');
57        }
58    }
59}
60
61// Обработчики кнопок
62function bindButtons() {
63    const acceptBtn = document.getElementById('cookieAccept');
64    if (acceptBtn) {
65        const newBtn = acceptBtn.cloneNode(true);
66        acceptBtn.parentNode.replaceChild(newBtn, acceptBtn);
67        
68        newBtn.addEventListener('click', async function(e) {
69            e.preventDefault();
70            
71            const settings = {
72                necessary: true,
73                analytics: true,
74                marketing: true
75            };
76            
77            const consentSet = await setSecureCookie('cookie_consent', 'accepted', 365);
78            const settingsSet = await setSecureCookie('cookie_settings', JSON.stringify(settings), 365);
79            
80            if (!consentSet || !settingsSet) {
81                setRegularCookie('cookie_consent', 'accepted', 365);
82                setRegularCookie('cookie_settings', JSON.stringify(settings), 365);
83            }
84            
85            const block = document.getElementById('cookieConsent');
86            if (block) block.style.display = 'none';
87            
88            const blok = document.getElementById('blok');
89            if (blok) blok.style.display = 'none';
90            
91            if (typeof jQuery !== 'undefined') {
92                jQuery('body').removeClass('fix');
93            }
94        });
95    }
96    
97    const declineBtn = document.getElementById('nocookieAccept');
98    if (declineBtn) {
99        const newBtn = declineBtn.cloneNode(true);
100        declineBtn.parentNode.replaceChild(newBtn, declineBtn);
101        
102        newBtn.addEventListener('click', function(e) {
103            e.preventDefault();
104            
105            const block = document.getElementById('cookieConsent');
106            if (block) block.style.display = 'none';
107            
108            const blok = document.getElementById('blok');
109            if (blok) blok.style.display = 'none';
110            
111            if (typeof jQuery !== 'undefined') {
112                jQuery('body').removeClass('fix');
113            }
114        });
115    }
116}
117
118// Запуск при загрузке
119document.addEventListener('DOMContentLoaded', function() {
120    const hasConsent = getCookie('cookie_consent');
121    
122    if (!hasConsent) {
123        const hasDelay = document.getElementById('cookie-has-delay')?.value === '1';
124        const delay = parseInt(document.getElementById('cookie-delay')?.value || '0');
125        
126        if (hasDelay && delay > 0) {
127            setTimeout(showCookieBlock, delay);
128        } else {
129            showCookieBlock();
130        }
131    }
132    
133    if (!getCookie('cookie_settings')) {
134        const defaultSettings = {
135            necessary: true,
136            analytics: false,
137            marketing: false
138        };
139        setRegularCookie('cookie_settings', JSON.stringify(defaultSettings), 365);
140    }
141    
142    bindButtons();
143});
144
145
146
147
148
149
150
151
152// Функция для получения оставшегося времени
153function getTimeRemaining(endtime) {
154    var t = Date.parse(endtime) - Date.parse(new Date());
155    var seconds = Math.floor((t / 1000) % 60);
156    var minutes = Math.floor((t / 1000 / 60) % 60);
157    var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
158    var days = Math.floor(t / (1000 * 60 * 60 * 24));
159    return {
160        'total': t,
161        'days': days,
162        'hours': hours,
163        'minutes': minutes,
164        'seconds': seconds
165    };
166}
167
168// Функция для инициализации таймера
169function initializeClock(container, deadline) {
170    var timerId = container.getAttribute('data-timer-id');
171    
172    var daysSpan = container.querySelector('.days_' + timerId);
173    var hoursSpan = container.querySelector('.hours_' + timerId);
174    var minutesSpan = container.querySelector('.minutes_' + timerId);
175    var secondsSpan = container.querySelector('.seconds_' + timerId);
176    
177    function updateClock() {
178        var t = getTimeRemaining(deadline);
179        
180        if (daysSpan) daysSpan.innerHTML = t.days;
181        if (hoursSpan) hoursSpan.innerHTML = ('0' + t.hours).slice(-2);
182        if (minutesSpan) minutesSpan.innerHTML = ('0' + t.minutes).slice(-2);
183        if (secondsSpan) secondsSpan.innerHTML = ('0' + t.seconds).slice(-2);
184        
185        if (t.total <= 0) {
186            clearInterval(timeinterval);
187            if (daysSpan) daysSpan.innerHTML = '0';
188            if (hoursSpan) hoursSpan.innerHTML = '00';
189            if (minutesSpan) minutesSpan.innerHTML = '00';
190            if (secondsSpan) secondsSpan.innerHTML = '00';
191        }
192    }
193    
194    updateClock();
195    var timeinterval = setInterval(updateClock, 1000);
196}
197
198// Запуск всех таймеров
199document.addEventListener('DOMContentLoaded', function() {
200    var timers = document.querySelectorAll('.countdown');
201    
202    timers.forEach(function(timer) {
203        var deadline = timer.getAttribute('data-deadline');
204        if (deadline) {
205            initializeClock(timer, deadline);
206        }
207    });
208});
209
210
211
212
213jQuery(document).ready(function(){
214    
215    
216    jQuery('#plasect .inpost').each(function(){
217        var set = jQuery('#set').val();
218        if (jQuery(this).find('.vis').length > 0)  {
219            
220        } else {
221           if (set == 1) {
222          jQuery(this).remove();           
223           }
224          
225        }
226    })
227    jQuery('#plasect .view-grouping').each(function(){
228        if (jQuery(this).find('.view-structure-node-item').length == 0)  {
229            jQuery(this).remove();
230        } else {
231        
232        }
233    })
234    
235})    

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.