Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object.prototype.toString = function dogToString() {
- return logObject(this);
- }
- global.logObject = function(obj, depth, currentDepth, isRoot)
- {
- if(isRoot == undefined) {isRoot = true; currentDepth = 0; obj = JSON.parse(JSON.stringify(obj))};
- if(depth != undefined && depth <= currentDepth)
- {
- return '...';
- }
- var str = "";
- if(isRoot)
- {
- str = '<style>details[open] > summary {background-color: rgba(255,255,255,0.1);} summary:hover {cursor: pointer;} details div, details summary {padding-left: 25px;} .singleline:hover{background-color: rgba(255,255,255,0.1);} details {width:100%;}</style><details><summary class="singleline">LogObject Out:</summary><div>';
- }
- var index = 0;
- for(var name in obj)
- {
- if(typeof(obj[name]) == 'object')
- {
- //Subdaten scan
- var count = 0;
- for(var name2 in obj[name])
- {
- count++;
- }
- str += '<details><summary class="singleline">' + name + ' (' + count + ')</summary><div>';
- str += logObject(obj[name], depth, currentDepth + 1, false);
- str += '</div></details>';
- }
- else
- {
- str += '<div class="singleline">' + name + ': ' + obj[name] + '</div>';
- }
- index++;
- }
- if(index == 0)
- {
- str += '<div>(empty)</div>';
- }
- if(isRoot)
- {
- str += '</div></details>';
- return str;//console.log(str);
- }
- return str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement