1(function ($) { 2 if (!$) { return; } 3 4 var STORAGE_KEY = 'tkGated.completed'; 5 var config = window.cirrusGating || {}; 6 var mode = config.mode === 'cookie' ? 'cookie' : 'session'; 7 8 function readSessionIds() { 9 try { 10 var raw = window.sessionStorage.getItem(STORAGE_KEY); 11 if (!raw) { return []; } 12 var parsed = JSON.parse(raw); 13 return Array.isArray(parsed) ? parsed.map(function (n) { return parseInt(n, 10); }).filter(function (n) { return !isNaN(n); }) : []; 14 } catch (e) { 15 return []; 16 } 17 } 18 19 function writeSessionIds(ids) { 20 try { 21 window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify(ids)); 22 } catch (e) { 23 // Storage may be disabled (private mode, quota); fail silently. 24 } 25 } 26 27 function markSessionCompleted(formId) { 28 var ids = readSessionIds(); 29 if (ids.indexOf(formId) === -1) { 30 ids.push(formId); 31 writeSessionIds(ids); 32 } 33 } 34 35 function revealSection($section) { 36 $section.find('> .cirrus-gated__form').hide(); 37 $section.find('> .cirrus-gated__content').removeAttr('hidden').show(); 38 } 39 40 $(function () { 41 if (mode !== 'session') { return; } 42 43 var completed = readSessionIds(); 44 if (!completed.length) { return; } 45 46 $('.cirrus-gated[data-mode="session"]').each(function () { 47 var $section = $(this); 48 var formId = parseInt($section.attr('data-form-id'), 10); 49 if (!isNaN(formId) && completed.indexOf(formId) !== -1) { 50 revealSection($section); 51 } 52 }); 53 }); 54 55 // Gravity Forms fires this jQuery event when an AJAX-submitted form has 56 // rendered its confirmation. The signature is (event, confirmation_html, 57 // form_id, ...). We only need the form_id. 58 $(document).on('gform_confirmation_loaded', function (event, formId) { 59 formId = parseInt(formId, 10); 60 if (isNaN(formId) || formId <= 0) { return; } 61 62 if (mode === 'cookie') { 63 // Cookie was set server-side by gform_after_submission. Reload 64 // so PHP renders the gated content directly. 65 window.location.reload(); 66 return; 67 } 68 69 markSessionCompleted(formId); 70 71 $('.cirrus-gated[data-mode="session"][data-form-id="' + formId + '"]').each(function () { 72 revealSection($(this)); 73 }); 74 }); 75})(window.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.