[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_installer_webinstaller/js/ -> client.min.js (source)

   1  if(!Joomla)throw new Error("Joomla API is not properly initialised");const allowList={button:["type"],input:["type","name","placeholder","inputmode"],select:["name"],option:["value","selected"]},webInstallerOptions={view:"dashboard",id:0,ordering:"",version:"current",list:0,options:Joomla.getOptions("plg_installer_webinstaller",{})};let instance;class WebInstaller{initialise(){webInstallerOptions.loaded=1;document.getElementById("uploadform-web-cancel").addEventListener("click",(()=>{document.getElementById("uploadform-web").classList.add("hidden"),webInstallerOptions.list&&document.querySelector(".list-view")&&document.querySelector(".list-view").click()}));document.getElementById("uploadform-web-install").addEventListener("click",(()=>{4===webInstallerOptions.options.installFrom?this.submitButtonUrl():this.submitButtonWeb()})),this.loadweb(`$webInstallerOptions.options.base_url}index.php?format=json&option=com_apps&view=dashboard`),this.clickforlinks()}loadweb(e){if(!e)return!1;if(!new RegExp(webInstallerOptions.options.base_url).test(e)&&!/^index\.php/.test(e))return window.open(e,"_blank"),!1;let t=`$e}&product=$webInstallerOptions.options.product}&release=$webInstallerOptions.options.release}&dev_level=$webInstallerOptions.options.dev_level}&list=$webInstallerOptions.list?"list":"grid"}&lang=$webInstallerOptions.options.language}`;const n=document.getElementById("com-apps-ordering"),l=document.getElementById("com-apps-filter-joomla-version");return""!==webInstallerOptions.ordering&&n&&n.value&&(webInstallerOptions.ordering=n.value,t+=`&ordering=$webInstallerOptions.ordering}`),""!==webInstallerOptions.version&&l&&l.value&&(webInstallerOptions.version=l.value,t+=`&filter_version=$webInstallerOptions.version}`),WebInstaller.showLoadingLayer(),new Promise(((e,n)=>{Joomla.request({url:t,onSuccess:t=>{let n;try{n=JSON.parse(t)}catch(e){throw new Error("Failed to parse JSON")}document.getElementById("web-loader")&&document.getElementById("web-loader").classList.add("hidden");document.getElementById("jed-container").innerHTML=Joomla.sanitizeHtml(n.data.html,allowList),document.getElementById("com-apps-searchbox").addEventListener("keypress",(({which:e})=>{13===e&&this.initiateSearch()})),document.getElementById("search-extensions").addEventListener("click",(()=>{this.initiateSearch()})),document.getElementById("search-reset").addEventListener("click",(()=>{document.getElementById("com-apps-searchbox").value="",this.initiateSearch(),document.getElementById("search-reset").setAttribute("disabled","disabled")})),""===document.getElementById("com-apps-searchbox").value&&document.getElementById("search-reset").setAttribute("disabled","disabled"),document.getElementById("search-reset").innerHTML=Joomla.sanitizeHtml(Joomla.Text._("JSEARCH_FILTER_CLEAR"));const l=document.getElementById("com-apps-ordering"),s=document.getElementById("com-apps-filter-joomla-version");l&&l.addEventListener("change",(()=>{const e=l.selectedIndex;webInstallerOptions.ordering=l.options[e].value,this.installfromwebajaxsubmit()})),s&&s.addEventListener("change",(()=>{const e=s.selectedIndex;webInstallerOptions.version=s.options[e].value,this.installfromwebajaxsubmit()})),""!==webInstallerOptions.options.installfrom_url&&WebInstaller.installfromweb(webInstallerOptions.options.installfrom_url),e()},onError:e=>{const t=document.getElementById("web-loader-error"),l=document.getElementById("web-loader");e.responseText&&t&&(t.innerHTML=Joomla.sanitizeHtml(e.responseText)),l&&(l.classList.add("hidden"),t.classList.remove("hidden")),Joomla.renderMessages({danger:[Joomla.Text._("PLG_INSTALLER_WEBINSTALLER_INSTALL_WEB_LOADING_ERROR")]},"#web-loader-error"),n()}})})).finally((()=>{const e=document.getElementById("joomlaapsinstallatinput");if(e&&(e.value=webInstallerOptions.options.installat_url),this.clickforlinks(),WebInstaller.clicker(),"extension"!==webInstallerOptions.view&&[].slice.call(document.querySelectorAll("div.load-extension")).forEach((e=>{e.addEventListener("click",(t=>{t.preventDefault(),this.processLinkClick(e.getAttribute("data-url"))})),e.setAttribute("href","#")})),"extension"===webInstallerOptions.view){const e=document.getElementById("install-extension"),t=document.getElementById("install-extension-from-external");e&&e.addEventListener("click",(()=>{WebInstaller.installfromweb(e.getAttribute("data-downloadurl"),e.getAttribute("data-name")),document.getElementById("uploadform-web-install").scrollIntoView({behavior:"smooth",block:"start"})})),t&&t.addEventListener("click",(()=>{const e=t.getAttribute("data-downloadurl");!0===window.confirm(Joomla.Text._("PLG_INSTALLER_WEBINSTALLER_REDIRECT_TO_EXTERNAL_SITE_TO_INSTALL").replace("[SITEURL]",e))&&(document.getElementById("adminForm").setAttribute("action",e),document.querySelector("input[name=task]").setAttribute("disabled",!0),document.querySelector("input[name=install_directory]").setAttribute("disabled",!0),document.querySelector("input[name=install_url]").setAttribute("disabled",!0),document.querySelector("input[name=installtype]").setAttribute("disabled",!0),document.querySelector("input[name=filter_search]").setAttribute("disabled",!0),document.getElementById("adminForm").submit())}))}webInstallerOptions.list&&document.querySelector(".list-view")&&document.querySelector(".list-view").click(),WebInstaller.hideLoadingLayer()})),!0}clickforlinks(){[].slice.call(document.querySelectorAll("a.transcode")).forEach((e=>{const t=e.getAttribute("href");e.addEventListener("click",(e=>{e.preventDefault(),this.processLinkClick(t)})),e.setAttribute("href","#")}))}initiateSearch(){document.getElementById("search-reset").removeAttribute("disabled"),webInstallerOptions.view="dashboard",this.installfromwebajaxsubmit()}installfromwebajaxsubmit(){let e=`&view=$webInstallerOptions.view}`;if(webInstallerOptions.id&&(e+=`&id=$webInstallerOptions.id}`),document.getElementById("com-apps-searchbox").value){e+=`&filter_search=$encodeURI(document.getElementById("com-apps-searchbox").value.toLowerCase().replace(/ +/g,"_").replace(/[^a-z0-9-_]/g,"").trim())}`}const t=document.getElementById("com-apps-ordering"),n=document.getElementById("com-apps-filter-joomla-version");""!==webInstallerOptions.ordering&&t&&t.value&&(webInstallerOptions.ordering=t.value),webInstallerOptions.ordering&&(e+=`&ordering=$webInstallerOptions.ordering}`),""!==webInstallerOptions.version&&n&&n.value&&(webInstallerOptions.version=n.value),webInstallerOptions.version&&(e+=`&filter_version=$webInstallerOptions.version}`),this.loadweb(`$webInstallerOptions.options.base_url}index.php?format=json&option=com_apps$e}`)}processLinkClick(e){new RegExp(webInstallerOptions.options.base_url).test(e)||/^index\.php/.test(e)?(webInstallerOptions.view=e.replace(/^.+[&?]view=(\w+).*$/,"$1"),"dashboard"===webInstallerOptions.view?webInstallerOptions.id=0:"category"===webInstallerOptions.view&&(webInstallerOptions.id=e.replace(/^.+[&?]id=(\d+).*$/,"$1")),this.loadweb(webInstallerOptions.options.base_url+e)):this.loadweb(e)}static showLoadingLayer(){document.getElementById("web").appendChild(document.createElement("joomla-core-loader"))}static hideLoadingLayer(){const e=document.querySelector("#web joomla-core-loader");e.parentNode.removeChild(e)}static clicker(){document.querySelector(".grid-view")&&document.querySelector(".grid-view").addEventListener("click",(()=>{webInstallerOptions.list=0,document.querySelector(".list-container").classList.add("hidden"),document.querySelector(".grid-container").classList.remove("hidden"),document.getElementById("btn-list-view").classList.remove("active"),document.getElementById("btn-grid-view").classList.remove("active")})),document.querySelector(".list-view")&&document.querySelector(".list-view").addEventListener("click",(()=>{webInstallerOptions.list=1,document.querySelector(".grid-container").classList.add("hidden"),document.querySelector(".list-container").classList.remove("hidden"),document.getElementById("btn-grid-view").classList.remove("active"),document.getElementById("btn-list-view").classList.add("active")}))}static installfromweb(e,t=null){return e?(document.getElementById("install_url").value=e,document.getElementById("uploadform-web-url").innerText=e,t?(document.getElementById("uploadform-web-name").innerText=t,document.getElementById("uploadform-web-name-label").classList.remove("hidden")):document.getElementById("uploadform-web-name-label").classList.add("hidden"),document.getElementById("uploadform-web").classList.remove("hidden"),!0):(Joomla.renderMessages({warning:[Joomla.Text._("PLG_INSTALLER_WEBINSTALLER_CANNOT_INSTALL_EXTENSION_IN_PLUGIN")]}),!1)}submitButtonUrl(){const e=document.getElementById("adminForm");if(""===e.install_url.value||"http://"===e.install_url.value||"https://"===e.install_url.value)Joomla.renderMessages({warning:[Joomla.Text._("COM_INSTALLER_MSG_INSTALL_ENTER_A_URL")]});else{const t=document.getElementById("loading");t&&t.classList.remove("hidden"),e.installtype.value="url",e.submit()}}submitButtonWeb(){const e=document.getElementById("adminForm");""!==e.install_url.value||"http://"!==e.install_url.value||"https://"!==e.install_url.value?this.submitButtonUrl():""===e.install_url.value?Joomla.renderMessages({warning:[Joomla.apps.options.btntxt]}):(document.querySelector("#appsloading").classList.remove("hidden"),e.installtype.value="web",e.submit())}}customElements.whenDefined("joomla-tab").then((()=>{const e=document.getElementById("myTab").querySelector("button[aria-controls=web]");e&&(webInstallerOptions.options.installfromon&&e.click(),e.hasAttribute("aria-expanded")&&"true"===e.getAttribute("aria-expanded")&&!instance&&(instance=new WebInstaller,instance.initialise()),""!==webInstallerOptions.options.installfrom_url&&e.click(),e.addEventListener("joomla.tab.shown",(()=>{instance||(instance=new WebInstaller,instance.initialise())})))}));


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer