PageSourceSearch

https://odmage.com/wp-content/themes/odmage/js/common.js

js odmage.com collected 2026-10-07 23:27:20 UTC 3,442 bytes, 106 lines download raw bytes

1/**
2 * Date: 12.04.13
3 * Last update: 18.04.13 - Добавлена функция light_switch.
4 * Last update: 18.04.16 - Добавлена поддержка cookies для темы.
5 */
6
7// Переключение темы (светлая/темная)
8function light_switch() {
9    const body = $('body');
10    const logoImg = $('.header__logo > a > img');
11    const logoPath = logoImg.attr('src').replace(/logo_(light|black)\.png$/, '');
12    const themeBtn = $('#header__chek__btn');
13    const currentTheme = body.attr('id');
14
15    if (currentTheme === "light") {
16        body.attr('id', 'black');
17        logoImg.attr('src', `${logoPath}logo_black.png`);
18        themeBtn.removeClass().addClass('header__chek-black');
19        Cookies.set('tpl', 'black', { expires: 333 }); // Используем библиотеку js-cookie
20    } else {
21        body.attr('id', 'light');
22        logoImg.attr('src', `${logoPath}logo_light.png`);
23        themeBtn.removeClass().addClass('header__chek-light');
24        Cookies.set('tpl', 'light', { expires: 333 }); // Используем библиотеку js-cookie
25    }
26}
27
28// Генерация уведомлений
29function notyGenerate(type, text) {
30    if (typeof noty !== 'undefined') {
31        noty({
32            text: text,
33            type: type,
34            dismissQueue: true,
35            layout: 'topRight',
36            theme: 'defaultTheme'
37        });
38    } else {
39        console.error('Библиотека noty не подключена.');
40    }
41}
42
43// Валидация формы
44function chekForm() {
45    const emailInput = $('[name="field_email"]');
46    const nameInput = $('[name="field_name_first"]');
47    const emailValue = emailInput.val().trim();
48    const nameValue = nameInput.val().trim();
49    const emailRegex = /\S+@\S+\.\S+/;
50
51    setTimeout(() => $.noty.closeAll(), 2600);
52
53    if (!nameValue) {
54        notyGenerate('error', 'Введите ваше имя');
55        return false;
56    }
57    if (!emailValue) {
58        notyGenerate('error', 'Введите ваш e-mail');
59        return false;
60    }
61    if (!emailRegex.test(emailValue)) {
62        notyGenerate('error', 'E-mail введен неправильно');
63        return false;
64    }
65    return true;
66}
67
68// Прокрутка страницы вверх
69function scrollTop() {
70    const scrollBtn = $('.scroll__top__btn');
71
72    $(window).scroll(function () {
73        if ($(this).scrollTop() > 100) {
74            scrollBtn.fadeIn(500);
75        } else {
76            scrollBtn.fadeOut(500);
77        }
78    });
79
80    scrollBtn.on('click', function () {
81        $("html, body").animate({ scrollTop: 0 }, 600);
82        return false;
83    });
84}
85
86// Инициализация при загрузке страницы
87$(document).ready(function () {
88    // Предзагрузка изображений
89    $.preloadImages = function () {
90        for (let i = 0; i < arguments.length; i++) {
91            $("<img>").attr("src", arguments[i]);
92        }
93    };
94    $.preloadImages("/wp-content/themes/odmage/img/logo_black.png", "/wp-content/themes/odmage/img/logo_light.png");
95
96    // Инициализация функций
97    scrollTop();
98    $('.post__line').last().hide();
99    $('.sb__block__text #searchsubmit').addClass('btn');
100
101    // Проверка темы из cookies
102    const savedTheme = Cookies.get('tpl');
103    if (typeof savedTheme === "undefined") {
104        light_switch();
105    }
106});

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.