import
This commit is contained in:
commit
3daa151896
1 changed files with 212 additions and 0 deletions
39
common.js
Normal file
39
common.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
const Common = {};
|
||||
|
||||
const HTTPP = document.location.protocol + "//" + document.location.host;
|
||||
|
||||
var currentGroupName = "";
|
||||
|
||||
// helpers
|
||||
const $C = (e, opts = {}) => {
|
||||
const elem = document.createElement(e);
|
||||
for (const key in opts) {
|
||||
if (key == "classList") {
|
||||
const cl = opts[key];
|
||||
if (typeof (cl) == "string") {
|
||||
elem.classList.add(cl);
|
||||
} else {
|
||||
elem.classList.add(...cl);
|
||||
}
|
||||
continue;
|
||||
} else if (key == "children") {
|
||||
elem.append(...opts[key]);
|
||||
continue;
|
||||
} else if (key == "title") {
|
||||
elem.setAttribute(key, opts[key]);
|
||||
continue;
|
||||
}
|
||||
elem[key] = opts[key];
|
||||
}
|
||||
return elem;
|
||||
}
|
||||
|
||||
const $G = (e) => document.getElementById(e);
|
||||
|
||||
const $S = (s) => document.querySelector(s);
|
||||
|
||||
Common.$G = $G;
|
||||
Common.$C = $C;
|
||||
Common.initializeModal = initializeModal;
|
||||
|
||||
// vim: ts=2 sts=2 sw=2
|
||||
Loading…
Reference in a new issue