Initial commit
This commit is contained in:
20
Frontend/pages/layouts/main/ts/CE.ts
Normal file
20
Frontend/pages/layouts/main/ts/CE.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
function ce(
|
||||
type: string,
|
||||
classList?: string | string[],
|
||||
attributes?: { [key: string]: string },
|
||||
innerText?: string,
|
||||
innerHTML?: string,
|
||||
styling?: { [key: string]: string }
|
||||
) {
|
||||
var element = document.createElement(type);
|
||||
if (classList)
|
||||
if (typeof classList == 'string') element.classList.add(classList);
|
||||
else element.classList.add(...classList);
|
||||
if (attributes) for (var key in attributes) element.setAttribute(key, attributes[key]);
|
||||
if (innerText) element.innerText = innerText;
|
||||
if (innerHTML) element.innerHTML = innerHTML;
|
||||
if (styling) for (var key in styling) element.style[key] = styling[key];
|
||||
return element;
|
||||
}
|
||||
|
||||
// declare var ce:(type:string, classList?:string|string[], attributes?:{[key:string]:string}, innerText?:string, innerHTML?:string) => HTMLDivElement;
|
||||
Reference in New Issue
Block a user