!function(a,b){function c(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a}function d(){X=0,$=a(".timer"),_=wpmdb_strings.time_elapsed+" ",A=setInterval(f,1e3)}function e(){var a=Math.floor(X/3600)%24,b=Math.floor(X/60)%60,d=X%60,e=_+c(a,2,0)+":"+c(b,2,0)+":"+c(d,2,0);$.html(e)}function f(){X+=1,e()}function g(a,b){var c,d,e=[],f={},g=b.length;for(c=0;g>c;c++)f[b[c]]=!0;for(g=a.length,c=0;g>c;c++)d=a[c],d in f&&e.push(d);return e}function h(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b=new RegExp("[\\?&]"+a+"=([^&#]*)"),c=b.exec(location.search);return null===c?"":decodeURIComponent(c[1].replace(/\+/g," "))}function i(b,c,d){var e=b.substr(0,b.indexOf(":"));return d!==e&&-1!==b.indexOf("https")?(a(".ssl-notice").show(),M=!0,b=b.replace("https","http"),void a(".pull-push-connection-info").val(b+"\n"+c)):void(M=!1)}function j(b){b!==wpmdb_data.this_prefix&&(a(".remote-prefix").html(b),L=!0,"pull"===wpmdb_migration_type()?a(".prefix-notice.pull").show():a(".prefix-notice.push").show())}function k(){if("undefined"!=typeof b.common.connection_data&&!1!==b.common.connection_data){var c=wpmdb_migration_type(),d=t(null,null);a(".mixed-case-table-name-notice").hide(),null!==d&&(d=d.join(""),d!==d.toLowerCase()&&("1"===b.common.connection_data.lower_case_table_names||"push"!==c&&"savefile"!==c)&&("1"===wpmdb_data.lower_case_table_names||"pull"!==c)&&("push"===c||"savefile"===c?a(".mixed-case-table-name-notice.push").show():a(".mixed-case-table-name-notice.pull").show()))}}function l(a){var b=a,c=b.replace(/\/\/(.*)@/,"//").replace("http://","").replace("https://","").replace("www.","");return c}function m(a,b,c){var d,e,f=l(a);return"pull"===b?(d=wpmdb_strings.pull_migration_label_migrating,e=wpmdb_strings.pull_migration_label_completed):(d=wpmdb_strings.push_migration_label_migrating,e=wpmdb_strings.push_migration_label_completed),d=d.replace("%s",f),e=e.replace("%s",f),"migrating"===c?d:e}function n(a){return a.replace(/^https?:/i,"")}function o(){a(".option-group").each(function(){a("input",this).attr("disabled","disabled"),a("label",this).css("cursor","default")})}function p(){a(".option-group").each(function(){a("input",this).removeAttr("disabled"),a("label",this).css("cursor","pointer")})}function q(b,c,d){a(".slider",b).slider("value",c),a(".amount",b).html(wpmdb_add_commas(c)+" "+d)}function r(){!0===T?(T=!1,E=!0,a(".progress-title").html(U),a(".progress-text",".progress-wrapper-primary").html(V),a(".progress-text",".progress-wrapper-secondary").html(W),a(".migration-progress-ajax-spinner").show(),a(".pause-resume").html(wpmdb_strings.pause),A=setInterval(f,1e3),b.functions.execute_next_step()):(T=!0,E=!1,U=a(".progress-title").html(),V=a(".progress-text",".progress-wrapper-primary").html(),W=a(".progress-text",".progress-wrapper-secondary ").html(),a(".progress-title").html(wpmdb_strings.migration_paused),a(".progress-text").html(wpmdb_strings.completing_current_request),a("body").off("click",".pause-resume"),a("body").off("click",".cancel"))}function s(b,c,d){var e=document.createElement("select");return a(e).attr({multiple:"multiple",name:"select_tables[]",id:"select-tables","class":"multiselect"}),0'+f+" ("+c[f]+")")}}),e}function t(){var c="",d=wpmdb_migration_type(),e=a("input[name=table_migrate_option]:checked").val();return c="migrate_select"===e?a("#select-tables").val():"push"===d||"savefile"===d?wpmdb_data.this_prefixed_tables:b.common.connection_data.prefixed_tables}function u(){return a(".table-select-wrap .table-prefix").text()}var v,w,x,y,z,A,B,C=!1,D="",E=!1,F=!1,G=!1,H=!1,I=!1,J=!1,K=!1,L=!1,M=!1,N=!1,O=!1,P=!1,Q="",R="",S="",T=!1,U="",V="",W="",X=0,Y=0,Z=!1,$=!1,_="",ab=!1,bb=0,cb=400,db=ajaxurl.replace("/admin-ajax.php",""),eb=db+"/images/spinner";2';window.onbeforeunload=function(a){return P?(a=a||window.event,a&&(a.returnValue=wpmdb_strings.sure),wpmdb_strings.sure):void 0},a(document).ready(function(){function c(b){K=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_check_licence",licence:b,context:"all",nonce:wpmdb_data.nonces.check_licence},error:function(){alert(wpmdb_strings.license_check_problem)},success:function(b){var c,d,e,f=a(".support-content"),g=a(".addons-content"),h=a(".licence-status:not(.notification-message)");if("undefined"!=typeof b.dbrains_api_down)d=b.dbrains_api_down+b.message,e=b.dbrains_api_down;else if("undefined"!=typeof b.errors){if("undefined"!=typeof b.errors.subscription_expired)c=b.errors.subscription_expired.licence,d=b.errors.subscription_expired.support,e=b.errors.subscription_expired.addons;else{var i="";for(var j in b.errors)i+=b.errors[j];d=i,e=i}"undefined"!=typeof b.addon_content&&(e+="\n"+b.addon_content)}else d=b.message,e=b.addon_content;h.stop().fadeOut(cb,function(){a(this).empty().html(c).stop().fadeIn(cb)}),f.stop().fadeOut(cb,function(){a(this).empty().html(d).stop().fadeIn(cb)}),g.stop().fadeOut(cb,function(){a(this).empty().html(e).stop().fadeIn(cb)})}})}function e(){void 0!==wpmdb_data&&void 0!==wpmdb_data.this_tables&&void 0!==wpmdb_data.this_table_sizes_hr&&(vb=s(wpmdb_data.this_tables,wpmdb_data.this_table_sizes_hr,a(vb).val())),void 0!==b.common.connection_data&&void 0!==b.common.connection_data.tables&&void 0!==b.common.connection_data.table_sizes_hr&&(wb=s(b.common.connection_data.tables,b.common.connection_data.table_sizes_hr,a(wb).val()))}function f(){a("#select-tables").remove(),a(".select-tables-wrap").prepend(vb)}function U(){a("#select-tables").remove(),a(".select-tables-wrap").prepend(wb)}function V(){a("#migrate-selected").parents(".option-section").children(".header-expand-collapse").children(".expand-collapse-arrow").removeClass("collapsed"),a(".table-select-wrap").show(),a("#migrate-only-with-prefix").prop("checked",!1),a("#migrate-selected").prop("checked",!0),a(".table-migrate-options").hide(),a(".select-tables-wrap").show()}function W(){a(".table-migrate-options").show()}function X(){a("#select-tables").children("option").prop("selected",!0)}function $(){return n(wpmdb_data.this_url)}function _(){var c=wpmdb_migration_type(),d=a.trim(a(".pull-push-connection-info").val()).split("\n");if("undefined"!=typeof wpmdb_default_profile&&!0!==wpmdb_default_profile&&"savefile"!==c&&!E&&wpmdb_data.is_pro){E=!0,o(),a(".connection-status").html(wpmdb_strings.establishing_remote_connection),a(".connection-status").removeClass("notification-message error-notice migration-error"),a(".connection-status").append(fb);var e=wpmdb_migration_type();a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_verify_connection_to_remote_site",url:d[0],key:d[1],intent:e,nonce:wpmdb_data.nonces.verify_connection_to_remote_site,convert_post_type_selection:wpmdb_convert_post_type_selection,profile:wpmdb_data.profile},error:function(b){a(".connection-status").html(lb(b.responseText,"(#102)",b)),a(".connection-status").addClass("notification-message error-notice migration-error"),a(".ajax-spinner").remove(),E=!1,p()},success:function(c){if(a(".ajax-spinner").remove(),E=!1,p(),"undefined"!=typeof c.wpmdb_error&&1===c.wpmdb_error)return a(".connection-status").html(c.body),a(".connection-status").addClass("notification-message error-notice migration-error"),void(c.body.indexOf("401 Unauthorized")>-1&&a(".basic-access-auth-wrapper").show());i(d[0],d[1],c.scheme),j(c.prefix),a(".pull-push-connection-info").addClass("temp-disabled"),a(".pull-push-connection-info").attr("readonly","readonly"),a(".connect-button").hide(),a(".connection-status").hide(),a(".step-two").show(),C=!0,b.common.connection_data=c,jb(),k();var e="";!1===wpmdb_default_profile&&"undefined"!=typeof wpmdb_loaded_tables&&(e=wpmdb_loaded_tables),wb=s(b.common.connection_data.tables,b.common.connection_data.table_sizes_hr,e);var f="";!1===wpmdb_default_profile&&"undefined"!=typeof wpmdb_loaded_post_types&&("undefined"!=typeof c.select_post_types?(a("#exclude-post-types").attr("checked","checked"),a(".post-type-select-wrap").show(),f=c.select_post_types):f=wpmdb_loaded_post_types);var g=document.createElement("select");a(g).attr({multiple:"multiple",name:"select_post_types[]",id:"select-post-types","class":"multiselect"}),a.each(b.common.connection_data.post_types,function(b,c){var d=a.inArray(c,f);d=-1!==d||!0===wpmdb_convert_exclude_revisions&&"revision"!==c?' selected="selected" ':" ",a(g).append("'+c+"")}),yb=g;var h="";!1===wpmdb_default_profile&&"undefined"!=typeof wpmdb_loaded_tables_backup&&(h=wpmdb_loaded_tables_backup);var l=document.createElement("select");a(l).attr({multiple:"multiple",name:"select_backup[]",id:"select-backup","class":"multiselect"}),a.each(b.common.connection_data.tables,function(c,d){var e=a.inArray(d,h);e=-1!==e?' selected="selected" ':" ",a(l).append("'+d+" ("+b.common.connection_data.table_sizes_hr[d]+")")}),zb=l,"pull"===wpmdb_migration_type()?(a.wpmdb.do_action("wpmdb_update_pull_table_select"),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(yb),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(Ab),a(".table-prefix").html(c.prefix),a(".uploads-dir").html(wpmdb_data.this_uploads_dir)):(a("#select-backup").remove(),a(".backup-tables-wrap").prepend(zb)),a.wpmdb.do_action("verify_connection_to_remote_site",b.common.connection_data)}})}}function db(b,d){a(".licence-input, .register-licence").remove(),a(".licence-not-entered").prepend(b.masked_licence),a(".support-content").empty().html("

"+wpmdb_strings.fetching_license+'

'),c(d),a(".migrate-selection label").removeClass("disabled"),a(".migrate-selection input").removeAttr("disabled")}function gb(){a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_get_log",nonce:wpmdb_data.nonces.get_log},error:function(){alert(wpmdb_strings.update_log_problem)},success:function(b){a(".debug-log-textarea").val(b)}})}function hb(){var b=a(".progress-content").outerHeight();a(".progress-content").animate({top:"-"+b+"px"},400,"swing",function(){a("#overlay").remove(),a(".progress-content").remove()}),O=!1}function ib(){var b;if(a(".save-settings-button").blur(),!H){if(a("#migrate-selected").is(":checked")&&null===a("#select-tables").val())return void alert(wpmdb_strings.please_select_one_table);if("savefile"!==wpmdb_migration_type()&&a("#backup-manual-select").is(":checked")&&null===a("#select-backup").val())return void alert(wpmdb_strings.please_select_one_table_backup);var c=!1;a("#create_new").is(":checked")&&(c=!0);var d=a(".create-new-profile").val();H=!0,b=a("#migrate-form").serialize(),a(".save-settings-button").attr("disabled","disabled").after(''),E=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_save_profile",profile:b,nonce:wpmdb_data.nonces.save_profile},error:function(){E=!1,alert(wpmdb_strings.save_profile_problem),a(".save-settings-button").removeAttr("disabled"),a(".save-profile-ajax-spinner").remove(),a(".save-settings-button").after(''+wpmdb_strings.saved+""),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()}),H=!1},success:function(b){var e=parseInt(a("#migrate-form input[name=save_migration_profile_option]:checked").val(),10)+1;if(E=!1,a(".save-settings-button").removeAttr("disabled"),a(".save-profile-ajax-spinner").remove(),a(".save-settings-button").after(''+wpmdb_strings.saved+""),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()}),H=!1,a(".create-new-profile").val(""),c){var f=parseInt(b,10),g=f+1,h=a('
  • ');h.find("label").append(document.createTextNode(" "+d)),e=g,a("#create_new").parents("li").before(h),a("#profile-"+g).attr("checked","checked")}var i=window.location.href.replace("#migrate","").replace(/&wpmdb-profile=-?\d+/,"")+"&wpmdb-profile="+e,j=a("#migrate-form input[name=save_migration_profile_option]:checked").parent().text().trim();if("function"==typeof window.history.pushState){if(a("#migrate-form .crumbs").length)a("#migrate-form .crumbs .crumb:last").text(j);else{var k=a('
    ').append(' Saved Profiles ').append(''+j+"");a("#migrate-form").prepend(k)}window.history.pushState({updated_profile_id:e},null,i)}}})}}function jb(){a(".connection-status").hide(),a(".prefix-notice").hide(),a(".ssl-notice").hide(),a(".different-plugin-version-notice").hide(),a(".step-two").show(),a(".backup-options").show(),a(".keep-active-plugins").show(),a(".directory-permission-notice").hide(),a("#create-backup").removeAttr("disabled"),a("#create-backup-label").removeClass("disabled"),a(".backup-option-disabled").hide(),a(".compatibility-older-mysql").hide();{var c;a.trim(a(".pull-push-connection-info").val()).split("\n")}wpmdb_toggle_migration_action_text(),"pull"===wpmdb_migration_type()?(a(".pull-list li").append(Bb),Bb.show(function(){var b=a(this).find(".pull-push-connection-info");b.val()||b.focus()}),C?(a(".connection-status").hide(),a(".step-two").show(),a(".table-prefix").html(b.common.connection_data.prefix),a(".uploads-dir").html(wpmdb_data.this_uploads_dir),!1===J&&(c=l(b.common.connection_data.url),a(".create-new-profile").val(c)),!0===L&&a(".prefix-notice.pull").show(),!0===M&&a(".ssl-notice").show(),!0===N&&(a(".different-plugin-version-notice").show(),a(".step-two").hide()),wpmdb_toggle_migration_action_text(),!1===wpmdb_data.write_permission&&(a("#create-backup").prop("checked",!1),a("#create-backup").attr("disabled","disabled"),a("#create-backup-label").addClass("disabled"),a(".backup-option-disabled").show(),a(".upload-directory-location").html(wpmdb_data.this_upload_dir_long))):(a(".connection-status").show(),a(".step-two").hide())):"push"===wpmdb_migration_type()?(a(".push-list li").append(Bb),Bb.show(function(){var b=a(this).find(".pull-push-connection-info");b.val()||b.focus()}),C?(a(".connection-status").hide(),a(".step-two").show(),a(".table-prefix").html(wpmdb_data.this_prefix),a(".uploads-dir").html(b.common.connection_data.uploads_dir),!1===J&&(c=l(b.common.connection_data.url),a(".create-new-profile").val(c)),!0===L&&a(".prefix-notice.push").show(),!0===M&&a(".ssl-notice").show(),!0===N&&(a(".different-plugin-version-notice").show(),a(".step-two").hide()),wpmdb_toggle_migration_action_text(),"0"===b.common.connection_data.write_permissions&&(a("#create-backup").prop("checked",!1),a("#create-backup").attr("disabled","disabled"),a("#create-backup-label").addClass("disabled"),a(".backup-option-disabled").show(),a(".upload-directory-location").html(b.common.connection_data.upload_dir_long))):(a(".connection-status").show(),a(".step-two").hide())):"savefile"===wpmdb_migration_type()&&(a(".connection-status").hide(),a(".step-two").show(),a(".table-prefix").html(wpmdb_data.this_prefix),a(".compatibility-older-mysql").show(),!1===J&&a(".create-new-profile").val(""),a(".backup-options").hide(),a(".keep-active-plugins").hide(),!1===wpmdb_data.write_permission&&(a(".directory-permission-notice").show(),a(".step-two").hide())),k(),a.wpmdb.do_action("move_connection_info_box",{migration_type:wpmdb_migration_type(),last_migration_type:D})}function kb(){var c=null,d=null;null!==b.common.previous_connection_data&&"object"==typeof b.common.previous_connection_data&&b.common.previous_connection_data.url!==b.common.connection_data.url&&(c=n(b.common.previous_connection_data.url),d=b.common.previous_connection_data.path),"push"===wpmdb_migration_type()||"savefile"===wpmdb_migration_type()?("pull"===D?a(".replace-row").each(function(){var b=a(".old-replace-col input",this).val();a(".old-replace-col input",this).val(a(".replace-right-col input",this).val()),a(".replace-right-col input",this).val(b)}):"push"===D&&"push"===wpmdb_migration_type()&&null!==c&&null!==d&&a(".replace-row").each(function(){var e=a(".replace-right-col input",this).val();e===d&&a(".replace-right-col input",this).val(b.common.connection_data.path),e===c&&a(".replace-right-col input",this).val(n(b.common.connection_data.url))}),a.wpmdb.do_action("wpmdb_update_push_table_select"),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(xb),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(zb)):"pull"===wpmdb_migration_type()&&(""===D||"push"===D||"savefile"===D?a(".replace-row").each(function(){var b=a(".old-replace-col input",this).val();a(".old-replace-col input",this).val(a(".replace-right-col input",this).val()),a(".replace-right-col input",this).val(b)}):"pull"===D&&"pull"===wpmdb_migration_type()&&null!==c&&null!==d&&a(".replace-row").each(function(){var e=a(".old-replace-col input",this).val();e===d&&a(".old-replace-col input",this).val(b.common.connection_data.path),e===c&&a(".old-replace-col input",this).val(n(b.common.connection_data.url))}),a.wpmdb.do_action("wpmdb_update_pull_table_select"),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(yb),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(Ab)),D=wpmdb_migration_type()}function lb(a,b,c){return wpmdbGetAjaxErrors(wpmdb_strings.connection_local_server_problem,b,a,c)}function mb(a){return/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)}function nb(b,d){a(".nav-tab").removeClass("nav-tab-active"),a(".nav-tab."+b).addClass("nav-tab-active"),a(".content-tab").hide(),a("."+b+"-tab").show(),"settings"===b&&!1===K&&"1"===wpmdb_data.has_licence&&(a("p.licence-status").append("Checking License... ").append(fb),c()),"help"===b&&(gb(),!1===K&&"1"===wpmdb_data.has_licence&&(a(".support-content p").append(fb),c())),"addons"===b&&!0!==d&&!1===K&&"1"===wpmdb_data.has_licence&&(a(".addons-content p").append(fb),c())}function ob(c){var d=a(".pull-push-connection-info");if(!E&&!a(d).hasClass("temp-disabled")){c=a(".pull-push-connection-info").val();var f=a.trim(c).split("\n"),g=!1,h="";if(""===f&&(g=!0,h=wpmdb_strings.connection_info_missing),2===f.length||g||(g=!0,h=wpmdb_strings.connection_info_incorrect),g||mb(f[0])||(g=!0,h=wpmdb_strings.connection_info_url_invalid),!g&&32>=f[1].length&&(g=!0,h=wpmdb_strings.connection_info_key_invalid),g||f[0]!==wpmdb_data.connection_info[0]||(g=!0,h=wpmdb_strings.connection_info_local_url),g||f[1]!==wpmdb_data.connection_info[1]||(g=!0,h=wpmdb_strings.connection_info_local_key),g)return a(".connection-status").html(h),void a(".connection-status").addClass("notification-message error-notice migration-error");var m=f[0]+"\n"+f[1];!1===wpmdb_data.openssl_available&&(f[0]=f[0].replace("https://","http://"),m=f[0]+"\n"+f[1],a(".pull-push-connection-info").val(m)),L=!1,E=!0,o(),a(".basic-access-auth-wrapper").is(":visible")&&(f[0]=f[0].replace(/\/\/(.*)@/,"//"),f[0]=f[0].replace("//","//"+encodeURIComponent(a.trim(a(".auth-username").val()))+":"+encodeURIComponent(a.trim(a(".auth-password").val()))+"@"),m=f[0]+"\n"+f[1],a(".pull-push-connection-info").val(m),a(".basic-access-auth-wrapper").hide()),a(".step-two").hide(),a(".ssl-notice").hide(),a(".prefix-notice").hide(),a(".connection-status").show(),a(".connection-status").html(wpmdb_strings.establishing_remote_connection),a(".connection-status").removeClass("notification-message error-notice migration-error"),a(".connection-status").append(fb);var q=wpmdb_migration_type();J=!1,a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_verify_connection_to_remote_site",url:f[0],key:f[1],intent:q,nonce:wpmdb_data.nonces.verify_connection_to_remote_site},error:function(b){a(".connection-status").html(lb(b.responseText,"(#100)",b)),a(".connection-status").addClass("notification-message error-notice migration-error"),a(".ajax-spinner").remove(),E=!1,p()},success:function(c){if(a(".ajax-spinner").remove(),E=!1,p(),i(f[0],f[1],c.scheme),"undefined"!=typeof c.wpmdb_error&&1===c.wpmdb_error)return a(".connection-status").html(c.body),a(".connection-status").addClass("notification-message error-notice migration-error"),void(c.body.indexOf("401 Unauthorized")>-1&&a(".basic-access-auth-wrapper").show());var d=l(c.url);a(".create-new-profile").val(d),a(".pull-push-connection-info").addClass("temp-disabled"),a(".pull-push-connection-info").attr("readonly","readonly"),a(".connect-button").hide(),a(".connection-status").hide(),a(".step-two").show(),j(c.prefix),C=!0,b.common.previous_connection_data=b.common.connection_data,b.common.connection_data=c,jb(),kb(),k(),e(),zb=a(wb).clone(),a(zb).attr({name:"select_backup[]",id:"select-backup"});var g=document.createElement("select");a(g).attr({multiple:"multiple",name:"select_post_types[]",id:"select-post-types","class":"multiselect"}),a.each(b.common.connection_data.post_types,function(b,c){a(g).append('")}),yb=g,a("#new-path-missing-warning, #new-url-missing-warning").hide(),"pull"===wpmdb_migration_type()?(a("#new-url").val(n(wpmdb_data.this_url)),a("#new-path").val(wpmdb_data.this_path),"true"===wpmdb_data.is_multisite&&(a("#new-domain").val(wpmdb_data.this_domain),a('.replace-row.pin .old-replace-col input[type="text"]').val(n(c.url))),a("#old-url").val(n(c.url)),a("#old-path").val(c.path),a.wpmdb.do_action("wpmdb_update_pull_table_select"),a("#select-post-types").remove(),a(".select-post-types-wrap").prepend(yb),a(".table-prefix").html(c.prefix),a(".uploads-dir").html(wpmdb_data.this_uploads_dir)):(a("#new-url").val(n(c.url)),a("#new-path").val(c.path),"true"===wpmdb_data.is_multisite&&a('.replace-row.pin .old-replace-col input[type="text"]').val(n(wpmdb_data.this_url)),a.wpmdb.do_action("wpmdb_update_push_table_select"),a("#select-backup").remove(),a(".backup-tables-wrap").prepend(zb)),b.common.next_step_in_migration={fn:a.wpmdb.do_action,args:["verify_connection_to_remote_site",b.common.connection_data]},b.functions.execute_next_step()}})}}function pb(){Z=!0,a(".progress-text").html(wpmdb_strings.completing_current_request),a(".progress-title").html(wpmdb_strings.cancelling_migration),a(".migration-controls").fadeOut(),a(".migration-progress-ajax-spinner").show(),!0===T&&(T=!1,b.functions.execute_next_step())}b.migration_state_id="",a("#plugin-compatibility").change(function(){var b="1";if(a(this).is(":checked")){var c=confirm(wpmdb_strings.mu_plugin_confirmation);if(!c)return void a(this).prop("checked",!1)}else b="0";a(".plugin-compatibility-wrap").toggle(),a(this).parent().append(fb),a("#plugin-compatibility").attr("disabled","disabled"),a(".plugin-compatibility").addClass("disabled"),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_plugin_compatibility",install:b},error:function(b){alert(wpmdb_strings.plugin_compatibility_settings_problem+"\r\n\r\n"+wpmdb_strings.status+" "+b.status+" "+b.statusText+"\r\n\r\n"+wpmdb_strings.response+"\r\n"+b.responseText),a(".ajax-spinner").remove(),a("#plugin-compatibility").removeAttr("disabled"),a(".plugin-compatibility").removeClass("disabled")},success:function(b){""!==a.trim(b)?alert(b):(a(".plugin-compatibility").append(''+wpmdb_strings.saved+""),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()})),a(".ajax-spinner").remove(),a("#plugin-compatibility").removeAttr("disabled"),a(".plugin-compatibility").removeClass("disabled")}})}),a("#plugin-compatibility").is(":checked")&&a(".plugin-compatibility-wrap").show(),(0<=navigator.userAgent.indexOf("MSIE")||0<=navigator.userAgent.indexOf("Trident"))&&a(".ie-warning").show(),0===wpmdb_data.valid_licence&&a("#savefile").prop("checked",!0);var qb=a(".max-request-size"),rb=a(".slider",qb);rb.slider({range:"min",value:parseInt(wpmdb_data.max_request/1024),min:512,max:parseInt(wpmdb_data.bottleneck/1024),step:1,create:function(){q(qb,wpmdb_data.max_request/1024,"kB")},slide:function(a,b){q(qb,b.value,"kB")},stop:function(b,c){a(".amount",qb).after(''),rb.slider("disable"),a.ajax({url:ajaxurl,type:"POST",cache:!1,data:{action:"wpmdb_update_max_request_size",max_request_size:parseInt(c.value),nonce:wpmdb_data.nonces.update_max_request_size},error:function(){rb.slider("enable"),a(".slider-spinner",qb).remove(),alert(wpmdb_strings.max_request_size_problem),q(qb,wpmdb_data.max_request/1024,"kB"),rb.slider("enable")},success:function(){rb.slider("enable"),a(".slider-success-msg",qb).show(),a(".slider-success-msg",qb).fadeOut(2e3,function(){a(this).hide()}),a(".slider-spinner",qb).remove()}})}});var sb=a(".delay-between-requests"),tb=a(".slider",sb);tb.slider({range:"min",value:parseInt(wpmdb_data.delay_between_requests/1e3),min:0,max:10,step:1,create:function(){q(sb,wpmdb_data.delay_between_requests/1e3,"s")},slide:function(a,b){q(sb,b.value,"s")},stop:function(b,c){a(".amount",sb).after(''),tb.slider("disable"),a.ajax({url:ajaxurl,type:"POST",cache:!1,data:{action:"wpmdb_update_delay_between_requests",delay_between_requests:parseInt(1e3*c.value),nonce:wpmdb_data.nonces.update_delay_between_requests},error:function(){tb.slider("enable"),a(".slider-spinner",sb).remove(),alert(wpmdb_strings.delay_between_requests_problem),q(sb,wpmdb_data.delay_between_requests/1e3,"s"),tb.slider("enable")},success:function(){wpmdb_data.delay_between_requests=parseInt(1e3*c.value),tb.slider("enable"),a(".slider-success-msg",sb).show(),a(".slider-success-msg",sb).fadeOut(2e3,function(){a(this).hide()}),a(".slider-spinner",sb).remove()}})}});var ub=a(".progress-content").clone();a(".progress-content").remove();var vb=a("#select-tables").clone(),wb=a("#select-tables").clone(),xb=a("#select-post-types").clone(),yb=a("#select-post-types").clone(),zb=a("#select-backup").clone(),Ab=a("#select-backup").clone();a(".help-tab .video").each(function(){var b=a(this),c=a(".video-viewer");a("a",this).click(function(d){d.preventDefault(),c.attr("src","//www.youtube.com/embed/"+b.data("video-id")+"?autoplay=1"),c.show();var e=c.offset();a(window).scrollTop(e.top-50)})}),a(".backup-options").show(),a(".keep-active-plugins").show(),"savefile"===wpmdb_migration_type()&&(a(".backup-options").hide(),a(".keep-active-plugins").hide()),D=wpmdb_migration_type(),a(".content-tab").on("click",".check-my-licence-again",function(b){b.preventDefault(),K=!1,a(b.target).replaceWith("Checking... "+fb),c(null,"all")}),a.wpmdb.add_action("wpmdb_refresh_table_selects",e),a.wpmdb.add_action("wpmdb_update_push_table_select",f),a.wpmdb.add_action("wpmdb_update_pull_table_select",U),a.wpmdb.add_action("wpmdb_disable_table_migration_options",V),a.wpmdb.add_action("wpmdb_enable_table_migration_options",W),a.wpmdb.add_action("wpmdb_select_all_tables",X),a.wpmdb.add_filter("wpmdb_base_old_url",$),_(),a("body").on("click",".js-action-link",function(b){b.preventDefault(),a(this).blur()}),a(".licence-form").submit(function(b){if(b.preventDefault(),!F){a(".licence-status").removeClass("notification-message error-notice success-notice");var c=a.trim(a(".licence-input").val());if(""===c)return a(".licence-status").addClass("notification-message error-notice"),void a(".licence-status").html(wpmdb_strings.enter_license_key);a(".licence-status").empty().removeClass("success"),F=!0,a(".button.register-licence").after(''),a.ajax({url:ajaxurl,type:"POST",dataType:"JSON",cache:!1,data:{action:"wpmdb_activate_licence",licence_key:c,nonce:wpmdb_data.nonces.activate_licence,context:"licence"},error:function(){F=!1,a(".register-licence-ajax-spinner").remove(),a(".licence-status").html(wpmdb_strings.register_license_problem)},success:function(b){if(F=!1,a(".register-licence-ajax-spinner").remove(),"undefined"!=typeof b.errors){var d="";for(var e in b.errors)d+=b.errors[e];a(".licence-status").html(d),"undefined"!=typeof b.masked_licence&&(db(b,c),a(".migrate-tab .invalid-licence").hide())}else"undefined"!=typeof b.wpmdb_error&&"undefined"!=typeof b.body?a(".licence-status").html(b.body):(a(".licence-status").html(wpmdb_strings.license_registered).delay(5e3).fadeOut(1e3),a(".licence-status").addClass("success notification-message success-notice"),db(b,c),a(".invalid-licence").hide())}})}}),a(".clear-log").click(function(){a(".debug-log-textarea").val(""),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_clear_log",nonce:wpmdb_data.nonces.clear_log},error:function(){alert(wpmdb_strings.clear_log_problem)},success:function(){}})}),a(".multiselect-select-all").click(function(){var b=a(this).parents(".select-wrap").children(".multiselect");a("option",b).prop("selected",1),a(b).focus().trigger("change")}),a(".multiselect-deselect-all").click(function(){var b=a(this).parents(".select-wrap").children(".multiselect");a("option",b).removeAttr("selected"),a(b).focus().trigger("change")}),a(".multiselect-invert-selection").click(function(){var b=a(this).parents(".select-wrap").children(".multiselect");a("option",b).each(function(){a(this).attr("selected",!a(this).attr("selected"))}),a(b).focus().trigger("change")}),a(".option-group input[type=radio]").change(function(){var b=a(this).closest(".option-group");a("ul",b).hide();var c=a(this).closest("li");a("ul",c).show()}),a(".option-group").each(function(){a(".option-group input[type=radio]").each(function(){if(a(this).is(":checked")){var b=a(this).closest("li");a("ul",b).show()}})}),a(".header-expand-collapse").click(function(){a(".expand-collapse-arrow",this).hasClass("collapsed")?(a(".expand-collapse-arrow",this).removeClass("collapsed"),a(this).next().show()):(a(".expand-collapse-arrow",this).addClass("collapsed"),a(this).next().hide())}),a(".checkbox-label input[type=checkbox]").change(function(){a(this).is(":checked")?a(this).parent().next().show():a(this).parent().next().hide()}),a("#save-migration-profile").change(function(){a(this).is(":checked")?(a(".save-settings-button").show(),a(".migrate-db .button-primary").val(wpmdb_strings.migrate_db_save)):(a(".save-settings-button").hide(),a(".migrate-db .button-primary").val(wpmdb_strings.migrate_db))}),a(".create-new-profile").focus(function(){a("#create_new").prop("checked",!0) }),a("#save-migration-profile").is(":checked")&&(a(".save-settings-button").show(),a(".migrate-db .button-primary").val(wpmdb_strings.migrate_db_save)),a(".checkbox-label input[type=checkbox]").each(function(){a(this).is(":checked")&&a(this).parent().next().show()}),a(".migrate-db-button").click(function(c){function e(b,c){var d=0,e=JSON.parse(JSON.stringify(c));a.each(b,function(a,b){d+=parseInt(e[b])});var f=0,g=0,h=[];a.each(b,function(a,b){var c=Math.round(e[b]/d*100);h[b]=c,c>f&&(f=c),g+=c});var i="",j=100-g;a.each(b,function(b,c){var d=h[c];0!==j&&d===f&&(d+=j,j=0),a(".progress-tables").append('
    '+c+"
    "),a(".progress-tables-hover-boxes").append('
    '),i=c}),a(".progress-tables",".progress-wrapper-primary").find(".progress-chunk").each(function(c){function d(b){a("span",b).innerWidth()>a(b).width()&&a("span",b).hide()}1>a(this).width()&&(a(this).hide(),a(".progress-chunk-hover[data-table="+b[c]+"]").hide(),e[i]=Number(e[i]),e[i]+=Number(e[b[c]]),e[b[c]]=0);var f=this;setTimeout(function(){d(f)},0)});var k=[e,d];return k}if(a(this).blur(),c.preventDefault(),b.migration_state_id="",!1!==a.wpmdb.apply_filters("wpmdb_migration_profile_ready",!0)){if(a("#migrate-selected").is(":checked")&&null===a("#select-tables").val())return void alert(wpmdb_strings.please_select_one_table);if("savefile"!==wpmdb_migration_type()&&a("#backup-manual-select").is(":checked")&&null===a("#select-backup").val())return void alert(wpmdb_strings.please_select_one_table_backup);var f=!1,h=!1;if(a("#new-url").length&&!a("#new-url").val()&&(a("#new-url-missing-warning").show(),a("#new-url").focus(),a("html,body").scrollTop(0),f=!0),a("#new-path").length&&!a("#new-path").val()&&(a("#new-path-missing-warning").show(),!1===f&&(a("#new-path").focus(),a("html,body").scrollTop(0)),h=!0),!0!==f&&!0!==h){a("#save-migration-profile").is(":checked")&&ib(),y=a("#migrate-form").serialize();var i=a(document).height();a("body").append('
    '),a("#overlay").height(i).css({position:"fixed",top:0,left:0,width:"100%","z-index":99999,display:"none"});var j=ub.clone();v=wpmdb_migration_type(),z="backup","savefile"===v&&(z="migrate"),!1===a("#create-backup").is(":checked")&&(z="migrate");var k=(a("input[name=table_migrate_option]:checked").val(),a.trim(a(".pull-push-connection-info").val()).split("\n")),l="";w=k[0],x=k[1];var n="";a("#overlay").after(j),B=wpmdb_strings.exporting_complete,"savefile"===v?n=wpmdb_strings.exporting_please_wait:(n=m(w,v,"migrating"),B=m(w,v,"completed")),a(".progress-title").html(n),a("#overlay").show();var o=a("input[name=backup_option]:checked").val(),p=a("input[name=table_migrate_option]:checked").val(),q="";"backup"===z?("migrate_only_with_prefix"===p&&"backup_selected"===o&&(o="backup_only_with_prefix"),"push"===v?(l=b.common.connection_data.table_rows,"backup_only_with_prefix"===o?S=b.common.connection_data.prefixed_tables:"backup_selected"===o?(q=a("#select-tables").val(),S=g(q,b.common.connection_data.tables)):"backup_manual_select"===o&&(S=a("#select-backup").val())):(l=wpmdb_data.this_table_rows,"backup_only_with_prefix"===o?S=wpmdb_data.this_prefixed_tables:"backup_selected"===o?(q=a("#select-tables").val(),S=g(q,wpmdb_data.this_tables)):"backup_manual_select"===o&&(S=a("#select-backup").val()))):(S=t(null,null),l="push"===v||"savefile"===v?wpmdb_data.this_table_rows:b.common.connection_data.table_rows);var r=e(S,l);l=r[0];var s=r[1];a(".progress-title").after('');var u=a(".progress-content").outerHeight();a(".progress-content").css("top","-"+u+"px").show().animate({top:"0px"}),d(),P=!0;var A={action:"wpmdb_initiate_migration",intent:v,url:w,key:x,form_data:y,stage:z,nonce:wpmdb_data.nonces.initiate_migration};"savefile"!==v&&(A.temp_prefix=b.common.connection_data.temp_prefix),E=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:A,error:function(c,d,e){a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(lb(c.responseText,"(#112)",c)),a(".progress-text").addClass("migration-error"),console.log(c),console.log(d),console.log(e),E=!1,b.common.migration_error=!0,b.functions.migration_complete_events()},success:function(c){if(E=!1,"undefined"!=typeof c&&"undefined"!=typeof c.wpmdb_error&&1===c.wpmdb_error)return b.common.migration_error=!0,b.functions.migration_complete_events(),a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").addClass("migration-error"),void a(".progress-text").html(c.body);b.migration_state_id=c.migration_state_id;var d=0,f=0;Y=0;var g=0,h=0,i=0,j=0;bb=0,"savefile"!==v&&"undefined"!=typeof b.common.connection_data&&"undefined"!=typeof b.common.connection_data.delay_between_requests&&(bb=Math.max(parseInt(wpmdb_data.delay_between_requests),parseInt(b.common.connection_data.delay_between_requests))),b.functions.migrate_table_recursive=function(c,k){if(d>=S.length){if("backup"!==z)return a(".progress-label").removeClass("label-visible"),b.common.hooks=a.wpmdb.apply_filters("wpmdb_before_migration_complete_hooks",b.common.hooks),b.common.hooks.push(b.functions.migration_complete),b.common.hooks.push(b.functions.wpmdb_flush),b.common.hooks=a.wpmdb.apply_filters("wpmdb_after_migration_complete_hooks",b.common.hooks),b.common.hooks.push(b.functions.migration_complete_events),b.common.next_step_in_migration={fn:wpmdb_call_next_hook},void b.functions.execute_next_step();z="migrate",d=0,f=0,Y=0,a(".progress-bar").width("0px"),S=t(null,null),l="push"===v||"savefile"===v?wpmdb_data.this_table_rows:b.common.connection_data.table_rows,a(".progress-tables").empty(),a(".progress-tables-hover-boxes").empty(),r=e(S,l),l=r[0],s=r[1]}a(".progress-text").html("backup"===z?Y+"% - "+wpmdb_strings.backing_up+' "'+S[d]+'"':Y+"% - "+wpmdb_strings.migrating+' "'+S[d]+'"');var m=0;d===S.length-1&&(m=1);var n=0;"savefile"!==v&&1===parseInt(b.common.connection_data.gzip)&&(n=1);var o={action:"wpmdb_migrate_table",migration_state_id:b.migration_state_id,table:S[d],stage:z,current_row:c,last_table:m,primary_keys:k,gzip:n,nonce:wpmdb_data.nonces.migrate_table};"savefile"!==v&&(o.bottleneck=b.common.connection_data.bottleneck,o.prefix=b.common.connection_data.prefix),b.common.connection_data&&b.common.connection_data.path_current_site&&b.common.connection_data.domain&&(o.path_current_site=b.common.connection_data.path_current_site,o.domain_current_site=b.common.connection_data.domain),E=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,timeout:0,data:o,error:function(c,e,f){a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(wpmdb_strings.table_process_problem+" "+S[d]),a(".progress-text").append("

    "+wpmdb_strings.status+": "+c.status+" "+c.statusText+"

    "+wpmdb_strings.response+":
    "+c.responseText),a(".progress-text").addClass("migration-error"),E=!1,console.log(c),console.log(e),console.log(f),b.common.migration_error=!0,b.functions.migration_complete_events()},success:function(c){E=!1,c=a.trim(c);var e=wpmdb_parse_json(c);return!1===e||null===e?(a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(""===c||null===c?wpmdb_strings.table_process_problem_empty_response+" "+S[d]:lb(c,null,null)),a(".progress-text").addClass("migration-error"),b.common.migration_error=!0,void b.functions.migration_complete_events()):"undefined"!=typeof e.wpmdb_error&&1===e.wpmdb_error?(a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").addClass("migration-error"),a(".progress-text").html(e.body),b.common.migration_error=!0,void b.functions.migration_complete_events()):(1===m&&"savefile"===v&&("undefined"!=typeof e.dump_filename&&(Q=e.dump_filename),"undefined"!=typeof e.dump_path&&(R=e.dump_path)),-1===e.current_row||"-1"===e.current_row?(f-=j,j=0,i=0,f+=parseInt(l[S[d]]),d++,e.current_row="",e.primary_keys=""):(h=parseInt(e.current_row),g=h-i,i=h,f+=g,j+=g),Y=Math.floor(f/s*100),a(".progress-bar").width(Y+"%"),b.common.next_step_in_migration={fn:b.functions.migrate_table_recursive,args:[e.current_row,e.primary_keys]},void b.functions.execute_next_step())}})},b.common.next_step_in_migration={fn:b.functions.migrate_table_recursive,args:["-1",""]},b.functions.execute_next_step()}})}}}),b.functions.migration_complete_events=function(){!1===b.common.migration_error&&(""===b.common.non_fatal_errors?("savefile"!==v&&!0===a("#save_computer").is(":checked")&&a(".progress-text").css("visibility","hidden"),a(".progress-title").html(B).append('
    ')):(a(".progress-text").html(b.common.non_fatal_errors),a(".progress-text").addClass("migration-error"),a(".progress-title").html(wpmdb_strings.completed_with_some_errors)),a(".progress-bar-wrapper").hide()),a(".migration-controls").hide(),b.common.hooks=[],b.common.call_stack=[],b.common.migration_error=!1,P=!1,O=!0,T=!1,Z=!1,E=!1,b.common.non_fatal_errors="",a(".progress-label").remove(),a(".migration-progress-ajax-spinner").remove(),a(".close-progress-content").show(),a("#overlay").css("cursor","pointer"),clearInterval(A)},b.functions.migration_complete=function(){if(a(".migration-controls").fadeOut(),"savefile"===v){P=!1;var c=wpmdb_strings.migration_complete;if(a("#save_computer").is(":checked")){var d=wpmdb_data.this_download_url+encodeURIComponent(Q);a("#gzip_file").is(":checked")&&(d+="&gzip=1"),window.location=d}else c=wpmdb_strings.completed_dump_located_at+" "+R;!1===b.common.migration_error&&(a(".progress-text").html(c),b.functions.migration_complete_events(),a(".progress-title").html(B))}else a(".progress-text").html(wpmdb_strings.finalizing_migration),E=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_finalize_migration",migration_state_id:b.migration_state_id,prefix:b.common.connection_data.prefix,tables:S.join(","),nonce:wpmdb_data.nonces.finalize_migration},error:function(c,d,e){E=!1,a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(wpmdb_strings.finalize_tables_problem),a(".progress-text").addClass("migration-error"),alert(c+" : "+d+" : "+e),b.common.migration_error=!0,b.functions.migration_complete_events()},success:function(c){return E=!1,"1"!==a.trim(c)?(a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(c),a(".progress-text").addClass("migration-error"),b.common.migration_error=!0,void b.functions.migration_complete_events()):(b.common.next_step_in_migration={fn:wpmdb_call_next_hook},void b.functions.execute_next_step())}})},b.functions.wpmdb_flush=function(){"savefile"!==v&&(a(".progress-text").html(wpmdb_strings.flushing),E=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_flush",migration_state_id:b.migration_state_id,nonce:wpmdb_data.nonces.flush},error:function(c,d,e){E=!1,a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(wpmdb_strings.flush_problem),a(".progress-text").addClass("migration-error"),alert(c+" : "+d+" : "+e),b.common.migration_error=!0,b.functions.migration_complete_events()},success:function(c){return E=!1,"1"!==a.trim(c)?(a(".progress-title").html(wpmdb_strings.migration_failed),a(".progress-text").html(c),a(".progress-text").addClass("migration-error"),b.common.migration_error=!0,void b.functions.migration_complete_events()):(b.common.next_step_in_migration={fn:wpmdb_call_next_hook},void b.functions.execute_next_step())}}))},a("body").on("click",".close-progress-content-button",function(){hb()}),a("body").on("click","#overlay",function(){!0===O&&hb()}),a(".save-settings-button").click(function(b){return b.preventDefault(),""===a.trim(a(".create-new-profile").val())&&a("#create_new").is(":checked")?(alert(wpmdb_strings.enter_name_for_profile),void a(".create-new-profile").focus()):void ib()}),a("body").on("mousemove",".progress-chunk-hover",function(b){var c=b.pageX,d=a(".progress-bar-wrapper").offset(),e=a(".progress-label").outerWidth()/2;c=c-d.left-e,a(".progress-label").css("left",c+"px"),a(".progress-label").html(a(this).attr("data-table"))}),a("body").on("mouseenter mouseleave",".progress-chunk-hover",function(b){"mouseenter"===b.type?a(".progress-label").addClass("label-visible"):a(".progress-label").removeClass("label-visible")});var Bb=a(".connection-info-wrapper");jb(),a(".migrate-selection.option-group input[type=radio]").change(function(){jb(),C&&kb()}),"pull"!==wpmdb_migration_type()&&"push"!==wpmdb_migration_type()||C||(a(".step-two").hide(),a(".connection-status").show()),a(".general-helper").click(function(b){b.preventDefault();var c=a(this),d=a(this).next();a(".helper-message").not(d).hide();var e=c.position();d.css(d.hasClass("bottom")?{left:e.left-d.width()/2+"px",top:e.top+c.height()+9+"px"}:{left:e.left+c.width()+9+"px",top:e.top+c.height()/2-18+"px"}),d.toggle(),b.stopPropagation()}),a("body").click(function(){a(".helper-message").hide()}),a(".helper-message").click(function(a){a.stopPropagation()}),a("body").on("click",".show-errors-toggle",function(b){b.preventDefault(),a(this).next(".migration-php-errors").toggle()}),a(".nav-tab").click(function(){var b=a(this).attr("data-div-name");b=b.replace("-tab",""),window.location.hash=b,nb(b,!1)}),a("body").on("click",'a[href^="#"]',function(b){var c=a(b.target).attr("href"),d=c.substr(1);if(d){var e=a("."+d);1===e.length&&(e.trigger("click"),b.preventDefault())}}),a("body").on("click",".add-row",function(){a(this).parents("tr").before(a(".original-repeatable-field").clone().removeClass("original-repeatable-field"))}),a("body").on("click",".replace-remove-row",function(){a(this).parents("tr").remove(),2>=a(".replace-row").length&&a(".no-replaces-message").show();var b=a(this).prev().attr("id");("new-url"===b||"new-path"===b)&&a("#"+b+"-missing-warning").hide()}),a("body").on("change","#new-url",function(){a("#new-url-missing-warning").hide()}).on("change","#new-path",function(){a("#new-path-missing-warning").hide()}),a("body").on("click",".arrow-col",function(){var b=this,c=a(b).prev("td").find("input").val(),d=a(b).next("td").find("input");d.val(c),"new-url"===d.prop("id")?a("#new-url-missing-warning").hide():"new-path"===d.prop("id")&&a("#new-path-missing-warning").hide()}),a(".add-replace").click(function(){a(".replace-fields").prepend(a(".original-repeatable-field").clone().removeClass("original-repeatable-field")),a(".no-replaces-message").hide()}),a("#find-and-replace-sort tbody").sortable({items:"> tr:not(.pin)",handle:"td:first",start:function(){a(".sort-handle").css("cursor","-webkit-grabbing"),a(".sort-handle").css("cursor","-moz-grabbing")},stop:function(){a(".sort-handle").css("cursor","-webkit-grab"),a(".sort-handle").css("cursor","-moz-grab")}});var Cb="";window.location.hash&&(Cb=window.location.hash.substring(1),nb(Cb,!1)),""!==h("install-plugin")&&(Cb="addons",K=!0,nb(Cb,!0)),a(".notice-link").click(function(b){b.preventDefault(),a(this).closest(".inline-message").hide(),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_process_notice_link",nonce:wpmdb_data.nonces.process_notice_link,notice:a(this).data("notice"),type:a(this).data("type"),reminder:a(this).data("reminder")}})}),a(".reset-api-key").click(function(){var b=confirm(wpmdb_strings.reset_api_key);b&&!G&&(G=!0,a(".reset-api-key").after(''),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_reset_api_key",nonce:wpmdb_data.nonces.reset_api_key},error:function(){alert(wpmdb_strings.reset_api_key_problem),a(".reset-api-key-ajax-spinner").remove(),G=!1},success:function(b){a(".reset-api-key-ajax-spinner").remove(),G=!1,a(".connection-info").html(b),wpmdb_data.connection_info=a.trim(b).split("\n")}}))}),a("input.multiselect-toggle").change(function(){a(this).parents(".expandable-content").children(".select-wrap").toggle()}),a(".show-multiselect").each(function(){a(this).is(":checked")&&(a(this).parents(".option-section").children(".header-expand-collapse").children(".expand-collapse-arrow").removeClass("collapsed"),a(this).parents(".expandable-content").show(),a(this).parents(".expandable-content").children(".select-wrap").toggle())}),a("input[name=backup_option]").change(function(){a(".backup-tables-wrap").hide(),"backup_manual_select"===a(this).val()&&a(".backup-tables-wrap").show()}),a("#backup-manual-select").is(":checked")&&a(".backup-tables-wrap").show(),a(".plugin-compatibility-save").click(function(){if(!I){a(this).addClass("disabled");var b=a("#selected-plugins");a(b).attr("disabled","disabled"),I=!0,a(this).after(''),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_blacklist_plugins",blacklist_plugins:a(b).val()},error:function(c){alert(wpmdb_strings.blacklist_problem+"\r\n\r\n"+wpmdb_strings.status+" "+c.status+" "+c.statusText+"\r\n\r\n"+wpmdb_strings.response+"\r\n"+c.responseText),a(b).removeAttr("disabled"),a(".plugin-compatibility-save").removeClass("disabled"),I=!1,a(".plugin-compatibility-spinner").remove(),a(".plugin-compatibility-success-msg").show().fadeOut(2e3)},success:function(c){""!==a.trim(c)&&alert(c),a(b).removeAttr("disabled"),a(".plugin-compatibility-save").removeClass("disabled"),I=!1,a(".plugin-compatibility-spinner").remove(),a(".plugin-compatibility-success-msg").show().fadeOut(2e3)}})}}),a("body").on("click",".delete-profile",function(){var b=a(this).next().clone();a("input",b).remove(),b=a.trim(a(b).html());var c=confirm(wpmdb_strings.remove_profile.replace("{{profile}}",b));if(c){var d=a(this).parent();if(d.find("input:checked").length){var e=d.siblings().last();if(e.find("input[type=radio]").prop("checked","checked"),e.find("input[type=text]").focus(),a("#migrate-form .crumbs .crumb:last").text("New Profile"),"function"==typeof window.history.pushState){var f=window.location.href.replace("#migrate","").replace(/&wpmdb-profile=-?\d+/,"")+"&wpmdb-profile=-1";window.history.pushState({updated_profile_id:-1},null,f)}}d.fadeOut(500),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_delete_migration_profile",profile_id:a(this).attr("data-profile-id"),nonce:wpmdb_data.nonces.delete_migration_profile},error:function(){alert(wpmdb_strings.remove_profile_problem)},success:function(a){"-1"===a&&alert(wpmdb_strings.remove_profile_not_found)}})}}),a(".main-list-delete-profile-link").click(function(){var b=a(this).prev().html(),c=confirm(wpmdb_strings.remove_profile.replace("{{profile}}",b));c&&(a(this).parent().fadeOut(500),a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_delete_migration_profile",profile_id:a(this).attr("data-profile-id"),nonce:wpmdb_data.nonces.delete_migration_profile},error:function(){alert(wpmdb_strings.remove_profile_problem)}}))}),a("body").on("click",".temp-disabled",function(){var b=confirm(wpmdb_strings.change_connection_info);b&&(a(".ssl-notice").hide(),a(".different-plugin-version-notice").hide(),a(".migrate-db-button").show(),a(".temp-disabled").removeAttr("readonly"),a(".temp-disabled").removeClass("temp-disabled"),a(".connect-button").show(),a(".step-two").hide(),a(".connection-status").show().html(wpmdb_strings.enter_connection_info),C=!1)}),a(".settings-tab input[type=checkbox]").change(function(){if("plugin-compatibility"!==a(this).attr("id")){var b=a(this).is(":checked"),c=a(this).attr("id");a(this).parent().append(fb);var d=a(this).parent();a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdb_save_setting",checked:b,setting:c,nonce:wpmdb_data.nonces.save_setting},error:function(){alert(wpmdb_strings.save_settings_problem),a(".ajax-spinner").remove()},success:function(){a(".ajax-spinner").remove(),a(d).append(''+wpmdb_strings.saved+""),a(".ajax-success-msg").fadeOut(2e3,function(){a(this).remove()})}})}}),a(".migrate-form").submit(function(a){a.preventDefault()}),a(".connect-button").click(function(b){b.preventDefault(),a(this).blur(),ob()}),a(".pull-push-connection-info").bind("paste",function(){setTimeout(function(){ob()},0)}),a("body").on("click",".try-again",function(){ob()}),a("body").on("click",".try-http",function(){var b=a.trim(a(".pull-push-connection-info").val()).split("\n"),c=b[0].replace("https","http"),d=c+"\n"+b[1];a(".pull-push-connection-info").val(d),ob()}),a(".create-new-profile").change(function(){J=!0}),a("body").on("click",".temporarily-disable-ssl",function(){var b="";window.location.hash&&(b=window.location.hash.substring(1)),a(this).attr("href",a(this).attr("href")+"&hash="+b)}),a("body").on("click",".pause-resume",function(a){r(a)}),a("body").on("click",".cancel",function(a){pb(a)}),a(".enter-licence").click(function(){a(".settings").click(),a(".licence-input").focus()}),b.functions.execute_next_step=function(){if(bb>0&&!1===ab)return void setTimeout(function(){ab=!0,b.functions.execute_next_step()},bb);if(ab=!1,!0===T)return a(".migration-progress-ajax-spinner").hide(),clearInterval(A),a(".progress-text").html(wpmdb_strings.paused),a("body").on("click",".pause-resume",function(a){r(a)}),a("body").on("click",".cancel",function(a){pb(a)}),void a(".pause-resume").html(wpmdb_strings.resume);if(!0===Z){v=wpmdb_migration_type();var c;"savefile"===v?c=wpmdb_strings.removing_local_sql:"pull"===v?c="backup"===z?wpmdb_strings.removing_local_backup:wpmdb_strings.removing_local_temp_tables:"push"===v&&(c="backup"===z?wpmdb_strings.removing_remote_sql:wpmdb_strings.removing_remote_temp_tables),a(".progress-text").html(c);var d={action:"wpmdb_cancel_migration",migration_state_id:b.migration_state_id};E=!0,a.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:d,error:function(c,d,e){a(".progress-title").html(wpmdb_strings.migration_cancellation_failed),a(".progress-text").html(wpmdb_strings.manually_remove_temp_files),a(".progress-text").append("

    "+wpmdb_strings.status+": "+c.status+" "+c.statusText+"

    "+wpmdb_strings.response+":
    "+c.responseText),a(".progress-text").addClass("migration-error"),console.log(c),console.log(d),console.log(e),E=!1,b.common.migration_error=!0,b.functions.migration_complete_events()},success:function(c){return E=!1,c=a.trim(c),"push"===v&&"1"!==c||"push"!==v&&""!==c?(a(".progress-title").html(wpmdb_strings.migration_cancellation_failed),a(".progress-text").html(c),a(".progress-text").addClass("migration-error"),b.common.migration_error=!0,void b.functions.migration_complete_events()):(B=wpmdb_strings.migration_cancelled,a(".progress-text").hide(),void b.functions.migration_complete_events())}})}else b.common.next_step_in_migration.fn.apply(null,b.common.next_step_in_migration.args)},a("body").on("click",".copy-licence-to-remote-site",function(){a(".connection-status").html(wpmdb_strings.copying_license),a(".connection-status").removeClass("notification-message error-notice migration-error"),a(".connection-status").append(fb);var b=a.trim(a(".pull-push-connection-info").val()).split("\n");E=!0,o(),a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_copy_licence_to_remote_site",url:b[0],key:b[1],nonce:wpmdb_data.nonces.copy_licence_to_remote_site},error:function(b){a(".connection-status").html(lb(b.responseText,"(#143)",b)),a(".connection-status").addClass("notification-message error-notice migration-error"),a(".ajax-spinner").remove(),E=!1,p()},success:function(b){return a(".ajax-spinner").remove(),E=!1,p(),"undefined"!=typeof b.wpmdb_error&&1===b.wpmdb_error?(a(".connection-status").html(b.body),a(".connection-status").addClass("notification-message error-notice migration-error"),void(b.body.indexOf("401 Unauthorized")>-1&&a(".basic-access-auth-wrapper").show())):void ob()}})}),a("body").on("click",".reactivate-licence",function(){E=!0,a(".invalid-licence").empty().html(wpmdb_strings.attempting_to_activate_licence),a(".invalid-licence").append(fb),a.ajax({url:ajaxurl,type:"POST",dataType:"json",cache:!1,data:{action:"wpmdb_reactivate_licence",nonce:wpmdb_data.nonces.reactivate_licence},error:function(b){a(".invalid-licence").html(wpmdb_strings.activate_licence_problem),a(".invalid-licence").append("

    "+wpmdb_strings.status+": "+b.status+" "+b.statusText+"

    "+wpmdb_strings.response+"
    "+b.responseText),a(".ajax-spinner").remove(),E=!1},success:function(b){return a(".ajax-spinner").remove(),E=!1,"undefined"!=typeof b.wpmdb_error&&1===b.wpmdb_error?void a(".invalid-licence").html(b.body):"undefined"!=typeof b.wpmdb_dbrains_api_down&&1===b.wpmdb_dbrains_api_down?(a(".invalid-licence").html(wpmdb_strings.temporarily_activated_licence),void a(".invalid-licence").append(b.body)):(a(".invalid-licence").empty().html(wpmdb_strings.licence_reactivated),void location.reload())}})}),a("input[name=table_migrate_option]").change(function(){k(),a.wpmdb.do_action("wpmdb_tables_to_migrate_changed")}),a("body").on("change","#select-tables",function(){k(),a.wpmdb.do_action("wpmdb_tables_to_migrate_changed")}),a.wpmdb.add_filter("wpmdb_get_table_prefix",u),a.wpmdb.add_filter("wpmdb_get_tables_to_migrate",t)})}(jQuery,wpmdb);