-
Notifications
You must be signed in to change notification settings - Fork 1
/
redump.js
59 lines (59 loc) · 1.18 KB
/
redump.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function redump(thevar,origname)
{
var dump=function(n,v)
{
var r='';
if (n)n+=' : ';
else n='';
var t=Object.prototype.toString.call(v);
t=t.substr(8,t.length-9);
switch(t)
{
case 'String':
case 'Date':
r+=n+t+' = "'+v.toString().replace('"','\\"')+'"';
break;
case 'Number':
case 'RegExp':
case 'Boolean':
r+=n+t+' = '+v;
break;
case 'Null':
case 'Undefined':
r+=n+t;
break;
case 'Array':
r+=n+'Array = [<ul style="list-style:none">';
for (c in v)
{
r+='<li>';
r+=dump('['+c+']',v[c])+',';
r+='</li>';
}
r+='</ul>]';
break;
case 'Object':
r+=n+'Object = {<ul style="list-style:none">';
for (c in v)
{
r+='<li>';
r+=dump('.'+c,v[c])+',';
r+='</li>';
}
r+='</ul>}'
break;
case 'Function':
r+=n+t+' = '+v.toString().substr(0,v.toString().indexOf('{'));
r+='{<ul style="list-style:none">';
r+='<li>Arguments: '+v.length+'</li>';
r+='</ul>}';
break;
default:
r+='>>'+t+'<<'+n;
break;
}
return r;
};
(typeof origname !== 'undefined')||(origname='');
return '<ul style="list-style:none"><li>'+dump(origname,thevar)+'</li></ul>';
}