-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdom_helpers.js
44 lines (36 loc) · 984 Bytes
/
dom_helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
window.dom_helpers = (function () {
const { setStyles } = window.style_helpers;
function dom_empty_table() {
const table = document.createElement("table");
const thead = document.createElement("thead");
table.append(thead);
const tbody = document.createElement("tbody");
table.append(tbody);
return { table, thead, tbody };
}
function dom_tr(...child_elems) {
const tr = document.createElement("tr");
tr.append(...child_elems);
return tr;
}
function dom_td({ id, elem }) {
const td = document.createElement("td");
td.id = id;
td.append(elem);
return td;
}
function maybe_stripe(elem, i, color) {
if (i % 2) {
setStyles(elem, {
background: color,
});
}
return elem;
}
return {
dom_empty_table,
dom_tr,
dom_td,
maybe_stripe,
};
})();