Files
amerike/wp-content/plugins/all-in-one-wp-migration/lib/view/assets/javascript/export.min.js
T
2026-10-06 19:11:48 -06:00

1 line
13 KiB
JavaScript

(()=>{var t={11(t,e,o){const a=o(132),n=jQuery,i=function(){const t=this;this.params=[],this.modal=new a,this.modal.onStop=function(e){t.onStop(e)}};i.prototype.setParams=function(t){this.params=Ai1wm.Util.list(t)},i.prototype.start=function(t,e){const o=this;if(0===(e=e||0)&&this.stopExport(!1),this.isExportStopped())return;n(window).on("beforeunload",function(){return ai1wm_locale.stop_exporting_your_website}),this.setStatus({type:"info",message:ai1wm_locale.preparing_to_export});let a=this.params.concat({name:"secret_key",value:ai1wm_export.secret_key});t&&(a=a.concat(Ai1wm.Util.list(t))),n.ajax({url:ai1wm_export.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){o.getStatus()}).done(function(t){t&&o.run(t)}).fail(function(n){const i=1e3*e;try{const t=Ai1wm.Util.json(n.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopExport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_export,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopExport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_export,message:ai1wm_locale.unable_to_start_the_export,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.start.bind(o,t,e),i)})},i.prototype.run=function(t,e){const o=this;e=e||0,this.isExportStopped()||n.ajax({url:ai1wm_export.ajax.url,type:"POST",dataType:"json",data:t,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(t){t&&o.run(t)}).fail(function(a){const n=1e3*e;try{const e=Ai1wm.Util.json(a.responseText);if(e){const a=JSON.parse(e).errors.pop();if(a.message)return o.stopExport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_export,message:a.message,nonce:Ai1wm.Util.findValueByName(t,"storage")})}}catch(t){}if(e>=5)return o.stopExport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_export,message:ai1wm_locale.unable_to_run_the_export,nonce:Ai1wm.Util.findValueByName(t,"storage")});e++,setTimeout(o.run.bind(o,t,e),n)})},i.prototype.clean=function(t,e){const o=this;0===(e=e||0)&&this.stopExport(!0),this.setStatus({type:"info",message:ai1wm_locale.please_wait_stopping_the_export});let a=this.params.concat({name:"secret_key",value:ai1wm_export.secret_key}).concat({name:"priority",value:300}).concat({name:"ai1wm_export_cancel",value:1});t&&(a=a.concat(Ai1wm.Util.list(t))),n.ajax({url:ai1wm_export.ajax.url,type:"POST",dataType:"json",data:a,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(){n(window).off("beforeunload"),o.modal.destroy()}).fail(function(n){const i=1e3*e;try{const t=Ai1wm.Util.json(n.responseText);if(t){const e=JSON.parse(t).errors.pop();if(e.message)return o.stopExport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_export,message:e.message,nonce:Ai1wm.Util.findValueByName(a,"storage")})}}catch(t){}if(e>=5)return o.stopExport(!0),void o.setStatus({type:"error",title:ai1wm_locale.unable_to_export,message:ai1wm_locale.unable_to_stop_the_export,nonce:Ai1wm.Util.findValueByName(a,"storage")});e++,setTimeout(o.clean.bind(o,t,e),i)})},i.prototype.getStatus=function(){const t=this;this.isExportStopped()||(this.statusXhr=n.ajax({url:ai1wm_export.status.url,type:"GET",dataType:"json",cache:!1,dataFilter:function(t){return Ai1wm.Util.json(t)}}).done(function(e){if(e)switch(t.setStatus(e),e.type){case"done":case"error":case"download":return void n(window).off("beforeunload")}setTimeout(t.getStatus.bind(t),3e3)}).fail(function(){setTimeout(t.getStatus.bind(t),3e3)}))},i.prototype.setStatus=function(t){this.modal.render(t)},i.prototype.onStop=function(t){this.clean(t)},i.prototype.stopExport=function(t){try{t&&this.statusXhr&&this.statusXhr.abort()}finally{this.isStopped=t}},i.prototype.isExportStopped=function(){return this.isStopped},t.exports=i},132(t){const e=jQuery,o=function(){const t=this;this.error=function(o){const a=e("<div></div>"),n=e("<section></section>"),i=e("<h1></h1>"),r=e("<p></p>").html(o.message),s=e("<div></div>"),p=e("<span></span>").addClass("ai1wm-title-red").text(o.title),l=e('<button type="button" class="ai1wm-button-red"></button>').on("click",function(){t.destroy()});if(l.append(ai1wm_locale.close_export),s.append(l),i.append(p),n.append(i).append(r),o.nonce){const t=e('<a target="_blank"></a>');t.text(ai1wm_locale.view_error_log_button),t.prop("href",ai1wm_export.storage.url+"/"+ai1wm_export.error_log.pattern.replace("%s",o.nonce)),n.append(e("<div></div>").append(t))}a.append(n).append(s),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.info=function(o){const a=e("<div></div>"),n=e("<section></section>"),i=e("<h1></h1>"),r=e("<p></p>").html(o.message),s=e("<div></div>"),p=e('<span class="ai1wm-loader"></span>'),l=e('<button type="button" class="ai1wm-button-red"></button>').on("click",function(){l.attr("disabled","disabled"),t.onStop()});l.append('<i class="ai1wm-icon-notification"></i> '+ai1wm_locale.stop_export),s.append(l),i.append(p),n.append(i).append(r),a.append(n).append(s),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.done=function(o){const a=e("<div></div>"),n=e("<section></section>"),i=e("<h1></h1>"),r=e("<p></p>").html(o.message),s=e("<div></div>"),p=e("<span></span>").addClass("ai1wm-title-green").text(o.title),l=e('<button type="button" class="ai1wm-button-red"></button>').on("click",function(){t.destroy()});l.append(ai1wm_locale.close_export),s.append(l),i.append(p),n.append(i).append(r),a.append(n).append(s),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.download=function(o){const a=e("<div></div>"),n=e("<section></section>"),i=e("<p></p>").html(o.message),r=e("<div></div>"),s=e('<button type="button" class="ai1wm-button-red"></button>').on("click",function(){t.destroy()}),p=e(".ai1wm-menu-count");p.text(+p.text()+1),p.text()>1?p.prop("title",ai1wm_locale.backups_count_plural.replace("%d",p.text())):(p.removeClass("ai1wm-menu-hide"),p.prop("title",ai1wm_locale.backups_count_singular.replace("%d",p.text()))),s.append(ai1wm_locale.close_export),r.append(s),n.append(i),a.append(n).append(r),t.modal.html(a).show(),t.modal.trigger("focus"),t.overlay.show()},this.overlay=e('<div class="ai1wm-overlay"></div>'),this.modal=e('<div class="ai1wm-modal-container" role="dialog" tabindex="-1"></div>'),e("body").append(this.overlay).append(this.modal)};o.prototype.render=function(t){switch(e(document).trigger("ai1wm-export-status",t),t.type){case"error":this.error(t);break;case"info":this.info(t);break;case"done":this.done(t);break;case"download":this.download(t)}},o.prototype.destroy=function(){this.modal.hide(),this.overlay.hide()},t.exports=o},827(){var t;(t=jQuery).fn.ai1wm_find_replace=function(){return t(this).on("click",function(e){e.preventDefault();const o=t("#ai1wm-queries > li:first").clone();o.find("input").val(""),o.find(".ai1wm-query-find-text").html("&lt;text&gt;"),o.find(".ai1wm-query-replace-text").html("&lt;another-text&gt;"),t("#ai1wm-queries > li").removeClass("ai1wm-open"),t(o).addClass("ai1wm-open"),t("#ai1wm-queries").append(o),t(o).ai1wm_query(),t(o).find("p:first").on("click",function(){t(this).parent().toggleClass("ai1wm-open")})}),this}},157(){var t;(t=jQuery).fn.ai1wm_query=function(){const e=t(this).find("input.ai1wm-query-find-input"),o=t(this).find("input.ai1wm-query-replace-input"),a=t(this).find("small.ai1wm-query-find-text"),n=t(this).find("small.ai1wm-query-replace-text");return e.on("change paste input keypress keydown keyup",function(){const e=t(this).val().length>0?t(this).val():"<text>";a.text(e)}),o.on("change paste input keypress keydown keyup",function(){const e=t(this).val().length>0?t(this).val():"<another-text>";n.text(e)}),this}},213(t,e){var o,a;void 0===(a="function"==typeof(o=function(){"use strict";function e(t,e,o){var a=new XMLHttpRequest;a.open("GET",t),a.responseType="blob",a.onload=function(){r(a.response,e,o)},a.onerror=function(){console.error("could not download file")},a.send()}function o(t){var e=new XMLHttpRequest;e.open("HEAD",t,!1);try{e.send()}catch(t){}return 200<=e.status&&299>=e.status}function a(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(o){var e=document.createEvent("MouseEvents");e.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(e)}}var n="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof globalThis&&globalThis.global===globalThis?globalThis:void 0,i=n.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),r=n.saveAs||("object"!=typeof window||window!==n?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(t,i,r){var s=n.URL||n.webkitURL,p=document.createElement("a");i=i||t.name||"download",p.download=i,p.rel="noopener","string"==typeof t?(p.href=t,p.origin===location.origin?a(p):o(p.href)?e(t,i,r):a(p,p.target="_blank")):(p.href=s.createObjectURL(t),setTimeout(function(){s.revokeObjectURL(p.href)},4e4),setTimeout(function(){a(p)},0))}:"msSaveOrOpenBlob"in navigator?function(t,n,i){if(n=n||t.name||"download","string"!=typeof t)navigator.msSaveOrOpenBlob(function(t,e){return void 0===e?e={autoBom:!1}:"object"!=typeof e&&(console.warn("Deprecated: Expected third argument to be a object"),e={autoBom:!e}),e.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(t.type)?new Blob(["\ufeff",t],{type:t.type}):t}(t,i),n);else if(o(t))e(t,n,i);else{var r=document.createElement("a");r.href=t,r.target="_blank",setTimeout(function(){a(r)})}}:function(t,o,a,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof t)return e(t,o,a);var s="application/octet-stream"===t.type,p=/constructor/i.test(n.HTMLElement)||n.safari,l=/CriOS\/[\d]+/.test(navigator.userAgent);if((l||s&&p||i)&&"undefined"!=typeof FileReader){var c=new FileReader;c.onloadend=function(){var t=c.result;t=l?t:t.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=t:location=t,r=null},c.readAsDataURL(t)}else{var u=n.URL||n.webkitURL,d=u.createObjectURL(t);r?r.location=d:location.href=d,r=null,setTimeout(function(){u.revokeObjectURL(d)},4e4)}});n.saveAs=r.saveAs=r,t.exports=r})?o.apply(e,[]):o)||(t.exports=a)}},e={};function o(a){var n=e[a];if(void 0!==n)return n.exports;var i=e[a]={exports:{}};return t[a].call(i.exports,i,i.exports,o),i.exports}o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var a in e)o.o(e,a)&&!o.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=o(213);const e=o(157),a=o(827),n=o(11);jQuery(document).ready(function(e){const o=new n;e("#ai1wm-export-file").on("click",function(t){if(e("#ai1wm-encrypt-backups").is(":checked")){const t=e("#ai1wm-backup-encrypt-password"),o=e("#ai1wm-backup-encrypt-password-confirmation");if(!t.val().length)return t.parent().addClass("ai1wm-has-error"),t.focus(),!1;if(t.val()!==o.val())return o.parent().addClass("ai1wm-has-error"),o.focus(),!1}const a=Ai1wm.Util.random(12),n=Ai1wm.Util.form("#ai1wm-export-form").concat({name:"storage",value:a}).concat({name:"file",value:1});o.setParams(n),o.start(),t.preventDefault()}),e(document).on("click",".ai1wm-modal-container .ai1wm-direct-download",function(o){o.preventDefault();const a=e(this).prop("download"),n={secret_key:ai1wm_export.secret_key,archive:a},i=new XMLHttpRequest;i.addEventListener("readystatechange",function(){2===i.readyState&&200===i.status||3===i.readyState||4===i.readyState&&(i.status<400?(0,t.saveAs)(i.response,Ai1wm.Util.basename(a)):Ai1wm.Util.handleAuthError(i)||alert(ai1wm_locale.archive_browser_download_error))}),i.responseType="blob";const r=new FormData;for(const t in n)r.append(t,n[t]);i.open("post",ai1wm_export.download_backup.url),i.send(r)}),e(".ai1wm-accordion > .ai1wm-title").on("click",function(){e(this).parent().toggleClass("ai1wm-active")}),e("#ai1wm-add-new-replace-button").ai1wm_find_replace(),e(".ai1wm-expandable > p:first, .ai1wm-expandable > h4:first, .ai1wm-expandable > div.ai1wm-button-main").on("click",function(){e(this).parent().toggleClass("ai1wm-open")}),e(".ai1wm-query").ai1wm_query(),e(".ai1wm-toggle-password-visibility").on("click",function(){return e(this).toggleClass("ai1wm-icon-eye ai1wm-icon-eye-blocked"),e(this).prev().prop("type",function(t,e){return"text"===e?"password":"text"}),!1}),e("#ai1wm-encrypt-backups").on("click",function(){e(".ai1wm-encrypt-backups-passwords-toggle").toggle()}),e("#ai1wm-backup-encrypt-password").on("keyup",function(){const t=e(this),o=e("#ai1wm-backup-encrypt-password-confirmation");t.val()!==o.val()&&o.parent().addClass("ai1wm-has-error"),t.val().length&&t.parent().removeClass("ai1wm-has-error")}),e("#ai1wm-backup-encrypt-password-confirmation").on("keyup",function(){const t=e(this);e("#ai1wm-backup-encrypt-password").val()!==t.val()?t.parent().addClass("ai1wm-has-error"):t.parent().removeClass("ai1wm-has-error")})}),globalThis.Ai1wm=jQuery.extend({},globalThis.Ai1wm,{Query:e,FindReplace:a,Export:n})})()})();