PageSourceSearch

https://oneclickhustle.com/wp-content/plugins/suremembers-core/assets/js/script.js?ver=1.4.1

js oneclickhustle.com collected 2026-09-28 09:29:04 UTC 6,724 bytes, 186 lines download raw bytes

1( function ( $ ) {
2	// Enable popup.
3	function enablePopup( e ) {
4		e.preventDefault();
5
6		if ( ! $( 'body' ).children( '.suremember-login-container-popup' ).length ) {
7			const popup = $( '.suremember-login-container-popup' );
8			popup.find( 'p, br' ).remove();
9			$( '.suremember-login-container-popup' ).appendTo( document.body );
10		}
11		$( '.suremember-login-container-popup' ).addClass( 'active' );
12
13		// Clear any previous error messages.
14		$( '.suremember-login-container-popup .field-error' ).remove();
15
16		// Render Turnstile - wait for script to load if needed.
17		function renderTurnstile( attempts = 0 ) {
18			if ( typeof window.turnstile !== 'undefined' ) {
19				// Check for Simple Turnstile widgets (they have class cf-turnstile but not cf-turnstile-manual)
20				const simpleTurnstileWidgets = $( '.suremember-login-container-popup .cf-turnstile' ).not( '.cf-turnstile-manual' );
21
22				if ( simpleTurnstileWidgets.length > 0 ) {
23					// Simple Turnstile widget exists, check if it needs rendering
24					simpleTurnstileWidgets.each( function() {
25						const widget = $( this );
26						// Check if widget is empty (needs rendering)
27						if ( widget.children().length === 0 && widget.data( 'sitekey' ) ) {
28							try {
29								window.turnstile.render( widget[ 0 ], {
30									sitekey: widget.data( 'sitekey' ),
31									theme: widget.data( 'theme' ) || 'auto',
32									language: widget.data( 'language' ) || 'auto',
33									action: widget.data( 'action' ) || 'submit',
34									size: widget.data( 'size' ) || 'normal',
35									appearance: widget.data( 'appearance' ) || 'always',
36									callback: widget.data( 'callback' ) || 'cfturnstileCallback',
37									'error-callback': widget.data( 'error-callback' ) || 'cfturnstileErrorCallback',
38								} );
39							} catch ( error ) {
40								console.warn( 'Simple Turnstile render error:', error );
41							}
42						}
43					} );
44				} else {
45					// No Simple Turnstile, check for SureMembers Turnstile
46					const turnstileContainer = $( '.suremember-login-container-popup .cf-turnstile-manual' );
47					if ( turnstileContainer.length && window.turnstileReady ) {
48						// Check if already rendered by looking for the hidden input.
49						const existingInput = turnstileContainer.find( 'input[name="cf-turnstile-response"]' );
50
51						if ( existingInput.length === 0 ) {
52							const siteKey = turnstileContainer.data( 'sitekey' );
53							const theme = turnstileContainer.data( 'theme' ) || 'light';
54
55							// Clear any existing content first.
56							turnstileContainer.empty();
57							turnstileContainer.addClass( 'cf-turnstile' );
58
59							try {
60								window.turnstile.render( turnstileContainer[ 0 ], {
61									sitekey: siteKey,
62									theme,
63								} );
64							} catch ( error ) {
65								console.warn( 'SureMembers Turnstile render error:', error );
66							}
67						}
68					}
69				}
70			} else if ( attempts < 50 ) {
71				setTimeout( () => renderTurnstile( attempts + 1 ), 100 );
72			}
73		}
74
75		// Always try to render Turnstile when popup opens
76		renderTurnstile();
77	}
78
79	// Submit user login form.
80	function loginSubmit( e ) {
81		e.preventDefault();
82		const form = $( this );
83		const getSubmitBtn = $( '.suremember-user-form-submit' );
84		getSubmitBtn.addClass( 'submit-loading' );
85		const formData = new FormData( form[ 0 ] );
86		$.ajax( {
87			method: 'POST',
88			url: suremembers_login.ajax_url,
89			data: formData,
90			dataType: 'json',
91			cache: false,
92			contentType: false,
93			processData: false,
94			success( response ) {
95				getSubmitBtn.removeClass( 'submit-loading' );
96				if ( true === response.success ) {
97					window.location.reload();
98				} else if ( response?.data?.result ) {
99					for ( const field in response.data.result ) {
100						const heading = $( '.suremember-login-heading' );
101						heading.after( `<span class='field-error'>${ response.data.result[ field ] }</span>` );
102					}
103
104					// Reset Turnstile on error
105					if ( typeof window.turnstile !== 'undefined' ) {
106						const turnstileContainer = $( '.suremember-login-container-popup .cf-turnstile-manual, .suremember-login-container-popup .cf-turnstile' );
107						if ( turnstileContainer.length ) {
108							// Get the widget ID from the container
109							const widgetId = turnstileContainer.find( 'input[name="cf-turnstile-response"]' ).attr( 'id' );
110							if ( widgetId ) {
111								const widgetIdValue = widgetId.replace( '_response', '' );
112								window.turnstile.reset( widgetIdValue );
113							} else {
114								// Fallback to container reset
115								window.turnstile.reset( turnstileContainer[ 0 ] );
116							}
117						}
118					}
119				}
120			},
121		} );
122	}
123
124	function logoutSubmit( e ) {
125		e.preventDefault();
126
127		const button = $( this ),
128			  processingText = button.data( 'processing' ),
129			  nonce = button.data( 'nonce' );
130		button.text( processingText );
131		const formData = new FormData();
132		formData.append( 'action', 'suremembers_user_logout' );
133		formData.append( 'logout_nonce', nonce );
134		$.ajax( {
135			method: 'POST',
136			url: suremembers_login.ajax_url,
137			data: formData,
138			dataType: 'json',
139			cache: false,
140			contentType: false,
141			processData: false,
142			success( response ) {
143				if ( true === response.success ) {
144					window.location.reload();
145				} else if ( response?.data?.result ) {
146					button.after( `<span class='field-error'>${ response?.data?.result?.message || 'Something went wrong. Please try again.' }</span>` );
147				}
148			},
149		} );
150	}
151
152	// When click outside hide popup.
153	$( document ).on( 'click', '.suremember-login-container-popup.active', function ( e ) {
154		const inner = $( '.suremember-login-wrapper' );
155		if ( ! inner.is( e.target ) && inner.has( e.target ).length === 0 ) {
156			$( this ).removeClass( 'active' );
157		}
158	} );
159
160	// Close by button.
161	$( document ).on( 'click', '.suremember-login-wrapper-close', function() {
162		$( '.suremember-login-container-popup' ).removeClass( 'active' );
163	} );
164
165	// Hide show password.
166	function showHidePwd( event ) {
167		event.preventDefault();
168		const button = $( this );
169		const input = button.siblings( 'input' );
170		button.toggleClass( 'show-pwd' );
171		if ( 'text' === input.attr( 'type' ) ) {
172			input.attr( 'type', 'password' );
173			button.find( 'span' ).removeClass( 'dashicons-hidden' );
174			button.find( 'span' ).addClass( 'dashicons-visibility' );
175		} else {
176			input.attr( 'type', 'text' );
177			button.find( 'span' ).removeClass( 'dashicons-visibility' );
178			button.find( 'span' ).addClass( 'dashicons-hidden' );
179		}
180	}
181
182	$( document ).on( 'submit', '.suremember-user-login-form', loginSubmit );
183	$( document ).on( 'click', '.suremembers-logout-button', logoutSubmit );
184	$( document ).on( 'click', '.suremembers-open-login-popup', enablePopup );
185	$( document ).on( 'click', '.suremembers-hide-if-no-js', showHidePwd );
186}( jQuery ) );

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.