| 1 |
jQuery(document).ready(function(t){function a(a){t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"hash_password",hash_nonce:ps_ajax.hash_nonce,password:a},success:function(t){Cookies.set("passster",t.password,{expires:parseInt(ps_ajax.days),sameSite:"strict"})},async:!1})}ps_ajax.link_pass&&"on"===ps_ajax.use_cookie&&(ps_ajax.link_pass.length<25?a(atob(ps_ajax.link_pass)):Cookies.set("passster",ps_ajax.link_pass,{expires:parseInt(ps_ajax.days),sameSite:"strict"}),window.location.replace(ps_ajax.permalink)),t(".passster-submit").on("click",function(e){e.preventDefault();var s=t(this).parent().parent();t(s)[0].checkValidity()||t(s)[0].reportValidity(),ps_id=t(this).attr("data-psid"),s=t("#"+ps_id),password=t("#"+ps_id+" .passster-password").attr("data-password"),type=t("#"+ps_id+" .passster-password").attr("data-protection-type"),list=t("#"+ps_id+" .passster-password").attr("data-list"),area=t("#"+ps_id+" .passster-password").attr("data-area"),protection=t("#"+ps_id+" .passster-password").attr("data-protection"),redirect=t(this).attr("data-redirect"),input=t("#"+ps_id+" .passster-password").val(),acf=t(this).attr("data-acf"),t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,input:input,password:password,post_id:ps_ajax.post_id,type:type,list:list,area:area,protection:protection,acf:acf,redirect:redirect},beforeSend:function(){s.find(".ps-loader").css("display","block")},success:function(e){if(s.find(".ps-loader").css("display","none"),!0===e.success){if("on"===ps_ajax.no_ajax)a(input),e.redirect?window.location.replace(redirect):window.location.reload();else{"on"===ps_ajax.use_cookie&&a(input),s.find(".passster-error").hide();let r=e.content;r&&(t.each(ps_ajax.shortcodes,function(t,a){r=r.replace(t,a)}),t("#"+ps_id).replaceWith(r)),e.redirect&&window.location.replace(redirect)}}else s.find(".passster-error").text(e.error),s.find(".passster-error").show().fadeOut(3500),t("#"+ps_id+" .passster-password").val("")}})}),t(".recaptcha-form-v2").length>0&&grecaptcha.ready(function(){grecaptcha.render("ps-recaptcha-v2",{sitekey:ps_ajax.recaptcha_key,callback:function(a){ps_id=t(".recaptcha-v2-submit").attr("data-psid"),form=t("#"+ps_id),protection=t(".recaptcha-v2-submit").attr("data-protection"),acf=t(".recaptcha-v2-submit").attr("data-acf"),area=t("#"+ps_id).find(".recaptcha-v2-submit").attr("data-area"),redirect=t("#"+ps_id).find(".recaptcha-v2-submit").attr("data-redirect"),t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,token:a,post_id:ps_ajax.post_id,type:"recaptcha",protection:protection,captcha_id:ps_id,acf:acf,area:area,redirect:redirect},success:function(a){if(!0===a.success){if("on"===ps_ajax.no_ajax)Cookies.set("passster","recaptcha",{expires:parseInt(ps_ajax.days),sameSite:"strict"}),window.location.reload();else{"on"===ps_ajax.use_cookie&&Cookies.set("passster","recaptcha",{expires:parseInt(ps_ajax.days),sameSite:"strict"}),form.find(".passster-error").hide();let e=a.content;e&&(t.each(ps_ajax.shortcodes,function(t,a){e=e.replace(t,a)}),t("#"+ps_id).replaceWith(e)),a.redirect&&window.location.replace(redirect)}}else form.find(".passster-error").text(a.error),form.find(".passster-error").show().fadeOut(3500)}})}})}),t(".recaptcha-form").on("submit",function(a){a.preventDefault(),ps_id=t(this).find(".passster-submit-recaptcha").attr("data-psid"),form=t("#"+ps_id),protection=t(this).find(".passster-submit-recaptcha").attr("data-protection"),acf=t(this).find(".passster-submit-recaptcha").attr("data-acf"),area=t(this).find(".passster-submit-recaptcha").attr("data-area"),redirect=t(this).find(".passster-submit-recaptcha").attr("data-redirect"),grecaptcha.ready(function(){grecaptcha.execute(ps_ajax.recaptcha_key,{action:"validate_input"}).then(function(a){form.prepend('<input type="hidden" name="token" value="'+a+'">'),form.prepend('<input type="hidden" name="action" value="validate_input">'),t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"validate_input",nonce:ps_ajax.nonce,token:a,post_id:ps_ajax.post_id,type:"recaptcha",protection:protection,captcha_id:ps_id,acf:acf,area:area,redirect:redirect},success:function(a){if(!0===a.success){if("on"===ps_ajax.no_ajax)Cookies.set("passster","recaptcha",{expires:parseInt(ps_ajax.days),sameSite:"strict"}),window.location.reload();else{"on"===ps_ajax.use_cookie&&Cookies.set("passster","recaptcha",{expires:parseInt(ps_ajax.days),sameSite:"strict"}),form.find(".passster-error").hide();let e=a.content;e&&(t.each(ps_ajax.shortcodes,function(t,a){e=e.replace(t,a)}),form.replaceWith(e)),a.redirect&&window.location.replace(redirect)}}else form.find(".passster-error").text(a.error),form.find(".passster-error").show().fadeOut(3500)}})})})}),t(document).on("click","#ps-logout",function(){t.ajax({type:"post",dataType:"json",url:ps_ajax.ajax_url,data:{action:"handle_logout",logout_nonce:ps_ajax.logout_nonce},success:function(t){!0===t.success&&(Cookies.set("passster","",{expires:0,sameSite:"strict"}),window.location.reload())}})})}); |