2 // Copyright 2008 Grégory Burri
4 // This file is part of Euphorik.
6 // Euphorik is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
11 // Euphorik is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Euphorik. If not, see <http://www.gnu.org/licenses/>.
20 * Affiche un objet quelconque sur la sortie du navigateur.
22 var dumpObj = function(obj
, name
)
24 if (typeof(dump
) == "undefined")
27 dump("---" + (name
== undefined ? "" : " : " + name
) + "\n")
32 var obj2text = function(obj
, curDepth
)
34 if (curDepth
== undefined)
43 else if (typeof(obj
) == "string")
45 acc
+= "\"" + obj
+ "\""
47 else if (obj
.length
!= undefined) // array
52 for (; i
< obj
.length
; i
++)
54 if (i
!= 0) acc
+= ","
55 acc
+= "\n" + indent(curDepth
+ 1, obj2text(obj
[i
], curDepth
+ 1))
58 acc
+= (i
== 0 ? "]" : "\n" + indent(curDepth
, "]"))
60 else if (typeof(obj
) == "object")
66 if (i
!= 0) acc
+= ","
67 acc
+= "\n" + indent(curDepth
+ 1, prop
+ " : " + obj2text(obj
[prop
], curDepth
+ 1))
70 acc
+= "\n" + indent(curDepth
, "}")
72 else if (typeof(obj
) == "function")
84 var indent = function(depth
, text
)
87 for (var i
= 0; i
< depth
* 3; i
++)
89 return indentText
+ text