Login appear to be working now

This commit is contained in:
Joseph Garrone
2021-03-04 13:56:51 +01:00
parent 21763db561
commit 6738f6f6cf
5 changed files with 85 additions and 68 deletions

View File

@ -0,0 +1,49 @@
import { Deferred } from "evt/tools/Deferred";
export function appendHead(
params: {
type: "css";
href: string;
} | {
type: "javascript";
src: string;
}
) {
const htmlElement = document.createElement(
(() => {
switch (params.type) {
case "css": return "link";
case "javascript": return "script";
}
})()
);
const dLoaded = new Deferred<void>();
htmlElement.addEventListener("load", () => dLoaded.resolve());
Object.assign(
htmlElement,
(() => {
switch (params.type) {
case "css": return {
"href": params.href,
"type": "text/css",
"rel": "stylesheet",
"media": "screen,print"
};
case "javascript": return {
"src": params.src,
"type": "text/javascript",
};
}
})()
);
document.getElementsByTagName("head")[0].appendChild(htmlElement);
return dLoaded.pr;
}

View File

@ -1,24 +0,0 @@
export function appendLinkInHead(
props: {
href: string;
}
) {
const { href } = props;
var link = document.createElement("link");
Object.assign(
link,
{
href,
"type": "text/css",
"rel": "stylesheet",
"media": "screen,print"
}
);
document.getElementsByTagName("head")[0].appendChild(link);
}

View File

@ -1,22 +0,0 @@
export function appendScriptInHead(
props: {
src: string;
}
) {
const { src } = props;
var script = document.createElement("script");
Object.assign(
script,
{
src,
"type": "text/javascript",
}
);
document.getElementsByTagName("head")[0].appendChild(script);
}