annotate index.php @ 24:3634b6b811ce

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