HamroKhanpin/hamrokhaanpaan/wp-content/__plugins/wp-optimize/js/cache-3-2-3.min.js
2024-04-29 13:12:44 +05:45

1 line
7.3 KiB
JavaScript

var WP_Optimize_Cache=function(){function e(){var e={};return r(".cache-settings").each(function(){var a=r(this),o=a.attr("name");a.is('input[type="checkbox"]')?e[o]=a.is(":checked")?1:0:a.is("textarea")?e[o]=a.val().split("\n"):e[o]=a.val()}),r(".cache-settings-array").each(function(){var a=r(this),o=a.attr("name");e.hasOwnProperty(o)||(e[o]=[]),a.is('input[type="checkbox"]')?"value"==a.data("saveas")?a.is(":checked")&&e[o].push(a.val()):e[o].push(a.is(":checked")?1:0):a.is("textarea")?e[o].push(a.val().split("\n")):e[o].push(a.val())}),e}function a(){d||(d=setInterval(function(){o()},5e3))}function o(){s("get_cache_preload_status",null,function(e){e.done?(_.val(wpoptimize.run_now),_.data("running",!1),clearInterval(d),d=null):(_.val(wpoptimize.cancel),_.data("running",!0)),l.text(e.message),t(e)})}function t(e){r("#wpo_current_cache_size_information").text(wpoptimize.current_cache_size+" "+e.size),r("#wpo_current_cache_file_count").text(wpoptimize.number_of_files+" "+e.file_count)}var r=jQuery,s=wp_optimize.send_command,n=r("#wp_optimize_browser_cache_enable"),i=r("#wp-optimize-purge-cache"),p=r("#enable_page_caching"),c=r("#page_cache_length_value");i.on("click",function(){var e=r(this),o=e.next(),n=o.next();o.show(),s("purge_page_cache",{},function(e){o.hide(),n.show(),setTimeout(function(){n.fadeOut("slow",function(){n.hide()}),a()},5e3),t(e)})}),r("body").on("wpo_purge_cache",function(){i.trigger("click")}),n.closest("form").on("submit",function(e){return e.preventDefault(),n.trigger("click"),!1}),c.on("change",function(){var e=parseInt(c.val(),10);r('#preload_schedule_type option[value="wpo_use_cache_lifespan"]').prop("disabled",isNaN(e)||e<=0)}),r("#wp_optimize_gzip_compression_enable").on("click",function(){var e=r(this),a=e.next();a.show(),s("enable_gzip_compression",{enable:e.data("enable")},function(o){var t=r("#wpo_gzip_compression_status");o?(o.enabled?(e.text(wpoptimize.disable),e.data("enable","0"),t.removeClass("wpo-disabled").addClass("wpo-enabled")):(e.text(wpoptimize.enable),e.data("enable","1"),t.addClass("wpo-disabled").removeClass("wpo-enabled")),o.message?r("#wpo_gzip_compression_error_message").text(o.message).show():r("#wpo_gzip_compression_error_message").hide(),o.output?r("#wpo_gzip_compression_output").html(o.output).show():r("#wpo_gzip_compression_output").hide()):alert(wpoptimize.error_unexpected_response),a.hide()}).fail(function(){alert(wpoptimize.error_unexpected_response),a.hide()})}),r(".wpo-refresh-gzip-status").on("click",function(e){e.preventDefault(),$link=r(this),$link.addClass("loading"),s("get_gzip_compression_status",null,function(e){$link.removeClass("loading");var a=r("#wpo_gzip_compression_status");e.hasOwnProperty("status")?e.status?a.removeClass("wpo-disabled").addClass("wpo-enabled"):a.addClass("wpo-disabled").removeClass("wpo-enabled"):e.hasOwnProperty("error")&&(alert(e.error),console.log("Gzip status error code: "+e.code),console.log("Gzip status error message: "+e.message))})}),n.on("click",function(){var e=r("#wpo_browser_cache_expire_days"),a=r("#wpo_browser_cache_expire_hours"),o=parseInt(e.val(),10),t=parseInt(a.val(),10),n=r(this),i=n.next();return isNaN(o)&&(o=0),isNaN(t)&&(t=0),o<0||t<0?(r("#wpo_browser_cache_error_message").text(wpoptimize.please_use_positive_integers).show(),!1):t>23?(r("#wpo_browser_cache_error_message").text(wpoptimize.please_use_valid_values).show(),!1):(r("#wpo_browser_cache_error_message").hide(),e.val(o),a.val(t),i.show(),void s("enable_browser_cache",{browser_cache_expire_days:o,browser_cache_expire_hours:t},function(e){var a=r("#wpo_browser_cache_status");e?(e.enabled?(n.text(wpoptimize.update),a.removeClass("wpo-disabled").addClass("wpo-enabled")):(n.text(wpoptimize.enable),a.addClass("wpo-disabled").removeClass("wpo-enabled")),e.message?r("#wpo_browser_cache_message").text(e.message).show():r("#wpo_browser_cache_message").hide(),e.error_message?r("#wpo_browser_cache_error_message").text(e.error_message).show():r("#wpo_browser_cache_error_message").hide(),e.output?r("#wpo_browser_cache_output").html(e.output).show():r("#wpo_browser_cache_output").hide()):alert(wpoptimize.error_unexpected_response),i.hide()}).fail(function(){alert(wpoptimize.error_unexpected_response),i.hide()}))}),r("#wp-optimize-save-cache-settings, #wp-optimize-save-cache-advanced-rules, #wp-optimize-save-cache-preload-settings").on("click",function(){var a=r(this),o=a.next(),t=o.next();o.show(),r.blockUI(),s("save_cache_settings",{"cache-settings":e()},function(e){if(e.hasOwnProperty("js_trigger")&&r(document).trigger(e.js_trigger,e),e.hasOwnProperty("error")?(console.log(e.error),r(".wpo-error__enabling-cache").removeClass("wpo_hidden").find("p").text(e.error.message)):r(".wpo-error__enabling-cache").addClass("wpo_hidden").find("p").text(""),e.hasOwnProperty("warnings")){console.log(e.warnings),r(".wpo-warnings__enabling-cache").removeClass("wpo_hidden").find("p").text(e.warnings_label);var a=r(".wpo-warnings__enabling-cache").find("ul").html("");r.each(e.warnings,function(e,o){a.append("<li>"+o+"</li>")})}else r(".wpo-warnings__enabling-cache").addClass("wpo_hidden").find("p").text("");if(e.hasOwnProperty("advanced_cache_file_writing_error")?r("#wpo_advanced_cache_output").text(e.advanced_cache_file_content).show():r("#wpo_advanced_cache_output").hide(),p.prop("checked",e.enabled),p.is(":checked")?(r(".purge-cache").show(),r("#wp_optimize_run_cache_preload").removeProp("disabled"),r("#wp_optimize_run_minify_preload").prop("disabled",!0),r("#minify-preload").show()):(r(".purge-cache").hide(),r("#wp_optimize_run_cache_preload").prop("disabled",!0),r("#wp_optimize_run_minify_preload").prop("disabled",!1),r("#minify-preload").hide()),e.result)t.show(),setTimeout(function(){t.fadeOut("slow",function(){t.hide()})},5e3);else{var o=r(".wp-optimize-nav-tab-contents .notice:visible").closest(".wp-optimize-nav-tab-contents").attr("id"),s="cache";if(/wpo_cache-(.+)-contents/.test(o)){var n=/wpo_cache-(.+)-contents/.exec(o);s=n[1]}r('.wpo-page.active .nav-tab-wrapper a[data-tab="'+s+'"]').trigger("click");var i=r(".wpo-page.active").offset();window.scroll(0,i.top-20)}}).always(function(){r.unblockUI(),o.hide()})}),p.on("change",function(){r(".wpo-error__enabling-cache").addClass("wpo_hidden"),r(".wpo-warnings__enabling-cache").addClass("wpo_hidden"),r("#wpo_advanced_cache_output").hide(),r("#wp-optimize-save-cache-settings").trigger("click")});var _=r("#wp_optimize_run_cache_preload"),l=r("#wp_optimize_preload_cache_status"),d=null,u=r("#enable_schedule_preload"),w=r("#preload_schedule_type");u.on("change",function(){u.prop("checked")?w.prop("disabled",!1):w.prop("disabled",!0)}),u.trigger("change"),_.on("click",function(){var e=r(this),o=e.data("running"),t=l.text();e.prop("disabled",!0),o?(e.data("running",!1),clearInterval(d),d=null,s("cancel_cache_preload",null,function(e){e&&e.hasOwnProperty("message")&&l.text(e.message)}).always(function(){e.val(wpoptimize.run_now),e.prop("disabled",!1)})):(l.text(wpoptimize.starting_preload),e.data("running",!0),s("run_cache_preload",null,null,!0,{timeout:3e3}).always(function(o){try{var r=wpo_parse_json(o)}catch(s){}if(r&&r.error){var n=wpoptimize.error_unexpected_response;return"function"!=typeof r.error?n=r.error:r.status&&(n=r.status+": "+r.statusText),alert(n),l.text(t),e.prop("disabled",!1),void e.data("running",!1)}l.text(wpoptimize.loading_urls),e.val(wpoptimize.cancel),e.prop("disabled",!1),a()}))}),_.data("running")&&a()};