annotate index.php @ 9:da404b8ff282

Container editing, persistent settings.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 10 Jan 2011 07:21:04 +0200
parents 5e1cdf22d647
children e2f975b0c518
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 <?
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
2 $pageTitle = "Pupunen BatMUD Container Command Creator ALPHA";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 $pageIndex = "index.php";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 require "mcommon.inc.php";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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',
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
10 "heavy black metal rings" => "a heavy black metal ring",
5
af0b958a6e17 Bugfix.
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
11 "bracelet mades of green crystal" => "bracelet made of green crystal",
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
12 "white cloth packs for holding salves" => "white cloth pack for holding salves",
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
13 );
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
14
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
15
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
16 $fixNumbers = array(
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
17 "one" => 1, "two" => 2, "three" => 3, "four" => 4,
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
18 "five" => 5, "six" => 6, "seven" => 7, "eight" => 8,
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
19 "nine" => 9, "ten" => 10
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
20 );
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
21
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
22
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 function getJSArraySegment($arr)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 $str = "";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 foreach ($arr as $item) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 if ($str != "") $str .= ", ";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 if (is_array($item))
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 $str .= "[".getJSArraySegment($item)."]";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 else
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 $str .= "\"".addslashes($item)."\"";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 return $str;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
37 function printInputField($id, $label, $len, $value = "")
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 {
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
39 global $jsData;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
40 $jsData .= "document.getElementById(\"".$id."\").value = \"".$value."\";\n";
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
41
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
42 echo "<label for=\"".$id."\">".htmlentities($label).": </label>".
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
43 "<input type=\"text\" name=\"".$id."\" maxlength=\"".$len.
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
44 "\" size=\"".$len."\" id=\"".$id."\" value=\"".htmlentities($value)."\" />\n";
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
45 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
46
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
47 function printCheckBox($id, $label, $value = FALSE)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
48 {
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."\").checked = ".($value ? "true" : "false").";\n";
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
51
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
52 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
53 "<label for=\"".$id."\">".htmlentities($label)."</label>";
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
54 }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
55
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
56 function printOptionSelect($id, $size, $multi = FALSE)
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
57 {
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
58 echo "<select ".($multi ? " multiple=\"multiple\"" : "")." size=\"".$size."\" id=\"".$id."\"><option></option></select>";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
62 if (isset($_POST["mode"])) {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
63 $formMode = intval($_POST["mode"]);
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
64 } else
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
65 $formMode = 0;
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
66
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
67
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
68 printPageHeader($pageTitle, "
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
69 <style type=\"text/css\">
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
70 <!--
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
71 .buttons { width: 100%; }
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
72 select { width: 100%; }
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
73
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
74 div.options, #commands, #status {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
75 background: #268;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
76 border: 1px solid white;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
77 }
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
78
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
79 div.options { display: none; position: fixed; top: 2em; left: 2em; padding: 1em; }
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
80
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
81 #commands { display: none; position: fixed; top: 2em; left: 2em; padding: 1em; z-index: 15; }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
82
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
83 #status { position: absolute; bottom: 1em; right: 1em; left: 1em; padding: 2pt; z-index: -1; }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
84 -->
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
85 </style>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
86 ");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 echo "<h1>".$pageTitle."</h1>\n";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
89
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
90 /*
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
91 * Initial mode, request item listing
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
92 */
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 if ($formMode == 0) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 ?>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 <noscript>
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
96 <p>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 <b>This application REQUIRES JavaScript to be enabled!</b>
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
98 </p>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 </noscript>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 <p>
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
101 <form action"<? echo $pageIndex; ?>" method="post">
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
102 <input type="hidden" value="YToxOntzOjU6Iml0ZW1zIjthOjQ3OntpOjA7czozODoiVGhlIHN0YWZmIG9mIExlcmV0aGluIGxhYmVsZWQgYXMgfEdncnwiO2k6MTtzOjM1OiJzd2lybGVkIGdyZWVuIHZlc3QgbGFiZWxlZCBhcyAoR2dyKSI7aToyO3M6Njk6ImEgd2VsbC1jcmFmdGVkIHBhaXIgb2Ygc3R1ZC1jb3ZlcmVkIGxlYXRoZXIgbGVnZ2luZ3MgbGFiZWxlZCBhcyAoR2dyKSI7aTozO3M6NTU6IlJpbmcgb2Ygd2lzZG9tIFtNYWRlIGJ5OiBOdWFuZV0gbGFiZWxlZCBhcyA2d2lzMWhwci9nZ3IiO2k6NDtzOjU0OiJzaGluaW5nIHJpbmcgY3JhZnRlZCBvdXQgb2YgbW9vbnN0b25lIGxhYmVsZWQgYXMgKEdncikiO2k6NTtzOjUxOiJHcmlteSBncmVhdCBjbG9hayBvZiB0cnVlIHNvcmNlcmVyIGxhYmVsZWQgYXMgfEdncnwiO2k6NjtzOjI5OiJhIGJsYWNrIGhvb2QgbGFiZWxlZCBhcyB8R2dyfCI7aTo3O3M6Mzg6InRoZSB0b21lIG9mIGtub3dsZWRnZSBsYWJlbGVkIGFzIChHZ3IpIjtpOjg7czo1MzoiaGVhdnkgdGFiYXJkIHdpdGggYSBjaGFsaWNlIGVuc2lnbmlhIGxhYmVsZWQgYXMgKEdncikiO2k6OTtzOjQ3OiJkYXJrIGdyZXkgYW5kIHdoaXRlIHBsYWlkIGtpbHQgbGFiZWxlZCBhcyAoR2dyKSI7aToxMDtzOjM4OiJzdHJvbmcgc2FwcGhpcmUgYm9vdHMgbGFiZWxlZCBhcyAoR2dyKSI7aToxMTtzOjI3OiJzdW4gYW11bGV0IGxhYmVsZWQgYXMgKEdncikiO2k6MTI7czo0MDoiQW5jaWVudCBCcmFjZXJzIG9mIFh6dWkgbGFiZWxlZCBhcyAoR2dyKSI7aToxMztzOjQyOiJnbGl0dGVyaW5nIGxlZyBwcm90ZWN0b3JzIGxhYmVsZWQgYXMgKEdncikiO2k6MTQ7czo0OToiYSBicmFjZWxldCBtYWRlIG9mIGdyZWVuIGNyeXN0YWwgbGFiZWxlZCBhcyAoR2dyKSI7aToxNTtzOjQ5OiJhIGJyYWNlbGV0IG1hZGUgb2YgZ3JlZW4gY3J5c3RhbCBsYWJlbGVkIGFzIChHZ3IpIjtpOjE2O3M6NDU6ImEgcmVpbmZvcmNlZCBicm9uemUgYnJhY2VsZXQgbGFiZWxlZCBhcyAoR2dyKSI7aToxNztzOjQyOiJ0aGUgQnJhY2VsZXRzIG9mIERhcmtuZXNzIGxhYmVsZWQgYXMgKEdncikiO2k6MTg7czozNDoiVGlidXJjaW8ncyBhbXVsZXQgbGFiZWxlZCBhcyAoR2dyKSI7aToxOTtzOjQ5OiJuZWNrbGFjZSBtYWRlIG91dCBvZiBzaGFycCBmYW5ncyBsYWJlbGVkIGFzIChHZ3IpIjtpOjIwO3M6NjI6ImEgZ2xpbW1lcmluZyBsZWF0aGVyIGJlbHQgd2l0aCBnZW0gZGVjb3JhdGlvbiBsYWJlbGVkIGFzIChHZ3IpIjtpOjIxO3M6NDE6ImEgaGVhdnkgYmxhY2sgbWV0YWwgcmluZyBsYWJlbGVkIGFzIChHZ3IpIjtpOjIyO3M6NDE6ImEgaGVhdnkgYmxhY2sgbWV0YWwgcmluZyBsYWJlbGVkIGFzIChHZ3IpIjtpOjIzO3M6NDU6IkRlbW9uaWMgUmluZyBvZiBJbnZpc2liaWxpdHkgbGFiZWxlZCBhcyAoR2dyKSI7aToyNDtzOjMxOiJhIHB1cnBsZSBnbG92ZSBsYWJlbGVkIGFzIChHZ3IpIjtpOjI1O3M6MzE6ImEgcHVycGxlIGdsb3ZlIGxhYmVsZWQgYXMgKEdncikiO2k6MjY7czozMDoiYSBncmVlbiBnbG92ZSBsYWJlbGVkIGFzIChHZ3IpIjtpOjI3O3M6MzA6ImEgZ3JlZW4gZ2xvdmUgbGFiZWxlZCBhcyAoR2dyKSI7aToyODtzOjQzOiJhIHBhaXIgb2YgYmxhY2sgYm9vdHMgbGFiZWxlZCBhcyB8R2dyTXVycml8IjtpOjI5O3M6NzI6IkEgYmVhdXRpZnVsIHJvc2FyeSBlbmZvbGRlZCB3aXRoIHdoaXRlIG1pc3QgbGFiZWxlZCBhcyB8R2dyTXVycml8IChob2x5KSI7aTozMDtzOjgyOiJhIHNtYWxsIHJpbmcgYmVhcmluZyB0aGUgZW1ibGVtIG9mIHRoZSBidW5ueSBbTWFkZSBieTogS2lvbWV0XSBsYWJlbGVkIGFzIDZ3aXMyaW50IjtpOjMxO3M6NjE6ImEgdmlhbCBjb250YWluaW5nIHRoZSB0ZWFycyBvZiBPeHRvdGggbGFiZWxlZCBhcyAoR2dyKSAoaG9seSkiO2k6MzI7czo0NDoiQSBsZWF0aGVyIHBvdWNoIGxhYmVsZWQgYXMgdjQgKHF1YXJ0ZXIgZnVsbCkiO2k6MzM7czo0Mzoic2xlZXZlcyBvZiBtb29taW4gZW11bHNpb24gbGFiZWxlZCBhcyAoR2dyKSI7aTozNDtzOjMzOiJhIGdyZWVuIGhlYWRiYW5kIGxhYmVsZWQgYXMgKEdncikiO2k6MzU7czozNDoiQ2FwZSBvZiBLbm93bGVkZ2UgbGFiZWxlZCBhcyAoR2dyKSI7aTozNjtzOjU0OiJUaGUgZ2xlYW1pbmcgYmx1ZSBjb2xsYXIgb2YgQmVuZ2Fsb3JlIGxhYmVsZWQgYXMgKEdncikiO2k6Mzc7czo1MToiZ29sZGVuIGJlbHQgb2YgRmFpciBSaXZlci1EYXVnaHRlciBsYWJlbGVkIGFzIChHZ3IpIjtpOjM4O3M6NDI6ImEgYmxhY2sgY2xvYWsgKGV2aWwgZ2xvdykgbGFiZWxlZCBhcyB8R2dyfCI7aTozOTtzOjM1OiJSaW5nIG9mIHRoZSBNZWR1c2EgbGFiZWxlZCBhcyAoR2dyKSI7aTo0MDtzOjQ0OiJBIGxvdyB3aWRlLWJyaW1tZWQgaGF0IGxhYmVsZWQgYXMgfEdnck11cnJpfCI7aTo0MTtzOjEzOiJhIHN0ZXRob3Njb3BlIjtpOjQyO3M6NjY6ImEgc2hpbW1lcmluZyBibHVlIGJyZWFzdHBsYXRlIG1hZGUgb2YgcXVhcnR6IGxhYmVsZWQgYXMgfEdnck11cnJpfCI7aTo0MztzOjUzOiJhIHBhaXIgb2YgcHVyZSB3aGl0ZSBmbG93aW5nIHNsZWV2ZXMgbGFiZWxlZCBhcyAoR2dyKSI7aTo0NDtzOjQzOiJSZWRmYW5nIEJlYWRzIG9mIElyb24gV2lsbCBsYWJlbGVkIGFzIChHZ3IpIjtpOjQ1O3M6NTk6Ik5vdmEgQXJjYW51bSwgTWVsa2lvcidzIGJvb2sgb2YgbmVjcm9tYW5jeSBsYWJlbGVkIGFzIChHZ3IpIjtpOjQ2O3M6NDQ6ImEgcGFpciBvZiBzaG9ydCBncmVlbiBib290cyBsYWJlbGVkIGFzIChHZ3IpIjt9fQ==" name="data" />
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
103 <input type="hidden" value="2" name="mode" />
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 First, you should provide a list of equipments you wish to manage.
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 Just plain copy &amp; paste of an inventory listing is enough.
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
106 You can also test with pre-defined equipments,
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
107 <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
108 </form>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 </p>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 <p>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 <b>Stacks of items are not supported, and few other things may cause problems too.</b>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 </p>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 <form action="<? echo $pageIndex; ?>" method="post">
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
114 <p>
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
115 <textarea name="data" cols="100" rows="20"></textarea>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 <input type="hidden" value="1" name="mode" />
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
117 </p>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 <div class="icenter">
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 <input type="submit" value=" Submit " />
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 </div>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 </form>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 <?
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 }
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
124
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
125 /*
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
126 * Parse and validate item
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
127 */
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 else if ($formMode == 1) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 if (isset($_POST["data"])) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 $formData = stripslashes($_POST["data"]);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 $postData = explode("\n", $formData);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 $data = array();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 $ignored = array();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
136 function addItems($num, $desc)
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
137 {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
138 global $data;
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
139 for ($i = 0; $i < $num; $i++)
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
140 $data["items"][] = $desc;
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
141 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
142
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 foreach ($postData as $line) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 // Trim whitespace
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 $str = trim($line);
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
146 if ($str == "") continue;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
148 // Strip glows and counters from item "handle"
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
149 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
150 $str = $m[1];
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
152 // Discard multi-item lines
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
153 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
154 if (!isset($fixNumbers[$m[1]])) {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
155 $ignored[$str] = "Unparsed stack of many";
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
156 } else {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
157 $n = $fixNumbers[$m[1]];
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
158 $changed = 0;
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
159 foreach ($fixItemTable as $pat => $rep) {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
160 if ($pat[0] == "*") {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
161 if (substr($pat, 1) == $m[2]) {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
162 $res = $rep;
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
163 $changed = 1;
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
164 }
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
165 } else {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
166 $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
167 }
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
168 if ($changed > 0) {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
169 addItems($n, $res.$m[3]);
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
170 break;
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
171 }
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
172 }
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
173 if ($changed == 0) {
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
174 $ignored[$str] = "Unsupported item stack";
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
175 }
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
176 }
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
177 } else
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
178 addItems(1, $str);
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 if (count($ignored) > 0) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 ?>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 <p>Item data processed. Following lines <b>were not accepted</b>:</p>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 <table>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 <tr><th>Item</th><th>Reason</th></tr>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 <?
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 foreach ($ignored as $name => $reason) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188 echo " <tr><td>".htmlentities($name)."</td><td>".htmlentities($reason)."</td></tr>\n";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 }
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
190
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
191 $encData = base64_encode(serialize($data));
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 ?>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 </table>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 <form action="<? echo $pageIndex; ?>" method="post">
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
196 <input type="hidden" value="<? echo $encData ?>" name="data" />
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 <input type="hidden" value="2" name="mode" />
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
198 <?
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
199 // 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
200 ?>
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
201 <br />
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 <input type="submit" value=" Continue " />
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 </form>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 <?
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205 } else
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 $formMode = 3;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 } else {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 $errorMsg = "No item data provided.";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 $errorSet = TRUE;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 }
3
aeb37c6b16fd Fixes, also added integrated test data.
Matti Hamalainen <ccr@tnsp.org>
parents: 2
diff changeset
211 } // formMode == 1
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
213
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
214 /*
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
215 * Unserialize data from previous step
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
216 */
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 if ($formMode == 2) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 if (isset($_POST["data"])) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 $formData = base64_decode($_POST["data"]);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 $data = @unserialize($formData);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 $formMode = 3;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 if ($data === FALSE) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 $errorMsg = "Could not unserialize data, internal error.";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 $errorSet = TRUE;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
229
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
230 /*
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
231 * Interactive editor mode begins here
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
232 */
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
233 if ($data !== FALSE && $formMode == 3) {
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 ?>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 <form id="done" action="<? echo $pageIndex; ?>" method="post">
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
236 <p id="create_buttons">
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
237 <input type="button" value=" Create BatMUD Commands " onclick="createInit('batmud');" />
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
238 <!-- <input type="button" value=" Create TinyFugue Macros " onclick="createInit('tf');" />
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
239 -->
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
240 <input type="button" value=" Create SAVEBLOB " onclick="createInit('save');" />
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
241 <input type="button" value=" Reset " onclick="resetAll();" />
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 </p>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
243
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
244
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 <table>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 <tr>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
247
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 <td>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 <h2>Items pool</h2>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
250 <? printOptionSelect("curr_items", 10, TRUE); ?>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
251 <table class="buttons">
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
252 <tr>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
253 <td><input type="button" value=" Delete " onclick="deleteItems(this.form);" /></td>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
254 <td><input type="button" value=" Add new " onclick="addItems(this.form);" disabled="disabled" /></td>
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
255 <td style="width: 60%; text-align: right;"><input id="move_button" type="button" value=" Move to container " onclick="moveItems(this.form);" /></td>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
256 </tr>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 </table>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
258 </td>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
259
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
260 <td id="container_editor">
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
261 <h2>Editing container "<span id="curr_name"></span>" - <span id="curr_info"></span></h2>
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
262 <? printOptionSelect("curr_container", 10, TRUE); ?>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
263 <table class="buttons">
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
264 <tr>
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
265 <td><input type="button" value=" Remove selected " onclick="containerRemoveItems(this.form);" /></td>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
266 </tr>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
267 </table>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 </td>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 </tr>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
270
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 <tr>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 <td>
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
273 <h2>Create / edit a container</h2>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 <?
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
275 printInputField("container_name", "Identifier/name", 15);
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
276 printInputField("container_slots", "Number of slots", 5);
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 ?>
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
278 <input type="button" value=" Create new " onclick="containerCreate(this.form);" id="create_button" />
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
279 <input type="button" value=" Change " onclick="containerChange(this.form);" id="change_button" />
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 </td>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
281
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
282 <td id="container_list_editor">
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
283 <h2>Defined containers</h2>
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
284 <? printOptionSelect("container_list", 5, FALSE); ?>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
285 <table class="buttons">
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
286 <tr>
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
287 <td><input type="button" value=" Switch to " onclick="containerEdit(this.form);" /></td>
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
288 <td><input type="button" value=" Delete " onclick="containerDelete(this.form);" /></td>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
289 </tr>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
290 </table>
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 </td>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
292
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 </tr>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 </table>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295 </form>
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
296
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
297 <div id="commands">
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
298 <textarea id="command_data" cols="80" rows="10"></textarea>
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
299 <br />
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
300 <input type="button" value=" Close " onclick="viewCommands(false, '');" />
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
301 </div>
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
302
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
303 <div id="options_batmud" class="options">
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
304 <? printInputField("cmd_delim", "Command delimiter", 15, ";"); ?><br />
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
305 <? printInputField("cmd_prefix", "Command name prefix", 15, "mcp"); ?><br />
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
306 <? 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
307 <? 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
308 <? printCheckBox("cmd_autoclose", "Add commands for automatically opening and closing each container.", FALSE); ?><br />
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
309 <br />
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
310 <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
311 <input type="button" value=" Cancel " onclick="createInit('clear');" />
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
312 </div>
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
313
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
314 <div id="options_tf" class="options">
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
315 <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
316 <input type="button" value=" Cancel " onclick="createInit('clear');" />
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
317 </div>
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
318
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
319
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
320 <div id="status">&nbsp;</div>
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
321
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 <script type="text/javascript">
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 <!--
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
324 var curr_container = null;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
326 function Container(name, slots, items)
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 this.name = name;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
329 this.slots = slots;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 this.items = items;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 this.changed = true;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
333 this.getCountByName = function(n) {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
334 var cnt = 0;
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
335 for (var i = 0; i < this.items.length; i++) {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
336 if (this.items[i] == n) cnt++;
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
337 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
338 return cnt;
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
339 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
340
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 this.getSpace = function() {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 return this.slots - this.items.length;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
344
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 this.addItem = function(item) {
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
346 if (this.items.length < slots) {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
347 this.changed = true;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
348 this.items.push(item);
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
349 return true;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
350 } else
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
351 return false;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 this.deleteItemById = function(id) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 this.changed = true;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 delete this.items[id];
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359 this.flush = function() {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 this.changed = true;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 for (var i = 0; i < this.items.length; i++) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362 if (this.items[i] == undefined) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 this.items.splice(i, 1);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 i -= 1;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
369 this.moveItemById = function(container, id) {
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 var item = this.getItemByIndex(id);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 if (item != null) {
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
372 if (!container.addItem(item))
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
373 return false;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 this.deleteItemById(id);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 this.changed = true;
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
376 return true;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
377 } else
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
378 return false;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
381 this.getItemId = function(item) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 return this.items.indexOf(item);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 this.getItemByIndex = function(id) {
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
386 if (id < 0 || id >= this.items.length) return null;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 return this.items[id];
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 -->
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 <?
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
392 function getContainerObject($name, $slots, $items)
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
394 return "new Container(\"".$name."\", \"".$slots."\", [".getJSArraySegment($items)."])";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 $str = "";
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
398 if (isset($data["containers"])) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
399 foreach ($data["containers"] as $container) {
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 if ($str != "") $str .= ", ";
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
401 $str .= getContainerObject($container["name"], $container["slots"], $container["items"]);
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
405 echo "
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
406 var list_containers;
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
407 var list_items;
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
408
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
409 function initAll()
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
410 {
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
411 list_containers = [".$str."];
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
412 list_items = ".(isset($data["items"]) ? getContainerObject("items", 10000, $data["items"]) : "null").";
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
413 ".$jsData."
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
414 updatePage();
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
415 }
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
416 ";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 ?>
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
418 <!-- kludge --><!--
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
419
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
421 function resetAll()
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
422 {
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
423 var answer = confirm("Really delete all defined containers and reset item pool to original state?");
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
424 if (!answer) {
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
425 statusMsg("Reset operation cancelled.");
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
426 return;
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
427 }
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
428 }
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430 function setHTML(id, str)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 var o = document.getElementById(id);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 if (o != null)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434 o.innerHTML = str;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
436
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437 function setListData(id, list)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 var o = document.getElementById(id);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 o.options.length = 0;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441 for (var i = 0; i < list.length; i++) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 o.options[i] = new Option(list[i], i, false, false);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
444 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 // Update the form data
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 function updatePage()
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
449 // List of items
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
450 if (list_items != null && list_items.changed) {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
451 list_items.changed = false;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452 setListData("curr_items", list_items.items);
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
453 }
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
455 // List of containers
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
456 var container_list_editor = document.getElementById("container_list_editor");
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
457 if (list_containers.length > 0) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
458 container_list_editor.style.display = "block";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
460 o = document.getElementById("container_list");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
461 o.options.length = 0;
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
462 for (var i = 0; i < list_containers.length; i++) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
463 o.options[i] = new Option(list_containers[i].name +" (" + list_containers[i].items.length +" of "+ list_containers[i].slots +" items)", i, false);
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 } else {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
466 container_list_editor.style.display = "none";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
470 // Update current container
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
471 var container_editor = document.getElementById("container_editor");
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
472 if (curr_container != null) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
473 container_editor.style.display = "block";
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
474 setHTML("curr_name", curr_container.name);
4
563783b8cd22 Show current item amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
475
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
476 setHTML("curr_info", "(" + curr_container.items.length+" / "+curr_container.slots+" items)");
4
563783b8cd22 Show current item amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 3
diff changeset
477
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
478 if (curr_container.changed) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
479 curr_container.changed = false;
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
480 setListData("curr_container", curr_container.items);
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
481 }
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 } else {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
483 container_editor.style.display = "none";
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 // Output status message
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488 function statusMsg(msg)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
490 var o = document.getElementById("status");
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491 o.innerHTML = msg;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495 // Clear values of a given form
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496 function clearForm(f)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 for (var i = 0; i < f.elements.length; i++) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499 var e = f.elements[i];
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500 if (e.type.toLowerCase() == "text") e.value = "";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
505 function validateContainerData(f)
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
507 var name = f.elements['container_name'].value;
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
508 var slots = parseInt(f.elements['container_slots'].value, 10);
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
510 if (isNaN(slots) || slots < 1) {
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
511 statusMsg("Number of slots not set or is invalid.");
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
512 return null;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 if (name == "") {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
516 statusMsg("Empty container name "+name+".");
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
517 return null;
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
519
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
520 if (name.match(/[^a-z0-9_]/)) {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
521 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
522 return null;
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
523 }
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
525 return {name: name, slots: slots};
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
526 }
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
527
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
528 // Create a new container, set current container to it
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
529 function containerCreate(f)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
530 {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
531 var c = validateContainerData(f);
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
532 if (c == null)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
533 return;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
534
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
535 for (var i = 0; i < list_containers.length; i++) {
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
536 if (list_containers[i].name == c.name) {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
537 statusMsg("Container with identifier '<b>"+c.name+"</b>' already exists!");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538 return;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
542 curr_container = new Container(c.name, c.slots, []);
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
543 list_containers.push(curr_container);
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 clearForm(f);
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
546 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
547 updatePage();
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
548 }
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
549
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
550
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
551 // Change current container
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
552 function containerChange(f)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
553 {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
554 var c = validateContainerData(f);
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
555 if (c == null)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
556 return;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
557
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
558 if (c.slots < curr_container.items.length) {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
559 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
560 return;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
561 }
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
562
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
563 curr_container.name = c.name;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
564 curr_container.slots = c.slots;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
565
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
566 clearForm(f);
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
567 statusMsg("Updated container.");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 updatePage();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
570
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
571
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
572 function containerCheckSelected(f)
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
573 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
574 var id = f.elements['container_list'].selectedIndex;
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
575
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
576 if (id < 0 || id >= list_containers.length) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
577 statusMsg("Invalid container, internal error!");
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
578 return -1;
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
579 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
580
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
581 return {id: id, container: list_containers[id]};
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
582 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
583
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
584
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
585 // Delete a container from container list
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
586 function containerDelete(f)
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
588 var ret = containerCheckSelected(f);
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
589 if (ret.id < 0 || ret.container == null) return;
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
590
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
591 var name = ret.container.name;
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
592 var len = ret.container.items.length;
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
593
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
594 var answer = confirm("Really delete selected container '"+name+"' and move "+len+" items back to pool?");
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
595 if (!answer) {
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
596 statusMsg("Delete operation cancelled.");
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
597 return;
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
598 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
599
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
600 if (curr_container == ret.container)
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
601 curr_container = null;
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
602
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
603 for (var i = 0; i < len; i++) {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
604 if (!ret.container.moveItemById(list_items, i)) {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
605 statusMsg("Internal error moving item "+ i);
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
606 return;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
607 }
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
608 }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
609
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
610 list_containers.splice(ret.id, 1);
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
611
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
612 if (len > 0) {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
613 statusMsg("Deleted container '"+name+"', "+len+" items returned to pool.");
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
614 } else {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
615 statusMsg("Deleted empty container '"+name+"'.");
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
616 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
617 updatePage();
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
618 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
619
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
620
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
621 // Change currently edited container to another
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
622 function containerEdit(f)
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
623 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
624 var ret = containerCheckSelected(f);
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
625 if (ret.id < 0 || ret.container == null) return;
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
626
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
627 curr_container = ret.container;
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
628 curr_container.changed = true;
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
629 statusMsg("Switched to container '"+ret.container.name+"'.");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
630 updatePage();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
631 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
632
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633
9
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
634 function containerRemoveItems(f)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
635 {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
636 if (curr_container == null) {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
637 statusMsg("Internal error.");
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
638 return;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
639 }
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
640
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
641 var selected = getSelectedItems(f.elements['curr_container']);
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
642
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
643 if (selected.length == 0) {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
644 statusMsg("No items selected for deletion.");
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
645 return;
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
646 } else {
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
647 for (var i = 0; i < selected.length; i++)
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
648 curr_container.moveItemById(list_items, selected[i]);
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
649
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
650 curr_container.flush();
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
651 updatePage();
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
652 statusMsg("Removed " + selected.length + " from current container.");
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
653 }
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
654 }
da404b8ff282 Container editing, persistent settings.
Matti Hamalainen <ccr@tnsp.org>
parents: 8
diff changeset
655
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
656 function getSelectedItems(items)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
657 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
658 var selected = [];
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
659 if (items != null) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
660 for (var i = 0; i < items.length; i++)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661 if (items[i].selected) selected.push(items[i].value);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
663 return selected;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
666
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
667 function deleteItems(f)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
668 {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
669 var selected = getSelectedItems(f.elements['curr_items']);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
670
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
671 if (selected.length == 0) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
672 statusMsg("No items selected for deletion.");
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
673 return;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
674 } else {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
675 var answer = confirm("Really delete selected items?");
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
676 if (!answer) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
677 statusMsg("Delete operation cancelled.");
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
678 return;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
679 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
680
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
681 for (var i = 0; i < selected.length; i++)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
682 list_items.deleteItemById(selected[i]);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
683
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
684 list_items.flush();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 updatePage();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686 statusMsg("Deleted "+selected.length+" items.");
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
687 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
689
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
691 function moveItems(f)
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
692 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
693 if (curr_container == null) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
694 statusMsg("No container selected, cannot move items.");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
695 return;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
696 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
697
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
698 var selected = getSelectedItems(f.elements['curr_items']);
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
699
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
700 if (selected.length == 0) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
701 statusMsg("No items selected for deletion.");
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
702 return;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
703 } else {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
704 if (curr_container.getSpace() < selected.length) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
705 statusMsg("Not enough space! "+ selected.length +" items, only "+ curr_container.getSpace() +" slots available!");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
706 return;
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
708
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
709 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
710 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
711 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
712 return;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
713 }
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
714 }
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
715
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
716 list_items.flush();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717 updatePage();
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
718 statusMsg("Moved " + selected.length + " items to current container.");
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
719 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
720 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
722
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
723 var edit_modes = ['batmud', 'tf', 'save'];
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
724
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
725 function createInit(mode)
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
726 {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
727 for (i = 0; i < edit_modes.length; i++) {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
728 var o = document.getElementById("options_"+edit_modes[i]);
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
729 if (o != null) {
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
730 o.style.display = (edit_modes[i] == mode) ? "block" : "none";
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
731 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
732 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
733 if (mode == "save")
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
734 createCommands(mode);
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
735 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
736
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
737
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
738 function expandCmd(cmd, item, name)
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
739 {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
740 var str = cmd.replace(/\$1/g, item);
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
741 return str.replace(/\$2/g, name);
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
742 }
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
743
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
744
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
745 function createCommands(mode)
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
746 {
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
747 if (list_containers.length == 0) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
748 statusMsg("No container configurations defined!");
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
749 return;
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
750 }
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
751
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
752
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
753 var str = "";
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
754 for (var i = 0; i < list_containers.length; i++) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
755 var container = list_containers[i];
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
756 var counts = [];
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
757 var curr = [];
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
758
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
759 for (var n = 0; n < container.items.length; n++) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
760 var cnt = container.getCountByName(container.items[n]);
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
761 counts[container.items[n]] = cnt;
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
762 curr[container.items[n]] = 1;
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
763 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
764
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
765 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
766 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
767 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
768 if (cmd_delim == "") cmd_delim = ";";
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
769 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
770 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
771 var s = "";
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
772
6
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
773 for (var n = 0; n < container.items.length; n++) {
2fb901161013 s/Chest/Container/g
Matti Hamalainen <ccr@tnsp.org>
parents: 5
diff changeset
774 var item = container.items[n];
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
775 var tmp = ""+item;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
776
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
777 if (counts[item] > 1) {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
778 tmp += " " + curr[item];
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
779 curr[item]++;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
780 }
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
781
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
782 if (mode == "batmud") {
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
783 if (cmd_seq) {
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
784 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
785 } else {
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
786 if (s != "") s += ",";
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
787 s += tmp;
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
788 }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
789 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
790 }
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
791
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
792 if (mode == "batmud") {
7
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
793 if (!cmd_seq) str += "command "+cmd_prefix+container.name+" ";
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
794 if (cmd_autoclose) str += "open "+container.name+delim;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
795 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
796 else str += s;
6ff1ee9122b2 Work more on generalization of the process.
Matti Hamalainen <ccr@tnsp.org>
parents: 6
diff changeset
797 if (cmd_autoclose) str += delim+"close "+container.name;
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
798 str += "\n";
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
799 }
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
800 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
801
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
802 viewCommands(true, str);
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
803 }
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
804
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
805 function viewCommands(state, str)
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
806 {
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
807 var o = document.getElementById("commands");
2
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
808 o.style.display = state ? "block" : "none";
666d475c8f92 Fixes, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 1
diff changeset
809 var o = document.getElementById("command_data");
1
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
810 o.innerHTML = str;
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
811 }
77d78ef45ed2 Lots of work.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
812
8
5e1cdf22d647 Cleanups, fixes, added a global "reset" button.
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
813 initAll();
0
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
814 -->
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
815 </script>
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
816 <?
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
817 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
818
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
819 if ($errorSet) {
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
820 echo "<h2>An error occured</h2>\n".
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
821 "<p>".$errorMsg."</p>";
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
822 }
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
823
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
824 printPageFooter();
332b25bb4e36 Initial import.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
825 ?>