PageSourceSearch

https://mieleguide.com/wp-content/plugins/rich-table-of-content/js/rtoc_highlight.js?ver=7.1.2

js mieleguide.com collected 2026-10-02 13:19:39 UTC 3,755 bytes, 114 lines download raw bytes

1(function () {
2	let rtocList = [];
3	let lastScrollY = 0;
4	let lastBodyClientHeight = 0;
5	let sidebar_rtoc_wrapper = document.querySelector('.sidebar #rtoc-mokuji-widget-wrapper');
6	if (!sidebar_rtoc_wrapper) {
7		sidebar_rtoc_wrapper = document.querySelector('.widget #rtoc-mokuji-widget-wrapper');
8	}
9	if (!sidebar_rtoc_wrapper) {
10		sidebar_rtoc_wrapper = document.querySelector('.c-widget #rtoc-mokuji-widget-wrapper');
11	}
12	if (!sidebar_rtoc_wrapper) {
13		sidebar_rtoc_wrapper = document.querySelector('#scrollad #rtoc-mokuji-widget-wrapper');
14	}
15	if (!sidebar_rtoc_wrapper) {
16		sidebar_rtoc_wrapper = document.querySelector('#sideBarTracking #rtoc-mokuji-widget-wrapper');
17	}
18	if (!sidebar_rtoc_wrapper) {
19		sidebar_rtoc_wrapper = document.querySelector('#sidebar1 #rtoc-mokuji-widget-wrapper');
20	}
21	if (sidebar_rtoc_wrapper) {
22		sidebar_rtoc_wrapper.classList.add('rtoc-sidebar-contents');
23	}
24	function rtoc_init() {
25		rtocList = [];
26		rtocParentList = [];
27		if (sidebar_rtoc_wrapper) {
28			const itemList = sidebar_rtoc_wrapper.querySelectorAll('a');
29			const itemAllList = sidebar_rtoc_wrapper.querySelectorAll('.level-1 > .rtoc-item > a');
30			for (let i = 0; i < itemList.length; i++) {
31				const a = itemList[i];
32				const linkAnker = a.href.substring(a.href.lastIndexOf('#'));
33				const itemElement = document.querySelector(decodeURI(linkAnker));
34				if (itemElement != null) {
35					let top = itemElement.offsetTop;
36					let parent = itemElement.offsetParent;
37					while (parent != null) {
38						top += parent.offsetTop;
39						parent = parent.offsetParent;
40					}
41					rtocList.push({ top: top, bottom: 1e30, itemdom: a.parentElement });
42					if (i > 0) {
43						if (rtocList[i]) {
44							rtocList[i - 1].bottom = rtocList[i].top;
45						}
46					}
47				}
48			}
49			for (let i = 0; i < itemAllList.length; i++) {
50				const a = itemAllList[i];
51				const linkAnker = a.href.substring(a.href.lastIndexOf('#'));
52				const itemAllElement = document.querySelector(decodeURI(linkAnker));
53				let top = itemAllElement.offsetTop;
54				let parent = itemAllElement.offsetParent;
55				while (parent != null) {
56					top += parent.offsetTop;
57					parent = parent.offsetParent;
58				}
59				rtocParentList.push({ top: top, bottom: 1e30, itemdom: a.parentElement });
60				if (i > 0) {
61					rtocParentList[i - 1].bottom = rtocParentList[i].top;
62				}
63			}
64		}
65	}
66	rtoc_init();
67	function rtocUpdateSection(scrollY) {
68		if (document.body.clientHeight !== lastBodyClientHeight) {
69			rtoc_init();
70		}
71		for (let sec of rtocList) {
72			sec.itemdom.classList.remove('rtoc-current');
73		}
74		for (let sec of rtocParentList) {
75			sec.itemdom.classList.remove('rtoc-show');
76		}
77
78		for (let i = 0; i < rtocList.length; i++) {
79			const sec = rtocList[i];
80			if (sec.top <= scrollY && scrollY < sec.bottom) {
81				sec.itemdom.classList.add('rtoc-current');
82				break;
83			}
84		}
85		for (let i = 0; i < rtocParentList.length; i++) {
86			const sec = rtocParentList[i];
87			if (sec.top <= scrollY && scrollY < sec.bottom) {
88				sec.itemdom.classList.add('rtoc-show');
89				break;
90			}
91		}
92	}
93	function widgetScroll(hiddenDOM) {
94		const highlightContents = sidebar_rtoc_wrapper.querySelector('.rtoc-current');
95	}
96	if(sidebar_rtoc_wrapper){
97		let ticking = false;
98		const scrollHeight = sidebar_rtoc_wrapper.querySelector('.rtoc-mokuji').scrollHeight;
99		const displayHeight = sidebar_rtoc_wrapper.querySelector('.rtoc-mokuji').offsetHeight;
100		document.addEventListener('scroll', function () {
101			lastScrollY = window.scrollY;
102			if (ticking === false) {
103				window.requestAnimationFrame(function () {
104					rtocUpdateSection(lastScrollY + 300);
105					ticking = false;
106				});
107				ticking = true;
108			}
109			if (scrollHeight > displayHeight) {
110				widgetScroll(scrollHeight - displayHeight);
111			}
112		});
113	}
114})();

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.