text: function notifySettingsSaved(){jQuery("#aj_notification").fadeIn("slow").html("Settings Saved <span class=\"aj_dismiss\"><a title=\"dismiss this notification\">x</a></span>").delay(500).fadeOut("slow")}function log_error(a){aj_error=a.error?a.error:JSON.stringify(a),jQuery("div.aj_loader").replaceWith("<h2 style='color:red'>Error: "+aj_error+"</h2>")}function aj_step(a){var b=jQuery("#aj_nonce").val(),c=jQuery("#aj_gtmetrix_username").val(),d=jQuery("#aj_gtmetrix_api_key").val(),e=jQuery("#aj_gtmetrix_server").val(),f={action:"aj_steps",sub_action:a,site_url:aj_localize_admin.siteurl,aj_gtmetrix_username:c,aj_gtmetrix_api_key:d,aj_gtmetrix_server:e,security:b};"aj_step_results"==a?jQuery.post(aj_localize_admin.ajaxurl,f,function(a){try{if(a=jQuery.parseJSON(a),!1!==a.status){var b=a.baseline_pagespeed,c=a.baseline_yslow,d=a.results.pagespeed_score,e=a.results.yslow_score,f=a.name,g=parseFloat(a.results.fully_loaded_time/1e3).toFixed(2),h=a.url;jQuery(".aj_gtmetrix_config").html(f),d>b?jQuery("#aj_gtmetrix_inde_pagespeed").html("an increase"):d<b?jQuery("#aj_gtmetrix_inde_pagespeed").html("a decrease"):jQuery("#aj_gtmetrix_inde_pagespeed").html("no change"),e>c?jQuery("#aj_gtmetrix_inde_yslow").html("an increase"):e<c?jQuery("#aj_gtmetrix_inde_yslow").html("a decrease"):jQuery("#aj_gtmetrix_inde_yslow").html("no change"),jQuery("#aj_gtmetrix_baseline_pagespeed").html(b+"%"),jQuery("#aj_gtmetrix_best_pagespeed").html(d+"%"),jQuery("#aj_gtmetrix_baseline_yslow").html(c+"%"),jQuery("#aj_gtmetrix_best_yslow").html(e+"%"),jQuery("#aj_gtmetrix_best_fullyloaded").html(g+"s"),jQuery("#aj_gtmetrix_best_url").attr("href",h).html(h),"aj_step2b"==a.id||"aj_step2c"==a.id?(jQuery("#aj_step4_jquery_excluded").hide(),jQuery("#aj_step4_jquery_not_excluded").show()):("aj_step2d"==a.id||"aj_step2e"==a.id)&&(jQuery("#aj_step4_jquery_excluded").show(),jQuery("#aj_step4_jquery_not_excluded").hide()),jQuery(".aj_gtmetrix_credits").html(a.credits),jQuery("#aj_step_results").show()}else log_error(a)}catch(a){log_error(a)}}):jQuery.post(aj_localize_admin.ajaxurl,f,function(b){try{if(b=jQuery.parseJSON(b),!1!==b.status){var e=b.results.report_url+"/screenshot.jpg",f=b.results.pagespeed_score,g=b.results.yslow_score,h=parseFloat(b.results.fully_loaded_time/1e3).toFixed(2),i=Math.floor(b.results.page_bytes/1024);1024<i?i=i/1024+"MB":i+="KB";var j=b.results.page_elements,k="<a href=\""+b.results.report_url+"\" target=\"_blank\">"+b.results.report_url+"</a>",l=k.replace("https://","https://"+c+":"+d+"@"),m=b.name,n=b.url,o="rgb("+Math.floor(255*(1-f/100))+","+Math.floor(255*(f/100))+",0 )",p="rgb("+Math.floor(255*(1-g/100))+","+Math.floor(255*(g/100))+",0 )";"aj_gtmetrix_test"==a&&(a="aj_latest"),jQuery("#"+a+"_please_wait").hide(),jQuery("."+a+"_screenshot").attr("src",e),jQuery("."+a+"_pagespeed").html(f+"%").css({color:o}),jQuery("."+a+"_yslow").html(g+"%").css({color:p}),jQuery("."+a+"_flt").html(h+"s"),jQuery("."+a+"_tps").html(i),jQuery("."+a+"_requests").html(j),jQuery("."+a+"_report").html(l),jQuery("#"+a+"_gtmetrix_results").show(),jQuery("."+a+"_gtmetrix").html(m),jQuery("."+a+"_url").attr("href",n).html(n),jQuery(".aj_gtmetrix_credits").html(b.credits),"aj_step2"==a?(notifySettingsSaved(),jQuery("#aj_step2b").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2b").offset().top},1e3),aj_step("aj_step2b")):"aj_step2b"==a?(jQuery("#aj_step2c").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2c").offset().top},1e3),aj_step("aj_step2c")):"aj_step2c"==a?(jQuery("#aj_step2d").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2d").offset().top},1e3),aj_step("aj_step2d")):"aj_step2d"==a?(jQuery("#aj_step2e").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step2e").offset().top},1e3),aj_step("aj_step2e")):"aj_step2e"==a?(jQuery("#aj_step_results").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step_results").offset().top},1e3),aj_step("aj_step_results")):"aj_latest"==a&&(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 log_error(b)}catch(a){log_error(a)}})}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(a){a.preventDefault();var b=jQuery("#aj_nonce").val(),c=jQuery(this).attr("data-id"),d=c.replace("_apply",""),e=1;if("aj_goto_settings"==c){var f=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=f}else if("aj_apply_settings"==c||"aj_step2b_apply"==c||"aj_step2c_apply"==c||"aj_step2d_apply"==c||"aj_step2e_apply"==c){"aj_apply_settings"==c?(d="",notifySettingsSaved()):d=c.replace("_apply","");var g={action:"aj_steps",sub_action:"aj_apply_settings",settings:d,site_url:aj_localize_admin.siteurl,security:b};jQuery.post(aj_localize_admin.ajaxurl,g,function(a){try{if(a=jQuery.parseJSON(a),!1===a.status)console.log(a);else if(jQuery("#aj_step4").length)jQuery("#aj_step5").show(),jQuery("html, body").animate({scrollTop:jQuery("#aj_step5").offset().top},1e3),""!=d&&notifySettingsSaved();else if(""!=d){notifySettingsSaved();var b=aj_localize_admin.ajadminurl+"&tab=settings";window.location.href=b}}catch(a){console.log(a)}})}else if("aj_save_settings"==c){e=jQuery("#aj_enabled").is(":checked")?1:0,aj_enabled_logged=jQuery("#aj_enabled_logged").is(":checked")?1:0,aj_enabled_shop=jQuery("#aj_enabled_shop").is(":checked")?1:0;var h=jQuery("input[type=radio][name=aj_method]:checked").val(),i=jQuery("input[type=radio][name=aj_jquery]:checked").val(),j=jQuery("#aj_async").val(),k=jQuery("#aj_defer").val(),l=jQuery("#aj_exclusions").val(),m=jQuery("#aj_plugin_exclusions").chosen().val(),n=jQuery("#aj_theme_exclusions").chosen().val(),o=1,p=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val();"function"==typeof jQuery(".aj_chosen").chosen?(m=jQuery("#aj_plugin_exclusions").chosen().val(),n=jQuery("#aj_theme_exclusions").chosen().val()):(m=jQuery("#aj_plugin_exclusions").val(),n=jQuery("#aj_theme_exclusions").val()),jQuery("#aj_autoptimize_enabled").is(":visible")?jQuery("#aj_autoptimize_enabled").is(":checked")?(o=1,p=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val()):(o=0,p=jQuery("input[type=radio][name=aj_autoptimize_method]:checked").val()):(o=0,p="async");var q={action:"aj_steps",sub_action:"aj_save_settings",aj_enabled:e,aj_enabled_logged:aj_enabled_logged,aj_enabled_shop:aj_enabled_shop,aj_method:h,aj_jquery:i,aj_async:j,aj_defer:k,aj_exclusions:l,aj_plugin_exclusions:m,aj_theme_exclusions:n,aj_autoptimize_enabled:o,aj_autoptimize_method:p,security:b};jQuery.post(aj_localize_admin.ajaxurl,q,function(a){try{a=jQuery.parseJSON(a),!1===a.status?console.log(a):notifySettingsSaved()}catch(a){console.log(a)}})}else{var r=jQuery("#aj_gtmetrix_username").val(),s=jQuery("#aj_gtmetrix_api_key").val(),t=jQuery("#aj_gtmetrix_server").val(),u=!1;if(""==r&&(jQuery("#aj_gtmetrix_username").addClass("aj_field_error"),u=!0),""==s&&(jQuery("#aj_gtmetrix_api_key").addClass("aj_field_error"),u=!0),!1===u)"aj_gtmetrix_test"==c?jQuery("#aj_latest_please_wait").show():(jQuery(this).hide(),jQuery("#"+c).show()),aj_step(c);else return!1}}),jQuery(document).on("change","input[type=radio][name=aj_step4_check]",function(){var a=jQuery("#aj_nonce").val(),b=jQuery(this).val();"y"==b?(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")})});