Hexagonal two-type tiles
[zzandy.git] / ini.html
blob7eead57604a544605cd1108729b95d738e177d87
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3 <html>
4 <head>
5 <script type="text/javascript" src="script/util.js"></script>
6 <title></title>
7 </head>
8 <body>
9 <textarea id="in" rows="5" cols="50">
10 [Main]
11 UserName=Grobachov
12 Resolution=1024x786
14 [Attributes]
15 Strength=3
16 Perception=6
17 Endurance=4
18 Charisma=4
19 Intelligence=6
20 Agility=10
21 Luck=7
22 Spare=0
25 [Traits]
26 ; Traits are kept as an array
27 Traits=Gifted
28 Traits=Small Frame
30 [Skills]
31 Small Arms=74
32 Big Guns=20
33 Energy Weapons=33
35 [Perks]
36 Finessee=1
37 Mutate=1
38 </textarea>
39 <div id="out"></div>
40 <script type="text/javascript">
41 var src=document.getElementById('in');
42 var out=document.getElementById('out');
44 var object = {};
45 var section = 'Main';
47 var text = src.value;
49 text
50 .trimsplit('\n')
51 .filter(keyValuePairsOnly)
52 .forEach(addProperty);
54 function keyValuePairsOnly(line){
55 return line.length && line[0]!=';'
58 function addProperty(line)
60 if(line[0] == '[')
62 section = line.substr(1, line.length-2);
63 if(!(section in object))object[section] = {};
65 else
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;
80 </script>
81 </body>
82 </html>