PageSourceSearch

https://adminta.ru/bitrix/components/adminta_publications/calendar/templates/.default/script.js?16716993693938

js adminta.ru collected 2026-10-02 14:56:14 UTC 3,938 bytes, 119 lines download raw bytes

1/**
2 * (C) DAVIDhaker 2022-12-17
3 * Made with very great moral thanks to
4 * - Sergey Potashev
5 * - Aexander Feoktistov
6 * - Marina Feoktistova
7 */
8(function () {
9    var now = new Date()
10    var months = [
11        'Январь', 'Февраль', 'Март', 'Апрель',
12        'Май', 'Июнь', 'Июль', 'Август',
13        'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
14    ]
15    var tbody = null
16
17    function render() {
18        adminta_publication_calendar_month_btn.innerText = (
19            months[now.getMonth()] + ' ' + now.getFullYear()
20        )
21
22        var html = ''
23        var month_length = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate()
24        var first_week_day = (new Date(
25            now.getFullYear() + '-' +
26            (now.getMonth() + 1).toString().padStart(2, '0') + '-' +
27            '01'
28        ).getDay() || 7)
29
30        for (var d = -first_week_day + 2, j = 0; d < month_length + 1; j++, d++) {
31            if (j % 7 === 0)
32                html += '<tr class="days">'
33
34            var isWeekend = j % 7 >= 5
35            var dayCellId = d > 0 ? 'adminta_calendar_day_' + d : ''
36            var isToday = (
37                new Date().getFullYear() === now.getFullYear()
38                && new Date().getMonth() === now.getMonth()
39                && new Date().getDate() === d
40            )
41
42            html += '<td id="' + dayCellId + '" class="adminta_calendar_day_btn day ' + (isWeekend ? ' weekend ' : '') + (isToday ? ' today ' : '') + '">'
43            html += d > 0 ? '<span>' + d + '</span>' : '&nbsp;';
44            html += '</td>'
45
46            if (j % 7 === 6)
47                html += '</tr>'
48        }
49
50        tbody.innerHTML = html
51
52        BX.ready(() => {
53            BX.ajax.runComponentAction("adminta_publications:calendar", "getMonthInfo", {
54                mode: "class",
55                data: {
56                    "year": now.getFullYear(),
57                    "month": now.getMonth() + 1,
58                }
59            }).then(function (response) {
60                response.data.map(day => {
61                    document.getElementById('adminta_calendar_day_' + day).classList.add('news')
62                })
63            });
64        })
65    }
66
67    document.addEventListener('DOMContentLoaded', () => {
68        tbody = document.querySelector('.adminta_publication_calendar tbody')
69
70        var override = document.getElementById('adminta_publications_override_date')
71
72        if (override) {
73            var override = override.value.split(';') // year;month
74
75            now.setFullYear(parseInt(override[0]), parseInt(override[1]) - 1)
76        }
77
78
79        adminta_publication_calendar_past_month.addEventListener('click', e => {
80            e.preventDefault()
81            now.setMonth(now.getMonth() - 1)
82            render()
83        })
84
85        adminta_publication_calendar_next_month.addEventListener('click', e => {
86            e.preventDefault()
87            now.setMonth(now.getMonth() + 1)
88            render()
89        })
90
91        render()
92    })
93
94    document.addEventListener('click', e => {
95        if (
96            (
97                e.target.classList.contains('adminta_calendar_day_btn')
98                && e.target.classList.contains('news')
99            ) || (
100                e.target.parentNode.classList.contains('adminta_calendar_day_btn')
101                && e.target.parentNode.classList.contains('news')
102            )
103        ) {
104            var day = e.target.innerText
105            var month = (now.getMonth() + 1).toString()
106
107            if (day.length === 1) {
108                day = '0' + day
109            }
110
111            if (month.length === 1) {
112                month = '0' + month
113            }
114
115            var date = day + '.' + month + '.' + now.getFullYear()
116            location.href = document.querySelector('.adminta_publication_calendar').dataset.linkTemplate.replace('{DATE}', date)
117        }
118    })
119})()

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.