PageSourceSearch

https://ccrc.gov.uk/wp-content/themes/hale/dist/js/accordion-auto-…?id=ae9486ec782866bd4d25a80b123f3208

js ccrc.gov.uk collected 2026-10-02 05:30:53 UTC 2,851 bytes, 53 lines download raw bytes

1( function() {
2	if (document.querySelector(".govuk-accordion") !== null) {
3
4		//A bit of JS to ensure that all Accordion headings and content IDs are unique
5		let haleAllAccordionHeadings = document.querySelectorAll("#accordion-default-heading-1");
6		let haleAllAccordionContentArray = document.querySelectorAll("#accordion-default-content-1");
7
8		//if the number of accordions and headings is greater than one and equal to the number of contents
9		if (haleAllAccordionHeadings.length && haleAllAccordionHeadings.length == haleAllAccordionContentArray.length) {
10			for (i=0;i<haleAllAccordionHeadings.length;i++) {
11				// Set ID for heading to be unique
12				haleAllAccordionHeadings[i].id = "hale-accordion-heading-" + (i+1);
13				// Set ID for content to be unique
14				haleAllAccordionContentArray[i].id = "hale-accordion-content-" + (i+1);
15				// Set the Aria controls to be the same as the (new) content ID
16				// This was the only thing being incremented by PHP, but was still insufficient for many accordions per page
17				haleAllAccordionHeadings[i].closest(".govuk-accordion__section-button").setAttribute("aria-controls", "hale-accordion-content-" + (i+1));
18			}
19		}
20
21		// Now we open the accordion section if the section is linked to directly
22		// Remember that accordions remember their state so this might result in two+ sections being open
23		haleAccordionDirectID();
24	}
25})();
26
27function haleAccordionDirectID() {
28	if (window.location.href.split("#").length == 2) {
29		
30		// Split the string and get the ID
31		const halePageRequestedID = window.location.href.split("#")[1];
32
33		// Check for the requested ID within the accordion
34		// We already know that an accordion exists on the page when this function is called
35		if (document.querySelector(".govuk-accordion__section #" + halePageRequestedID) !== null) {
36
37			const haleRequiredSection = document.getElementById(halePageRequestedID).closest(".govuk-accordion__section");
38			haleRequiredSection.classList.add("govuk-accordion__section--expanded");
39
40			// If the rest of the JS has (for some reason) already run, we need to do the things it would usually deal with
41			// This probably won't be needed, but included as a catchall
42			if (document.getElementById(halePageRequestedID).querySelector("button") !== null) {
43				const haleAccordionButton = haleRequiredSection.querySelector("button");
44				const haleAccordionChevron = haleRequiredSection.querySelector(".govuk-accordion-nav__chevron"); 
45				const haleShowHideControl = haleRequiredSection.querySelector(".govuk-accordion__section-toggle-text");
46				haleAccordionButton.setAttribute("aria-expanded", "true");
47				haleAccordionChevron.classList.remove("govuk-accordion-nav__chevron--down");
48				haleShowHideControl.innerHTML = haleShowHideControl.innerHTML.replace('Show', 'Hide');
49			}
50			haleRequiredSection.scrollIntoView();
51		}
52	}
53}

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.