Viewing File: /usr/local/cpanel/base/frontend/jupiter/sitejet-domains/sitejet-api.min.js
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).SitejetAPI=t()}(this,(function(){"use strict";return class{constructor(e,t,i,s){this.securityToken=e,this.translations=t,this.homePath=i,this.isBeta=s}apiRequest(e,t){return fetch(`${this.securityToken}/execute/Sitejet/${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((e=>e.ok?e.json():Promise.reject(this.translations.requestFailed))).then((e=>1!==e.status?Promise.reject(e.errors[0]||this.translations.unknownError):e))}showAlert(e){const t=new CustomEvent("cp-alert-message",{detail:e});document.dispatchEvent(t)}createWebsite(e){return this.apiRequest("create_website",{domain:e,company:e}).then((()=>!0)).catch((e=>{throw this.showAlert({type:"danger",message:e,id:"sitejet-domains__error--createWebsite"}),new Error(e)}))}getSsoLink(e){const t=`${window.location.origin}${this.homePath}/sitejet/index.html#`;return this.apiRequest("get_sso_link",{domain:e,referrer:t,ui_mode:this.isBeta?"prompt":""}).then((e=>e.data)).catch((e=>{throw this.showAlert({type:"danger",message:e,id:"sitejet-domains__error--getSsoLink"}),new Error(e)}))}createWebsiteAndGetSsoLink(e){return this.createWebsite(e).then((()=>this.getSsoLink(e))).then((e=>(window.location.href=e,e))).catch((e=>(console.error(e),setTimeout((()=>{this.showAlert({type:"info",message:this.translations.redirect,id:"sitejet-domains__info--Loading",replace:!0}),setTimeout((()=>{window.location.href=`${this.homePath}/sitejet/index.html#`}),2e3)}),5e3),null)))}sitejetCallback(e){return setTimeout((()=>{this.showAlert({type:"info",message:this.translations.loadingSitejetBuilder,id:"sitejet-domains__info--Loading",autoClose:5e3})}),200),this.createWebsiteAndGetSsoLink(e)}}}));
Back to Directory
File Manager