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

1 line
30 KiB
JavaScript

jQuery(function(t){WP_Optimize=WP_Optimize(),"undefined"!=typeof WP_Optimize_Cache&&(WP_Optimize_Cache=WP_Optimize_Cache()),"undefined"!=typeof wp_optimize.minify&&(WP_Optimize_Minify=wp_optimize.minify.init())}),function(t){var e=[];t.fn.form_errors=function(){return this},t.fn.form_errors.add=function(t,i){!1===this.has_error(t)&&e.push({type:t,message:i})},t.fn.form_errors.remove=function(t){var i=this.has_error(t);i!==!1&&e.splice(i,1)},t.fn.form_errors.has_error=function(i){var o=!1;return t.each(e,function(t,e){console.log(t,e),i==e.type&&(o=t)}.bind(this)),o},t.fn.form_errors.has_errors=function(){return e.length>0}}(jQuery);var WP_Optimize=function(){function t(){if(T("#enable-schedule").length){var t=T("#enable-schedule").is(":checked");t?T("#wp-optimize-auto-options").css("opacity","1"):T("#wp-optimize-auto-options").css("opacity","0.5")}}function e(t,e,i){e="undefined"==typeof e?"#wp-optimize-wrap":e,i="undefined"==typeof i?15:i,T(t).hide().prependTo(e).slideDown("fast").delay(1e3*i).slideUp("fast",function(){T(this).remove()})}function i(t,i){var o={type:t,enable:i?1:0};T("#"+t+"_spinner").show(),A("enable_or_disable_feature",o,function(i){if(T("#"+t+"_spinner").hide(),i&&i.hasOwnProperty("output"))for(var o=0,n=i.output.length;o<n;o++){var a='<div class="updated"><p>'+i.output[o]+"</p></div>";e(a,"#"+t+"_notice")}i&&i.hasOwnProperty("messages")&&T("#"+t+"_actionmsg").html(i.messages.join(" - "))})}function o(t){t?T("#wp-optimize-wrap").addClass("wpo-mobile-menu-opened"):T("#wp-optimize-wrap").removeClass("wpo-mobile-menu-opened")}function n(){if(!Q){var t=T(".wpo-page[data-whichpage=WP-Optimize]"),e=t.find(".wpo_shade");e.removeClass("hidden"),A("get_database_tabs",{},function(e){Q=!0,e.hasOwnProperty("optimizations")&&t.find(".wp-optimize-optimizations-table-placeholder").replaceWith(e.optimizations),b(e),T(document).trigger("wpo_database_tabs_loaded")}).always(function(){e.addClass("hidden")})}}function a(t){var e="",t="undefined"==typeof t?"string":t,i=T("#wp-optimize-database-settings form input[name!='action'], #wp-optimize-database-settings form select, #wp-optimize-database-settings form textarea, #wp-optimize-general-settings form input[name!='action'], #wp-optimize-general-settings form textarea, #wp-optimize-general-settings form select, #wp-optimize-nav-tab-contents-optimize input[type='checkbox'], .wp-optimize-nav-tab-contents input[name^='enable-auto-backup-']");return"object"==t?e=i.serializeJSON({useIntKeysAsArrayIndex:!0}):(e=i.serialize(),T.each(T('#wp-optimize-database-settings form input[type=checkbox], #wp-optimize-general-settings form input[type=checkbox], .wp-optimize-nav-tab-contents input[name^="enable-auto-backup-"]').filter(function(t){return 0==T(this).prop("checked")}),function(t,i){var o="0";e+="&"+T(i).attr("name")+"="+o})),e}function s(){A("optimizations_done",{},function(){}),S=!1}function p(){if(!I.get_lock())return void(q>0&&console.log("WP-Optimize: process_queue(): queue is currently locked - exiting"));q>0&&console.log("WP-Optimize: process_queue(): got queue lock");var t=I.peek(),e=0,i=T("#wpo_all_sites"),o=i.data("active_site");if("object"==typeof t){if(data=t,t=t.optimization_id,e=data.blog_id,"undefined"==typeof o)i.data("active_site",e),r(e,0);else if(o!=e){var n=o;i.data("active_site",e),r(e,n)}}else data={};if("undefined"==typeof t){q>0&&console.log("WP-Optimize: process_queue(): queue is apparently empty - exiting"),I.unlock();var n=i.data("active_site");return r(0,n),void s()}if(q>0&&console.log("WP-Optimize: process_queue(): processing item: "+t),I.dequeue(),T(document).trigger(["do_optimization_",t,"_start"].join("")),"optimizetables"===t){T("#optimization_info_"+t).html(wpoptimize.optimizing_table+" "+data.optimization_table);var a=parseInt(wpoptimize.table_optimization_timeout)?parseInt(wpoptimize.table_optimization_timeout):12e4,l={timeout:a,error:function(e,o){if(S=!0,"timeout"===o?console.warn("The request to optimize the table "+data.optimization_table+" timed out after "+a/1e3+" seconds"):console.warn('There was an error when running the optimization "'+t+'".',o,e,data),I.is_empty()){var n=i.data("active_site");r(n,0),T("#optimization_spinner_"+t).hide(),T("#optimization_checkbox_"+t).show(),T(".optimization_button_"+t).prop("disabled",!1),T("#optimization_info_"+t).html(wpoptimize.optimization_complete+" "+wpoptimize.with_warnings)}setTimeout(function(){I.unlock(),p()},500)}}}else var l={};A("do_optimization",{optimization_id:t,data:data},function(e){if(T("#optimization_spinner_"+t).hide(),T("#optimization_checkbox_"+t).show(),T(".optimization_button_"+t).prop("disabled",!1),T(document).trigger(["do_optimization_",t,"_done"].join(""),e),e){for(var i="",o=0,n=e.errors.length;o<n;o++)i+='<span class="error">'+e.errors[o]+"</span><br>";for(var o=0,n=e.messages.length;o<n;o++)i+=e.errors[o]+"<br>";for(var o=0,n=e.result.output.length;o<n;o++)i+=e.result.output[o]+"<br>";if(T("#optimization_info_"+t).html(i),e.hasOwnProperty("status_box_contents")&&T("#wp_optimize_status_box").css("opacity","1").find(".inside").html(e.status_box_contents),e.hasOwnProperty("table_list")&&T("#wpoptimize_table_list tbody").html(T(e.table_list).find("tbody").html()),e.hasOwnProperty("total_size")&&T("#optimize_current_db_size").html(e.total_size),"optimizetables"==t&&data.optimization_table&&(I.is_empty()?(T("#optimization_spinner_"+t).hide(),T("#optimization_checkbox_"+t).show(),T(".optimization_button_"+t).prop("disabled",!1),T("#optimization_info_"+t).html(wpoptimize.optimization_complete+(S?" "+wpoptimize.with_warnings:""))):(T("#optimization_checkbox_"+t).hide(),T("#optimization_spinner_"+t).show(),T(".optimization_button_"+t).prop("disabled",!0))),e.result.meta&&e.result.meta.hasOwnProperty("awaiting_mod")){var a=e.result.meta.awaiting_mod;a>0?T("#adminmenu .awaiting-mod .pending-count").remove(a):T("#adminmenu .awaiting-mod").remove()}}setTimeout(function(){I.unlock(),p()},500)},!0,l)}function r(t,e){0!=e&&(T("#site-"+e).show(),T("#optimization_spinner_site-"+e).hide()),T("#site-"+t).hide(),T("#optimization_spinner_site-"+t).show()}function l(t){var e=T("#wp-optimize-nav-tab-contents-optimize .wp-optimize-settings-"+t);e||console.log("do_optimization: row corresponding to this optimization ("+t+") not found");var i={},o=0;if(T('input[type="checkbox"]',T("#optimization_info_"+t)).each(function(){var t=T(this);t.is(":checked")&&(i[t.attr("name")]=t.val(),o++)}),1!=T(".optimization_button_"+t).prop("disabled")){var n=!1;if("optimizetables"==t){var a=T("#wpoptimize_table_list #the-list tr"),s=T("#wpo_sitelist_moreoptions").length>0&&T("#wpo_sitelist_moreoptions").is(":visible"),r=[];s&&(r=T('#wpo_sitelist_moreoptions input[type="checkbox"]:checked').map(function(){return parseInt(T(this).val())}).get()),n=!0,T(a).each(function(e){var i=(T(this).find("td"),T(this).data("type")),o=T(this).data("tablename"),a=T(this).data("optimizable"),p=T(this).data("blog_id")?parseInt(T(this).data("blog_id")):1,l=!0;if(s&&-1==r.indexOf(p)&&(l=!1),""!=o&&l&&(1==parseInt(a)||F)){var c={optimization_id:t,blog_id:p,optimization_table:o,optimization_table_type:i,optimization_force:F};I.enqueue(c),n=!1}})}else if(o>0){data={optimization_id:t};for(var l in i)i.hasOwnProperty(l)&&(data[l]=i[l]);I.enqueue(data)}else I.enqueue(t);n||(T("#optimization_checkbox_"+t).hide(),T("#optimization_spinner_"+t).show(),T(".optimization_button_"+t).prop("disabled",!0),T("#optimization_info_"+t).html("..."),p())}}function c(t){T("#wpo_settings_sites_list").length?A("save_site_settings",{"wpo-sites":_()},function(){t&&t()}):t&&t()}function _(){var t=[];return T('#wpo_settings_sites_list input[type="checkbox"]').each(function(){var e=T(this);e.is(":checked")&&t.push(e.attr("value"))}),t}function d(){var t=!1;T("#enable-auto-backup").is(":checked")&&(t=!0),m(),1==t?u(w):w()}function u(t,e){"undefined"==typeof e&&(e="");var i=e?0:1;"function"==typeof updraft_backupnow_inpage_go?updraft_backupnow_inpage_go(function(){T("#updraft-backupnow-inpage-modal").dialog("close"),t&&t()},e,"autobackup",0,i,0,wpoptimize.automatic_backup_before_optimizations):t&&t()}function m(){var t=a("object");t.auto_backup=T("#enable-auto-backup").is(":checked"),A("save_auto_backup_option",t)}function f(t,e,i,o){t.on("click",function(){return e.hasClass("wpo_always_visible")||e.toggleClass("wpo_hidden"),!1}),g(i,o)}function g(t,e){t.on("change",function(){t.is(":checked")?e.prop("checked",!0):e.prop("checked",!1),h(t,e)}),e.on("change",function(){h(t,e)}),h(t,e)}function h(t,e){var i=0,o=0;if(e.each(function(){T(this).is(":checked")&&o++,i++}),t.next().is("label")&&t.next().data("label")){var n=t.next(),a=n.data("label");i==o?n.text(a):n.text(a.replace("all",[o," of ",i].join("")))}i==o?t.prop("checked",!0):t.prop("checked",!1)}function w(){$optimizations=T("#optimizations_list .optimization_checkbox:checked"),$optimizations.sort(function(t,e){return t=T(t).closest(".wp-optimize-settings").data("optimization_run_sort_order"),e=T(e).closest(".wp-optimize-settings").data("optimization_run_sort_order"),t>e?1:t<e?-1:0});var t={};$optimizations.each(function(e){var i=T(this).closest(".wp-optimize-settings").data("optimization_id");return i?(t[i]={active:1},void l(i)):void console.log("Optimization ID corresponding to pressed button not found")}),A("save_manual_run_optimization_options",t)}function b(t){if(t.hasOwnProperty("table_list")){var e=!0,i=function(t){T("#wpoptimize_table_list tbody").css("opacity","1")};T("#wpoptimize_table_list tbody").remove(),T("#wpoptimize_table_list thead").after(t.table_list),T("#wpoptimize_table_list").trigger("updateAll",[e,i])}t.hasOwnProperty("total_size")&&T("#optimize_current_db_size").html(t.total_size),t.hasOwnProperty("show_innodb_force_optimize")&&T(".innodb_force_optimize--container").toggleClass("hidden",!t.show_innodb_force_optimize),D(),y($)}function z(t){var e=t.next(),i=e.next(),o=t.data("table"),n=t.data("type"),a={optimization_id:"optimizetables",optimization_table:o,optimization_table_type:n};t.hide(),$&&(a.optimization_force=!0),e.removeClass("visibility-hidden"),A("do_optimization",{optimization_id:"optimizetables",data:a},function(o){if(o.result.meta.error)t.closest("tr").html('<td colspan="8" class="no-table"><p>'+o.result.meta.message+"</p></td>"),setTimeout(function(){T("#wp_optimize_table_list_refresh").trigger("click")},2e3);else if(o.result.meta.tableinfo){var n=t.closest("tr"),a=o.result.meta,s=a.tableinfo;v(n,s),T("#wpoptimize_table_list > tbody:last th:eq(6)").html(['<span style="color:',a.overhead>0?"#0000FF":"#004600",'">',a.overhead_formatted,"</span>"].join(""))}t.prop("disabled",!1),e.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden").delay(2500).fadeOut("fast",function(){t.show()})})}function v(t,e){T("td:eq(2)",t).text(e.rows),T("td:eq(3)",t).text(e.data_size),T("td:eq(4)",t).text(e.index_size),T("td:eq(5)",t).text(e.type),e.is_optimizable?T("td:eq(6)",t).html(['<span style="color:',e.overhead>0?"#0000FF":"#004600",'">',e.overhead,"</span>"].join("")):T("td:eq(6)",t).html('<span color="#0000FF">-</span>')}function y(t){T(".run-single-table-optimization").each(function(){var e=T(this);e.data("disabled")&&(t?e.prop("disabled",!1):e.prop("disabled",!0))})}function k(t){var e,i,o;if(t)for(e in t)t.hasOwnProperty(e)&&(i=["#wp-optimize-settings-",t[e].dom_id].join(""),o=t[e].info?t[e].info.join("<br>"):"",T(i+" .wp-optimize-settings-optimization-info").html(o))}function x(){var t=["",_().join("_")].join("");X.hasOwnProperty(t)?k(X[t]):A("get_optimizations_info",{"wpo-sites":_()},function(e){e&&(X[t]=e,k(e))})}function O(t){var e=T("#wpo_import_spinner"),i=T("#wpo_import_success_message"),o=T("#wpo_import_error_message");e.show(),A("import_settings",{settings:t},function(t){e.hide(),t&&t.errors&&t.errors.length?(o.text(t.errors.join("<br>")),o.slideDown()):t&&t.messages&&t.messages.length&&(i.text(t.messages.join("<br>")),i.slideDown(),setTimeout(function(){window.location.reload()},500)),T("#wpo_import_settings_btn").prop("disabled",!1)})}function C(t,e){var i=document.body.appendChild(document.createElement("a")),o=new Date,n=o.getFullYear(),a=o.getMonth()<10?["0",o.getMonth()].join(""):o.getMonth(),s=o.getDay()<10?["0",o.getDay()].join(""):o.getDay();e=e?e:["wpo-settings-",n,"-",a,"-",s,".json"].join(""),i.setAttribute("download",e),i.setAttribute("style","display:none;"),i.setAttribute("href","data:text/json;charset=UTF-8,"+encodeURIComponent(JSON.stringify(t))),i.click()}function j(t){var e=t.next(),i=e.next(),o=t.data("table"),n={optimization_id:"orphanedtables",optimization_table:o,optimization_action:"toinnodb"};e.removeClass("visibility-hidden"),A("do_optimization",{optimization_id:"orphanedtables",data:n},function(e){if(e.result.meta.error)return t.closest("tr").html('<td colspan="8" class="no-table"><p>'+e.result.meta.message+"</p></td>"),void setTimeout(function(){T("#wp_optimize_table_list_refresh").trigger("click")},2e3);if(e.result.meta.success){var n=t.closest("tr");i.show().removeClass("visibility-hidden"),n.find(".toinnodb").remove(),setTimeout(function(){i.fadeOut("slow",function(){n.find("[data-colname='Type']").text("InnoDB")})},500)}else{var a=wpoptimize.table_was_not_converted.replace("%s",o);e.result.meta.message&&(a+="("+e.result.meta.message+")"),alert(a)}}).always(function(){t.prop("disabled",!1),e.addClass("visibility-hidden")})}function P(){var t=tt.next(),e=t.next(),i=tt.data("table"),o={optimization_id:"orphanedtables",optimization_table:i};t.removeClass("visibility-hidden"),A("do_optimization",{optimization_id:"orphanedtables",data:o},function(t){if(t.result.meta.success){var o=tt.closest("tr");e.show().removeClass("visibility-hidden"),setTimeout(function(){o.fadeOut("slow",function(){o.remove(),D()})},500)}else{var n=wpoptimize.table_was_not_deleted.replace("%s",i);t.result.meta.message&&(n+="("+t.result.meta.message+")"),alert(n)}}).always(function(){tt.prop("disabled",!1),t.addClass("visibility-hidden")})}function D(){var t=T("#wpoptimize_table_list"),e=!0;T("tr",t).each(function(){var t=T(this);if(T("button",t).length>0)return e=!1,!1}),T("tr",t).each(function(){var t=T(this);e?T("td:last, th:last",t).hide():T("td:last, th:last",t).show()})}function W(t,e){var i=t.val(),o=t.data("validate");if(!o&&e)return""!=T.trim(i);if(o&&!e&&""==T.trim(i))return!0;var n=!0;switch(o){case"email":for(var a=/\S+@\S+\.\S+/,s=i.split(","),p="",r=0;r<s.length;r++)p=T.trim(s[r]),""!=p&&a.test(p)||(n=!1);break;case"url":var a=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))\.?)(?::\d{2,5})?(?:[/?#]\S*)?$/i;n=a.test(i)}return n}var T=jQuery,q=0,I=new Updraft_Queue,A=wp_optimize.send_command,F=!1,S=!1,$=!1;g(T("#select_all_optimizations"),T("#optimizations_list .optimization_checkbox")),t(),T("#enable-schedule").on("change",function(){t()}),T.tablesorter.addParser({id:"sizes",is:function(t){return!1},format:function(t,e,i){var o=T(i).data("raw_value");return o||(o=0),parseInt(o)},type:"numeric"}),T(document).on("wpo_database_tabs_loaded",function(){var t=T("#wpoptimize_table_list_filter"),e=T("#wpoptimize_table_list"),i=T("#wpoptimize_table_list tbody:last"),o=T("#wpoptimize_table_list_tables_not_found");e.tablesorter({theme:"default",widgets:["zebra","rows","filter"],cssInfoBlock:"tablesorter-no-sort",headers:{2:{sorter:"digit"},3:{sorter:"sizes"},4:{sorter:"sizes"},7:{sorter:!1}},widgetOptions:{filter_external:t,filter_defaultFilter:{2:"~{query}"}}}),e.on("filterEnd",function(){var n=T.trim(t.val());""==n?i.show():i.hide(),0==T("#the-list tr:visible",e).length?o.show():o.hide()});var n=T("#innodb_force_optimize"),a=n.closest("tr"),s=T("#innodb_force_optimize_single");n.on("change",function(){T('button, input[type="checkbox"]',a).each(function(){F=n.is(":checked");var t=T(this);t.data("disabled")&&(F?t.prop("disabled",!1):t.prop("disabled",!0))})}),s.on("change",function(){$=T(this).is(":checked"),y($)}),$=s.is(":checked"),F=n.is(":checked"),y($)}),T("#wp-optimize-disable-enable-trackbacks-enable").on("click",function(){i("trackbacks",!0)}),T("#wp-optimize-disable-enable-trackbacks-disable").on("click",function(){i("trackbacks",!1)}),T("#wp-optimize-disable-enable-comments-enable").on("click",function(){i("comments",!0)}),T("#wp-optimize-disable-enable-comments-disable").on("click",function(){i("comments",!1)}),T(".wpo-pages-menu").on("click","a",function(t){t.preventDefault(),T(this).is(".active")||(T(".wpo-pages-menu a.active").removeClass("active"),T(".wpo-page.active").removeClass("active"),T(this).addClass("active"),T('.wpo-page[data-whichpage="'+T(this).data("menuslug")+'"]').addClass("active"),window.scroll(0,0),T("#wp-optimize-wrap").trigger("page-change",{page:T(this).data("menuslug")})),T("#wp-optimize-nav-page-menu").trigger("click")}),T("#wp-optimize-wrap").on("page-change",function(t,e){"WP-Optimize"==e.page&&T("#wp-optimize-nav-tab-WP-Optimize-optimize").is(".nav-tab-active")&&T("#wp-optimize-nav-tab-WP-Optimize-optimize").trigger("click");var i=T(".wpo-page[data-whichpage="+e.page+"]").find(".nav-tab-wrapper .nav-tab-active");T("#wp-optimize-wrap").trigger("tab-change",{page:e.page,tab:i.data("tab")}),T("#wp-optimize-wrap").trigger("tab-change/"+e.page+"/"+i.data("tab"),{content:T("#"+i.attr("id")+"-contents")})}),setTimeout(function(){T("#wp-optimize-wrap").trigger("page-change",{page:T(".wpo-pages-menu a.active").data("menuslug")})},500),T(".nav-tab-wrapper .nav-tab").on("click",function(t){t.preventDefault();var e=T(this).attr("id"),i=T(this).closest(".nav-tab-wrapper");if(e){if(o(!1),T(this).is('[role="toggle-menu"]'))return void o(!0);i.find(".nav-tab:not(#wp-optimize-nav-tab-"+e+")").removeClass("nav-tab-active"),T(this).addClass("nav-tab-active"),T(this).closest(".wpo-page").find(".wp-optimize-nav-tab-contents").hide(),T("#"+e+"-contents").show(),T("#wp-optimize-wrap").trigger("tab-change",{page:T(this).data("page"),tab:T(this).data("tab")}),T("#wp-optimize-wrap").trigger("tab-change/"+T(this).data("page")+"/"+T(this).data("tab"),{content:T("#"+e+"-contents")})}}),T("#wp-optimize-nav-page-menu").on("click",function(t){t.preventDefault(),T(this).toggleClass("opened")}),T("#wp-optimize-wrap").on("click",".js--wpo-goto",function(t){t.preventDefault();var e=T(this).data("page"),i=T(this).data("tab");e&&T('.wpo-pages-menu a[data-menuslug="'+e+'"]').trigger("click"),i&&T('.wpo-page.active .nav-tab-wrapper a[data-tab="'+i+'"]').trigger("click")});var Q=!1;T("#wp-optimize-wrap").on("tab-change/WP-Optimize/tables",function(t){n()}),T("#wp-optimize-wrap").on("tab-change/WP-Optimize/optimize",function(t,e){n()}),T("#wp-optimize-wrap").on("tab-change/wpo_settings/settings",function(t,e){e.content.find(".innodb_force_optimize--container").length&&n()}),T("#wp-optimize-nav-tab-WP-Optimize-optimize-contents").on("click","button.wp-optimize-settings-optimization-run-button",function(){var t=T(this).closest(".wp-optimize-settings").data("optimization_id");return t?void(1!=T(".optimization_button_"+t).prop("disabled")&&(T(".optimization_button_"+t).prop("disabled",!0),c(function(){T(".optimization_button_"+t).prop("disabled",!1),l(t)}))):void console.log("Optimization ID corresponding to pressed button not found")}),T("#wp-optimize-nav-tab-WP-Optimize-optimize-contents").on("click","#wp-optimize",function(t){var e=T(this);t.preventDefault(),e.prop("disabled",!0),c(function(){e.prop("disabled",!1),d()})});var U=T("#wpo_settings_sites_list"),M=U.find("ul").first(),N=T('input[type="checkbox"]',M),B=U.find("#wpo_all_sites"),E=T("#wpo_sitelist_show_moreoptions"),J=T("#wpo_sitelist_moreoptions"),R=T("#wpo_settings_sites_list_cron"),Y=R.find("ul").first(),K=T('input[type="checkbox"]',Y),G=R.find("#wpo_all_sites_cron"),H=T("#wpo_sitelist_show_moreoptions_cron"),L=T("#wpo_sitelist_moreoptions_cron");f(E,J,B,N);var V=0;T([B,N]).each(function(){T(this).on("change",function(){V++,setTimeout(function(){V--,0==V&&x()},1e3)})}),f(H,L,G,K),T("#wp_optimize_table_list_refresh").on("click",function(t){t.preventDefault();var e=T(this).closest(".wpo-tab-postbox").find(".wpo_shade");e.removeClass("hidden"),T("#wpoptimize_table_list tbody").css("opacity","0.5"),A("get_table_list",{refresh_plugin_json:!0},b).always(function(){e.addClass("hidden")})}),T("#database_settings_form, #settings_form").on("click",".wpo-save-settings",function(t){t.preventDefault();var i=T(this).closest("form"),o=i.find(".wpo-saving-settings"),n=a();i.trigger("wpo-saving-form-data"),i.form_errors.has_errors()||(o.show(),T("#optimizations_list").length&&T("#optimizations_list .optimization_checkbox:checked").each(function(){var t=T(this).closest(".wp-optimize-settings").data("optimization_id");t&&(n+="&optimization-options["+t+"][active]=1")}),T("#purge_cache_permissions").length&&(T("#purge_cache_permissions").val()||(n+="&purge_cache_permissions[]")),A("save_settings",n,function(t){if(o.closest("div").find(".save-done").show().delay(5e3).fadeOut(),t&&t.hasOwnProperty("save_results")&&t.save_results&&t.save_results.hasOwnProperty("errors"))for(var i=0,n=t.save_results.errors.length;i<n;i++){var a='<div class="error">'+t.errors[i]+"</div>";e(a,"#wp-optimize-settings-save-results")}t&&t.hasOwnProperty("status_box_contents")&&T(t.status_box_contents).each(function(t,e){T(e).is("#wp_optimize_status_box")&&T("#wp_optimize_status_box").replaceWith(T(e))}),t&&t.hasOwnProperty("optimizations_table")&&T("#optimizations_list").replaceWith(t.optimizations_table),t.save_results.refresh&&location.reload()}).always(function(){o.hide()}))}),T("#settings_form").on("click",".wpo-wipe-settings",function(){var t=T(this).parent().find(".wpo_spinner");t.show(),A("wipe_settings",{},function(){t.next().removeClass("display-none").delay(5e3).fadeOut(),alert(wpoptimize.settings_have_been_deleted_successfully),location.replace(wpoptimize.settings_page_url)}).always(function(){t.hide()})}),T("#wp-optimize-wrap").on("click","#wp_optimize_status_box_refresh",function(t){t.preventDefault(),T("#wp_optimize_status_box").css("opacity","0.5"),A("get_status_box_contents",null,function(t){T("#wp_optimize_status_box").css("opacity","1"),T(t).each(function(t,e){T(e).is("#wp_optimize_status_box")&&T("#wp_optimize_status_box").replaceWith(T(e))})})});var X={};T("#wpo_import_settings_btn").on("click",function(t){var e=T("#wpo_import_settings_file"),i=e.val(),o=e[0].files[0],n=new FileReader;return T("#wpo_import_settings_btn").prop("disabled",!0),/\.json$/.test(i)?(n.onload=function(){O(this.result)},n.readAsText(o),!1):(t.preventDefault(),T("#wpo_import_settings_btn").prop("disabled",!1),T("#wpo_import_error_message").text(wpoptimize.please_select_settings_file).slideDown(),!1)}),T("#wpo_import_settings_file").on("change",function(){T("#wpo_import_error_message").slideUp()}),T("#wpo_export_settings_btn").on("click",function(t){return C(a("object")),!1});var Z=function(t,e,i){return A("get_optimization_info",{optimization_id:e,data:i},function(i){var o=i&&i.result&&i.result.meta?i.result.meta:{},n=i&&i.result&&i.result.output?i.result.output.join("<br>"):"...";T(document).trigger(["optimization_get_info_",e].join(""),[n,o]),t.html(n),o.finished?T(document).trigger(["optimization_get_info_",e,"_done"].join(""),i):setTimeout(function(){var i=Z(t,e,o);T(document).trigger(["optimization_get_info_xhr_",e].join(""),[i,o])},1)})};jQuery(function(){T(".wp-optimize-optimization-info-ajax").each(function(){var t=T(this),e=t.parent(),i=t.data("id");T(document).trigger(["optimization_get_info_",i,"_start"].join("")),Z(e,i,{support_ajax_get_info:!0})})}),T("#wpoptimize_table_list").on("click",".run-single-table-optimization",function(){var t=T("#enable-auto-backup-1"),e=T(this);t.is(":checked")?u(function(){z(e)}):z(e)}),T("#wpoptimize_table_list").on("click",".run-single-table-repair",function(){var t=T(this),e=t.next(),i=e.next(),o=t.data("table"),n={optimization_id:"repairtables",optimization_table:o};e.removeClass("visibility-hidden"),A("do_optimization",{optimization_id:"repairtables",data:n},function(n){if(n.result.meta.success){var a=t.closest("tr"),s=n.result.meta.tableinfo;t.prop("disabled",!1),e.addClass("visibility-hidden"),i.show().removeClass("visibility-hidden"),v(a,s),setTimeout(function(){var e=t.closest("td"),i=t.closest(".wpo_button_wrap");i.fadeOut("fast",function(){i.closest(".wpo_button_wrap").remove(),s.is_type_supported&&T(".wpo_button_wrap",e).removeClass("wpo_hidden")}),D()},1e3)}else t.prop("disabled",!1),e.addClass("visibility-hidden"),alert(wpoptimize.table_was_not_repaired.replace("%s",o))})}),T("#wpoptimize_table_list").on("click",".toinnodb",function(){j(T(this))});var tt;return T("#wpoptimize_table_list").on("click",".run-single-table-delete",function(){tt=T(this);var t=T("#enable-auto-backup-1");""==wpoptimize.user_always_ignores_table_delete_warning||"1"!==wpoptimize.user_always_ignores_table_delete_warning?wp_optimize.modal.open({className:"wpo-confirm",events:{"click .wpo-modal--bg":"close","click .delete-table":"deleteTable","change #confirm_deletion_without_backup":"changeConfirm","change #confirm_table_deletion":"changeConfirm"},content:function(){var e=wp.template("wpo-table-delete"),i=tt.closest("tr").find(".table-plugins").html();return e({no_backup:!t.is(":checked"),plugins_list:i,table_name:tt.data("table")})},changeConfirm:function(){var t=!0,e=this.$("#confirm_deletion_without_backup"),i=this.$("#confirm_table_deletion");e.length&&!e.is(":checked")&&(t=!1),i.is(":checked")||(t=!1),this.$(".delete-table").prop("disabled",!t)},deleteTable:function(){var e=this.$("#ignores_table_delete_warning");e.is(":checked")&&A("user_ignores_table_delete_warning",{},function(t){t.success&&(wpoptimize.user_always_ignores_table_delete_warning="1")}),t.is(":checked")?u(P):P(),this.close()}}):t.is(":checked")?u(P):P()}),D(),T("#wp-optimize-general-settings").on("wpo-saving-form-data",function(){var t=!0,e=T(this);T(".wpo_logger_addition_option, .wpo_logger_type").each(function(){W(T(this),!0)?T(this).removeClass("wpo_error_field"):(t=!1,T(this).addClass("wpo_error_field"))}),t?(e.form_errors.remove("missing-fields"),T("#wp-optimize-logger-settings .save_settings_reminder").slideUp()):(e.form_errors.add("missing-fields",""),T("#wp-optimize-settings-save-results").show().addClass("wpo_alert_notice").text(wpoptimize.fill_all_settings_fields).delay(5e3).fadeOut(3e3,function(){T(this).removeClass("wpo_alert_notice")}))}),setTimeout(function(){A("check_overdue_crons",null,function(t){t&&t.hasOwnProperty("m")&&T("#wpo_settings_warnings").append(t.m)})},11e3),T(".wpo-introduction-notice .notice-dismiss, .wpo-introduction-notice .close").on("click",function(t){T(".wpo-introduction-notice").remove(),A("dismiss_install_or_update_notice",null,function(t){t&&t.hasOwnProperty("error")&&console.log("There was an error dismissing the install or update notice (dismiss_install_or_update_notice)",t)})}),{send_command:A,optimization_get_info:Z,take_a_backup_with_updraftplus:u,save_auto_backup_options:m}};jQuery(function(t){function e(e){var i=["#",e.data("additional")].join("");e.is(":checked")?t(i).show():t(i).hide()}function i(){var e=t("#wp-optimize-logger-settings .save_settings_reminder");e.is(":visible")||e.slideDown("normal")}function o(){t(".wpo_logger_type").each(function(){n(t(this))})}function n(e){var i,o,n=a();for(i in n)o=n[i],wpoptimize.loggers_classes_info[o].allow_multiple?t('option[value="'+o+'"]',e).show():t('option[value="'+o+'"]',e).hide()}function a(){var e=[];return t(".wpo_logging_row, .wpo_logger_type").each(function(){var i=t(this).is("select")?t(this).val():t(this).data("id");i&&e.push(i)}),e}function s(){var t,e=['<option value="">Select destination</option>'];for(t in wpoptimize.loggers_classes_info)wpoptimize.loggers_classes_info.hasOwnProperty(t)&&wpoptimize.loggers_classes_info[t].available&&e.push(['<option value="',t,'">',wpoptimize.loggers_classes_info[t].description,"</option>"].join(""));return['<div class="wpo_add_logger_form">','<select class="wpo_logger_type" name="wpo-logger-type[]">',e.join(""),"<select>",'<a href="#" class="wpo_delete_logger dashicons dashicons-no-alt"></a>','<div class="wpo_additional_logger_options"></div>',"</div>"].join("")}function p(e){if(!wpoptimize.loggers_classes_info[e].options)return"";var i,o=wpoptimize.loggers_classes_info[e].options,n=[],a="",s="";for(i in o)o.hasOwnProperty(i)&&(Array.isArray(o[i])?(a=t.trim(o[i][0]),s=t.trim(o[i][1])):(a=t.trim(o[i]),s=""),n.push(['<input class="wpo_logger_addition_option" type="text" name="wpo-logger-options[',i,'][]" value="" ','placeholder="',a,'" ',""!==s?'data-validate="'+s+'"':"","/>"].join("")));return n.push('<input type="hidden" name="wpo-logger-options[active][]" value="1" />'),n.join("")}t(".wp-optimize-logging-settings").each(function(){var i=t(this);e(i),i.on("change",function(){e(i)})});var r=t("#wpo_add_logger_link");r.on("click",function(e){e.preventDefault(),t("#wp-optimize-logger-settings .save_settings_reminder").after(s()),n(t(".wpo_logger_type").first())}),t("#wp-optimize-general-settings").on("change",".wpo_logger_type",function(){var e=t(this),o=e.val(),n=e.parent().find(".wpo_additional_logger_options");n.html(p(o)),e.val()&&i()}),t(".wpo_logging_actions_row .dashicons-edit").on("click",function(){var e=t(this),i=e.closest(".wpo_logging_row");return t(".wpo_additional_logger_options",i).removeClass("wpo_hidden"),t(".wpo_logging_options_row",i).text(""),t(".wpo_logging_status_row",i).text(""),e.hide(),!1}),t("#wp-optimize-logger-settings").on("change",".wpo_logger_addition_option",function(){i()}),t(".wpo_logger_active_checkbox").on("change",function(){var e=t(this),i=e.closest("label").find('input[type="hidden"]');i.val(e.is(":checked")?"1":"0")}),t("#wp-optimize-general-settings").on("click",".wpo_delete_logger",function(){if(!confirm(wpoptimize.are_you_sure_you_want_to_remove_logging_destination))return!1;var e=t(this);return e.closest(".wpo_logging_row, .wpo_add_logger_form").remove(),o(),0==t("#wp-optimize-logging-options .wpo_logging_row").length&&t("#wp-optimize-logging-options").hide(),i(),!1});var l=!1;t(window).on("scroll",function(e){window.requestAnimationFrame(function(){var e=t(".wpo-main-header").length?t(".wpo-main-header")[0].offsetTop:0;window.pageYOffset>e-20!=l&&(l=!l,t("body").toggleClass("is-scrolled",l))})}),t(".wpo-info__trigger").on("click",function(e){e.preventDefault();var i=t(this).closest(".wpo-info");i.toggleClass("opened")}),t(".wpo-video-preview a").on("click",function(e){var i=t(this).data("embed");if(i){e.preventDefault();var o=t('<iframe width="356" height="200" allowfullscreen webkitallowfullscreen mozallowfullscreen>').attr("src",i);o.insertAfter(t(this)),t(this).remove(),o.focus()}})});