PageSourceSearch

https://www.source-7.com/wp-content/themes/rocket/style.js?ver=51

js source-7.com collected 2026-10-02 21:38:05 UTC 38,671 bytes, 990 lines download raw bytes

1!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self,function(){var n=e.Cookies,o=e.Cookies=t();o.noConflict=function(){return e.Cookies=n,o}}())}(this,(function(){"use strict";function e(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)e[o]=n[o]}return e}return function t(n,o){function r(t,r,i){if("undefined"!=typeof document){"number"==typeof(i=e({},o,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),t=encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var c="";for(var u in i)i[u]&&(c+="; "+u,!0!==i[u]&&(c+="="+i[u].split(";")[0]));return document.cookie=t+"="+n.write(r,t)+c}}return Object.create({set:r,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var t=document.cookie?document.cookie.split("; "):[],o={},r=0;r<t.length;r++){var i=t[r].split("="),c=i.slice(1).join("=");try{var u=decodeURIComponent(i[0]);if(o[u]=n.read(c,u),e===u)break}catch(e){}}return e?o[e]:o}},remove:function(t,n){r(t,"",e({},n,{expires:-1}))},withAttributes:function(n){return t(this.converter,e({},this.attributes,n))},withConverter:function(n){return t(e({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(o)},converter:{value:Object.freeze(n)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"})}));
2
3a4h = {
4
5    init: function() {
6        scrollbarWidth = 0;
7        adminbarHeight = 0;
8        headerHeight = 0;
9        headerHeightTrue = 0;
10        headerStickyRowHeight = 0;
11    },
12
13    scrollbar: function() {
14        window.addEventListener('scroll', function() {
15            scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
16
17            document.body.style.setProperty('--scrollbar-width', scrollbarWidth + 'px');
18        });
19    },
20
21    adminbar: function() {
22        const adminbar = document.querySelector('#wpadminbar');
23        if ( !adminbar ) return;
24
25        window.addEventListener('scroll', function() {
26            const adminbarBounding = adminbar.getBoundingClientRect();
27
28            adminbarHeight = Math.max(Math.min(adminbarBounding.bottom, window.innerHeight), 0);
29            
30            document.body.style.setProperty('--adminbar-height', adminbarHeight + 'px');
31        });
32    },
33
34    header: function() {
35        const header = document.querySelector('#header');
36        if ( !header ) return;
37
38        let lastScroll = 0;
39        const stickyLimit = 100;
40
41        window.addEventListener('scroll', function() {
42            const currentScroll = window.scrollY;
43
44            if ( currentScroll < stickyLimit ) {
45                document.body.classList.remove('scroll-down');
46                document.body.classList.remove('scroll-up');
47            }
48            if ( currentScroll > stickyLimit && currentScroll > lastScroll ) {
49                document.body.classList.remove('scroll-up');
50                document.body.classList.add('scroll-down');
51            }
52            if ( currentScroll > stickyLimit && currentScroll < lastScroll ) {
53                document.body.classList.remove('scroll-down');
54                document.body.classList.add('scroll-up');
55            }
56
57            lastScroll = currentScroll;
58        });
59
60        window.addEventListener('scroll', function() {
61            const headerBounding = header.getBoundingClientRect();
62
63            headerHeight = Math.max(Math.min(headerBounding.bottom, window.innerHeight), 0);
64            headerHeightTrue = parseFloat(getComputedStyle(header).height) || 0;
65
66            document.body.style.setProperty('--header-height', headerHeight + 'px');
67            document.body.style.setProperty('--header-height-true', headerHeightTrue + 'px');
68        });
69
70        window.addEventListener('scroll', function() {
71            const headerStickyRows = header.querySelectorAll('.layout-row.sticky');
72
73            headerStickyRows.forEach((elem) => {
74                let headerStickyRowStyle = getComputedStyle(elem);
75                if ( headerStickyRowStyle.display === 'none' ) return;
76
77                headerStickyRowHeight = parseFloat(headerStickyRowStyle.height) || 0;
78
79                document.body.style.setProperty('--header-sticky-row-height', headerStickyRowHeight + 'px');
80            });
81        });
82
83        window.addEventListener('resize', function() {
84            headerStickyRowHeight = 0;
85            document.body.style.setProperty('--header-sticky-row-height', headerStickyRowHeight + 'px');
86        });
87    },
88
89    searchForm: function() {
90        const searchFormDivs = document.querySelectorAll('.search-form .search-form-inner');
91
92        searchFormDivs.forEach((elem) => {
93            const searchFormField = elem.querySelector('.search-field');
94            const searchFormSelect = elem.querySelector('.search-select');
95
96            if ( !searchFormField ) return;
97
98            elem.addEventListener('click', (event) => {
99                if ( !event.target.closest('select') && !event.target.closest('[type="submit"]') ) {
100                    searchFormField.focus();
101                }
102            });
103
104            searchFormField.addEventListener('focus', () => {
105                elem.classList.add('active');
106            });
107            
108            searchFormField.addEventListener('blur', () => {
109                elem.classList.remove('active');
110            });
111
112            if ( searchFormSelect ) {
113                searchFormSelect.addEventListener('focus', () => {
114                    elem.classList.add('active');
115                });
116
117                searchFormSelect.addEventListener('blur', () => {
118                    elem.classList.remove('active');
119                });
120            }
121        });
122    },
123
124    overlayToggle: function() {
125        let openedOverlayPanel;
126        let openedOverlayClass;
127
128        const afterOpen = (event) => {
129            if ( !event.target.closest(openedOverlayPanel) ) {
130                close();
131            }
132        }
133
134        const open = () => {
135            document.querySelector(openedOverlayPanel).setAttribute('aria-hidden', 'false');
136            document.body.classList.add('overlay-on');
137            document.body.classList.add(openedOverlayClass);
138            if ( openedOverlayPanel == '#overlay-search-outer' ) {
139                document.querySelector('#overlay-search-outer .search-field').focus();
140            }
141            document.body.addEventListener('click', afterOpen);
142
143        }
144
145        const close = () => {
146            document.querySelector(openedOverlayPanel).setAttribute('aria-hidden', 'true');
147            document.body.classList.remove('overlay-on');
148            document.body.classList.remove(openedOverlayClass);
149            document.body.removeEventListener('click', afterOpen);
150            openedOverlayPanel = '';
151            openedOverlayClass = '';
152        }
153
154        document.body.addEventListener('click', (event) => {
155            const target = event.target.closest('.overlay-toggle-btn');
156            if ( !target) return;
157    
158            event.preventDefault();
159
160            const newOverlayPanel = target.getAttribute('data-target');
161            const newOverlayClass = target.getAttribute('data-class');
162
163            if ( openedOverlayPanel ) {
164                if ( openedOverlayPanel == newOverlayPanel ) {
165                    close();
166                } else {
167                    close();
168                    openedOverlayPanel = newOverlayPanel;
169                    openedOverlayClass = newOverlayClass;
170                    open();
171                }
172            } else {
173                openedOverlayPanel = newOverlayPanel;
174                openedOverlayClass = newOverlayClass;  
175                open();
176            }
177        });
178    },
179
180    navMenuClickable: function() {
181        const clickableMenuItems = document.querySelectorAll('#header .nav-menu ul li.click > a');
182        if ( !clickableMenuItems ) return;
183
184        document.body.addEventListener('click', (event) => {
185            if ( !event.target.closest('#header .nav-menu ul li.click') ) {
186                clickableMenuItems.forEach((elem) => {
187                    elem.parentNode.classList.remove('active');
188                });
189            }
190        });
191    
192        clickableMenuItems.forEach((elem) => {
193            elem.addEventListener('click', (event) => {
194                event.preventDefault();
195                event.stopPropagation();
196    
197                elem.parentNode.classList.toggle('active');
198    
199                clickableMenuItems.forEach((otherElem) => {
200                    if ( otherElem !== elem ) {
201                        otherElem.parentNode.classList.remove('active');
202                    }
203                });
204            });
205        });
206    },
207
208    navMenuOverlay: function() {
209        const menusWithChildren = document.querySelectorAll('#overlay-menu .nav-menu ul li:not(.no-toggle)');
210        if ( !menusWithChildren ) return;
211
212        menusWithChildren.forEach(function(menuWithChildren) {
213            const subMenu = menuWithChildren.querySelector('ul');
214            if ( !subMenu ) return;
215            
216            const menuWithChildrenCloned = menuWithChildren.cloneNode(true); 
217            const subMenuCloned = menuWithChildrenCloned.querySelector('ul');
218            const menuArrowCloned = menuWithChildrenCloned.querySelector('.menu-item-arrow');
219  
220            subMenuCloned.parentNode.removeChild(subMenuCloned);
221            menuArrowCloned.parentNode.removeChild(menuArrowCloned);
222
223            if ( !menuWithChildren.classList.contains('not-link') ) {
224                subMenu.insertBefore(menuWithChildrenCloned, subMenu.firstChild);
225            }
226
227            const parentMenuAnchor = menuWithChildren.querySelector('a');
228
229            parentMenuAnchor.addEventListener('click', (event) => {
230                const parentMenu = parentMenuAnchor.closest('li');
231                parentMenu.classList.toggle('opened');
232                event.preventDefault();
233            });
234        });
235    },
236
237    navMenuSubMenuTheme: function() {
238        const subMenuParents = document.querySelectorAll('#header .nav-menu li.theme-dark, #header .nav-menu li.theme-light');
239
240        subMenuParents.forEach(function(elem) {
241            let theme = elem.classList.contains('theme-dark') ? 'dark' : 'light';
242            let subMenu = elem.querySelector('.sub-menu');
243            if ( subMenu ) {
244                subMenu.setAttribute('data-theme', theme);
245                subMenu.setAttribute('data-bs-theme', theme);
246            }
247        });
248    },
249
250    switchTheme: function() {
251        const switchTheme = () => {
252            const currentTheme = document.body.getAttribute('data-theme');
253            let newTheme = currentTheme == 'light' ? 'dark' : 'light';
254
255            document.body.setAttribute('data-theme', newTheme);
256            document.body.setAttribute('data-bs-theme', newTheme);
257            
258            Cookies.set('site_theme', newTheme, { expires: 30 });
259        }
260
261        document.body.addEventListener('click', (event) => {
262            if ( event.target.closest('.theme-switch') ) {
263                event.preventDefault();
264                
265                switchTheme();
266            }
267        });
268    },
269
270    jumpToLink: function(source, target, hash) {
271        if ( source === undefined || target === undefined ) return;
272
273        let sourcePosition = source.getBoundingClientRect().top + window.scrollY;
274        let targetPosition = target.getBoundingClientRect().top + window.scrollY;;
275
276        let offset = 0;
277        offset += adminbarHeight;
278        offset += 20;
279
280        if ( document.body.classList.contains('header-fixed') ) {
281            offset += headerHeightTrue;
282        } else if ( document.body.classList.contains('header-dynamic') && sourcePosition > targetPosition ) {
283            offset += headerHeightTrue;
284        } else if ( document.body.classList.contains('header-dynamic') && sourcePosition < targetPosition ) {
285            offset += headerStickyRowHeight;
286        }
287
288        if ( hash ) {
289            window.location.hash = hash;
290        }
291
292        window.scrollTo({
293            top: targetPosition - offset,
294        });
295    },
296
297    singularBodyHashAnchor: function() {
298        document.body.addEventListener('click', (event) => {
299
300            let singularCitations = document.querySelectorAll('.singular-citations .singular-citation');
301            
302            singularCitations.forEach((elem) => {
303                elem.classList.remove('active');
304            });
305
306            let elem = event.target.closest('.singular-body a[href^="#"]:not([href="#"]), #widgets-area-singular_side .widget-toc-widget a[href^="#"]:not([href="#"]');
307            
308            if ( elem ) {
309                let elem_href = elem.getAttribute('href');
310
311                let source = elem;
312                let target = elem.closest('.primary') ? elem.closest('.primary').querySelector(elem.getAttribute('href')) : document.querySelector('.primary').querySelector(elem.getAttribute('href'));
313                let hash = elem.getAttribute('href');
314    
315                if ( elem_href.startsWith('#c_note') ) {
316                    let citations = elem.closest('.primary').querySelector('.singular-citations .singular-section-header');
317                    if ( citations ) {
318                        target.closest('.singular-citation').classList.add('active');
319                        target = citations.parentNode;
320                        citations.classList.add('active');
321                    }
322                }
323    
324                event.preventDefault();
325
326                this.jumpToLink(source, target, hash);
327
328                event.stopPropagation();
329            }
330        });
331    },
332
333    LoadMorePostsArchive: function() {
334        if ( typeof theme_js_vars === 'undefined' ) return;
335        if ( theme_js_vars.archive_pagination_mode != 'dynamic' && theme_js_vars.archive_pagination_mode != 'auto' ) return;
336        const mode = theme_js_vars.archive_pagination_mode;
337
338        const postsListContainer = document.querySelector('.primary-archive .primary-content-primary .posts-list-outer');
339        if ( !postsListContainer ) return;
340
341        let navDiv = postsListContainer.closest('.primary-archive').querySelector('.nav-pages-archive[data-position="bottom"]');
342        if ( !navDiv ) return;
343
344        let next = navDiv.querySelector('.next');
345        if ( !next ) return;
346
347        let nextUrl = next.href;
348
349        let showMorebutton = navDiv.querySelector('.nav-show-more');
350        let navLoading = navDiv.querySelector('.content-loading');
351        let navDivInner = navDiv.querySelector('.nav-pages-inner');
352
353        navDivInner.innerHTML = '';
354        
355        navDivInner.appendChild(showMorebutton);
356        if ( mode == 'dynamic' ) {
357            showMorebutton.style.display = 'block';
358        } else {
359            navLoading.style.display = 'block';
360        }
361
362        const fetchData = async () => {
363            let url = nextUrl;
364            let response = await fetch(url);
365            let data = await response.text();
366            let parser = new DOMParser();
367            data = parser.parseFromString(data, 'text/html');
368            return data;
369        };
370
371        const appendData = (data) => {
372            let postsListFetched = data.querySelector('.primary-archive .primary-content-primary .posts-list');
373
374            postsListContainer.insertAdjacentHTML('beforeend', postsListFetched.outerHTML);
375
376            this.refresh();
377
378            next = data.querySelector('.nav-pages-archive .nav-pages-inner .next');
379            if ( next ) {
380                nextUrl = next.href;
381            } else {
382                nextUrl = '';
383            }
384        };
385
386        const observerCallback = async (entries) => {
387            if ( entries[0].isIntersecting ) {
388                if ( nextUrl ) {
389                    fetchData().then(appendData).then(() => {
390                        observer.disconnect();
391                        observer.observe(navLoading);
392                    })
393                } else {
394                    navDiv.remove();
395                    observer.disconnect();
396                }
397            }
398        };
399            
400        const observer = new IntersectionObserver(observerCallback, { threshold: 0.5 });
401
402        if ( mode == 'auto' ) {
403            observer.observe(navLoading);
404        }
405    
406        showMorebutton.addEventListener('click', function(event) {
407
408            event.preventDefault();
409
410            showMorebutton.style.display = 'none';
411            navLoading.style.display = 'block';
412            
413            fetchData().then(appendData).then(() => {
414                if ( nextUrl ) {
415                    showMorebutton.style.display = 'block';
416                    navLoading.style.display = 'none';
417                } else {
418                    navDiv.remove();
419                }
420            });
421
422        });
423    },
424
425    loadNextPostSingular: function() {
426        let currentPost = document.querySelector('.primary-singular:last-of-type');
427        if ( !currentPost ) return;
428
429        let nextUrl = currentPost.getAttribute('data-next_post');
430        if ( !nextUrl ) return;
431
432        let navLoading = document.querySelector('.content-loading');
433        if ( !navLoading ) return;
434        
435        navLoading.style.display = 'block';
436
437        const fetchData = async () => {
438            let url = nextUrl;
439            let response = await fetch(url);
440            let data = await response.text();
441            let parser = new DOMParser();
442            data = parser.parseFromString(data, 'text/html');
443            return data;
444        };
445
446        const appendData = (data) => {
447            let postFetched = data.querySelector('.primary-singular');
448            currentPost = document.querySelector('.primary-singular:last-of-type');
449            currentPost.insertAdjacentHTML('afterend', postFetched.outerHTML);
450
451            this.refresh();
452
453            nextUrl = postFetched.getAttribute('data-next_post');
454
455            if ( !nextUrl ) {
456                navLoading.remove();
457            }
458        };
459
460        const observerCallback = async (entries) => {
461            if ( entries[0].isIntersecting ) {
462                if ( nextUrl ) {
463                    fetchData().then(appendData).then(() => {
464                        observer.disconnect();
465                        observer.observe(navLoading);
466                    })
467                } else {
468                    observer.disconnect();
469                }
470            }
471        };
472            
473        const observer = new IntersectionObserver(observerCallback, { threshold: 0.5 });
474
475        observer.observe(navLoading);
476    
477    },
478    
479    LoadMoreComments: function() {
480        const commentsListContainer = document.querySelector('.comments-lists');
481        if ( !commentsListContainer ) return;
482
483        const navDiv = document.querySelector('.nav-pages-comments');
484        if ( !navDiv ) return;
485
486        let nextAnchor = navDiv.querySelector('.next');
487        let prevAnchor = navDiv.querySelector('.prev');
488        if ( !nextAnchor && !prevAnchor ) return;
489
490        let target = prevAnchor ? 'prev' : 'next';
491        let targetAnchor = prevAnchor ? prevAnchor : nextAnchor;
492        let targetUrl = targetAnchor.href;
493
494        let showMorebutton = navDiv.querySelector('.nav-show-more');
495        let navLoading = navDiv.querySelector('.content-loading');
496
497        navDivInner = navDiv.querySelector('.nav-pages-inner');
498        navDivInner.innerHTML = '';
499        
500        navDivInner.appendChild(showMorebutton);
501        
502        showMorebutton.style.display = 'block';
503
504        const fetchData = async () => {
505            let url = targetUrl;
506            let response = await fetch(url);
507            let data = await response.text();
508            let parser = new DOMParser();
509            data = parser.parseFromString(data, 'text/html');
510            return data;
511        };
512
513        const appendData = (data) => {
514            let commentsListFetched = data.querySelector('#comments .comments-list');
515
516            commentsListContainer.insertAdjacentHTML('beforeend', commentsListFetched.outerHTML);
517
518            this.refresh();
519
520            nextAnchor = data.querySelector('.nav-pages-comments .nav-pages-inner .next');
521            prevAnchor = data.querySelector('.nav-pages-comments .nav-pages-inner .prev');
522
523            targetAnchor = target == 'prev' ? prevAnchor : nextAnchor;
524
525            if ( targetAnchor ) {
526                targetUrl = targetAnchor.href;
527            } else {
528                targetUrl = '';
529            }
530        };
531            
532        showMorebutton.addEventListener('click', function(event) {
533            
534            event.preventDefault();
535
536            showMorebutton.style.display = 'none';
537            navLoading.style.display = 'block';
538            
539            fetchData().then(appendData).then(() => {
540                if ( targetUrl ) {
541                    showMorebutton.style.display = 'block';
542                    navLoading.style.display = 'none';
543                } else {
544                    navDiv.remove();
545                }
546            });
547
548        });
549    },
550
551    singularSections: function() {
552        document.body.addEventListener('click', function(event) {
553            let sectionHeaderToggleable = event.target.closest('.singular-section-header.toggleable');
554            if ( sectionHeaderToggleable ) {
555                sectionHeaderToggleable.classList.toggle('active');
556            }
557        });
558    },
559
560    questions: function() {
561        document.body.addEventListener('click', function(event) {
562            let questionHeader = event.target.closest('.question-header');
563            if ( questionHeader ) {
564                questionHeader.closest('.singular-question').classList.toggle('active');
565            }
566        });
567    },
568
569    continueReadingSingular: function() {
570        let primarySingular = document.querySelectorAll('.primary.primary-singular.continue-reading-on');
571    
572        primarySingular.forEach((elem) => {
573            let continueReadingWrap = elem.querySelector('.continue-reading-wrap');
574            if ( !continueReadingWrap ) return;
575    
576            let continueReadingWrapClonded = continueReadingWrap.cloneNode(true);
577            continueReadingWrap.remove();
578
579            let singularBody = elem.querySelectorAll('.singular-body');
580
581            singularBody.forEach((elem2) => {
582                if ( elem2.classList.contains('continue-reading-done') ) return;
583                elem2.classList.add('continue-reading-done');
584                /*
585                elem2.style.maxHeight = 'none';
586                let height = parseInt(getComputedStyle(elem2).height);
587
588                if ( height < 400 ) {
589                    elem.classList.add('continue-reading-removed');
590                    elem2.style.maxHeight = 'none';
591                    return;
592                }
593
594                elem2.style.maxHeight = '400px';
595                */
596                
597                elem2.insertAdjacentHTML('beforeend', continueReadingWrapClonded.outerHTML);
598            
599                let continueReadingAnchor = elem2.querySelectorAll('a.continue-reading-btn');
600
601                continueReadingAnchor.forEach((elem3) => {
602                    if ( elem3.classList.contains('continue-reading-done') ) return;
603                    elem3.classList.add('continue-reading-done');
604
605                    elem3.addEventListener('click', removeContinueReading);
606                });
607
608            });
609        });
610
611        function removeContinueReading(event) {
612            event.preventDefault();
613
614            let target = event.currentTarget;
615            let singularBody = target.closest('.singular-body');
616
617            singularBody.classList.add('continue-reading-removed');
618            singularBody.querySelector('.continue-reading-wrap').remove();
619        }
620    },
621    
622    continueReadingArchiveDescription: function() {
623        let archiveDescriptionContainer = document.querySelectorAll('.archive-description.continue-reading-on');
624    
625        archiveDescriptionContainer.forEach((elem) => {
626            let continueReadingWrap = elem.querySelector('.continue-reading-wrap');
627            if ( !continueReadingWrap ) return;
628
629            let continueReadingAnchor = elem.querySelector('a.continue-reading-btn');
630            if ( !continueReadingAnchor ) return;
631
632            continueReadingAnchor.addEventListener('click', (event) => {
633                event.preventDefault();
634                
635                elem.classList.add('continue-reading-removed');
636                let continueReadingWrap = elem.querySelector('.continue-reading-wrap');
637                if ( continueReadingWrap ) {
638                    continueReadingWrap.remove();
639                }
640            });
641
642        });
643    },
644
645    shareLinks: function() {
646        document.body.addEventListener('click', (event) => {
647
648            let moreLink = event.target.closest('.singular-share a[data-site_name="more"]');
649            
650            if ( moreLink ) {
651                event.preventDefault();
652                let data = {
653                    text: moreLink.getAttribute('data-post_title'),
654                    url: moreLink.href,
655                }
656                try {
657                    navigator.share(data);
658                } catch (err) {
659                    console.log(err);
660                }
661                return false;
662            }
663        });        
664    },
665
666    timeFormat: function() {
667        if ( typeof theme_js_vars === 'undefined' ) return;
668        if ( theme_js_vars.enable_short_time === undefined ) return;
669
670        let locale = document.documentElement.getAttribute('lang') || 'en-US';
671        const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });
672        const now = new Date();
673        
674        let timeDiv = document.querySelectorAll('time[datetime]');
675
676        timeDiv.forEach((elem) => {
677            if ( elem.classList.contains('time-format-done') ) return;
678            elem.classList.add('time-format-done');
679
680            let timeStr = elem.getAttribute('datetime');
681
682            const date = new Date(timeStr);
683
684            const diffInSeconds = (date - now) / 1000;
685            const diffInMinutes = diffInSeconds / 60;
686            const diffInHours = diffInMinutes / 60;
687            const diffInDays = diffInHours / 24;
688            const diffInWeeks = diffInDays / 7;
689            const diffInMonths = diffInDays / 30;
690            const diffInYears = diffInDays / 365;
691
692            let output;
693        
694            if ( Math.abs(diffInSeconds) < 60 ) {
695                output = rtf.format(Math.round(diffInSeconds), 'second');
696            } else if ( Math.abs(diffInMinutes) < 60 ) {
697                output = rtf.format(Math.round(diffInMinutes), 'minute');
698            } else if ( Math.abs(diffInHours) < 24 ) {
699                output = rtf.format(Math.round(diffInHours), 'hour');
700            } else if ( Math.abs(diffInDays) < 7 ) {
701                output = rtf.format(Math.round(diffInDays), 'day');
702            } else if ( Math.abs(diffInWeeks) < 4 ) {
703                output = rtf.format(Math.round(diffInWeeks), 'week');
704            } else if ( Math.abs(diffInMonths) < 12 ) {
705                output = rtf.format(Math.round(diffInMonths), 'month');
706            } else {
707                output = rtf.format(Math.round(diffInYears), 'year');
708            }
709
710            elem.textContent = output.replace(/\u0642\u0628\u0644/g, '\u0645\u0646\u0630');
711        });
712    },
713
714    timer: function() {
715        let timerDiv = document.querySelectorAll('.timer');
716
717        timerDiv.forEach((elem) => {
718            if ( elem.classList.contains('timer-done') ) return;
719            elem.classList.add('timer-done');
720
721            const timeStr = elem.getAttribute('datetime');
722            const end = new Date(timeStr);
723
724            let daysDiv = elem.querySelector('.timer-counter-item[data-type="days"] .value');
725            let hoursDiv = elem.querySelector('.timer-counter-item[data-type="hours"] .value');
726            let minutesDiv = elem.querySelector('.timer-counter-item[data-type="minutes"] .value');
727            let secondsDiv = elem.querySelector('.timer-counter-item[data-type="seconds"] .value');
728
729            setInterval(function() {
730                const now = new Date();
731                const diff = end - now;
732
733                const days = Math.max(Math.floor(diff / (1000 * 60 * 60 * 24)), 0);
734                const hours = Math.max(Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)), 0);
735                const minutes = Math.max(Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)), 0);
736                const seconds = Math.max(Math.floor((diff % (1000 * 60)) / 1000), 0);
737
738                daysDiv.textContent = days;
739                hoursDiv.textContent = hours;
740                minutesDiv.textContent = minutes;
741                secondsDiv.textContent = seconds;
742
743            }, 1000);
744        });
745    },
746    
747    newsTicker: function() {
748        let newsTickerDiv = document.querySelector('#news-ticker');
749        if ( !newsTickerDiv ) return;
750
751        newsTickerDiv.classList.add('active');
752
753        let newsTickerItems = newsTickerDiv.querySelectorAll('.news-ticker-item');
754
755        let randomIndex = Math.floor(Math.random() * newsTickerItems.length);
756        newsTickerItems[randomIndex].classList.add('active');
757
758        newsTickerClose = newsTickerDiv.querySelector('.news-ticker-close');
759
760        let dismissedItemsStr = Cookies.get('newsticker_dismissed_items') || '';
761        
762        let dismissedItemsArr = dismissedItemsStr.split(',');
763        dismissedItemsArr = dismissedItemsArr.filter(function(value) {
764            return value.trim() !== '';
765        });
766
767        newsTickerClose.addEventListener('click', (event) => {
768            event.preventDefault();
769
770            dismissedItemsArr.push(newsTickerItems[randomIndex].getAttribute('data-id'));
771            dismissedItemsStr = dismissedItemsArr.join(',');
772
773            Cookies.set('newsticker_dismissed_items', dismissedItemsStr, { expires: 30 });
774
775            newsTickerDiv.remove();
776        });
777
778    },
779
780    tabbedWidgets: function() {
781        let tabs = document.querySelectorAll('.widgets-list.tabbed');
782
783        tabs.forEach((elem) => {
784            if ( elem.classList.contains('tabs-done') ) return;
785            elem.classList.add('tabs-done');
786
787            elem.querySelector('.widget-tabs a').classList.add('active');
788            elem.querySelector('.widgets-area-inner .widget').classList.add('active');
789
790            let tabsAnchors = elem.querySelectorAll('.widget-tabs a');
791
792            tabsAnchors.forEach((elem2) => {
793                elem2.addEventListener('click', (event) => {
794                    let href = elem2.getAttribute('href');
795
796                    for ( const tabsAnchor of tabsAnchors ) {
797                        if ( tabsAnchor !== elem2 ) {
798                            tabsAnchor.classList.remove('active');
799                        } else {
800                            tabsAnchor.classList.add('active');
801                        }
802                    }
803
804                    const tabsWidgets = elem.querySelectorAll('.widgets-area-inner .widget');
805                    for ( const tabsWidget of tabsWidgets ) {
806                        if ( '#' + tabsWidget.id !== href ) {
807                            tabsWidget.classList.remove('active');
808                        } else {
809                            tabsWidget.classList.add('active');
810                        }
811                    }
812
813                    event.preventDefault();
814                });
815            });
816        });
817    },
818
819    viewsCounter: function() {
820        if ( typeof theme_js_vars === 'undefined' ) return;
821        if ( theme_js_vars.post_id === undefined ) return;
822
823        let viewedPostsStr = Cookies.get('posts_viewed') || '';
824        
825        let viewedPostsArr = viewedPostsStr.split(',');
826        viewedPostsArr = viewedPostsArr.filter(function(value) {
827            return value.trim() !== '';
828        });
829
830        if ( viewedPostsArr.includes(theme_js_vars.post_id) ) return;
831        
832        viewedPostsArr.unshift(theme_js_vars.post_id);
833        viewedPostsStr = viewedPostsArr.join(',');
834        Cookies.set('posts_viewed', viewedPostsStr, { expires: 30 });
835
836        if ( theme_js_vars.count_views === undefined ) return;
837
838        fetch(theme_js_vars.ajax_url, {
839            method: 'POST',
840            credentials: 'same-origin',
841            headers: {
842                'Content-Type': 'application/x-www-form-urlencoded',
843                'Cache-Control': 'no-cache',
844            },
845            body: new URLSearchParams(
846                {
847                    nonce: theme_js_vars.nonce,
848                    action: 'a4h_count_post_views',
849                    post_id: theme_js_vars.post_id,
850                }
851            ),
852        })
853        .then(function(response) {
854            return response.json();
855        })
856        .then(function(data) {
857        })
858        .catch(function(error) {
859        });        
860    },
861
862    viewedPosts: function() {
863        if ( typeof theme_js_vars === 'undefined' ) return;
864        if ( theme_js_vars.post_id === undefined ) return;
865        if ( theme_js_vars.count_views === undefined ) return;
866
867        let referringPost = Cookies.get('post_referring') || '';
868        if ( !referringPost ) {
869            Cookies.set('post_referring', JSON.stringify({'type': theme_js_vars.post_type, 'id': theme_js_vars.post_id}), { expires: 30 })
870            referringPost = Cookies.get('post_referring')
871        }
872        referringPost = JSON.parse(referringPost);
873           
874        if ( theme_js_vars.post_id == referringPost.id ) return;
875        if ( theme_js_vars.post_type != referringPost.type ) return;
876             
877        fetch(theme_js_vars.ajax_url, {
878            method: 'POST',
879            credentials: 'same-origin',
880            headers: {
881                'Content-Type': 'application/x-www-form-urlencoded',
882                'Cache-Control': 'no-cache',
883            },
884            body: new URLSearchParams(
885                {
886                    nonce: theme_js_vars.nonce,
887                    action: 'a4h_add_to_viewed_posts',
888                    referring_post_id: referringPost.id,
889                    current_post_id: theme_js_vars.post_id,
890                }
891            ),
892        })
893        .then(function(response) {
894            return response.json();
895        })
896        .then(function(data) {
897        })
898        .catch(function(error) {
899        });
900    },
901
902    stickyContent: function() {
903        let sticky = document.querySelectorAll('.content-sticky');
904        if ( !sticky ) return;
905
906        window.addEventListener('scroll', function() {
907            sticky.forEach((elem) => {
908                let rect = elem.getBoundingClientRect();
909
910                requestAnimationFrame(function() {
911                    if ( elem.classList.contains('sticky-top') ) {
912                        if ( rect.top - headerHeight <= adminbarHeight ) {
913                            elem.classList.add('pinned');
914                        } else {
915                            elem.classList.remove('pinned');
916                        }   
917                    }
918                    if ( elem.classList.contains('sticky-bottom') ) {
919                        if ( rect.bottom < window.innerHeight ) {
920                            elem.classList.remove('pinned');
921                        } else {
922                            elem.classList.add('pinned');
923                        }
924                    }
925                });
926            });
927        });
928    },
929
930    stickyAdClose: function() {
931        let stickyAds = document.querySelectorAll('.inserted[data-location="sticky"]');
932        stickyAds.forEach((elem) => {
933            let stickyAdClose = elem.querySelector('.inserted-sticky-close');
934
935            stickyAdClose.addEventListener('click', (event) => {
936                event.preventDefault();
937                
938                elem.remove();
939            });
940        });
941    },
942
943    toolTips: function() {
944        if ( typeof bootstrap === 'undefined' ) return;
945        if ( bootstrap.Tooltip === undefined ) return;
946
947        var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
948        var tooltipList = tooltipTriggerList.map(function(tooltipTriggerEl) {
949            return new bootstrap.Tooltip(tooltipTriggerEl);
950        });
951    },
952
953    scrollTop: function() {
954        let scrollTop = document.querySelectorAll('.scroll-top');
955        
956        scrollTop.forEach((elem) => {
957            elem.addEventListener('click', (event) => {
958                document.documentElement.scrollTop = 0;
959                event.preventDefault();
960            });
961        });
962    },
963
964    refresh: function() {
965        this.toolTips();
966        this.continueReadingSingular();
967        this.continueReadingArchiveDescription();
968        this.LoadMorePostsArchive();
969        this.timeFormat();
970        this.timer();
971        this.tabbedWidgets();
972        this.stickyContent();
973    },
974
975}
976
977addEventListener('DOMContentLoaded', function() {
978    Object.keys(a4h).forEach(function(key) {
979        if ( key == 'refresh' ) return;
980        a4h[key]();
981    });
982});
983
984addEventListener('load', function() {
985    window.dispatchEvent(new Event('scroll'));
986});
987
988addEventListener('resize', function() {
989    window.dispatchEvent(new Event('scroll'));
990});

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.