Updated the load so I could reload the UI without a need of restarting the full client
This commit is contained in:
parent
41323f9a5c
commit
52d998000d
6 changed files with 10 additions and 5 deletions
|
@ -17,12 +17,15 @@ export interface Config {
|
||||||
loader_groups: boolean;
|
loader_groups: boolean;
|
||||||
verbose: boolean;
|
verbose: boolean;
|
||||||
error: boolean;
|
error: boolean;
|
||||||
|
|
||||||
|
baseUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export let config: Config = {
|
export let config: Config = {
|
||||||
loader_groups: false,
|
loader_groups: false,
|
||||||
verbose: false,
|
verbose: false,
|
||||||
error: true
|
error: true,
|
||||||
|
baseUrl: "./"
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Task = {
|
export type Task = {
|
||||||
|
|
|
@ -51,7 +51,7 @@ function load_script_url(url: string) : Promise<void> {
|
||||||
|
|
||||||
document.getElementById("scripts").appendChild(script_tag);
|
document.getElementById("scripts").appendChild(script_tag);
|
||||||
|
|
||||||
script_tag.src = url;
|
script_tag.src = config.baseUrl + url;
|
||||||
})).then(result => {
|
})).then(result => {
|
||||||
/* cleanup memory */
|
/* cleanup memory */
|
||||||
_script_promises[url] = Promise.resolve(); /* this promise does not holds the whole script tag and other memory */
|
_script_promises[url] = Promise.resolve(); /* this promise does not holds the whole script tag and other memory */
|
||||||
|
|
|
@ -79,7 +79,7 @@ function load_style_url(url: string) : Promise<void> {
|
||||||
};
|
};
|
||||||
|
|
||||||
document.getElementById("style").appendChild(tag);
|
document.getElementById("style").appendChild(tag);
|
||||||
tag.href = url;
|
tag.href = config.baseUrl + url;
|
||||||
})).then(result => {
|
})).then(result => {
|
||||||
/* cleanup memory */
|
/* cleanup memory */
|
||||||
_style_promises[url] = Promise.resolve(); /* this promise does not holds the whole script tag and other memory */
|
_style_promises[url] = Promise.resolve(); /* this promise does not holds the whole script tag and other memory */
|
||||||
|
|
|
@ -8,7 +8,7 @@ function load_template_url(url: string) : Promise<void> {
|
||||||
return _template_promises[url];
|
return _template_promises[url];
|
||||||
|
|
||||||
return (_template_promises[url] = (async () => {
|
return (_template_promises[url] = (async () => {
|
||||||
const response = await $.ajax(url);
|
const response = await $.ajax(config.baseUrl + url);
|
||||||
|
|
||||||
let node = document.createElement("html");
|
let node = document.createElement("html");
|
||||||
node.innerHTML = response;
|
node.innerHTML = response;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as loader from "../loader/loader";
|
import * as loader from "../loader/loader";
|
||||||
|
import {config} from "../loader/loader";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
|
@ -74,7 +75,7 @@ const loader_javascript = {
|
||||||
|
|
||||||
let manifest: Manifest;
|
let manifest: Manifest;
|
||||||
try {
|
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;
|
if(!response.ok) throw response.status + " " + response.statusText;
|
||||||
|
|
||||||
manifest = await response.json();
|
manifest = await response.json();
|
||||||
|
|
1
loader/exports/loader.d.ts
vendored
1
loader/exports/loader.d.ts
vendored
|
@ -2,6 +2,7 @@ export interface Config {
|
||||||
loader_groups: boolean;
|
loader_groups: boolean;
|
||||||
verbose: boolean;
|
verbose: boolean;
|
||||||
error: boolean;
|
error: boolean;
|
||||||
|
baseUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum BackendType {
|
export enum BackendType {
|
||||||
|
|
Loading…
Add table
Reference in a new issue