From 52d998000dcb9bd0407b99bb268b919939697e32 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Wed, 10 Jun 2020 22:44:24 +0200 Subject: [PATCH] Updated the load so I could reload the UI without a need of restarting the full client --- loader/app/loader/loader.ts | 5 ++++- loader/app/loader/script_loader.ts | 2 +- loader/app/loader/style_loader.ts | 2 +- loader/app/loader/template_loader.ts | 2 +- loader/app/targets/app.ts | 3 ++- loader/exports/loader.d.ts | 1 + 6 files changed, 10 insertions(+), 5 deletions(-) diff --git a/loader/app/loader/loader.ts b/loader/app/loader/loader.ts index 64402407..cf725c82 100644 --- a/loader/app/loader/loader.ts +++ b/loader/app/loader/loader.ts @@ -17,12 +17,15 @@ export interface Config { loader_groups: boolean; verbose: boolean; error: boolean; + + baseUrl: string; } export let config: Config = { loader_groups: false, verbose: false, - error: true + error: true, + baseUrl: "./" }; export type Task = { diff --git a/loader/app/loader/script_loader.ts b/loader/app/loader/script_loader.ts index 7c47ae26..80a3622f 100644 --- a/loader/app/loader/script_loader.ts +++ b/loader/app/loader/script_loader.ts @@ -51,7 +51,7 @@ function load_script_url(url: string) : Promise { document.getElementById("scripts").appendChild(script_tag); - script_tag.src = url; + script_tag.src = config.baseUrl + url; })).then(result => { /* cleanup memory */ _script_promises[url] = Promise.resolve(); /* this promise does not holds the whole script tag and other memory */ diff --git a/loader/app/loader/style_loader.ts b/loader/app/loader/style_loader.ts index 7eb84153..f23ec3e2 100644 --- a/loader/app/loader/style_loader.ts +++ b/loader/app/loader/style_loader.ts @@ -79,7 +79,7 @@ function load_style_url(url: string) : Promise { }; document.getElementById("style").appendChild(tag); - tag.href = url; + tag.href = config.baseUrl + url; })).then(result => { /* cleanup memory */ _style_promises[url] = Promise.resolve(); /* this promise does not holds the whole script tag and other memory */ diff --git a/loader/app/loader/template_loader.ts b/loader/app/loader/template_loader.ts index 7d503af4..cfe51660 100644 --- a/loader/app/loader/template_loader.ts +++ b/loader/app/loader/template_loader.ts @@ -8,7 +8,7 @@ function load_template_url(url: string) : Promise { return _template_promises[url]; return (_template_promises[url] = (async () => { - const response = await $.ajax(url); + const response = await $.ajax(config.baseUrl + url); let node = document.createElement("html"); node.innerHTML = response; diff --git a/loader/app/targets/app.ts b/loader/app/targets/app.ts index 4df3e0ff..9b8f06e0 100644 --- a/loader/app/targets/app.ts +++ b/loader/app/targets/app.ts @@ -1,4 +1,5 @@ import * as loader from "../loader/loader"; +import {config} from "../loader/loader"; declare global { interface Window { @@ -74,7 +75,7 @@ const loader_javascript = { let manifest: Manifest; try { - const response = await fetch("js/manifest.json"); + const response = await fetch(config.baseUrl + "js/manifest.json"); if(!response.ok) throw response.status + " " + response.statusText; manifest = await response.json(); diff --git a/loader/exports/loader.d.ts b/loader/exports/loader.d.ts index 3620bc10..851fc6d3 100644 --- a/loader/exports/loader.d.ts +++ b/loader/exports/loader.d.ts @@ -2,6 +2,7 @@ export interface Config { loader_groups: boolean; verbose: boolean; error: boolean; + baseUrl: string; } export enum BackendType {