PageSourceSearch

https://www.choice.com.au/wp-content/themes/choice/assets/js/script.js?ver=1789966201

js choice.com.au collected 2026-09-24 15:17:41 UTC 2,604 bytes, 81 lines download raw bytes

1document.addEventListener( 'DOMContentLoaded', function() {
2	function scrollToElement( tabId ) {
3		const container = document.querySelector( '.uagb-tabs__panel' );
4		const target = document.querySelector( tabId );
5
6		if ( container && target ) {
7			container.scrollTo( {
8				left: target.offsetLeft - container.offsetLeft + container.scrollLeft,
9				behavior: 'smooth',
10			} );
11		}
12	}
13
14	function getSafeHash() {
15		const hash = window.location.hash;
16
17		// Allow only hashes like "#section-1", "#faq_2", etc.
18		const isValid = /^#[a-zA-Z0-9_-]+$/.test( hash );
19		return isValid ? hash : null;
20	}
21
22	// Call the function when needed
23	setTimeout( () => {
24		const safeHash = getSafeHash();
25		if ( safeHash ) {
26			scrollToElement( safeHash );
27		}
28	}, 800 );
29
30	document.querySelectorAll( '.gform_wrapper select' ).forEach( function( select ) {
31		function updateStyle() {
32			select.style.color = select.selectedIndex === 0 ? '#555555' : '#002E46';
33			select.style.opacity = select.selectedIndex === 0 ? '0.8' : '1';
34		}
35
36		select.addEventListener( 'change', updateStyle );
37		updateStyle();
38
39	} );
40}, {} );
41
42document.addEventListener( 'DOMContentLoaded', function() {
43	document.querySelectorAll('form.checkout select[name="billing_country"], form.checkout select[name="shipping_country"], form.checkout input[name="ship_to_same_address"]').forEach(function (el) {
44        el.addEventListener('change', function () {
45			document.body.dispatchEvent(new Event('update_checkout'));
46		});
47	});
48
49	// Add landmark role and accessible label for the sidebar.
50	const rightSidebar = document.getElementById( 'right-sidebar' );
51	if ( rightSidebar ) {
52		rightSidebar.setAttribute( 'role', 'complementary' );
53		rightSidebar.setAttribute( 'aria-label', 'Right Sidebar' );
54	}
55});
56
57/**
58 * Set --header-height and --footer-height custom properties on <body>,
59 * kept in sync on load and on window resize.
60 */
61( function() {
62	function setHeaderFooterVars() {
63		var header = document.querySelector( 'header' );
64		var footer = document.querySelector( 'footer' );
65
66		var headerHeight = header ? header.offsetHeight : 0;
67		var footerHeight = footer ? footer.offsetHeight : 0;
68
69		document.body.style.setProperty( '--header-height', headerHeight + 'px' );
70		document.body.style.setProperty( '--footer-height', footerHeight + 'px' );
71	}
72
73	document.addEventListener( 'DOMContentLoaded', setHeaderFooterVars );
74	window.addEventListener( 'load', setHeaderFooterVars );
75
76	var resizeTimeout;
77	window.addEventListener( 'resize', function() {
78		clearTimeout( resizeTimeout );
79		resizeTimeout = setTimeout( setHeaderFooterVars, 100 );
80	} );
81} )();

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.