PageSourceSearch

https://cactus-russia.ru/js/common.js?260558

js cactus-russia.ru collected 2026-10-06 23:51:19 UTC 3,166 bytes, 100 lines download raw bytes

1/**
2 * Функция для debouncing
3 * @param {function} callback Функция, для которой выполняется debouncing
4 * @param {number} timer Время, которое нужно подождать
5 * @param {string} key Ключ, под которым будет сохранено действие
6 * @returns {functionDebounce} Функция
7 */
8function debounce(callback, timer, key) {
9  var functionDebounce = function() {
10    if (!this.hasOwnProperty('debounce')) {
11      this.debounce = {};
12    }
13
14    if (!this.debounce.hasOwnProperty(key)) {
15      this.debounce[key] = {};
16    }
17
18    if (this.debounce[key].timerResize) {
19      clearTimeout(this.debounce[key].timerResize);
20    }
21
22    this.debounce[key].timerResize = setTimeout(callback, timer);
23  };
24
25  return functionDebounce;
26}
27
28/**
29 * Возвращает ширину элемента со всеми отступами и рамками
30 * @param {HTMLElement} element Элемент, у которого вычисляется ширрина
31 * @returns {number} Ширина элемента
32 */
33function getWidthElement(element) {
34  return (
35    parseFloat(getComputedStyle(element).marginLeft) +
36    parseFloat(getComputedStyle(element).borderLeftWidth) +
37    element.clientWidth +
38    parseFloat(getComputedStyle(element).borderRightWidth) +
39    parseFloat(getComputedStyle(element).marginRight)
40  );
41}
42
43/**
44 * Возвращает высоту элемента со всеми отступами и рамками
45 * @param {Element} element Элемент, у которого вычисляется ширрина
46 * @returns {number} Высота элемента
47 */
48function getHeightElement(element) {
49  return (
50    parseFloat(getComputedStyle(element).marginTop) +
51    parseFloat(getComputedStyle(element).borderTopWidth) +
52    element.clientHeight +
53    parseFloat(getComputedStyle(element).borderBottomWidth) +
54    parseFloat(getComputedStyle(element).marginBottom)
55  );
56}
57
58/**
59 * Выполняет AJAX-запрос методом POST
60 * @param {string} url Ссылка, на которую идет запрос
61 * @param {function} callback Функция, которая выполняется, после получения результата
62 * @param {FormData} [formData] Данные формы, которую отправляем
63 * @returns {void}
64 */
65function ajaxPOST(url, callback, formData) {
66  var formDataPost = !formData ? new FormData() : formData;
67
68  var xhr = new XMLHttpRequest();
69
70  xhr.open('POST', url);
71
72  xhr.onreadystatechange = function functionOnReady() {
73    if (xhr.readyState === xhr.DONE) {
74      if (xhr.status === 200) {
75        callback(JSON.parse(xhr.responseText));
76      } else {
77        callback({
78          error: true,
79        });
80      }
81    }
82  };
83
84  xhr.send(formDataPost);
85}
86
87/**
88 * Возвращает расширение файла
89 * @param {string} fileName Имя файла
90 * @returns {string} Расширение файла
91 */
92function getExtFile(fileName) {
93  var extFile = /\.[a-zA-Z]+$/.exec(fileName);
94  extFile = extFile[0];
95  extFile = extFile.replace('.', '');
96
97  return extFile;
98}
99
100

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.