PageSourceSearch

https://wpsimplepay.com/wp-content/themes/wp-simple-pay/build/scripts/index.js?ver=2.8.6

js wpsimplepay.com collected 2026-10-02 02:44:18 UTC 2,992 bytes, 124 lines download raw bytes

1/**
2 * Sticks the header and exposes the call to action based on the window size.
3 */
4function maybeStickHeader() {
5	if ( window.innerWidth < 1080 ) {
6		return;
7	}
8
9	const templatePartEl = document.querySelector(
10		'.wp-block-wpsp-template-part-header:not(.is-static)'
11	);
12
13	if ( ! templatePartEl ) {
14		return;
15	}
16
17	const toStickEl = document.querySelector( '.wp-block-wpsp-header' );
18
19	if ( ! toStickEl ) {
20		return;
21	}
22
23	const body = document.querySelector( 'body' );
24
25	window.onscroll = function () {
26		if ( window.pageYOffset > toStickEl.offsetTop + 100 ) {
27			toStickEl.parentElement.style.position = 'sticky';
28			toStickEl.parentElement.style.zIndex = 1000;
29			toStickEl.parentElement.style.top = body.classList.contains(
30				'admin-bar'
31			)
32				? '32px'
33				: '0';
34
35			toStickEl.classList.add( 'is-sticky' );
36			toStickEl.parentElement.classList.add( 'is-sticky' );
37		} else {
38			toStickEl.parentElement.style.position = 'relative';
39			toStickEl.classList.remove( 'is-sticky' );
40			toStickEl.parentElement.style.top = 0;
41			toStickEl.parentElement.classList.remove( 'is-sticky' );
42		}
43	};
44}
45
46/**
47 * Hides the "Resources" list and adds a toggle to the header click.
48 */
49function faqsToggle() {
50	const faqsWrapperEl = document.querySelector( '.wp-block-wpsp-faqs' );
51
52	if ( ! faqsWrapperEl ) {
53		return;
54	}
55
56	const toggleEl = faqsWrapperEl.querySelector( 'h2' );
57	const faqsEl = faqsWrapperEl.querySelector( '.wp-block-wpsp-faqs__faqs' );
58	const resourcesEl = faqsWrapperEl.querySelector(
59		'.wp-block-wpsp-faqs__resources'
60	);
61
62	resourcesEl.style.display = 'none';
63
64	toggleEl.addEventListener( 'click', () => {
65		faqsEl.style.display =
66			'block' === faqsEl.style.display || '' === faqsEl.style.display
67				? 'none'
68				: 'block';
69		resourcesEl.style.display =
70			'block' === resourcesEl.style.display ? 'none' : 'block';
71	} );
72}
73
74/**
75 * Sets some cookies in the client for better reliability with caching.
76 */
77function track() {
78	const url = new URLSearchParams( window.location.search );
79	const today = new Date();
80
81	// PPC ads.
82	if (
83		'google' === url.get( 'utm_source' ) &&
84		'cpc' === url.get( 'utm_medium' )
85	) {
86		setCookie( 'wpsp_ppc', today.getTime(), 365 );
87	}
88}
89
90/**
91 * Sticks the header element to the top of the page.
92 */
93document.addEventListener( 'DOMContentLoaded', function () {
94	// Stick or unstick the header on window resize.
95	maybeStickHeader();
96	window.addEventListener( 'resize', maybeStickHeader );
97
98	// FAQs toggle.
99	faqsToggle();
100
101	// Cookie tracking.
102	track();
103} );
104
105/**
106 * Sets a cookie.
107 *
108 * @param {string} name   The name of the cookie.
109 * @param {string} value  The value of the cookie.
110 * @param {int}    length Number of days to keep the cookie.
111 */
112function setCookie( name, value, length ) {
113	const d = new Date();
114	d.setTime( d.getTime() + length * 24 * 60 * 60 * 1000 );
115	const expires = 'expires=' + d.toUTCString();
116
117	document.cookie =
118		encodeURIComponent( name ) +
119		'=' +
120		encodeURIComponent( value ) +
121		';' +
122		expires +
123		';path=/;';
124}

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.