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