PageSourceSearch

https://sven-lehmann.eu/wp-content/themes/modulbuero_theme/blocks/inhaltsverzeichnis/frontend.js?ver=3.2.6

js sven-lehmann.eu collected 2026-10-02 17:55:59 UTC 2,281 bytes, 80 lines download raw bytes

1$(document).ready(() => {
2	let inhaltsverz = ".wp-block-modulbuero-inhaltsverzeichnis"
3    const content	= $("main .post-content");
4	const tocList  	= $(".mb-toc-list");
5	const tocTitle 	= $(inhaltsverz + " h2");
6	const shorty   	= "mb-toc-compress";
7	const opener   	= shorty+"-opener"
8	const openState	= 'mb-toc-comp-open'
9
10	if(tocList.length){
11		// Find all headings in the content that come after the aside container
12		//const headings = content.find("aside ~ h2, aside ~ h3, aside ~ h4, aside ~ h5, aside ~ h6");
13		let headings = [];
14		
15		$(inhaltsverz).nextAll().each(function() {
16			// Loop through each heading and create a table of contents
17			if ($(this).is("h2, h3, h4, h5, h6")) {
18				headings.push($(this));
19				// Recursive call to find nested headings
20				
21			}else{
22				$(this).find('h2, h3, h4, h5, h6').each(function() {
23					headings.push($(this));
24	            });
25			}
26		});
27		
28		$.each(headings, function(index, value) {
29			console.log(value)
30			const heading = $(this);
31			const listItem = $("<li></li>");
32			const link = $("<a></a>");
33			const text = heading.text();
34			const id = text.toLowerCase().replace(/\s+/g, "-");
35
36			// Get the heading level (h2, h3, etc.)
37			const headingLevel = heading[0].tagName.toLowerCase();
38			
39			heading.attr("id", id);
40			link.text(text);
41			link.attr("href", `#${id}`);
42			// Add a class to the link indicating the heading level
43			link.addClass(`toc-heading-${headingLevel}`);
44			listItem.append(link);
45			tocList.append(listItem);
46			
47	    });
48		
49
50
51		//Ein- Ausschalten
52		tocTitle.on("click", function(){
53			$(".mb-toc-list").toggleClass("mb-toc-closed")
54			$(this).toggleClass("mb-toc-closed-h")
55		})
56	
57		//Clone for Mobile'n'Scrolled TOC
58		$(inhaltsverz).clone().appendTo("footer").addClass(shorty).hide();
59		const sInhaltsv = $('.'+shorty)
60		sInhaltsv.prepend("<div class='"+opener+"'></div>")
61		
62		$("."+opener).on("click", function(){
63			$(this).parent().toggleClass(openState)
64		})
65		$("."+shorty +" li a").on("click", function(){
66			$("."+shorty).removeClass(openState)
67		})
68		
69		$(window).on('scroll', function() {
70			let isInView = MB.isInViewport(inhaltsverz + ":not(.mb-toc-compress)");
71			
72			if(!isInView){
73				sInhaltsv.fadeIn()
74			}else{
75				sInhaltsv.fadeOut().removeClass(openState)
76			}
77		})
78	}
79});
80

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.