Current File : /home/pacjaorg/public_html/copp/copp/wp-content/plugins/backwpup/assets/js/backup-downloader.min.js |
window.BWU=window.BWU||{},function(i,s,n,e,t){var r,o,c;function a(){this.closeEventSource(),this.cleanUi(),this.decrypter&&this.decrypter.destruct()}function d(e){e&&(e.style.display="none")}function h(e){e&&(e.style.display="block")}e?"EventSource"in window?(c={showWaitingMessage:function(){h(this.waitingUi)},showProgressUi:function(){h(this.progressUi)},showSuccessMsg:function(){h(this.successUi)},hideWaitingMessage:function(){d(this.waitingUi)},hideProgressUi:function(){d(this.progressUi)},hideNotice:function(){n.Functions.removeMessages(this.containerUi)},hideSuccessMsg:function(){d(this.successUi)},cleanUi:function(){this.hideWaitingMessage(),this.hideProgressUi(),this.hideNotice(),this.hideSuccessMsg(),this.decrypter&&this.decrypter.hide()},done:function(){this.showSuccessMsg(),window.location.href=this.currentTarget.dataset.url,setTimeout(t,3e3)},onMessage:function(e){var t;try{switch((t=JSON.parse(e.data)).state){case n.States.DOWNLOADING:this.cleanUi(),this.showProgressUi(),i("#progresssteps").css({width:t.download_percent+"%"}).text(t.download_percent+"%");break;case n.States.DONE:this.done(t.message)}}catch(e){n.Functions.printMessageError(e.message,this.containerUi),a.call(this)}},onError:function(e){var t=JSON.parse(e.data);switch(this.closeEventSource(),t.message){case n.States.NEED_DECRYPTION_KEY:this.cleanUi(),this.decrypter&&this.decrypter.needDecryption(t.status);break;default:n.Functions.printMessageError(t.message,this.containerUi),a.call(this)}return this},initializeEventSource:function(){s.isUndefined(this.eventSource)&&(this.eventSource=new EventSource(e+"?action=download_backup_file&destination="+this.currentTarget.dataset.destination+"&jobid="+this.currentTarget.dataset.jobid+"&file="+this.currentTarget.dataset.file+"&local_file="+this.currentTarget.dataset.localFile+"&backwpup_action_nonce="+this.currentTarget.dataset.nonce),this.eventSource.onmessage=this.onMessage,this.eventSource.addEventListener("log",this.onError))},closeEventSource:function(){s.isUndefined(this.eventSource)||(this.eventSource.close(),this.eventSource=void 0)},startDownload:function(e){e.preventDefault(),this.currentTarget=e.target,this.showWaitingMessage(),this.initializeEventSource()},decrypt:function(){this.cleanUi(),this.decrypter&&this.decrypter.decrypt({backwpup_action_nonce:this.currentTarget.dataset.nonce,encrypted_file_path:this.currentTarget.dataset.localFile})},construct:function(e){var t=document.querySelector("#tb_container");return!!t&&(s.bindAll(this,"showWaitingMessage","hideWaitingMessage","showProgressUi","hideSuccessMsg","showSuccessMsg","done","onMessage","onError","initializeEventSource","closeEventSource","startDownload","addListeners","decrypt","hideNotice","cleanUi","init"),this.containerUi=t,this.waitingUi=this.containerUi.querySelector("#download-file-waiting"),this.progressUi=this.containerUi.querySelector(".progressbar"),this.successUi=this.containerUi.querySelector("#download-file-success"),this.currentTarget=void 0,this.eventSource=void 0,this.decrypter=e,this)},addListeners:function(){return s.forEach(document.querySelectorAll("#backup-download-link"),function(e){e.addEventListener("click",this.startDownload)}.bind(this)),i("#submit_decrypt_key").on("click",this.decrypt),i("body").on("thickbox:removed",function(){a.call(this)}.bind(this)),this.decrypter&&i("body").on(this.decrypter.ACTION_DECRYPTION_SUCCESS,this.done),this},init:function(){return this.addListeners(),this}},r=Object.create(c),s.isUndefined(n.DecrypterFactory)||(o=n.DecrypterFactory(e,document.querySelector("#decrypt_key"),document.querySelector("#decryption_key"))),r.construct(o)&&r.init()):console.warn("Event Source does not exist in this browser"):console.warn("Missing ajaxurl value.")}(window.jQuery,window._,window.BWU,window.ajaxurl,window.tb_remove);