/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Page.js :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: edbernar { if (response.status != 200) throw Error("Page '" + name + "' can't be loaded") return (response); }) .then(data => { data.text().then(text => { document.body.innerHTML = text; this.actualPage = this.availablePages[i].class; document.title = this.availablePages[i].title; if (!isBack) history.pushState({}, this.availablePages[i].title, this.availablePages[i].url); if (arg) this.actualPage.create(arg); else this.actualPage.create(); console.log("Page created."); }) }) .catch(error => { window.location.href = '/'; // throw Error(error); }); return ; } } throw Error("Page '" + name + "' not exist"); } #showUnknownPage() { if (this.actualPage != null) this.actualPage.dispose(); fetch('/404') .then(response => { if (response.status != 200) throw Error("Page '" + name + "' can't be loaded") return (response); }) .then(data => { data.text().then(text => { document.body.innerHTML = text; this.actualPage = null; document.title = 'PTME - Page not found'; history.pushState({}, this.availablePages[i].title, this.availablePages[i].url); }) }) .catch(error => { window.location.href = '/'; throw Error(error); }); } }; export { Page }