- md5
- 3816ca5e3a072e43ec00d04a981b91ca
- sha1
- 89d41a466091ff0a14c8958239b2ea0c5b4201ca
- sha256
- b4f016a8bc9ffb2a366d9f76f19d48d746f57b984b5da0d17dbaedb79c929bf4
if(!Joomla)throw new Error("Joomla API was not initialised properly");Joomla.Update=window.Joomla.Update||{stat_total:0,stat_files:0,stat_inbytes:0,stat_outbytes:0,password:null,totalsize:0,ajax_url:null,return_url:null,genericErrorMessage:e=>{const t=document.getElementById("errorDialogLabel"),a=document.getElementById("errorDialogMessage"),o=document.getElementById("progress-bar"),s=document.getElementById("update-title"),r=document.getElementById("update-help");o.classList.add("bg-danger"),o.classList.remove("bg-success"),s.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_UPDATING_FAIL"),r.classList.remove("d-none"),r.classList.add("d-grid"),t.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_ERRORMODAL_HEAD_GENERIC"),a.innerHTML=e,"invalid login"===e.toLowerCase()&&(a.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_ERRORMODAL_BODY_INVALIDLOGIN"));new bootstrap.Modal(document.getElementById("errorDialog"),{keyboard:!0,backdrop:!0}).show()},handleErrorResponse:e=>{const t=403===e.status,a=document.getElementById("errorDialogLabel"),o=document.getElementById("errorDialogMessage"),s=document.getElementById("progress-bar"),r=document.getElementById("update-title"),l=document.getElementById("update-help");s.classList.add("bg-danger"),s.classList.remove("bg-success"),r.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_UPDATING_FAIL"),l.classList.remove("d-none"),l.classList.add("d-grid"),t?(a.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_ERRORMODAL_HEAD_FORBIDDEN"),o.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_ERRORMODAL_BODY_FORBIDDEN")):(a.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_ERRORMODAL_HEAD_SERVERERROR"),o.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_ERRORMODAL_BODY_SERVERERROR"));new bootstrap.Modal(document.getElementById("errorDialog"),{keyboard:!0,backdrop:!0}).show()},startExtract:()=>{Joomla.Update.stat_files=0,Joomla.Update.stat_inbytes=0,Joomla.Update.stat_outbytes=0,document.getElementById("extbytesin").innerText=Joomla.Update.formatBytes(Joomla.Update.stat_inbytes),document.getElementById("extbytesout").innerText=Joomla.Update.formatBytes(Joomla.Update.stat_outbytes),document.getElementById("extfiles").innerText=Joomla.Update.stat_files;const e=new FormData;e.append("task","startExtract"),e.append("password",Joomla.Update.password),Joomla.request({url:Joomla.Update.ajax_url,data:e,method:"POST",perform:!0,onSuccess:e=>{try{const t=JSON.parse(e);Joomla.Update.stepExtract(t)}catch(e){Joomla.Update.genericErrorMessage(e.message)}},onError:Joomla.Update.handleErrorResponse})},stepExtract:e=>{if(!1===e.status)return void Joomla.Update.genericErrorMessage(e.message);const t=document.getElementById("progress-bar"),a=document.getElementById("update-title");if(Joomla.Update.stat_inbytes=e.bytesIn,Joomla.Update.stat_percent=e.percent,Joomla.Update.stat_percent=Joomla.Update.stat_percent||Joomla.Update.stat_inbytes/Joomla.Update.totalsize*100,Joomla.Update.stat_outbytes=e.bytesOut,Joomla.Update.stat_files=e.files,Joomla.Update.stat_percent<100?(t.classList.remove("bg-success"),t.style.width=`${Joomla.Update.stat_percent}%`,t.setAttribute("aria-valuenow",Joomla.Update.stat_percent)):Joomla.Update.stat_percent>=100&&(t.classList.add("bg-success"),t.style.width="100%",t.setAttribute("aria-valuenow",100)),t.innerText=`${Joomla.Update.stat_percent.toFixed(1)}%`,document.getElementById("extbytesin").innerText=Joomla.Update.formatBytes(Joomla.Update.stat_inbytes),document.getElementById("extbytesout").innerText=Joomla.Update.formatBytes(Joomla.Update.stat_outbytes),document.getElementById("extfiles").innerText=Joomla.Update.stat_files,e.done)return t.classList.add("bg-success"),t.style.width="100%",t.setAttribute("aria-valuenow",100),a.innerHTML=Joomla.Text._("COM_JOOMLAUPDATE_UPDATING_COMPLETE"),void Joomla.Update.finalizeUpdate();window.setTimeout((()=>{Joomla.Update.delayedStepExtract(e.instance)}),50)},delayedStepExtract:e=>{const t=new FormData;t.append("task","stepExtract"),t.append("password",Joomla.Update.password),e&&t.append("instance",e),Joomla.request({url:Joomla.Update.ajax_url,data:t,method:"POST",perform:!0,onSuccess:e=>{try{const t=JSON.parse(e);Joomla.Update.stepExtract(t)}catch(e){Joomla.Update.genericErrorMessage(e.message)}},onError:Joomla.Update.handleErrorResponse})},finalizeUpdate:()=>{const e=new FormData;e.append("task","finalizeUpdate"),e.append("password",Joomla.Update.password),Joomla.request({url:Joomla.Update.ajax_url,data:e,method:"POST",perform:!0,onSuccess:()=>{window.location=Joomla.Update.return_url},onError:Joomla.Update.handleErrorResponse})},formatBytes:(e,t=2)=>{if(0===e)return`0 ${Joomla.Text._("JLIB_SIZE_BYTES")}`;const a=t<0?0:t,o=[Joomla.Text._("JLIB_SIZE_BYTES"),Joomla.Text._("JLIB_SIZE_KB"),Joomla.Text._("JLIB_SIZE_MB"),Joomla.Text._("JLIB_SIZE_GB"),Joomla.Text._("JLIB_SIZE_TB"),Joomla.Text._("JLIB_SIZE_PB"),Joomla.Text._("JLIB_SIZE_EB"),Joomla.Text._("JLIB_SIZE_ZB"),Joomla.Text._("JLIB_SIZE_YB")],s=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/1024**s).toFixed(a))} ${o[s]}`}};const JoomlaUpdateOptions=Joomla.getOptions("joomlaupdate");JoomlaUpdateOptions&&Object.keys(JoomlaUpdateOptions).length&&(Joomla.Update.password=JoomlaUpdateOptions.password,Joomla.Update.totalsize=JoomlaUpdateOptions.totalsize,Joomla.Update.ajax_url=JoomlaUpdateOptions.ajax_url,Joomla.Update.return_url=JoomlaUpdateOptions.return_url,Joomla.Update.startExtract());
The same content is in 37 releases, Joomla 4.0.4-rc1 to 4.2.0-beta1. See them all, or every version of this file.