annotate index.php @ 28:5305bd5a44aa default tip

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