1 // Library for Dragonblocks
4 elem.style.left = elem.parentNode.clientWidth / 2 - parseInt(elem.clientWidth) / 2 + "px";
6 static centerVertical(elem){
7 elem.style.top = elem.parentNode.clientHeight / 2 - parseInt(elem.clientHeight) / 2 + "px";
11 elem.parentNode.removeChild(elem);
13 static random(min, max){
14 return Math.floor(min + Math.random() * (max - min + 1));
16 static humanFormat(str){
17 var str = str.replace("_", " ");
18 str = str[0].toUpperCase() + str.slice(1, str.length);
21 static copy(dest, src){
23 if(src[prop] instanceof Array){
25 this.copy(dest[prop], src[prop]);
27 else if(src[prop] instanceof Function){
28 dest[prop] = src[prop];
30 else if(src[prop] instanceof Object){
32 this.copy(dest[prop], src[prop]);
35 dest[prop] = src[prop];
39 static copySimple(dest, src){
41 dest[prop] = src[prop];
44 static htmlEntities(str){
45 return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/\n/g, "<br>").replace(/\t/g, "  ").replace(/ /g, " ");
47 static removeTmp(src){
49 if(src instanceof Array)
58 static replaceRecursive(src, search, replace){
60 if(src instanceof Array)
62 dblib.copySimple(obj, src);
64 if(obj[prop] === search)
66 else if(obj[prop] instanceof Object)
67 obj[prop] = this.replaceRecursive(obj[prop], search, replace);