PageSourceSearch

https://tedsnote.com/wp-content/plugins/simple-cloudflare-turnstile/js/integrations/blocksy.js?ver=1.3

js tedsnote.com collected 2026-09-29 01:00:07 UTC 2,831 bytes, 68 lines download raw bytes

1/* Blocksy */
2( function () {
3
4    // Blocksy renders its header account forms inside <template id="ct-account-modal-template">,
5    // and clones them into the page the first time the modal is opened. Template content is inert,
6    // so document.getElementById() cannot see it and the widget can never be rendered at page load
7    // - it has to be rendered here, once the clone is in the live DOM. Re-opening the modal then
8    // resets the widget, so a second attempt never submits an already-used token.
9
10    var MODAL = '#account-modal, .ct-account-modal';
11    var timer = null;
12
13    // Explicit rendering ignores data-*-callback, which would leave the submit button disabled.
14    function cftOpts( el ) {
15        return ( typeof window.cfturnstileOpts === 'function' ) ? window.cfturnstileOpts( el ) : {};
16    }
17
18    function refresh() {
19        if ( typeof turnstile === 'undefined' ) {
20            return;
21        }
22
23        var widgets = document.querySelectorAll( '#account-modal .cf-turnstile, .ct-account-modal .cf-turnstile' );
24        for ( var i = 0; i < widgets.length; i++ ) {
25            var el = widgets[ i ];
26            if ( el.firstElementChild ) {
27                // Already rendered: clear the used token but keep the widget in place.
28                try { turnstile.reset( el ); } catch ( e ) {}
29            } else {
30                // First open: this is the widget's only chance to be rendered.
31                try { turnstile.render( el, cftOpts( el ) ); } catch ( e ) {}
32            }
33        }
34    }
35
36    // Debounced: the toggle fires on open and on close, and the observer may fire alongside it.
37    function schedule() {
38        clearTimeout( timer );
39        timer = setTimeout( refresh, 500 );
40    }
41
42    // Re-opening an already-cloned modal, and any other control that opens it.
43    document.addEventListener( 'click', function ( e ) {
44        if ( e.target && e.target.closest && e.target.closest( '.ct-header-account' ) ) {
45            schedule();
46        }
47    } );
48
49    // First open: catch the modal being cloned in, however it was triggered.
50    if ( window.MutationObserver ) {
51        new MutationObserver( function ( mutations ) {
52            for ( var i = 0; i < mutations.length; i++ ) {
53                var added = mutations[ i ].addedNodes;
54                for ( var j = 0; j < added.length; j++ ) {
55                    var n = added[ j ];
56                    if ( n.nodeType !== 1 ) {
57                        continue;
58                    }
59                    if ( ( n.matches && n.matches( MODAL ) ) || ( n.querySelector && n.querySelector( MODAL ) ) ) {
60                        schedule();
61                        return;
62                    }
63                }
64            }
65        } ).observe( document.documentElement, { childList: true, subtree: true } );
66    }
67
68} )();

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.