PageSourceSearch

https://globalkids.ua/view/js/functions.js?v=NHzLV

js globalkids.ua collected 2026-10-07 23:04:44 UTC 17,667 bytes, 481 lines download raw bytes

1var hiddenPopupAfter = 5000;
2var maxSizeUploadFile = 10 * 1024 * 1000; // Maximum file size upload. 10 MB
3
4function hiddenMainPreloader() {
5	$('#preloader').fadeOut(200);
6}
7
8function viewMainPreloader() {
9	$('#preloader').css('display', 'block');
10}
11
12// Crossbrowse window size
13function getPageSize() {
14    var xScroll, yScroll;
15
16    if (window.innerHeight && window.scrollMaxY) {
17        xScroll = document.body.scrollWidth;
18        yScroll = window.innerHeight + window.scrollMaxY;
19    } else if (document.body.scrollHeight > document.body.offsetHeight) { // all but Explorer Mac
20        xScroll = document.body.scrollWidth;
21        yScroll = document.body.scrollHeight;
22    } else if (document.documentElement && document.documentElement.scrollHeight > document.documentElement.offsetHeight) { // Explorer 6 strict mode
23        xScroll = document.documentElement.scrollWidth;
24        yScroll = document.documentElement.scrollHeight;
25    } else { // Explorer Mac...would also work in Mozilla and Safari
26        xScroll = document.body.offsetWidth;
27        yScroll = document.body.offsetHeight;
28    }
29
30    var windowWidth, windowHeight;
31
32    if (self.innerHeight) { // all except Explorer
33        windowWidth = self.innerWidth;
34        windowHeight = self.innerHeight;
35    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
36        windowWidth = document.documentElement.clientWidth;
37        windowHeight = document.documentElement.clientHeight;
38    } else if (document.body) { // other Explorers
39        windowWidth = document.body.clientWidth;
40        windowHeight = document.body.clientHeight;
41    }
42
43    // for small pages with total height less then height of the viewport
44    if (yScroll < windowHeight){
45        pageHeight = windowHeight;
46    } else {
47        pageHeight = yScroll;
48    }
49
50    // for small pages with total width less then width of the viewport
51    if (xScroll < windowWidth){
52        pageWidth = windowWidth;
53    } else {
54        pageWidth = xScroll;
55    }
56
57    return [pageWidth, pageHeight, windowWidth, windowHeight];
58}
59
60// Check touch device
61function isTouchDevice() {
62    var prefixes = ' -webkit- -moz- -o- -ms- '.split(' ');
63
64    var mq = function(query) {
65        return window.matchMedia(query).matches;
66    }
67
68    if (('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
69        return true;
70    }
71
72    var query = ['(', prefixes.join('touch-enabled),('), 'heartz', ')'].join('');
73
74    return mq(query);
75}
76
77// Valid email
78function isValidMail(mail) {
79    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
80
81    return pattern.test(mail);
82}
83
84// Cursor coordinates
85function getPosition(e) {
86    var x = y = 0;
87 
88    if (!e) {
89        var e = window.event;
90    }
91 
92    if (e.pageX || e.pageY){
93        x = e.pageX;
94        y = e.pageY;
95    } else if (e.clientX || e.clientY){
96        x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
97        y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
98    }
99 
100    return {x: x, y: y}
101}
102
103// Cookie
104var WFCookie = {
105    get: function(e) {
106        var t = document.cookie.match(new RegExp("(?:^|; )" + e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") + "=([^;]*)"));
107        return t ? decodeURIComponent(t[1]) : null
108    },
109    set: function(e, t, n) {
110        null == n && (n = {}),
111        (n = Object.assign({}, {
112            path: "/"
113        }, n)).expires instanceof Date && (n.expires = n.expires.toUTCString());
114        var i = encodeURIComponent(e) + "=" + encodeURIComponent(t);
115        for (var r in n)
116            if (!1 !== n.hasOwnProperty(r)) {
117                i += "; " + r;
118                var o = n[r];
119                !0 !== o && (i += "=" + o)
120            }
121        document.cookie = i
122    },
123    remove: function(e) {
124        this.set(e, "", {
125            "max-age": -1
126        })
127    }
128};
129"undefined" != typeof module && void 0 !== module.exports && (module.exports = WFCookie);
130
131/*// Remove dublicates from array
132function removeDublicatesFromArray(list) {
133    return list.filter(function(element, index, self) {
134        return index === self.indexOf(element); 
135    });
136}*/
137
138// Fix quotes
139function wfFixQuotes(str) {
140    str = str.replace(/"/g, '&quot;');
141    str = str.replace(/'/g, '&#039;');
142
143    return str;
144}
145
146function wfFixQuotesReverse(str) {
147    str = str.replaceAll("&quot;", "\"");
148    str = str.replaceAll("&#039;", "\'");
149
150    return str;
151}
152
153// Url get-parameters
154var getUrlParameter = function getUrlParameter(sParam) {
155    var sPageURL = window.location.search.substring(1),
156        sURLVariables = sPageURL.split('&'),
157        sParameterName,
158        i;
159
160    for (i = 0; i < sURLVariables.length; i++) {
161        sParameterName = sURLVariables[i].split('=');
162
163        if (sParameterName[0] === sParam) {
164            return typeof sParameterName[1] === 'undefined' ? true : decodeURIComponent(sParameterName[1]);
165        }
166    }
167    return false;
168};
169
170// Additional fix for formation of url when redirecting
171function fixedEncodeURIComponent(str) {
172    return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
173        return '%' + c.charCodeAt(0).toString(16);
174    });
175}
176
177// Copy text to buffer
178function copy(value) {
179    var $temp = $("<textarea>");
180
181    $("body").append($temp);
182
183    $temp.val(value).select();
184
185    document.execCommand("copy");
186
187    $temp.remove();
188}
189
190// Generate random string
191function generateRandomString(stringLength) {
192    var returnValue = '';
193
194    var chars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
195    var numChars = chars.length;
196
197    for (var i = 0; i < stringLength; i++) {
198        returnValue += chars[randomIntFromInterval(0, numChars - 1)];
199    }
200
201    return returnValue;
202}
203
204// Random number between
205function randomIntFromInterval(min, max) {
206    return Math.floor(Math.random() * (max - min + 1) + min)
207}
208
209// Open error modal
210function errorModal(errorText) {
211    var modal = '<div class="popup popup-error">';
212    modal += '      <div class="popup_layout"></div>';
213    modal += '      <div class="popup_inner">';
214    modal += '          <div class="popup-close"><svg xmlns="http://www.w3.org/2000/svg" width="31" height="31" viewBox="0 0 31 31" fill="none"><path d="M30 1L0.999999 30" stroke="white"/><path d="M30 30L1 0.999997" stroke="white"/></svg></div>';
215    modal += '          <div class="popup-title">' + errorTitle + '</div>';
216    modal += '          <div class="popup-scroll-box">';
217    modal += '              <div class="popup-text">' + errorText + '</div>';
218    modal += '              <div class="popup-btns">';
219    modal += '                  <div class="popup-btn popup-btn-close">' + ofCourseText + '</div>';
220    modal += '              </div>';
221    modal += '          </div>';
222    modal += '      </div>';
223    modal += '  </div>';
224
225    if ($('.popup-error').length > 0) {
226		$('.popup-error').remove();
227	}
228
229	$('body').append(modal);
230
231	$.scrollLock(true);
232
233	$('.popup-error').toggleClass('is-visible');
234}
235
236// Open successfully modal
237function successfullyModal(successfullyTitle, successfullyText) {
238    var modal = '<div class="popup popup-successfully">';
239    modal += '      <div class="popup_layout"></div>';
240    modal += '      <div class="popup_inner">';
241    modal += '          <div class="popup-close"><svg xmlns="http://www.w3.org/2000/svg" width="31" height="31" viewBox="0 0 31 31" fill="none"><path d="M30 1L0.999999 30" stroke="white"/><path d="M30 30L1 0.999997" stroke="white"/></svg></div>';
242    modal += '          <div class="popup-title">' + successfullyTitle + '</div>';
243    modal += '          <div class="popup-scroll-box">';
244    modal += '              <div class="popup-text">' + successfullyText + '</div>';
245    modal += '              <div class="popup-btns">';
246    modal += '                  <div class="popup-btn popup-btn-close">' + closeText + '</div>';
247    modal += '              </div>';
248    modal += '          </div>';
249    modal += '      </div>';
250    modal += '  </div>';
251
252    if ($('.popup-successfully').length > 0) {
253		$('.popup-successfully').remove();
254	}
255
256	$('body').append(modal);
257
258	$.scrollLock(true);
259
260	$('.popup-successfully').toggleClass('is-visible');
261
262    setTimeout(function() {
263        if ($('.popup-successfully').length > 0) {
264            $('.popup-successfully').remove();
265        }
266    }, hiddenPopupAfter);
267}
268
269/*// Formated and open modal
270function openModalSimple(modalType, titleText, message) {
271	var returnHtml = '	<div class="modal modal_message">';
272	returnHtml += '			<div class="modal-overlay modal-toggle"></div>';
273	returnHtml += '			<div class="modal-wrapper modal-transition">';
274	returnHtml += '				<div class="modal-header">';
275	returnHtml += '					<div class="modal-close modal-toggle"><svg width="21" height="19" viewBox="0 0 21 19" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.1719 18.3684L1.59108 2.8421C0.923326 2.17669 0.921804 1.29098 1.58727 0.627846C2.25274 -0.0352936 3.14155 -0.033777 3.8093 0.631637L19.3901 16.158C20.0579 16.8234 20.0594 17.7091 19.3939 18.3722C18.7284 19.0354 17.8396 19.0338 17.1719 18.3684Z" fill="white"/>
275<path d="M3.80929 18.3684L19.3901 2.8421C20.0578 2.17669 20.0594 1.29098 19.3939 0.627846C18.7284 -0.0352936 17.8396 -0.033777 17.1719 0.631637L1.59107 16.158C0.923318 16.8234 0.921796 17.7091 1.58726 18.3722C2.25273 19.0354 3.14154 19.0338 3.80929 18.3684Z" fill="white"/></svg></div>';
276	returnHtml += '				</div>';
277	returnHtml += '				<div class="modal-body">';
278	returnHtml += '					<div class="modal-icon">' + (modalType == 'success' ? '<svg width="71" height="71" viewBox="0 0 71 71" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_44_3575)"><path d="M35.5 0C15.9241 0 0 15.9241 0 35.5C0 55.0759 15.9241 71 35.5 71C55.0759 71 71 55.0731 71 35.5C71 15.9269 55.0759 0 35.5 0ZM35.5 65.5004C18.9599 65.5004 5.49959 52.0429 5.49959 35.5C5.49959 18.9571 18.9599 5.49959 35.5 5.49959C52.0429 5.49959 65.5004 18.9571 65.5004 35.5C65.5004 52.0429 52.0401 65.5004 35.5 65.5004Z" fill="white"/><path d="M51.7872 23.1533C50.6679 22.1359 48.9273 22.2157 47.9045 23.3403L31.1306 41.8108L23.0269 33.5725C21.9572 32.489 20.2193 32.4725 19.1387 33.5395C18.0552 34.6036 18.0387 36.3442 19.1057 37.4277L29.2496 47.7395C29.7694 48.2674 30.4733 48.5616 31.2102 48.5616C31.2267 48.5616 31.246 48.5616 31.2625 48.5644C32.0214 48.5479 32.7364 48.2234 33.2451 47.6625L51.9739 27.0389C52.9943 25.9114 52.9118 24.1736 51.7872 23.1533Z" fill="white"/></g><defs><clipPath id="clip0_44_3575"><rect width="71" height="71" fill="white"/></clipPath></defs></svg>' : '<svg width="71" height="71" viewBox="0 0 71 71" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_44_3575)"><path d="M35.5 0C15.9241 0 0 15.9241 0 35.5C0 55.0759 15.9241 71 35.5 71C55.0759 71 71 55.0731 71 35.5C71 15.9269 55.0759 0 35.5 0ZM35.5 65.5004C18.9599 65.5004 5.49959 52.0429 5.49959 35.5C5.49959 18.9571 18.9599 5.49959 35.5 5.49959C52.0429 5.49959 65.5004 18.9571 65.5004 35.5C65.5004 52.0429 52.0401 65.5004 35.5 65.5004Z" fill="white"/><path d="M46.8977 45.9525C47.6911 44.8918 47.5894 43.2733 46.6634 42.3423L31.4567 27.0756L29.0465 24.7001C25.9776 21.7706 23.548 24.828 24.5826 26.3043C24.6123 27.0104 26.338 28.6901 26.7998 29.153L43.7791 46.199C44.7074 47.1276 46.1022 47.0183 46.8977 45.9525Z" fill="white"/><path d="M46.9454 24.4006C45.9034 23.5828 44.283 23.6469 43.3307 24.5509L27.7146 39.3986L25.2836 41.7528C22.2836 44.7528 25.2836 47.2528 26.7836 46.2528C27.4902 46.2396 29.2096 44.5534 29.6831 44.1025L47.1193 27.5241C48.0692 26.6177 47.9924 25.2207 46.9454 24.4006Z" fill="white"/></g><defs><clipPath id="clip0_44_3575"><rect width="71" height="71" fill="white"/></clipPath></defs></svg>') + '</div>';
279	returnHtml += '					<div class="modal-title">' + titleText + '</div>';
280	returnHtml += '					<div class="modal-message">' + message + '</div>';
281	returnHtml += '				</div>';
282	returnHtml += '			</div>';
283	returnHtml += '		</div>';
284
285	if ($('.modal_message').length > 0) {
286		$('.modal_message').remove();
287	}
288
289	$('body').append(returnHtml);
290
291	$.scrollLock(true);
292	$('.modal_message').toggleClass('is-visible');
293
294	// setTimeout(function() {
295	// 	if ($('.modal_message').length > 0) {
296	// 		$('.modal_message').remove();
297	// 	}
298	// }, hiddenPopupAfter);
299}*/
300
301// Add user visit
302function addUserVisit() {
303	var formData = new FormData();
304	formData.append('method', 'ajaxAddVisit');
305	formData.append('ajax_file', 'Conversions');
306	formData.append('full_url', $(location).attr('href'));
307	formData.append('referrer', document.referrer);
308	formData.append('browser_language', navigator.language);
309	formData.append('site_language', $('html').attr('lang'));
310	formData.append('monitor_width', screen.width);
311	formData.append('monitor_height', screen.height);
312	formData.append('monitor_really_width', getPageSize()[2]);
313	formData.append('monitor_really_height', getPageSize()[3]);
314
315	$.ajax({
316		url: '/',
317        type: "POST",
318        dataType: "json",
319        cache: false,
320        contentType: false,
321        processData: false,
322        data: formData,
323		success: function(response) {},
324		error: function(xhr, ajaxOptions, thrownError) {	
325			console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
326		}
327	});
328}
329
330$(function() {
331	// Function disable global scroll
332  	$.scrollLock = (function scrollLockClosure() {
333        'use strict';
334
335        var $html = $('html'),
336            // State: unlocked by default
337            locked = false,
338            // State: scroll to revert to
339            prevScroll = {
340                scrollLeft: $(window).scrollLeft(),
341                scrollTop: $(window).scrollTop()
342            },
343            // State: styles to revert to
344            prevStyles = {},
345            lockStyles = {
346                'overflow-y': 'scroll',
347                'position': 'fixed',
348                'width': '100%'
349            };
350
351        // Instantiate cache in case someone tries to unlock before locking
352        saveStyles();
353
354        // Save context's inline styles in cache
355        function saveStyles() {
356            var styleAttr = $html.attr('style'),
357                styleStrs = [],
358                styleHash = {};
359
360            if (!styleAttr) {
361                return;
362            }
363
364            styleStrs = styleAttr.split(/;\s/);
365
366            $.each(styleStrs, function serializeStyleProp(styleString) {
367                if (!styleString) {
368                    return;
369                }
370
371                var keyValue = styleString.split(/\s:\s/);
372
373                if (keyValue.length < 2) {
374                    return;
375                }
376
377                styleHash[keyValue[0]] = keyValue[1];
378            });
379
380            $.extend(prevStyles, styleHash);
381        }
382
383        function lock() {
384            var appliedLock = {};
385
386            // Duplicate execution will break DOM statefulness
387            if (locked) {
388                return;
389            }
390
391            // Save scroll state...
392            prevScroll = {
393                scrollLeft: $(window).scrollLeft(),
394                scrollTop: $(window).scrollTop()
395            };
396
397            // ...and styles
398            saveStyles();
399
400            // Compose our applied CSS
401            $.extend(appliedLock, lockStyles, {
402                // And apply scroll state as styles
403                'left': - prevScroll.scrollLeft + 'px',
404                'top': - prevScroll.scrollTop  + 'px'
405            });
406
407            // Then lock styles...
408            $html.css(appliedLock);
409
410            // ...and scroll state
411            $(window)
412                .scrollLeft(0)
413                .scrollTop(0);
414
415            locked = true;
416        }
417
418        function unlock() {
419            // Duplicate execution will break DOM statefulness
420            if (!locked) {
421                return;
422            }
423
424            // Revert styles
425            $html.attr('style', $('<x>').css(prevStyles).attr('style') || '');
426
427            // Revert scroll values
428            $(window)
429                .scrollLeft(prevScroll.scrollLeft)
430                .scrollTop( prevScroll.scrollTop);
431
432            locked = false;
433        }
434
435        return function scrollLock(on) {
436            // If an argument is passed, lock or unlock depending on truthiness
437            if (arguments.length) {
438                if (on) {
439                    lock();
440                } else {
441                    unlock();
442                }
443            }
444            // Otherwise, toggle
445            else {
446                if (locked) {
447                    unlock();
448                } else {
449                    lock();
450                }
451            }
452        };
453    }());
454
455    // Add user visit
456    addUserVisit();
457
458    // Close modal
459    $('body').on('click', '.popup_layout, .popup-close, .popup-btn-close', function(e){
460    	e.stopPropagation();
461
462        var wrapper = $(this).closest('.popup');
463
464		$.scrollLock(false);
465
466    	wrapper.toggleClass('is-visible');
467
468    	setTimeout(function() {
469    		if (
470                wrapper.length > 0 && 
471                !wrapper.hasClass('popup-simple-form') && 
472                !wrapper.hasClass('wf-popup-big') && 
473                !wrapper.hasClass('popup-career') && 
474                !wrapper.hasClass('popup-brukhovychi-open-door') &&
475                !wrapper.hasClass('popup-dynamic-form')
476            ) {
477	    		wrapper.remove();
478	    	}
479    	}, 200);
480    });
481});

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.