2018-05-11 12:31:53 +02:00
|
|
|
function Dom() {
|
2018-05-21 23:28:33 +02:00
|
|
|
return {
|
2018-05-26 21:26:12 +02:00
|
|
|
clear: clear,
|
|
|
|
make: make
|
2018-05-21 23:28:33 +02:00
|
|
|
}
|
2018-05-11 12:31:53 +02:00
|
|
|
|
|
|
|
function clear(elem) {
|
|
|
|
while(elem.firstChild) {
|
|
|
|
elem.removeChild(elem.firstChild);
|
|
|
|
}
|
|
|
|
}
|
2018-05-26 21:26:12 +02:00
|
|
|
|
|
|
|
function make(tag, properties) {
|
|
|
|
var e = document.createElement(tag);
|
|
|
|
for(key in properties) {
|
|
|
|
var value = properties[key];
|
|
|
|
switch(key) {
|
|
|
|
case "class":
|
|
|
|
e.className = Array.isArray(value) ? value.join(' ') : value;
|
|
|
|
break;;
|
|
|
|
case "onClick":
|
|
|
|
e.addEventListener("click", value);
|
|
|
|
break;;
|
|
|
|
default:
|
|
|
|
e[key] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return e;
|
|
|
|
}
|
2018-08-02 00:00:13 +02:00
|
|
|
|
2018-05-11 12:31:53 +02:00
|
|
|
}
|