| 1 |
window.Patchstack=window.Patchstack||{},function(t,a,c,e){var n={},i=null,o=!1,s=0;e.init=function(){e.cache(),e.bindEvents()},e.cache=function(){n.window=c(t),n.body=c(a.body)},e.poller=function(){i=setInterval(()=>{o||0!=s||(e.autoActivate(),s=5),s--},1e3)},e.autoActivate=function(){o=!0;var a={action:"patchstack_activate_auto",PatchstackNonce:PatchstackVars.nonce};c.post(PatchstackVars.ajaxurl,a,function(a){var e={action:"patchstack_activation_status",PatchstackNonce:PatchstackVars.nonce};c.post(PatchstackVars.ajaxurl,e,function(a){a.activated&&(t.location=t.location.href.replace("&ps_autoa=1","")+"&resync=1"),o=!1})})},e.bindEvents=function(){c("input#patchstack-activate").on("click",function(a){a.preventDefault();var e={action:"patchstack_activate_license",key:""==c(".patchstack-auto-activate").attr("style")?c("#patchstack_api_key2").val():c("#patchstack_api_key").val(),PatchstackNonce:PatchstackVars.nonce};if(0==c.trim(e.key).length)return alert("Please enter the API key."),!1;c(".patchstack-resync").hide(),c("#patchstack-activate").hide(),c(".patchstack-loading").show(),c(".is-polling-section").hide(),o=!0,c.post(PatchstackVars.ajaxurl,e,function(a){o=!1,s=5,"error"==a.result?(c("#patchstack-activate, .is-polling-section").show(),c(".patchstack-loading").hide(),a.error_message?alert(a.error_message):alert(PatchstackVars.error_message)):t.location=t.location.href+"&resync=1"})})},c(e.init)}(window,document,jQuery,window.Patchstack); |