1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
5 <script type=
"text/javascript" src=
"script/util.js"></script>
9 <textarea id=
"in" rows=
"5" cols=
"50">
26 ; Traits are kept as an array
40 <script type=
"text/javascript">
41 var src
=document
.getElementById('in');
42 var out
=document
.getElementById('out');
51 .filter(keyValuePairsOnly
)
52 .forEach(addProperty
);
54 function keyValuePairsOnly(line
){
55 return line
.length
&& line
[0]!=';'
58 function addProperty(line
)
62 section
= line
.substr(1, line
.length
-2);
63 if(!(section
in object
))object
[section
] = {};
67 var eqIndex
= line
.indexOf('=');
68 var key
= line
.substr(0, eqIndex
);
69 var value
= line
.substr(eqIndex
+1);
71 if(key
in object
[section
]) {
72 if(!(object
[section
][key
] instanceof Array
))
73 object
[section
][key
]=[object
[section
][key
]];
74 object
[section
][key
].push(value
);
76 else object
[section
][key
]=value
;