corrade-nucleus-nucleons – Blame information for rev 16
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
10 | office | 1 | <!DOCTYPE html> |
2 | |||
3 | <html lang="en"> |
||
4 | <head> |
||
5 | <meta charset="utf-8"> |
||
6 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||
7 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
||
8 | <meta name="description" content="Corrade Nucleon"> |
||
9 | <meta name="author" content="Wizardry and Steamworks"> |
||
10 | <link rel="icon" href="favicon.ico"> |
||
11 | |||
12 | <title>Corrade Nucleus - Pack Rat Inventory Manager</title> |
||
13 | |||
14 | <!-- Bootstrap core CSS --> |
||
15 | <link href="/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"> |
||
16 | <!-- Corrade Nucleus Fonts --> |
||
17 | <link href="/css/nucleus/fonts.css" rel="stylesheet" type="text/css"> |
||
18 | <!-- Customized bootstrap style. --> |
||
19 | <link href="/css/nucleus/nucleus.css" rel="stylesheet" type="text/css"> |
||
20 | |||
21 | <!-- jsTree style --> |
||
22 | <link href="/pack-rat/bower_components/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css"> |
||
23 | </script> |
||
24 | </head> |
||
25 | |||
26 | <body> |
||
27 | <!-- Bootstrap Modal --> |
||
28 | <div id="popup" class="modal fade bs-example-modal-lg" role="dialog"> |
||
29 | <div class="modal-dialog modal-lg"> |
||
30 | <!-- Modal content--> |
||
31 | |||
32 | <div class="modal-content"> |
||
33 | <div class="modal-header"> |
||
34 | <button type="button" class="close" data-dismiss="modal">×</button> |
||
35 | |||
36 | <h1 id="title" class="modal-title"></h1> |
||
37 | </div> |
||
38 | |||
39 | <div id="content" class="modal-body"> |
||
40 | <div class="progress"> |
||
41 | <div id="progressbar" class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: 2%;"> |
||
42 | 0% |
||
43 | </div> |
||
44 | </div> |
||
45 | |||
46 | <div class="modal-footer"> |
||
47 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
48 | </div> |
||
49 | </div> |
||
50 | </div> |
||
51 | </div> |
||
52 | </div> |
||
53 | |||
54 | <div class="container"> |
||
55 | <div class="jumbotron"> |
||
56 | <h1>Corrade Pack Rat</h1> |
||
57 | <p class="lead">Pack Rat is an inventory manager for Corrade Nucleus that allows you to sort your inventory and perform other management operations.</p> |
||
58 | <img src="/pack-rat/img/pack-rat.png"></div> |
||
59 | |||
60 | <!-- Will hold the inventory tree (completed dynamically). --> |
||
61 | <div id="tree"> |
||
62 | </div> |
||
63 | |||
64 | <footer class="footer"> |
||
65 | <p>© 2017 Wizardry and Steamworks</p> |
||
66 | </footer> |
||
67 | </div> |
||
68 | <!-- jQuery --> |
||
69 | <script src="/bower_components/jquery/dist/jquery.min.js" type="text/javascript"></script> |
||
70 | <!-- Wizardry and Steamworks JavaScript Includes --> |
||
71 | <script src="/bower_components/was/dist/was.min.js" type="text/javascript"></script> |
||
72 | <!-- Bootstrap Javascript --> |
||
73 | <script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script> |
||
74 | <!-- Bootstrap Form Validator --> |
||
75 | <script src="/pack-rat/bower_components/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script> |
||
76 | <!-- XML <-> JSON --> |
||
77 | <!-- <script src="/bootstrap/bower_components/x2js/xml2json.min.js" type="text/javascript"></script> --> |
||
78 | <!-- CryptoJS --> |
||
79 | <script src="/bower_components/cryptojslib/components/core.js" type="text/javascript"></script> |
||
80 | <script src="/bower_components/cryptojslib/rollups/md5.js" type="text/javascript"></script> |
||
81 | <!-- Form To Object --> |
||
82 | <!-- <script src="/bootstrap/node_modules/form_to_object/dist/formToObject.min.js" type="text/javascript"></script> --> |
||
83 | <!-- Load form processor. --> |
||
84 | <!-- <script src="/bootstrap/js/corrade-bootstrap-processor.js" type="text/javascript"></script> --> |
||
85 | <!-- Moment JS --> |
||
86 | <script src="/pack-rat/bower_components/moment/min/moment.min.js" type="text/javascript"></script> |
||
87 | <!-- JsTree --> |
||
88 | <script src="/pack-rat/bower_components/jstree/dist/jstree.min.js" type="text/javascript"></script> |
||
89 | <!-- JSON to Table --> |
||
90 | <script src="/pack-rat/bower_components/json-to-table/json-to-table.js" type="text/javascript"></script> |
||
91 | <!-- Main script --> |
||
92 | <script type="text/javascript"> |
||
93 | $(function() { |
||
94 | function customMenu(node) { |
||
95 | // The default set of menu items for all types |
||
96 | var items = { |
||
97 | // Grab information about the item. |
||
98 | infoItem: { |
||
99 | label: "Get Info", |
||
100 | action: function(obj) { |
||
101 | $('#popup').dialog({ |
||
102 | width: 800, |
||
103 | height: 600, |
||
104 | modal: true, |
||
105 | resizable: false, |
||
106 | dialogClass: 'no-close texture-dialog' |
||
107 | }).on('dialogclose', function(event) { |
||
108 | $('#content').html(''); |
||
109 | }); |
||
110 | $.ajax({ |
||
111 | type: 'POST', |
||
112 | url: '/', |
||
113 | dataType: 'json', |
||
114 | data: { |
||
115 | command: 'getinventorydata', |
||
116 | item: node.id.split(/[\/]+/).pop(), |
||
117 | data: [ |
||
118 | 'AssetUUID', |
||
119 | 'CreationDate', |
||
120 | 'Description', |
||
121 | 'Permissions', |
||
122 | 'UUID' // part of InventoryBase |
||
123 | ] |
||
124 | } |
||
125 | }).done(function(data) { |
||
126 | $('#content').html(ConvertJsonToTable(data, null, null, null)); |
||
127 | }); |
||
128 | } |
||
129 | } |
||
130 | }; |
||
131 | |||
132 | // Give inventory items menu for anything but folders. |
||
133 | // They could be supported too but would require first |
||
134 | // counting the number of items inside the folder and |
||
135 | // only accepting to send if the number is below max. |
||
136 | if (node.data.type != "folder") { |
||
137 | $.extend(items, { |
||
138 | giveItem: { |
||
139 | label: "Give", |
||
140 | action: function(obj) { |
||
141 | $("#content").html('<form><fieldset class="ui-helper-reset"><label for="firstname">Firstname</label><input type="text" name="firstname" id="firstname" value="" class="ui-widget-content ui-corner-all"><br/><label for="lastname">Lastname</label><input type="text" name="lastname" id="lastname" value="" class="ui-widget-content ui-corner-all"></fieldset></form>'); |
||
142 | $("#popup").dialog({ |
||
143 | width: 320, |
||
144 | height: 180, |
||
145 | modal: true, |
||
146 | resizable: false, |
||
147 | buttons: { |
||
148 | Select: function() { |
||
149 | if ($.trim($("#firstname").val()) == '' || |
||
150 | $.trim($("#lastname").val()) == '') |
||
151 | return; |
||
152 | var firstName = $("#firstname").val(); |
||
153 | var lastName = $("#lastname").val(); |
||
154 | $.ajax({ |
||
155 | type: 'POST', |
||
156 | url: "giveInventoryItem.php?t=" + Math.random(), |
||
157 | data: { |
||
158 | uuid: node.id.split(/[\/]+/).pop(), |
||
159 | firstname: firstName, |
||
160 | lastname: lastName |
||
161 | } |
||
162 | }).done(function(data) { |
||
163 | $("#popup").dialog("close"); |
||
164 | if ($.trim(data) != '') |
||
165 | alert(data); |
||
166 | }); |
||
167 | }, |
||
168 | Cancel: function() { |
||
169 | $("#popup").dialog("close"); |
||
170 | } |
||
171 | } |
||
172 | }).on('dialogclose', function(event) { |
||
173 | $('#content').html(''); |
||
174 | $('#popup').dialog('option', 'buttons', {}); |
||
175 | }); |
||
176 | } |
||
177 | } |
||
178 | }); |
||
179 | } |
||
180 | |||
181 | // The "download" menu item for textures. |
||
182 | if (node.data.type == "texture" || node.data.type == "snapshot") { |
||
183 | $.extend(items, { |
||
184 | downloadItem: { |
||
185 | label: "Download", |
||
186 | "action": function(obj) { |
||
187 | $('#texture').attr('src', 'images/loader.gif'); |
||
188 | $('#popup').dialog({ |
||
189 | width: 800, |
||
190 | height: 600, |
||
191 | modal: true, |
||
192 | resizable: false, |
||
193 | dialogClass: 'no-close texture-dialog' |
||
194 | }).on('dialogclose', function(event) { |
||
195 | $('#content').html(''); |
||
196 | }); |
||
197 | $.ajax({ |
||
198 | type: 'POST', |
||
199 | url: "downloadTexture.php?t=" + Math.random(), |
||
200 | data: { |
||
201 | uuid: node.id.split(/[\/]+/).pop() |
||
202 | } |
||
203 | }).done(function(data) { |
||
204 | $('#content').html('<img src="" align="middle" id="texture">'); |
||
205 | $('#texture').attr('src', "data:image/png;base64," + data); |
||
206 | }); |
||
207 | } |
||
208 | } |
||
209 | }); |
||
210 | } |
||
211 | |||
212 | // The "download" menu item for notecards. |
||
213 | if (node.data.type == "notecard") { |
||
214 | $.extend(items, { |
||
215 | downloadItem: { |
||
216 | label: "Download", |
||
217 | "action": function(obj) { |
||
218 | $('#texture').attr('src', 'images/loader.gif'); |
||
219 | $('#popup').dialog({ |
||
220 | width: 800, |
||
221 | height: 600, |
||
222 | modal: true, |
||
223 | resizable: false, |
||
224 | dialogClass: 'no-close texture-dialog' |
||
225 | }).on('dialogclose', function(event) { |
||
226 | $('#content').html(''); |
||
227 | }); |
||
228 | $.ajax({ |
||
229 | type: 'POST', |
||
230 | url: "downloadNotecard.php?t=" + Math.random(), |
||
231 | data: { |
||
232 | uuid: node.id.split(/[\/]+/).pop() |
||
233 | } |
||
234 | }).done(function(data) { |
||
235 | $.base64.utf8decode = true; |
||
236 | $('#content').html('<pre>' + $.base64.atob(data) + '</pre>'); |
||
237 | }); |
||
238 | } |
||
239 | } |
||
240 | }); |
||
241 | } |
||
242 | |||
243 | // The "download" menu item for sounds. |
||
244 | if (node.data.type == "sound") { |
||
245 | $.extend(items, { |
||
246 | downloadItem: { |
||
247 | label: "Download", |
||
248 | "action": function(obj) { |
||
249 | $('#texture').attr('src', 'images/loader.gif'); |
||
250 | $('#popup').dialog({ |
||
251 | width: 800, |
||
252 | height: 600, |
||
253 | modal: true, |
||
254 | resizable: false, |
||
255 | dialogClass: 'no-close texture-dialog' |
||
256 | }).on('dialogclose', function(event) { |
||
257 | $('#content').html(''); |
||
258 | }); |
||
259 | $.ajax({ |
||
260 | type: 'POST', |
||
261 | url: "downloadSound.php?t=" + Math.random(), |
||
262 | data: { |
||
263 | uuid: node.id.split(/[\/]+/).pop() |
||
264 | } |
||
265 | }).done(function(data) { |
||
266 | $('#content').html('<audio controls="controls"><source id="source" src="" type="audio/mp3"></source></audio>'); |
||
267 | $('#source').attr('src', "data:audio/mp3;base64," + data); |
||
268 | }); |
||
269 | } |
||
270 | } |
||
271 | }); |
||
272 | } |
||
273 | |||
274 | return items; |
||
275 | } |
||
276 | |||
277 | $("#tree").jstree({ |
||
278 | // - sort will sort items by date |
||
279 | // - state will store the open / closed state of the jstree |
||
280 | 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"], |
||
15 | office | 281 | 'contextmenu': { |
10 | office | 282 | "items": function(node) { |
283 | return customMenu(node); |
||
284 | } |
||
15 | office | 285 | }, |
10 | office | 286 | 'dnd': { |
287 | // Do not copy items. |
||
288 | 'copy': false, |
||
289 | // Do not execute the check callback whilst dragging. |
||
16 | office | 290 | 'check_while_dragging': true |
10 | office | 291 | }, |
292 | 'sort': function(a, b) { |
||
16 | office | 293 | return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1; |
10 | office | 294 | }, |
295 | 'core': { |
||
15 | office | 296 | 'check_callback': function(operation, node, parent, position, more) { |
16 | office | 297 | // Only allow move operations |
298 | if (operation !== 'move_node' || |
||
299 | // Do not move system folders. |
||
300 | node.data.system !== false || |
||
301 | // Do not allow moves above the root node. |
||
302 | parent.id === "#" || |
||
303 | // Do not allow moving an item over another item. |
||
304 | (node.data.type !== 'folder' && parent.data.type !== 'folder')) |
||
10 | office | 305 | return false; |
15 | office | 306 | |
307 | var source = node.id; |
||
308 | var target = parent.id; |
||
309 | |||
310 | // Normalize source and target. |
||
311 | if(source === '#') |
||
312 | source = '/'; |
||
313 | |||
314 | if(target === '#') |
||
315 | target = '/'; |
||
316 | |||
317 | if(source == '/' && target == '/') |
||
16 | office | 318 | return false; |
15 | office | 319 | |
320 | // Check if source path is sane. |
||
321 | if(source.split('/').some( |
||
322 | function(part) { |
||
323 | return /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/.test(part); |
||
324 | })) { |
||
16 | office | 325 | return false; |
15 | office | 326 | } |
327 | |||
328 | // Check if target path is sane. |
||
329 | if(target.split('/').some( |
||
330 | function(part) { |
||
331 | return /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/.test(part); |
||
332 | })) { |
||
16 | office | 333 | return false; |
15 | office | 334 | } |
335 | |||
16 | office | 336 | return true; |
15 | office | 337 | }, |
10 | office | 338 | data: function(node, callback) { |
339 | if(node.id === '#') { |
||
340 | callback.call(this, [ |
||
341 | { |
||
342 | "id" : "/My Inventory", |
||
343 | "parent" : "#", |
||
344 | "text" : "My Inventory", |
||
345 | "data" : { |
||
16 | office | 346 | "type" : "folder", |
347 | 'time' : Date.now(), |
||
348 | 'system' : true |
||
10 | office | 349 | }, |
350 | "children" : true, |
||
351 | "opened" : false |
||
352 | }, |
||
353 | { |
||
354 | "id" : "/Library", |
||
355 | "parent" : "#", |
||
356 | "text" : "Library", |
||
357 | "data" : { |
||
16 | office | 358 | "type" : "folder", |
359 | 'time' : Date.now(), |
||
360 | 'system' : true |
||
10 | office | 361 | }, |
362 | "children" : true, |
||
363 | "opened" : false |
||
364 | } |
||
365 | ]); |
||
366 | return; |
||
367 | } |
||
368 | $.ajax({ |
||
369 | //async: false, |
||
370 | type: 'POST', |
||
371 | url: '/', |
||
372 | dataType: 'json', |
||
373 | data: { |
||
374 | command: 'inventory', |
||
375 | action: 'ls', |
||
376 | path: node.id |
||
377 | } |
||
378 | }).done(function(response) { |
||
14 | office | 379 | var list = []; |
380 | $.each(wasCSVToArray(response.data) |
||
16 | office | 381 | .chunk(10), |
382 | function(i, e) { |
||
383 | e = wasKeyValueObjectify(e); |
||
384 | //alert(node.id + " to " + JSON.stringify(e, 4, null)); |
||
385 | list.push({ |
||
386 | 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'], |
||
387 | 'parent' : node.id, |
||
388 | 'data' : { |
||
389 | 'type' : e['type'], |
||
390 | 'time' : Date.parse(e['time']), |
||
391 | // Check if this folder is a system folder. |
||
392 | 'system' : node.id === '/My Inventory' && ( |
||
393 | e['name'] === 'Trash' || |
||
394 | e['name'] === 'Notecards' || |
||
395 | e['name'] === 'Scripts' || |
||
396 | e['name'] === 'Lost And Found' || |
||
397 | e['name'] === 'Landmarks' || |
||
398 | e['name'] === 'Current Outfit' || |
||
399 | e['name'] === 'Calling Cards' || |
||
400 | e['name'] === 'Textures' || |
||
401 | e['name'] === 'Objects' || |
||
402 | e['name'] === 'My Outfits' || |
||
403 | e['name'] === 'Clothing' || |
||
404 | e['name'] === 'Body Parts' || |
||
405 | e['name'] === 'Photo Album' || |
||
406 | e['name'] === 'Favorites' || |
||
407 | e['name'] === 'Gestures' || |
||
408 | e['name'] === 'Animations' |
||
409 | ) |
||
410 | }, |
||
411 | 'text' : e['name'], |
||
412 | 'children' : e['type'] === 'folder', |
||
413 | 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif', |
||
414 | 'opened' : 'false' |
||
14 | office | 415 | }); |
13 | office | 416 | }); |
14 | office | 417 | callback.call(this, list); |
10 | office | 418 | }); |
419 | } |
||
420 | } |
||
421 | }).bind('move_node.jstree', function(e, data) { |
||
16 | office | 422 | $.ajax({ |
423 | //async: false, |
||
424 | type: 'POST', |
||
425 | url: '/', |
||
426 | dataType: 'json', |
||
427 | data: { |
||
428 | command: 'inventory', |
||
429 | action: 'mv', |
||
430 | source: data.node.id, |
||
431 | target: data.parent |
||
432 | } |
||
433 | }).done(function(response) { |
||
434 | if(response.success !== 'True') { |
||
435 | alert('Error moving item: ' + response.error); |
||
436 | } |
||
437 | }); |
||
10 | office | 438 | // Once the node is moved, update the node ID to reflect the path change. |
439 | var parentPath = data.parent != '/' ? data.parent : ""; |
||
440 | var item = data.node.id.split(/[\/]+/).pop(); |
||
441 | data.instance.set_id(data.node, parentPath + '/' + item); |
||
442 | }); |
||
443 | }); |
||
444 | </script> |
||
445 | </body> |
||
446 | </html> |