Mercurial > hg > batmud > chester
annotate index.php @ 20:5208a2a2668d
Comment out HTML comments in JavaScript portions, IE is happier that way,
and of course it's the Right Thing To Do.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 10 Jan 2011 13:18:05 +0200 |
parents | 4add67f75075 |
children | f9211d1917b7 |
rev | line source |
---|---|
0 | 1 <? |
6 | 2 $pageTitle = "Pupunen BatMUD Container Command Creator ALPHA"; |
0 | 3 $pageIndex = "index.php"; |
4 require "mcommon.inc.php"; | |
5 | |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
6 |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
7 // Multi-stack item fixups |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
8 $fixItemTable = array( |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
9 "(purple|green) gloves" => 'a ${1} glove', |
5 | 10 "bracelet mades of green crystal" => "bracelet made of green crystal", |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
11 "alchemist moulded rings" => "alchemist moulded ring", |
14 | 12 |
13 // Generic rings | |
14 "(heavy black metal|steel) rings" => "a ${1} ring", | |
15 | |
16 // Damiens | |
17 "arm protectors called Damien \(\S+\)" => "an arm protector called Damien (${1})", | |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
18 |
14 | 19 // Containers |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
20 "white cloth packs for holding salves" => "white cloth pack for holding salves", |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
21 "(small|HUGE) shiny boxes for storing minerals" => 'a ${1} shiny box for storing minerals', |
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
22 "(small|HUGE) sturdy packs for storing potions" => 'a ${1} sturdy pack for storing potions', |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
23 ); |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
24 |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
25 |
2 | 26 $fixNumbers = array( |
27 "one" => 1, "two" => 2, "three" => 3, "four" => 4, | |
28 "five" => 5, "six" => 6, "seven" => 7, "eight" => 8, | |
29 "nine" => 9, "ten" => 10 | |
30 ); | |
31 | |
32 | |
0 | 33 function getJSArraySegment($arr) |
34 { | |
35 $str = ""; | |
36 foreach ($arr as $item) { | |
37 if ($str != "") $str .= ", "; | |
38 if (is_array($item)) | |
39 $str .= "[".getJSArraySegment($item)."]"; | |
40 else | |
41 $str .= "\"".addslashes($item)."\""; | |
42 } | |
43 return $str; | |
44 } | |
45 | |
46 | |
2 | 47 function printInputField($id, $label, $len, $value = "") |
0 | 48 { |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
49 global $jsData; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
50 $jsData .= "document.getElementById(\"".$id."\").value = \"".$value."\";\n"; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
51 |
2 | 52 echo "<label for=\"".$id."\">".htmlentities($label).": </label>". |
53 "<input type=\"text\" name=\"".$id."\" maxlength=\"".$len. | |
54 "\" size=\"".$len."\" id=\"".$id."\" value=\"".htmlentities($value)."\" />\n"; | |
1 | 55 } |
56 | |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
57 function printCheckBox($id, $label, $value = FALSE) |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
58 { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
59 global $jsData; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
60 $jsData .= "document.getElementById(\"".$id."\").checked = ".($value ? "true" : "false").";\n"; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
61 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
62 echo "<input type=\"checkbox\" id=\"".$id."\" value=\"".$value."\" ".($value ? "checked=\"checked\"" : "")." />". |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
63 "<label for=\"".$id."\">".htmlentities($label)."</label>"; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
64 } |
1 | 65 |
66 function printOptionSelect($id, $size, $multi = FALSE) | |
67 { | |
68 echo "<select ".($multi ? " multiple=\"multiple\"" : "")." size=\"".$size."\" id=\"".$id."\"><option></option></select>"; | |
0 | 69 } |
70 | |
71 | |
2 | 72 if (isset($_POST["mode"])) { |
73 $formMode = intval($_POST["mode"]); | |
74 } else | |
75 $formMode = 0; | |
76 | |
77 | |
1 | 78 printPageHeader($pageTitle, " |
79 <style type=\"text/css\"> | |
80 <!-- | |
81 .buttons { width: 100%; } | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
82 select { width: 100%; } |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
83 |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
84 div.options, #commands, #status { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
85 background: #268; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
86 border: 1px solid white; |
11 | 87 color: white; |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
88 } |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
89 |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
90 div.options { display: none; position: fixed; top: 2em; left: 2em; padding: 1em; } |
2 | 91 |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
92 #commands { display: none; position: fixed; top: 2em; left: 2em; padding: 1em; z-index: 15; } |
1 | 93 |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
94 #status { position: absolute; bottom: 1em; right: 1em; left: 1em; padding: 2pt; z-index: -1; } |
1 | 95 --> |
96 </style> | |
97 "); | |
0 | 98 echo "<h1>".$pageTitle."</h1>\n"; |
99 | |
2 | 100 |
101 /* | |
102 * Initial mode, request item listing | |
103 */ | |
0 | 104 if ($formMode == 0) { |
105 ?> | |
106 <noscript> | |
2 | 107 <p> |
0 | 108 <b>This application REQUIRES JavaScript to be enabled!</b> |
2 | 109 </p> |
0 | 110 </noscript> |
111 <p> | |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
112 <form action="<? echo $pageIndex; ?>" method="post"> |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
113 <input type="hidden" value="YToxOntzOjU6Iml0ZW1zIjthOjQ3OntpOjA7czozODoiVGhlIHN0YWZmIG9mIExlcmV0aGluIGxhYmVsZWQgYXMgfEdncnwiO2k6MTtzOjM1OiJzd2lybGVkIGdyZWVuIHZlc3QgbGFiZWxlZCBhcyAoR2dyKSI7aToyO3M6Njk6ImEgd2VsbC1jcmFmdGVkIHBhaXIgb2Ygc3R1ZC1jb3ZlcmVkIGxlYXRoZXIgbGVnZ2luZ3MgbGFiZWxlZCBhcyAoR2dyKSI7aTozO3M6NTU6IlJpbmcgb2Ygd2lzZG9tIFtNYWRlIGJ5OiBOdWFuZV0gbGFiZWxlZCBhcyA2d2lzMWhwci9nZ3IiO2k6NDtzOjU0OiJzaGluaW5nIHJpbmcgY3JhZnRlZCBvdXQgb2YgbW9vbnN0b25lIGxhYmVsZWQgYXMgKEdncikiO2k6NTtzOjUxOiJHcmlteSBncmVhdCBjbG9hayBvZiB0cnVlIHNvcmNlcmVyIGxhYmVsZWQgYXMgfEdncnwiO2k6NjtzOjI5OiJhIGJsYWNrIGhvb2QgbGFiZWxlZCBhcyB8R2dyfCI7aTo3O3M6Mzg6InRoZSB0b21lIG9mIGtub3dsZWRnZSBsYWJlbGVkIGFzIChHZ3IpIjtpOjg7czo1MzoiaGVhdnkgdGFiYXJkIHdpdGggYSBjaGFsaWNlIGVuc2lnbmlhIGxhYmVsZWQgYXMgKEdncikiO2k6OTtzOjQ3OiJkYXJrIGdyZXkgYW5kIHdoaXRlIHBsYWlkIGtpbHQgbGFiZWxlZCBhcyAoR2dyKSI7aToxMDtzOjM4OiJzdHJvbmcgc2FwcGhpcmUgYm9vdHMgbGFiZWxlZCBhcyAoR2dyKSI7aToxMTtzOjI3OiJzdW4gYW11bGV0IGxhYmVsZWQgYXMgKEdncikiO2k6MTI7czo0MDoiQW5jaWVudCBCcmFjZXJzIG9mIFh6dWkgbGFiZWxlZCBhcyAoR2dyKSI7aToxMztzOjQyOiJnbGl0dGVyaW5nIGxlZyBwcm90ZWN0b3JzIGxhYmVsZWQgYXMgKEdncikiO2k6MTQ7czo0OToiYSBicmFjZWxldCBtYWRlIG9mIGdyZWVuIGNyeXN0YWwgbGFiZWxlZCBhcyAoR2dyKSI7aToxNTtzOjQ5OiJhIGJyYWNlbGV0IG1hZGUgb2YgZ3JlZW4gY3J5c3RhbCBsYWJlbGVkIGFzIChHZ3IpIjtpOjE2O3M6NDU6ImEgcmVpbmZvcmNlZCBicm9uemUgYnJhY2VsZXQgbGFiZWxlZCBhcyAoR2dyKSI7aToxNztzOjQyOiJ0aGUgQnJhY2VsZXRzIG9mIERhcmtuZXNzIGxhYmVsZWQgYXMgKEdncikiO2k6MTg7czozNDoiVGlidXJjaW8ncyBhbXVsZXQgbGFiZWxlZCBhcyAoR2dyKSI7aToxOTtzOjQ5OiJuZWNrbGFjZSBtYWRlIG91dCBvZiBzaGFycCBmYW5ncyBsYWJlbGVkIGFzIChHZ3IpIjtpOjIwO3M6NjI6ImEgZ2xpbW1lcmluZyBsZWF0aGVyIGJlbHQgd2l0aCBnZW0gZGVjb3JhdGlvbiBsYWJlbGVkIGFzIChHZ3IpIjtpOjIxO3M6NDE6ImEgaGVhdnkgYmxhY2sgbWV0YWwgcmluZyBsYWJlbGVkIGFzIChHZ3IpIjtpOjIyO3M6NDE6ImEgaGVhdnkgYmxhY2sgbWV0YWwgcmluZyBsYWJlbGVkIGFzIChHZ3IpIjtpOjIzO3M6NDU6IkRlbW9uaWMgUmluZyBvZiBJbnZpc2liaWxpdHkgbGFiZWxlZCBhcyAoR2dyKSI7aToyNDtzOjMxOiJhIHB1cnBsZSBnbG92ZSBsYWJlbGVkIGFzIChHZ3IpIjtpOjI1O3M6MzE6ImEgcHVycGxlIGdsb3ZlIGxhYmVsZWQgYXMgKEdncikiO2k6MjY7czozMDoiYSBncmVlbiBnbG92ZSBsYWJlbGVkIGFzIChHZ3IpIjtpOjI3O3M6MzA6ImEgZ3JlZW4gZ2xvdmUgbGFiZWxlZCBhcyAoR2dyKSI7aToyODtzOjQzOiJhIHBhaXIgb2YgYmxhY2sgYm9vdHMgbGFiZWxlZCBhcyB8R2dyTXVycml8IjtpOjI5O3M6NzI6IkEgYmVhdXRpZnVsIHJvc2FyeSBlbmZvbGRlZCB3aXRoIHdoaXRlIG1pc3QgbGFiZWxlZCBhcyB8R2dyTXVycml8IChob2x5KSI7aTozMDtzOjgyOiJhIHNtYWxsIHJpbmcgYmVhcmluZyB0aGUgZW1ibGVtIG9mIHRoZSBidW5ueSBbTWFkZSBieTogS2lvbWV0XSBsYWJlbGVkIGFzIDZ3aXMyaW50IjtpOjMxO3M6NjE6ImEgdmlhbCBjb250YWluaW5nIHRoZSB0ZWFycyBvZiBPeHRvdGggbGFiZWxlZCBhcyAoR2dyKSAoaG9seSkiO2k6MzI7czo0NDoiQSBsZWF0aGVyIHBvdWNoIGxhYmVsZWQgYXMgdjQgKHF1YXJ0ZXIgZnVsbCkiO2k6MzM7czo0Mzoic2xlZXZlcyBvZiBtb29taW4gZW11bHNpb24gbGFiZWxlZCBhcyAoR2dyKSI7aTozNDtzOjMzOiJhIGdyZWVuIGhlYWRiYW5kIGxhYmVsZWQgYXMgKEdncikiO2k6MzU7czozNDoiQ2FwZSBvZiBLbm93bGVkZ2UgbGFiZWxlZCBhcyAoR2dyKSI7aTozNjtzOjU0OiJUaGUgZ2xlYW1pbmcgYmx1ZSBjb2xsYXIgb2YgQmVuZ2Fsb3JlIGxhYmVsZWQgYXMgKEdncikiO2k6Mzc7czo1MToiZ29sZGVuIGJlbHQgb2YgRmFpciBSaXZlci1EYXVnaHRlciBsYWJlbGVkIGFzIChHZ3IpIjtpOjM4O3M6NDI6ImEgYmxhY2sgY2xvYWsgKGV2aWwgZ2xvdykgbGFiZWxlZCBhcyB8R2dyfCI7aTozOTtzOjM1OiJSaW5nIG9mIHRoZSBNZWR1c2EgbGFiZWxlZCBhcyAoR2dyKSI7aTo0MDtzOjQ0OiJBIGxvdyB3aWRlLWJyaW1tZWQgaGF0IGxhYmVsZWQgYXMgfEdnck11cnJpfCI7aTo0MTtzOjEzOiJhIHN0ZXRob3Njb3BlIjtpOjQyO3M6NjY6ImEgc2hpbW1lcmluZyBibHVlIGJyZWFzdHBsYXRlIG1hZGUgb2YgcXVhcnR6IGxhYmVsZWQgYXMgfEdnck11cnJpfCI7aTo0MztzOjUzOiJhIHBhaXIgb2YgcHVyZSB3aGl0ZSBmbG93aW5nIHNsZWV2ZXMgbGFiZWxlZCBhcyAoR2dyKSI7aTo0NDtzOjQzOiJSZWRmYW5nIEJlYWRzIG9mIElyb24gV2lsbCBsYWJlbGVkIGFzIChHZ3IpIjtpOjQ1O3M6NTk6Ik5vdmEgQXJjYW51bSwgTWVsa2lvcidzIGJvb2sgb2YgbmVjcm9tYW5jeSBsYWJlbGVkIGFzIChHZ3IpIjtpOjQ2O3M6NDQ6ImEgcGFpciBvZiBzaG9ydCBncmVlbiBib290cyBsYWJlbGVkIGFzIChHZ3IpIjt9fQ==" name="data" /> |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
114 <input type="hidden" value="2" name="mode" /> |
0 | 115 First, you should provide a list of equipments you wish to manage. |
116 Just plain copy & paste of an inventory listing is enough. | |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
117 You can also test with pre-defined equipments, |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
118 <input type="submit" value=" Test " /> by clicking the button. |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
119 </form> |
0 | 120 </p> |
121 <p> | |
122 <b>Stacks of items are not supported, and few other things may cause problems too.</b> | |
123 </p> | |
124 <form action="<? echo $pageIndex; ?>" method="post"> | |
2 | 125 <p> |
126 <textarea name="data" cols="100" rows="20"></textarea> | |
0 | 127 <input type="hidden" value="1" name="mode" /> |
2 | 128 </p> |
0 | 129 <div class="icenter"> |
130 <input type="submit" value=" Submit " /> | |
131 </div> | |
132 </form> | |
133 <? | |
134 } | |
2 | 135 |
136 /* | |
137 * Parse and validate item | |
138 */ | |
0 | 139 else if ($formMode == 1) { |
140 if (isset($_POST["data"])) { | |
141 $formData = stripslashes($_POST["data"]); | |
142 | |
143 $postData = explode("\n", $formData); | |
144 $data = array(); | |
145 $ignored = array(); | |
146 | |
2 | 147 function addItems($num, $desc) |
148 { | |
149 global $data; | |
150 for ($i = 0; $i < $num; $i++) | |
151 $data["items"][] = $desc; | |
152 } | |
153 | |
0 | 154 foreach ($postData as $line) { |
155 // Trim whitespace | |
156 $str = trim($line); | |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
157 if ($str == "") continue; |
0 | 158 |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
159 // Strip glows and counters from item "handle" |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
160 if (preg_match("/^(.+?)\s+(<.+? glow>|\(\d+\/\d+\)|\[\d+\/\d+\])$/", $str, $m)) |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
161 $str = $m[1]; |
0 | 162 |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
163 // Discard multi-item lines |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
164 if (preg_match("/^(many|two|three|four|five|six|seven|eight|nine|ten)\s+(.+?)( labeled as .+|)$/", $str, $m)) { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
165 if (!isset($fixNumbers[$m[1]])) { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
166 $ignored[$str] = "Unparsed stack of many"; |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
167 } else { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
168 $n = $fixNumbers[$m[1]]; |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
169 $changed = 0; |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
170 foreach ($fixItemTable as $pat => $rep) { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
171 if ($pat[0] == "*") { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
172 if (substr($pat, 1) == $m[2]) { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
173 $res = $rep; |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
174 $changed = 1; |
2 | 175 } |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
176 } else { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
177 $res = preg_replace("/".$pat."/", $rep, $m[2], -1, &$changed); |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
178 } |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
179 if ($changed > 0) { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
180 addItems($n, $res.$m[3]); |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
181 break; |
2 | 182 } |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
183 } |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
184 if ($changed == 0) { |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
185 $ignored[$str] = "Unsupported item stack"; |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
186 } |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
187 } |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
188 } else |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
189 addItems(1, $str); |
0 | 190 } |
191 | |
192 if (count($ignored) > 0) { | |
193 ?> | |
194 <p>Item data processed. Following lines <b>were not accepted</b>:</p> | |
195 <table> | |
196 <tr><th>Item</th><th>Reason</th></tr> | |
197 <? | |
198 foreach ($ignored as $name => $reason) { | |
199 echo " <tr><td>".htmlentities($name)."</td><td>".htmlentities($reason)."</td></tr>\n"; | |
200 } | |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
201 |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
202 $encData = base64_encode(serialize($data)); |
0 | 203 ?> |
204 </table> | |
205 | |
206 <form action="<? echo $pageIndex; ?>" method="post"> | |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
207 <input type="hidden" value="<? echo $encData ?>" name="data" /> |
0 | 208 <input type="hidden" value="2" name="mode" /> |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
209 <? |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
210 // echo "<textarea name=\"data\" cols=\"100\" rows=\"20\">".$encData."</textarea>\n"; |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
211 ?> |
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
212 <br /> |
0 | 213 <input type="submit" value=" Continue " /> |
214 </form> | |
215 <? | |
216 } else | |
217 $formMode = 3; | |
218 } else { | |
219 $errorMsg = "No item data provided."; | |
220 $errorSet = TRUE; | |
221 } | |
3
aeb37c6b16fd
Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
222 } // formMode == 1 |
0 | 223 |
1 | 224 |
225 /* | |
226 * Unserialize data from previous step | |
227 */ | |
0 | 228 if ($formMode == 2) { |
229 if (isset($_POST["data"])) { | |
230 $formData = base64_decode($_POST["data"]); | |
231 $data = @unserialize($formData); | |
232 $formMode = 3; | |
233 } | |
234 if ($data === FALSE) { | |
235 $errorMsg = "Could not unserialize data, internal error."; | |
236 $errorSet = TRUE; | |
237 } | |
238 } | |
239 | |
1 | 240 |
241 /* | |
242 * Interactive editor mode begins here | |
243 */ | |
2 | 244 if ($data !== FALSE && $formMode == 3) { |
0 | 245 ?> |
246 <form id="done" action="<? echo $pageIndex; ?>" method="post"> | |
1 | 247 <p id="create_buttons"> |
2 | 248 <input type="button" value=" Create BatMUD Commands " onclick="createInit('batmud');" /> |
249 <!-- <input type="button" value=" Create TinyFugue Macros " onclick="createInit('tf');" /> | |
1 | 250 --> |
2 | 251 <input type="button" value=" Create SAVEBLOB " onclick="createInit('save');" /> |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
252 <input type="button" value=" Reset All " onclick="resetAll();" /> |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
253 <input type="button" value=" Empty Containers " onclick="emptyContainers();" /> |
0 | 254 </p> |
1 | 255 |
256 | |
0 | 257 <table> |
258 <tr> | |
1 | 259 |
0 | 260 <td> |
261 <h2>Items pool</h2> | |
1 | 262 <? printOptionSelect("curr_items", 10, TRUE); ?> |
263 <table class="buttons"> | |
264 <tr> | |
265 <td><input type="button" value=" Delete " onclick="deleteItems(this.form);" /></td> | |
266 <td><input type="button" value=" Add new " onclick="addItems(this.form);" disabled="disabled" /></td> | |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
267 <td><b><span id="curr_nitems"></span> items</b></td> |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
268 <td><input type="button" value=" AutoMove " onclick="autoMoveItems(this.form);" /></td> |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
269 <td style="width: 60%; text-align: right;"><input type="button" value=" Move to container " onclick="moveItems(this.form);" /></td> |
1 | 270 </tr> |
0 | 271 </table> |
272 </td> | |
1 | 273 |
6 | 274 <td id="container_editor"> |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
275 <h2>Editing container "<span id="curr_name"></span>"</h2> |
6 | 276 <? printOptionSelect("curr_container", 10, TRUE); ?> |
1 | 277 <table class="buttons"> |
278 <tr> | |
6 | 279 <td><input type="button" value=" Remove selected " onclick="containerRemoveItems(this.form);" /></td> |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
280 <td><b><span id="curr_info"></span> items</b></td> |
1 | 281 </tr> |
282 </table> | |
0 | 283 </td> |
284 </tr> | |
1 | 285 |
0 | 286 <tr> |
287 <td> | |
6 | 288 <h2>Create / edit a container</h2> |
0 | 289 <? |
6 | 290 printInputField("container_name", "Identifier/name", 15); |
291 printInputField("container_slots", "Number of slots", 5); | |
0 | 292 ?> |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
293 <input type="button" value=" Create new " onclick="containerCreate(this.form);" id="create_button" /> |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
294 <input type="button" value=" Modify " onclick="containerModify(this.form);" id="modify_button" /> |
0 | 295 </td> |
1 | 296 |
6 | 297 <td id="container_list_editor"> |
298 <h2>Defined containers</h2> | |
299 <? printOptionSelect("container_list", 5, FALSE); ?> | |
1 | 300 <table class="buttons"> |
301 <tr> | |
6 | 302 <td><input type="button" value=" Switch to " onclick="containerEdit(this.form);" /></td> |
303 <td><input type="button" value=" Delete " onclick="containerDelete(this.form);" /></td> | |
19 | 304 <td><b><span id="containers_info"></span> items total</b></td> |
1 | 305 </tr> |
306 </table> | |
0 | 307 </td> |
1 | 308 |
0 | 309 </tr> |
310 </table> | |
311 </form> | |
1 | 312 |
2 | 313 <div id="commands"> |
314 <textarea id="command_data" cols="80" rows="10"></textarea> | |
315 <br /> | |
316 <input type="button" value=" Close " onclick="viewCommands(false, '');" /> | |
317 </div> | |
318 | |
319 <div id="options_batmud" class="options"> | |
320 <? printInputField("cmd_delim", "Command delimiter", 15, ";"); ?><br /> | |
321 <? printInputField("cmd_prefix", "Command name prefix", 15, "mcp"); ?><br /> | |
6 | 322 <? printInputField("cmd_cmd", "Command", 32, "put \$1 in \$2"); ?> (<b>$1</b> = item, <b>$2</b> = container)<br /> |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
323 <? printCheckBox("cmd_sequence", "Create sequence for each item, instead of command alias list.", FALSE); ?><br /> |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
324 <? printCheckBox("cmd_autoclose", "Add commands for automatically opening and closing each container.", FALSE); ?><br /> |
6 | 325 <br /> |
2 | 326 <input type="button" value=" Create " onclick="createCommands('batmud');" /> |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
327 <input type="button" value=" Cancel " onclick="createInit('clear');" /> |
2 | 328 </div> |
329 | |
330 <div id="options_tf" class="options"> | |
331 <input type="button" value=" Create " onclick="createCommands('tf');" /> | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
332 <input type="button" value=" Cancel " onclick="createInit('clear');" /> |
2 | 333 </div> |
334 | |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
335 <div id="lol" class="options"></div> |
1 | 336 |
337 <div id="status"> </div> | |
338 | |
0 | 339 <script type="text/javascript"> |
340 <!-- | |
6 | 341 var curr_container = null; |
0 | 342 |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
343 |
6 | 344 function Container(name, slots, items) |
0 | 345 { |
346 this.name = name; | |
347 this.slots = slots; | |
348 this.items = items; | |
349 this.changed = true; | |
350 | |
2 | 351 this.getCountByName = function(n) { |
352 var cnt = 0; | |
353 for (var i = 0; i < this.items.length; i++) { | |
354 if (this.items[i] == n) cnt++; | |
355 } | |
356 return cnt; | |
357 } | |
358 | |
0 | 359 this.getSpace = function() { |
360 return this.slots - this.items.length; | |
361 } | |
362 | |
363 this.addItem = function(item) { | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
364 if (this.items.length < slots) { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
365 this.changed = true; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
366 this.items.push(item); |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
367 return true; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
368 } else |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
369 return false; |
0 | 370 } |
371 | |
372 this.deleteItemById = function(id) { | |
373 this.changed = true; | |
374 delete this.items[id]; | |
375 } | |
376 | |
377 this.flush = function() { | |
378 this.changed = true; | |
379 for (var i = 0; i < this.items.length; i++) { | |
380 if (this.items[i] == undefined) { | |
381 this.items.splice(i, 1); | |
382 i -= 1; | |
383 } | |
384 } | |
385 } | |
386 | |
6 | 387 this.moveItemById = function(container, id) { |
0 | 388 var item = this.getItemByIndex(id); |
389 if (item != null) { | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
390 if (!container.addItem(item)) |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
391 return false; |
0 | 392 this.deleteItemById(id); |
393 this.changed = true; | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
394 return true; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
395 } else |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
396 return false; |
0 | 397 } |
398 | |
399 this.getItemId = function(item) { | |
400 return this.items.indexOf(item); | |
401 } | |
402 | |
403 this.getItemByIndex = function(id) { | |
1 | 404 if (id < 0 || id >= this.items.length) return null; |
0 | 405 return this.items[id]; |
406 } | |
407 } | |
20
5208a2a2668d
Comment out HTML comments in JavaScript portions, IE is happier that way,
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
408 //--> |
0 | 409 <? |
6 | 410 function getContainerObject($name, $slots, $items) |
0 | 411 { |
6 | 412 return "new Container(\"".$name."\", \"".$slots."\", [".getJSArraySegment($items)."])"; |
0 | 413 } |
414 | |
415 $str = ""; | |
6 | 416 if (isset($data["containers"])) { |
417 foreach ($data["containers"] as $container) { | |
0 | 418 if ($str != "") $str .= ", "; |
6 | 419 $str .= getContainerObject($container["name"], $container["slots"], $container["items"]); |
0 | 420 } |
421 } | |
422 | |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
423 echo " |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
424 var list_containers; |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
425 var list_items; |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
426 |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
427 function initContainers() |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
428 { |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
429 list_containers = [".$str."]; |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
430 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
431 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
432 function initItems() |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
433 { |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
434 list_items = ".(isset($data["items"]) ? getContainerObject("items", 10000, $data["items"]) : "null")."; |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
435 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
436 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
437 function initSettings() |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
438 { |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
439 ".$jsData." |
10
e2f975b0c518
Fix reset functionality. Add startup message.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
440 curr_container = null; |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
441 } |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
442 "; |
0 | 443 ?> |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
444 <!-- kludge --><!-- |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
445 |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
446 function resetAll() |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
447 { |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
448 var answer = confirm("Really delete all defined containers and reset item pool to original state? You will have to re-define containers from scratch."); |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
449 if (!answer) { |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
450 statusMsg("Reset operation cancelled."); |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
451 return; |
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
452 } |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
453 initContainers(); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
454 initItems(); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
455 initSettings(); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
456 updatePage(); |
17 | 457 statusMsg('Welcome to the editor. <b>© Copyright 2011 Matti Hämäläinen aka Ggr Pupunen.</b>'); |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
458 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
459 |
16 | 460 |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
461 function emptyContainers() |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
462 { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
463 var answer = confirm("Really clear (empty) all defined containers and reset item pool to original state?"); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
464 if (!answer) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
465 statusMsg("Clear operation cancelled."); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
466 return; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
467 } |
16 | 468 |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
469 initItems(); |
16 | 470 |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
471 for (var i = 0; i < list_containers.length; i++) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
472 list_containers[i].items = []; |
16 | 473 if (i == 0) { |
474 curr_container = list_containers[i]; | |
475 curr_container.changed = true; | |
476 } | |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
477 } |
16 | 478 |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
479 updatePage(); |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
480 } |
0 | 481 |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
482 |
0 | 483 function setHTML(id, str) |
484 { | |
485 var o = document.getElementById(id); | |
486 if (o != null) | |
487 o.innerHTML = str; | |
488 } | |
489 | |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
490 |
0 | 491 function setListData(id, list) |
492 { | |
493 var o = document.getElementById(id); | |
494 o.options.length = 0; | |
495 for (var i = 0; i < list.length; i++) { | |
496 o.options[i] = new Option(list[i], i, false, false); | |
497 } | |
498 } | |
499 | |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
500 |
0 | 501 // Update the form data |
502 function updatePage() | |
503 { | |
504 // List of items | |
2 | 505 if (list_items != null && list_items.changed) { |
506 list_items.changed = false; | |
0 | 507 setListData("curr_items", list_items.items); |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
508 setHTML("curr_nitems", list_items.items.length); |
2 | 509 } |
0 | 510 |
6 | 511 // List of containers |
512 var container_list_editor = document.getElementById("container_list_editor"); | |
513 if (list_containers.length > 0) { | |
514 container_list_editor.style.display = "block"; | |
0 | 515 |
6 | 516 o = document.getElementById("container_list"); |
0 | 517 o.options.length = 0; |
19 | 518 var total_items = 0; |
519 var total_slots = 0; | |
6 | 520 for (var i = 0; i < list_containers.length; i++) { |
521 o.options[i] = new Option(list_containers[i].name +" (" + list_containers[i].items.length +" of "+ list_containers[i].slots +" items)", i, false); | |
19 | 522 total_items += list_containers[i].items.length; |
523 total_slots += list_containers[i].slots; | |
0 | 524 } |
19 | 525 setHTML("containers_info", total_items+" / "+total_slots); |
0 | 526 } else { |
6 | 527 container_list_editor.style.display = "none"; |
0 | 528 } |
529 | |
530 | |
6 | 531 // Update current container |
532 var container_editor = document.getElementById("container_editor"); | |
533 if (curr_container != null) { | |
534 container_editor.style.display = "block"; | |
535 setHTML("curr_name", curr_container.name); | |
12
774db3b4bedc
Add some informational output.
Matti Hamalainen <ccr@tnsp.org>
parents:
11
diff
changeset
|
536 setHTML("curr_info", curr_container.items.length+" / "+curr_container.slots); |
4 | 537 |
6 | 538 if (curr_container.changed) { |
539 curr_container.changed = false; | |
540 setListData("curr_container", curr_container.items); | |
2 | 541 } |
0 | 542 } else { |
6 | 543 container_editor.style.display = "none"; |
0 | 544 } |
545 } | |
546 | |
547 // Output status message | |
548 function statusMsg(msg) | |
549 { | |
550 var o = document.getElementById("status"); | |
551 o.innerHTML = msg; | |
552 } | |
553 | |
554 | |
555 // Clear values of a given form | |
556 function clearForm(f) | |
557 { | |
558 for (var i = 0; i < f.elements.length; i++) { | |
559 var e = f.elements[i]; | |
560 if (e.type.toLowerCase() == "text") e.value = ""; | |
561 } | |
562 } | |
563 | |
564 | |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
565 function validateContainerData(f) |
0 | 566 { |
6 | 567 var name = f.elements['container_name'].value; |
568 var slots = parseInt(f.elements['container_slots'].value, 10); | |
0 | 569 |
1 | 570 if (isNaN(slots) || slots < 1) { |
571 statusMsg("Number of slots not set or is invalid."); | |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
572 return null; |
0 | 573 } |
574 | |
575 if (name == "") { | |
6 | 576 statusMsg("Empty container name "+name+"."); |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
577 return null; |
0 | 578 } |
1 | 579 |
2 | 580 if (name.match(/[^a-z0-9_]/)) { |
6 | 581 statusMsg("Invalid container name, only lower case alphanumerics and underscore are allowed."); |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
582 return null; |
1 | 583 } |
0 | 584 |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
585 return {name: name, slots: slots}; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
586 } |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
587 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
588 // Create a new container, set current container to it |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
589 function containerCreate(f) |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
590 { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
591 var c = validateContainerData(f); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
592 if (c == null) |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
593 return; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
594 |
6 | 595 for (var i = 0; i < list_containers.length; i++) { |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
596 if (list_containers[i].name == c.name) { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
597 statusMsg("Container with identifier '<b>"+c.name+"</b>' already exists!"); |
0 | 598 return; |
599 } | |
600 } | |
601 | |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
602 curr_container = new Container(c.name, c.slots, []); |
6 | 603 list_containers.push(curr_container); |
0 | 604 |
605 clearForm(f); | |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
606 statusMsg("Created new container '<b>"+c.name+"</b>' with <b>"+c.slots+"</b> slots."); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
607 updatePage(); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
608 } |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
609 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
610 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
611 // Change current container |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
612 function containerModify(f) |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
613 { |
10
e2f975b0c518
Fix reset functionality. Add startup message.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
614 if (curr_container == null) { |
e2f975b0c518
Fix reset functionality. Add startup message.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
615 statusMsg("No current container, create or select one."); |
e2f975b0c518
Fix reset functionality. Add startup message.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
616 return; |
e2f975b0c518
Fix reset functionality. Add startup message.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
617 } |
e2f975b0c518
Fix reset functionality. Add startup message.
Matti Hamalainen <ccr@tnsp.org>
parents:
9
diff
changeset
|
618 |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
619 var c = validateContainerData(f); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
620 if (c == null) |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
621 return; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
622 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
623 if (c.slots < curr_container.items.length) { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
624 statusMsg("New number of slots can't be smaller than number of items in it! ("+ c.slots +" < "+ curr_container.items.length +")"); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
625 return; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
626 } |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
627 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
628 curr_container.name = c.name; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
629 curr_container.slots = c.slots; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
630 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
631 clearForm(f); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
632 statusMsg("Updated container."); |
0 | 633 updatePage(); |
634 } | |
635 | |
636 | |
6 | 637 function containerCheckSelected(f) |
1 | 638 { |
6 | 639 var id = f.elements['container_list'].selectedIndex; |
1 | 640 |
6 | 641 if (id < 0 || id >= list_containers.length) { |
642 statusMsg("Invalid container, internal error!"); | |
1 | 643 return -1; |
644 } | |
645 | |
6 | 646 return {id: id, container: list_containers[id]}; |
1 | 647 } |
648 | |
649 | |
6 | 650 // Delete a container from container list |
651 function containerDelete(f) | |
0 | 652 { |
6 | 653 var ret = containerCheckSelected(f); |
654 if (ret.id < 0 || ret.container == null) return; | |
1 | 655 |
6 | 656 var name = ret.container.name; |
657 var len = ret.container.items.length; | |
1 | 658 |
6 | 659 var answer = confirm("Really delete selected container '"+name+"' and move "+len+" items back to pool?"); |
1 | 660 if (!answer) { |
661 statusMsg("Delete operation cancelled."); | |
662 return; | |
663 } | |
664 | |
6 | 665 if (curr_container == ret.container) |
666 curr_container = null; | |
1 | 667 |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
668 for (var i = 0; i < len; i++) { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
669 if (!ret.container.moveItemById(list_items, i)) { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
670 statusMsg("Internal error moving item "+ i); |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
671 return; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
672 } |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
673 } |
1 | 674 |
6 | 675 list_containers.splice(ret.id, 1); |
1 | 676 |
677 if (len > 0) { | |
6 | 678 statusMsg("Deleted container '"+name+"', "+len+" items returned to pool."); |
1 | 679 } else { |
6 | 680 statusMsg("Deleted empty container '"+name+"'."); |
1 | 681 } |
682 updatePage(); | |
683 } | |
684 | |
685 | |
6 | 686 // Change currently edited container to another |
687 function containerEdit(f) | |
1 | 688 { |
6 | 689 var ret = containerCheckSelected(f); |
690 if (ret.id < 0 || ret.container == null) return; | |
1 | 691 |
6 | 692 curr_container = ret.container; |
693 curr_container.changed = true; | |
694 statusMsg("Switched to container '"+ret.container.name+"'."); | |
0 | 695 updatePage(); |
696 } | |
697 | |
698 | |
9
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
699 function containerRemoveItems(f) |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
700 { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
701 if (curr_container == null) { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
702 statusMsg("Internal error."); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
703 return; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
704 } |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
705 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
706 var selected = getSelectedItems(f.elements['curr_container']); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
707 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
708 if (selected.length == 0) { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
709 statusMsg("No items selected for deletion."); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
710 return; |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
711 } else { |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
712 for (var i = 0; i < selected.length; i++) |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
713 curr_container.moveItemById(list_items, selected[i]); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
714 |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
715 curr_container.flush(); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
716 updatePage(); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
717 statusMsg("Removed " + selected.length + " from current container."); |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
718 } |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
719 } |
da404b8ff282
Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents:
8
diff
changeset
|
720 |
0 | 721 function getSelectedItems(items) |
722 { | |
723 var selected = []; | |
724 if (items != null) { | |
725 for (var i = 0; i < items.length; i++) | |
726 if (items[i].selected) selected.push(items[i].value); | |
727 } | |
728 return selected; | |
729 } | |
730 | |
731 | |
732 function deleteItems(f) | |
733 { | |
734 var selected = getSelectedItems(f.elements['curr_items']); | |
735 | |
736 if (selected.length == 0) { | |
737 statusMsg("No items selected for deletion."); | |
738 return; | |
739 } else { | |
740 var answer = confirm("Really delete selected items?"); | |
741 if (!answer) { | |
742 statusMsg("Delete operation cancelled."); | |
743 return; | |
744 } | |
745 | |
746 for (var i = 0; i < selected.length; i++) | |
747 list_items.deleteItemById(selected[i]); | |
748 | |
749 list_items.flush(); | |
750 updatePage(); | |
751 statusMsg("Deleted "+selected.length+" items."); | |
752 } | |
753 } | |
754 | |
755 | |
756 function moveItems(f) | |
757 { | |
6 | 758 if (curr_container == null) { |
759 statusMsg("No container selected, cannot move items."); | |
0 | 760 return; |
761 } | |
762 | |
763 var selected = getSelectedItems(f.elements['curr_items']); | |
764 | |
765 if (selected.length == 0) { | |
766 statusMsg("No items selected for deletion."); | |
767 return; | |
768 } else { | |
6 | 769 if (curr_container.getSpace() < selected.length) { |
770 statusMsg("Not enough space! "+ selected.length +" items, only "+ curr_container.getSpace() +" slots available!"); | |
0 | 771 return; |
772 } | |
773 | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
774 for (var i = 0; i < selected.length; i++) { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
775 if (!list_items.moveItemById(curr_container, selected[i])) { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
776 statusMsg("Internal error moving item #"+i+": '"+selected[i]+"'."); |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
777 return; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
778 } |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
779 } |
0 | 780 |
781 list_items.flush(); | |
782 updatePage(); | |
6 | 783 statusMsg("Moved " + selected.length + " items to current container."); |
0 | 784 } |
785 } | |
786 | |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
787 |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
788 function autoMoveItems(f) |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
789 { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
790 var selected = getSelectedItems(f.elements['curr_items']); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
791 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
792 if (selected.length == 0) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
793 statusMsg("No items selected for AutoMove(tm)."); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
794 return; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
795 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
796 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
797 if (list_containers.length == 0) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
798 statusMsg("No containers available for AutoMove(tm)."); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
799 return; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
800 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
801 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
802 var remaining = selected.length; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
803 var n = 0; |
15
2aa632a8610f
AutoMove: Don't clear item selections if no changes were made.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
804 var changed = 0; |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
805 while (remaining > 0 && n < list_containers.length) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
806 curr = list_containers[n]; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
807 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
808 for (var q = curr.getSpace(); q > 0 && remaining > 0; q--) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
809 remaining--; |
15
2aa632a8610f
AutoMove: Don't clear item selections if no changes were made.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
810 changed++; |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
811 if (!list_items.moveItemById(curr, selected[remaining])) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
812 statusMsg("Internal error moving item #"+remaining+": '"+selected[remaining]+"'."); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
813 return; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
814 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
815 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
816 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
817 n++; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
818 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
819 |
15
2aa632a8610f
AutoMove: Don't clear item selections if no changes were made.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
820 if (changed > 0) { |
2aa632a8610f
AutoMove: Don't clear item selections if no changes were made.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
821 list_items.flush(); |
2aa632a8610f
AutoMove: Don't clear item selections if no changes were made.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
822 updatePage(); |
2aa632a8610f
AutoMove: Don't clear item selections if no changes were made.
Matti Hamalainen <ccr@tnsp.org>
parents:
14
diff
changeset
|
823 } |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
824 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
825 if (remaining > 0) { |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
826 statusMsg("Not enough space! <b>"+ remaining +" of "+ selected.length +"</b> items left without slots!"); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
827 return; |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
828 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
829 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
830 statusMsg("AutoMoved " + selected.length + " items to containers."); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
831 } |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
832 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
833 |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
834 function serializePHP(obj) |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
835 { |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
836 var res; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
837 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
838 if (obj == undefined) |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
839 return null; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
840 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
841 switch (typeof(obj)) { |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
842 case "array": |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
843 res = "["; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
844 for (var i = 0; i < obj.length; i++) { |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
845 if (i > 0) res += ", "; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
846 res += serializePHP(obj[i]); |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
847 } |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
848 res += "]"; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
849 return res; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
850 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
851 case "string": |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
852 return " '" + escape(obj) + "'"; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
853 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
854 case "number": |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
855 return isFinite(obj) ? obj.toString() : null; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
856 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
857 case "object": |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
858 var o = []; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
859 for (a in obj) { |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
860 if (typeof(obj[a]) != "function") { |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
861 o.push('"' + a + '": ' + serializePHP(obj[a])); |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
862 } |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
863 } |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
864 if (o.length > 0) |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
865 return " {" + o.join(",") + "} "; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
866 else |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
867 return " {} "; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
868 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
869 case "boolean": |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
870 return obj ? "true" : "false"; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
871 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
872 default: |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
873 return obj.toString(); |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
874 } |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
875 } |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
876 |
0 | 877 |
2 | 878 var edit_modes = ['batmud', 'tf', 'save']; |
1 | 879 |
2 | 880 function createInit(mode) |
881 { | |
882 for (i = 0; i < edit_modes.length; i++) { | |
883 var o = document.getElementById("options_"+edit_modes[i]); | |
884 if (o != null) { | |
885 o.style.display = (edit_modes[i] == mode) ? "block" : "none"; | |
886 } | |
887 } | |
18
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
888 |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
889 if (mode == "save") { |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
890 var tmp = { "containers": list_containers, "items": list_items }; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
891 viewCommands(true, serializePHP(tmp)); |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
892 /* |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
893 var o = document.getElementById("lol"); |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
894 o.style.display = "block"; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
895 o.innerHTML = serializePHP(tmp); |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
896 */ |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
897 return; |
716329d47372
Serialization and saveblob generation. Not complete yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
17
diff
changeset
|
898 } |
2 | 899 } |
900 | |
901 | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
902 function expandCmd(cmd, item, name) |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
903 { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
904 var str = cmd.replace(/\$1/g, item); |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
905 return str.replace(/\$2/g, name); |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
906 } |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
907 |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
908 |
2 | 909 function createCommands(mode) |
1 | 910 { |
6 | 911 if (list_containers.length == 0) { |
912 statusMsg("No container configurations defined!"); | |
1 | 913 return; |
914 } | |
2 | 915 |
1 | 916 var str = ""; |
6 | 917 for (var i = 0; i < list_containers.length; i++) { |
918 var container = list_containers[i]; | |
2 | 919 var counts = []; |
920 var curr = []; | |
921 | |
6 | 922 for (var n = 0; n < container.items.length; n++) { |
923 var cnt = container.getCountByName(container.items[n]); | |
924 counts[container.items[n]] = cnt; | |
925 curr[container.items[n]] = 1; | |
2 | 926 } |
927 | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
928 var cmd_autoclose = document.getElementById("cmd_autoclose").checked; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
929 var cmd_delim = document.getElementById("cmd_delim").value; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
930 var cmd_prefix = document.getElementById("cmd_prefix").value; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
931 if (cmd_delim == "") cmd_delim = ";"; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
932 var cmd_cmd = document.getElementById("cmd_cmd").value; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
933 var cmd_seq = document.getElementById("cmd_sequence").checked; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
934 var s = ""; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
935 |
6 | 936 for (var n = 0; n < container.items.length; n++) { |
937 var item = container.items[n]; | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
938 var tmp = ""+item; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
939 |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
940 if (counts[item] > 1) { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
941 tmp += " " + curr[item]; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
942 curr[item]++; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
943 } |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
944 |
1 | 945 if (mode == "batmud") { |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
946 if (cmd_seq) { |
8
5e1cdf22d647
Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
947 s += expandCmd(cmd_cmd, tmp, container.name) + "\n"; |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
948 } else { |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
949 if (s != "") s += ","; |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
950 s += tmp; |
2 | 951 } |
1 | 952 } |
953 } | |
2 | 954 |
955 if (mode == "batmud") { | |
14 | 956 if (!cmd_seq) str += "command "+ cmd_prefix + container.name +" "; |
957 if (cmd_autoclose) str += "open "+ container.name + cmd_delim; | |
7
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
958 if (!cmd_seq) str += expandCmd(cmd_cmd, s, container.name); |
6ff1ee9122b2
Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
959 else str += s; |
14 | 960 if (cmd_autoclose) str += cmd_delim +"close "+ container.name; |
2 | 961 str += "\n"; |
962 } | |
1 | 963 } |
964 | |
2 | 965 viewCommands(true, str); |
966 } | |
967 | |
968 function viewCommands(state, str) | |
969 { | |
1 | 970 var o = document.getElementById("commands"); |
2 | 971 o.style.display = state ? "block" : "none"; |
972 var o = document.getElementById("command_data"); | |
1 | 973 o.innerHTML = str; |
974 } | |
975 | |
13
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
976 |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
977 initContainers(); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
978 initItems(); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
979 initSettings(); |
1edbabcbcdbd
Cleanups, and AutoMove(tm) functionality.
Matti Hamalainen <ccr@tnsp.org>
parents:
12
diff
changeset
|
980 updatePage(); |
20
5208a2a2668d
Comment out HTML comments in JavaScript portions, IE is happier that way,
Matti Hamalainen <ccr@tnsp.org>
parents:
19
diff
changeset
|
981 //--> |
0 | 982 </script> |
983 <? | |
984 } | |
985 | |
986 if ($errorSet) { | |
987 echo "<h2>An error occured</h2>\n". | |
988 "<p>".$errorMsg."</p>"; | |
989 } | |
990 | |
991 printPageFooter(); | |
992 ?> |