function aj_step(e){var a=jQuery("#aj_nonce").val(),t=jQuery("#aj_gtmetrix_username").val(),s=jQuery("#aj_gtmetrix_api_key").val(),r=jQuery("#aj_gtmetrix_server").val();if("aj_step_results"==e){var _={action:"aj_steps",sub_action:e,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:t,aj_gtmetrix_api_key:s,aj_gtmetrix_server:r,security:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{if(!1!==(e=jQuery.parseJSON(e)).status){var a=e.baseline_pagespeed,t=e.baseline_yslow,s=e.results.pagespeed_score,r=e.results.yslow_score,_=e.name,i=parseFloat(e.results.fully_loaded_time/1e3).toFixed(2),j=e.url;jQuery(".aj_gtmetrix_config").html(_),s>a?jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase"):st?jQuery("#aj_gtmetrix_inde_yslow").html("an increase"):r1024?l=l/1024+"MB":l+="KB";var o=a.results.page_elements,u=(''+a.results.report_url+"").replace("https://","https://"+t+":"+s+"@"),n=a.name,y=a.url,p=255*(1-_/100),c=255*(1-i/100),d=_/100*255,m=i/100*255,Q="rgb("+Math.floor(p)+","+Math.floor(d)+",0 )",h="rgb("+Math.floor(c)+","+Math.floor(m)+",0 )";"aj_gtmetrix_test"==e&&(e="aj_latest"),jQuery("#"+e+"_please_wait").hide(),jQuery("."+e+"_screenshot").attr("src",r),jQuery("."+e+"_pagespeed").html(_+"%").css({color:Q}),jQuery("."+e+"_yslow").html(i+"%").css({color:h}),jQuery("."+e+"_flt").html(j+"s"),jQuery("."+e+"_tps").html(l),jQuery("."+e+"_requests").html(o),jQuery("."+e+"_report").html(u),jQuery("#"+e+"_gtmetrix_results").show(),jQuery("."+e+"_gtmetrix").html(n),jQuery("."+e+"_url").attr("href",y).html(y),jQuery(".aj_gtmetrix_credits").html(a.credits),"aj_step2"==e?(jQuery("#aj_notification").fadeIn("slow").html('Settings Saved x'),jQuery("#aj_step2b").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2b").offset().top},1e3),aj_step("aj_step2b")):"aj_step2b"==e?(jQuery("#aj_step2c").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2c").offset().top},1e3),aj_step("aj_step2c")):"aj_step2c"==e?(jQuery("#aj_step2d").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2d").offset().top},1e3),aj_step("aj_step2d")):"aj_step2d"==e?(jQuery("#aj_step2e").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2e").offset().top},1e3),aj_step("aj_step2e")):"aj_step2e"==e?(jQuery("#aj_step_results").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step_results").offset().top},1e3),aj_step("aj_step_results")):"aj_latest"==e&&(jQuery("#aj_notification").fadeIn("slow").html('Settings Saved x'),jQuery("#aj_latest_gtmetrix_results").show(),jQuery("#aj_latest_please_wait").hide(),jQuery("html, body").animate({scrollTop:jQuery("#aj_latest_please_wait").offset().top},1e3))}else console.log(a)}catch(e){console.log(e)}})}}jQuery(document).ready(function(){"function"==typeof jQuery(".aj_chosen").chosen&&jQuery(".aj_chosen").chosen(),jQuery(document).on("click",".aj-upgrade-notice .notice-dismiss",function(){var e=jQuery("#aj_nonce").val(),a=jQuery(".aj-upgrade-notice").attr("data-id");jQuery.ajax({url:aj.ajaxurl,data:{action:"async_javascript_dismiss_upgrade",notice_id:a,security:e}})}),jQuery(document).on("click",".aj_steps_button",function(e){e.preventDefault();var a=jQuery("#aj_nonce").val(),t=jQuery(this).attr("data-id");if("aj_goto_settings"==t){var s=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=s}else if("aj_apply_settings"==t||"aj_step2b_apply"==t||"aj_step2c_apply"==t||"aj_step2d_apply"==t||"aj_step2e_apply"==t){if("aj_apply_settings"!=t)var r=t.replace("_apply","");else{r="";jQuery("#aj_notification").fadeIn("slow").html('Settings Saved x')}var _={action:"aj_steps",sub_action:"aj_apply_settings",settings:r,site_url:aj_localize_admin.siteurl,security:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{if(!1!==(e=jQuery.parseJSON(e)).status){if(jQuery("#aj_step4").length)jQuery("#aj_step5").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step5").offset().top},1e3),""!=r&&jQuery("#aj_notification").fadeIn("slow").html('Settings Saved x');else if(""!=r){jQuery("#aj_notification").fadeIn("slow").html('Settings Saved x');var a=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=a}}else console.log(e)}catch(e){console.log(e)}})}else if("aj_save_settings"==t){if(jQuery("#aj_enabled").is(":checked"))var i=1;else i=0;var j=jQuery("input[type=radio][name=aj_method]:checked").val(),l=jQuery("input[type=radio][name=aj_jquery]:checked").val(),o=jQuery("#aj_async").val(),u=jQuery("#aj_defer").val(),n=jQuery("#aj_exclusions").val();if("function"==typeof jQuery(".aj_chosen").chosen)var y=jQuery("#aj_plugin_exclusions").chosen().val(),p=jQuery("#aj_theme_exclusions").chosen().val();else y=jQuery("#aj_plugin_exclusions").val(),p=jQuery("#aj_theme_exclusions").val();if(jQuery("#aj_autoptimize_enabled").is(":visible"))if(jQuery("#aj_autoptimize_enabled").is(":checked"))var c=1,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else c=0,d=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();else c=0,d="async";_={action:"aj_steps",sub_action:"aj_save_settings",aj_enabled:i,aj_method:j,aj_jquery:l,aj_async:o,aj_defer:u,aj_exclusions:n,aj_plugin_exclusions:y,aj_theme_exclusions:p,aj_autoptimize_enabled:c,aj_autoptimize_method:d,security:a};jQuery.post(aj_localize_admin.ajaxurl,_,function(e){try{!1!==(e=jQuery.parseJSON(e)).status?jQuery("#aj_notification").fadeIn("slow").html('Settings Saved x'):console.log(e)}catch(e){console.log(e)}})}else{var m=jQuery("#aj_gtmetrix_username").val(),Q=jQuery("#aj_gtmetrix_api_key").val(),h=(jQuery("#aj_gtmetrix_server").val(),!1);if(""==m&&(jQuery("#aj_gtmetrix_username").addClass("aj_field_error"),h=!0),""==Q&&(jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error"),h=!0),!1!==h)return!1;"aj_gtmetrix_test"!=t?(jQuery(this).hide(),jQuery("#"+t).show()):jQuery("#aj_latest_please_wait").show(),aj_step(t)}}),jQuery(document).on("change","input[type=radio][name=aj_step4_check]",function(){jQuery("#aj_nonce").val();"y"==jQuery(this).val()?(jQuery("#aj_step4_y").show(),jQuery("#aj_step4_n").hide()):(jQuery("#aj_step4_n").show(),jQuery("#aj_step4_y").hide())}),jQuery(document).on("click",".aj_dismiss",function(){jQuery("#aj_nonce").val();jQuery("#aj_notification").fadeOut("slow")})});