PageSourceSearch

https://ra-direct.ru/local/blog/assets/blog.js?v=5

js ra-direct.ru collected 2026-10-08 01:41:12 UTC 9,200 bytes, 380 lines download raw bytes

1(function () {
2    'use strict';
3
4
5    /* =====================================================
6       ТОЛЬКО СПИСОК СТАТЕЙ
7
8       На /blog/detail/ ничего не меняем.
9       ===================================================== */
10
11    function initBlogCards() {
12
13        if (
14            document.documentElement
15                .classList
16                .contains(
17                    'divektor-blog-detail'
18                )
19            ||
20            document.querySelector(
21                '.news-list-wrap.detail'
22            )
23        ) {
24            return;
25        }
26
27
28        var readingTimes =
29            window.DIVEKTOR_BLOG_READING_TIMES
30            || {};
31
32
33        /* =================================================
34           HELPERS
35           ================================================= */
36
37        function normalizePath(url) {
38
39            try {
40
41                return new URL(
42                    url,
43                    window.location.origin
44                ).pathname;
45
46            } catch (error) {
47
48                return url;
49            }
50        }
51
52
53        function getMinutes(path) {
54
55            if (
56                readingTimes[path]
57            ) {
58                return readingTimes[path];
59            }
60
61
62            var alternate =
63                path.endsWith('/')
64                    ? path.slice(0, -1)
65                    : path + '/';
66
67
68            return (
69                readingTimes[alternate]
70                || null
71            );
72        }
73
74
75        function createClockIcon() {
76
77            var svg =
78                document.createElementNS(
79                    'http://www.w3.org/2000/svg',
80                    'svg'
81                );
82
83
84            svg.setAttribute(
85                'class',
86                'blog-reading-time__icon'
87            );
88
89
90            svg.setAttribute(
91                'viewBox',
92                '0 0 256 256'
93            );
94
95
96            svg.setAttribute(
97                'aria-hidden',
98                'true'
99            );
100
101
102            svg.innerHTML =
103                '<circle '
104                + 'cx="128" '
105                + 'cy="128" '
106                + 'r="88" '
107                + 'fill="none" '
108                + 'stroke="currentColor" '
109                + 'stroke-width="16"'
110                + '/>'
111                +
112
113                '<polyline '
114                + 'points="128 72 128 128 184 128" '
115                + 'fill="none" '
116                + 'stroke="currentColor" '
117                + 'stroke-width="16" '
118                + 'stroke-linecap="round" '
119                + 'stroke-linejoin="round"'
120                + '/>';
121
122
123            return svg;
124        }
125
126
127        /* =================================================
128           КАРТОЧКИ
129           ================================================= */
130
131        document
132            .querySelectorAll(
133                '.news.flat .wrap-element'
134            )
135            .forEach(
136                function (card) {
137
138                    var wrapText =
139                        card.querySelector(
140                            '.wrap-text'
141                        );
142
143
144                    if (!wrapText) {
145                        return;
146                    }
147
148
149                    var title =
150                        wrapText.querySelector(
151                            '.new-name'
152                        );
153
154
155                    if (!title) {
156                        return;
157                    }
158
159
160                    var detailLink =
161                        title.closest(
162                            'a[href]'
163                        );
164
165
166                    if (!detailLink) {
167                        return;
168                    }
169
170
171                    var path =
172                        normalizePath(
173                            detailLink.getAttribute(
174                                'href'
175                            )
176                        );
177
178
179                    var minutes =
180                        getMinutes(
181                            path
182                        );
183
184
185                    /*
186                     * Ищем штатный блок рубрики.
187                     */
188                    var section =
189                        wrapText.querySelector(
190                            '.section'
191                        );
192
193
194                    /*
195                     * Даже если Kraken по какой-то причине
196                     * не создал .section, создаём метастроку
197                     * самостоятельно.
198                     */
199                    if (!section) {
200
201                        section =
202                            document.createElement(
203                                'div'
204                            );
205
206
207                        section.className =
208                            'section';
209
210
211                        wrapText.insertBefore(
212                            section,
213                            wrapText.firstChild
214                        );
215                    }
216
217
218                    var sectionLink =
219                        section.querySelector(
220                            'a.wrap-link-sect'
221                        );
222
223
224                    var date =
225                        wrapText.querySelector(
226                            '.date'
227                        );
228
229
230                    /*
231                     * Убираем только наши ранее
232                     * созданные элементы.
233                     */
234                    section
235                        .querySelectorAll(
236                            '.blog-reading-time'
237                        )
238                        .forEach(
239                            function (element) {
240
241                                element.remove();
242                            }
243                        );
244
245
246                    section.classList.add(
247                        'blog-card-meta'
248                    );
249
250
251                    /* =====================================
252                       1. ДАТА
253                       ===================================== */
254
255                    if (date) {
256
257                        date.classList.add(
258                            'blog-card-meta__date'
259                        );
260
261
262                        section.appendChild(
263                            date
264                        );
265                    }
266
267
268                    /* =====================================
269                       2. ВРЕМЯ ЧТЕНИЯ
270
271                       Если данных пока нет —
272                       карточка всё равно оформляется.
273                       ===================================== */
274
275                    if (minutes) {
276
277                        var readingTime =
278                            document.createElement(
279                                'span'
280                            );
281
282
283                        readingTime.className =
284                            'blog-reading-time';
285
286
287                        readingTime.appendChild(
288                            createClockIcon()
289                        );
290
291
292                        var readingText =
293                            document.createElement(
294                                'span'
295                            );
296
297
298                        readingText.className =
299                            'blog-reading-time__text';
300
301
302                        readingText.textContent =
303                            minutes
304                            + ' мин';
305
306
307                        readingTime.appendChild(
308                            readingText
309                        );
310
311
312                        section.appendChild(
313                            readingTime
314                        );
315                    }
316
317
318                    /* =====================================
319                       3. РУБРИКА
320
321                       appendChild переносит существующую
322                       ссылку Kraken в конец метастроки.
323                       ===================================== */
324
325                    if (sectionLink) {
326
327                        section.appendChild(
328                            sectionLink
329                        );
330                    }
331                }
332            );
333    }
334
335
336    /* =====================================================
337       ЗАПУСК
338       ===================================================== */
339
340    function start() {
341
342        setTimeout(
343            initBlogCards,
344            50
345        );
346    }
347
348
349    if (
350        document.readyState
351        === 'loading'
352    ) {
353
354        document.addEventListener(
355            'DOMContentLoaded',
356            start
357        );
358
359    } else {
360
361        start();
362    }
363
364
365    /*
366     * Повторный запуск после полной загрузки.
367     * Нужен для Kraken / Lazy / Composite.
368     */
369    window.addEventListener(
370        'load',
371        function () {
372
373            setTimeout(
374                initBlogCards,
375                150
376            );
377        }
378    );
379
380})();

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.