5 elem.style.left = elem.parentNode.clientWidth / 2 - parseInt(elem.clientWidth) / 2 + "px";
8 static centerVertical(elem)
10 let parent = elem.parentNode;
11 if (parent == document.body)
12 parent = document.documentElement;
13 elem.style.top = parent.clientHeight / 2 - parseInt(elem.clientHeight) / 2 + "px";
16 static random(min, max)
18 return Math.floor(min + Math.random() * (max - min + 1));
21 static humanFormat(str)
23 str = str.replace("_", " ");
24 str = str[0].toUpperCase() + str.slice(1, str.length);
28 static copy(dst, src, condition)
33 if (condition && ! condition(key, value)) {
34 console.log(key, value);
38 if (value instanceof Array)
39 this.copy(dst[key] = [], value, condition);
40 else if (value instanceof Function)
42 else if (value instanceof Object)
43 this.copy(dst[key] = {}, value, condition);
51 static copySimple(dst, src)
59 static htmlEntities(str)
62 .replace(/&/g, '&')
63 .replace(/</g, '<')
64 .replace(/>/g, '>')
65 .replace(/"/g, '"')
66 .replace(/\n/g, "<br>")
67 .replace(/\t/g, "  ")
68 .replace(/ /g, " ");
75 if (src instanceof Array)
78 return dblib.copy(dst, src, key => key != "tmp");;
81 static replaceRecursive(src, search, replace)
85 if (src instanceof Array)
88 dblib.copySimple(dst, src);
90 for (let key in dst) {
95 else if (value instanceof Object)
96 value = this.replaceRecursive(value, search, replace);