corrade-nucleus-nucleons – Blame information for rev 26
?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 --> |
||
20 | office | 15 | <link href="/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"> |
10 | office | 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"> |
||
26 | office | 20 | <!-- Manager for Windows. --> |
21 | <link href="/css/wm/wm.css" rel="stylesheet" type="text/css"> |
||
10 | office | 22 | |
23 | <!-- jsTree style --> |
||
20 | office | 24 | <link href="/pack-rat/node_modules/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css"> |
17 | office | 25 | <!-- Bootstrap table --> |
20 | office | 26 | <link href="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet" type="text/css"> |
10 | office | 27 | </script> |
28 | </head> |
||
29 | |||
30 | <body> |
||
31 | <!-- Bootstrap Modal --> |
||
18 | office | 32 | <div id="item-info-modal" class="modal fade bs-example-modal-lg" role="dialog"> |
10 | office | 33 | <div class="modal-dialog modal-lg"> |
34 | <!-- Modal content--> |
||
35 | |||
36 | <div class="modal-content"> |
||
37 | <div class="modal-header"> |
||
38 | <button type="button" class="close" data-dismiss="modal">×</button> |
||
39 | |||
24 | office | 40 | <h1 class="modal-title">Item Information</h1> |
10 | office | 41 | </div> |
42 | |||
24 | office | 43 | <div id="item-info-content" class="modal-body"> |
17 | office | 44 | <table id="info" data-height="460"> |
45 | <thead> |
||
46 | <tr> |
||
47 | <th data-field="AssetUUID">Asset UUID</th> |
||
48 | <th data-field="CreationDate">Creation Date</th> |
||
49 | <th data-field="Description">Description</th> |
||
50 | <th data-field="Permissions">Permissions</th> |
||
51 | <th data-field="UUID">Inventory UUID</th> |
||
52 | </tr> |
||
53 | </thead> |
||
54 | </table> |
||
10 | office | 55 | </div> |
17 | office | 56 | <div class="modal-footer"> |
57 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
58 | </div> |
||
10 | office | 59 | </div> |
60 | </div> |
||
61 | </div> |
||
18 | office | 62 | |
63 | <!-- Give Inventory Item Destination Dialog --> |
||
64 | <div id="avatar-select-modal" class="modal fade bs-example-modal-lg" role="dialog"> |
||
65 | <div class="modal-dialog modal-lg"> |
||
66 | <!-- Modal content--> |
||
10 | office | 67 | |
18 | office | 68 | <div class="modal-content"> |
69 | <div class="modal-header"> |
||
70 | <button type="button" class="close" data-dismiss="modal">×</button> |
||
71 | |||
24 | office | 72 | <h1 class="modal-title">Avatar Selection</h1> |
18 | office | 73 | </div> |
74 | |||
75 | <form id="avatar-select-form" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();"> |
||
24 | office | 76 | <div id="avatar-select-content" class="modal-body"> |
18 | office | 77 | <p>Please enter the avatar firstname and lastname to send the script to.</p> |
78 | <div class="form-group has-feedback"> |
||
79 | <label for="avatar-firstname">First Name</label> |
||
80 | <input id="avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required> |
||
81 | <label for="avatar-lastname">Last Name</label> |
||
82 | <input id="avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required> |
||
83 | </div> |
||
84 | </div> |
||
85 | <div class="modal-footer"> |
||
86 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
24 | office | 87 | <button id="send-item" type="button" class="btn btn-primary">Confirm</button> |
18 | office | 88 | </div> |
89 | </form> |
||
90 | </div> |
||
91 | </div> |
||
92 | </div> |
||
93 | |||
24 | office | 94 | <!-- Inventory Item Download Dialog --> |
95 | <div id="item-download-modal" class="modal fade bs-example-modal-lg" role="dialog"> |
||
18 | office | 96 | <div class="modal-dialog modal-lg"> |
97 | <!-- Modal content--> |
||
98 | |||
99 | <div class="modal-content"> |
||
100 | <div class="modal-header"> |
||
101 | <button type="button" class="close" data-dismiss="modal">×</button> |
||
102 | |||
24 | office | 103 | <h1 class="modal-title">Download</h1> |
18 | office | 104 | </div> |
105 | |||
24 | office | 106 | <div id="item-download-content" class="modal-body"> |
107 | <!-- <img width="100%" height="100%" src="" align="middle" id="texture"> --> |
||
18 | office | 108 | </div> |
109 | |||
110 | <div class="modal-footer"> |
||
111 | <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> |
||
112 | </div> |
||
113 | </div> |
||
114 | </div> |
||
115 | </div> |
||
116 | |||
10 | office | 117 | <div class="container"> |
118 | <div class="jumbotron"> |
||
119 | <h1>Corrade Pack Rat</h1> |
||
120 | <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> |
||
121 | <img src="/pack-rat/img/pack-rat.png"></div> |
||
122 | |||
26 | office | 123 | <div class="panel panel-default draggable movable"> |
124 | <div class="panel-heading"> |
||
125 | <h3 class="panel-title">Pack-Rat</h3> |
||
126 | </div> |
||
127 | <div class="panel-body"> |
||
128 | <!-- Will hold the inventory tree (completed dynamically). --> |
||
129 | <div id="tree"> |
||
130 | </div> |
||
131 | </div> |
||
132 | </div> |
||
133 | |||
134 | <!-- Nucleons --> |
||
135 | <div class="panel panel-default draggable movable"> |
||
136 | <div class="panel-heading"> |
||
137 | <h3 class="panel-title">Nucleons</h3> |
||
138 | </div> |
||
139 | <div class="panel-body"> |
||
140 | <div id="nucleons" class="row"></div> |
||
141 | </div> |
||
142 | </div> |
||
10 | office | 143 | |
144 | <footer class="footer"> |
||
145 | <p>© 2017 Wizardry and Steamworks</p> |
||
146 | </footer> |
||
147 | </div> |
||
148 | <!-- jQuery --> |
||
20 | office | 149 | <script src="/node_modules/jquery/dist/jquery.min.js" type="text/javascript"></script> |
10 | office | 150 | <!-- Wizardry and Steamworks JavaScript Includes --> |
20 | office | 151 | <script src="/node_modules/was/dist/was.min.js" type="text/javascript"></script> |
10 | office | 152 | <!-- Bootstrap Javascript --> |
20 | office | 153 | <script src="/node_modules/bootstrap/dist/js/bootstrap.min.js" type="text/javascript"></script> |
154 | <script src="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.js" type="text/javascript"></script> |
||
10 | office | 155 | <!-- Bootstrap Form Validator --> |
20 | office | 156 | <script src="/node_modules/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script> |
24 | office | 157 | <!-- Forge --> |
158 | <script src="/node_modules/node-forge/dist/forge.all.min.js" type="text/javascript"></script> |
||
20 | office | 159 | <!-- Moment JS --> |
160 | <script src="/pack-rat/node_modules/moment/min/moment.min.js" type="text/javascript"></script> |
||
23 | office | 161 | <!-- JsTree --> |
20 | office | 162 | <script src="/pack-rat/node_modules/jstree/dist/jstree.min.js" type="text/javascript"></script> |
23 | office | 163 | <!-- JSON to Table --> |
20 | office | 164 | <script src="/pack-rat/node_modules/json-to-table/json-to-table.js" type="text/javascript"></script> |
26 | office | 165 | <!-- Interact JS --> |
166 | <script src="/node_modules/interactjs/dist/interact.min.js" type="text/javascript"></script> |
||
167 | <!-- Manager for Windows. --> |
||
168 | <script src="/js/wm/wm.js" type="text/javascript"></script> |
||
169 | <!-- Nucleons Loader --> |
||
170 | <script src="/js/nucleus/load-nucleons.js" type="text/javascript"></script> |
||
10 | office | 171 | <!-- Main script --> |
172 | <script type="text/javascript"> |
||
173 | $(function() { |
||
174 | function customMenu(node) { |
||
175 | // The default set of menu items for all types |
||
176 | var items = { |
||
177 | // Grab information about the item. |
||
178 | infoItem: { |
||
179 | label: "Get Info", |
||
180 | action: function(obj) { |
||
181 | $.ajax({ |
||
17 | office | 182 | //async: false, |
10 | office | 183 | type: 'POST', |
184 | url: '/', |
||
185 | dataType: 'json', |
||
186 | data: { |
||
187 | command: 'getinventorydata', |
||
17 | office | 188 | item: node.id, |
189 | data: wasArrayToCSV([ |
||
10 | office | 190 | 'AssetUUID', |
191 | 'CreationDate', |
||
192 | 'Description', |
||
193 | 'Permissions', |
||
194 | 'UUID' // part of InventoryBase |
||
17 | office | 195 | ]) |
10 | office | 196 | } |
18 | office | 197 | }).done(function(response) { |
198 | if(response.success !== 'True') { |
||
199 | alert('Error moving item: ' + response.error); |
||
200 | return; |
||
201 | } |
||
17 | office | 202 | $('#info').bootstrapTable({ |
203 | data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ] |
||
204 | }); |
||
18 | office | 205 | $('#item-info-modal').modal('show'); |
10 | office | 206 | }); |
207 | } |
||
208 | } |
||
209 | }; |
||
210 | |||
211 | // Give inventory items menu for anything but folders. |
||
212 | // They could be supported too but would require first |
||
213 | // counting the number of items inside the folder and |
||
214 | // only accepting to send if the number is below max. |
||
215 | if (node.data.type != "folder") { |
||
216 | $.extend(items, { |
||
217 | giveItem: { |
||
218 | label: "Give", |
||
219 | action: function(obj) { |
||
18 | office | 220 | $('#avatar-select-modal') |
221 | .modal('show') |
||
24 | office | 222 | .on('click', '#send-item', function(e) { |
223 | $('#avatar-select-modal').modal('hide').unbind('click'); |
||
18 | office | 224 | $.ajax({ |
225 | type: 'POST', |
||
226 | url: '/', |
||
227 | data: { |
||
228 | command: 'give', |
||
229 | entity: 'avatar', |
||
230 | item: node.id, |
||
231 | firstname: $('#avatar-firstname').val(), |
||
232 | lastname: $('#avatar-lastname').val() |
||
233 | }, |
||
234 | dataType: 'json' |
||
235 | }).done(function(response) { |
||
236 | if(response.success !== 'True') { |
||
237 | alert('Error sending item: ' + response.error); |
||
10 | office | 238 | return; |
18 | office | 239 | } |
240 | }); |
||
241 | }); |
||
10 | office | 242 | } |
243 | } |
||
244 | }); |
||
245 | } |
||
246 | |||
247 | // The "download" menu item for textures. |
||
248 | if (node.data.type == "texture" || node.data.type == "snapshot") { |
||
249 | $.extend(items, { |
||
250 | downloadItem: { |
||
251 | label: "Download", |
||
252 | "action": function(obj) { |
||
24 | office | 253 | $("<img id='item-download-texture' width='100%' height='100%'>") |
254 | .attr('src', '/pack-rat/img/loader.svg') |
||
255 | .appendTo('#item-download-content'); |
||
256 | $('#item-download-modal') |
||
257 | .modal('show') |
||
258 | .on('hidden.bs.modal', function (e) { |
||
26 | office | 259 | $('#item-download-content') |
24 | office | 260 | .html(''); |
261 | }); |
||
10 | office | 262 | $.ajax({ |
263 | type: 'POST', |
||
18 | office | 264 | url: '/', |
10 | office | 265 | data: { |
18 | office | 266 | command: 'download', |
267 | item: node.id, |
||
268 | format: 'Png', |
||
269 | type: 'Texture' |
||
270 | }, |
||
271 | dataType: 'json' |
||
272 | }).done(function(response) { |
||
24 | office | 273 | // Create the image tag and set the content. |
274 | $("#item-download-texture") |
||
275 | .attr('src', "data:image/png;base64," + response.data); |
||
10 | office | 276 | }); |
277 | } |
||
278 | } |
||
279 | }); |
||
280 | } |
||
281 | |||
282 | // The "download" menu item for notecards. |
||
283 | if (node.data.type == "notecard") { |
||
284 | $.extend(items, { |
||
285 | downloadItem: { |
||
286 | label: "Download", |
||
287 | "action": function(obj) { |
||
24 | office | 288 | $("<img id='item-download-texture' width='100%' height='100%'>") |
289 | .attr('src', '/pack-rat/img/loader.svg') |
||
290 | .appendTo('#item-download-content'); |
||
291 | $('#item-download-modal') |
||
292 | .modal('show') |
||
293 | .on('hidden.bs.modal', function (e) { |
||
294 | $('#item-download-content') |
||
295 | .html(''); |
||
296 | }); |
||
10 | office | 297 | $.ajax({ |
298 | type: 'POST', |
||
24 | office | 299 | url: '/', |
10 | office | 300 | data: { |
24 | office | 301 | command: 'download', |
302 | item: node.id, |
||
303 | type: 'Notecard' |
||
304 | }, |
||
305 | dataType: 'json' |
||
306 | }).done(function(response) { |
||
26 | office | 307 | $('#item-download-content') |
24 | office | 308 | .html(''); |
309 | |||
310 | // Decode notecard and display it. |
||
311 | $('#item-download-content').html( |
||
312 | '<pre>' + |
||
313 | forge.util.decodeUtf8( |
||
314 | forge.util.decode64(response.data) |
||
315 | ) + |
||
316 | '</pre>' |
||
317 | ); |
||
10 | office | 318 | }); |
319 | } |
||
320 | } |
||
321 | }); |
||
322 | } |
||
323 | |||
324 | // The "download" menu item for sounds. |
||
325 | if (node.data.type == "sound") { |
||
326 | $.extend(items, { |
||
327 | downloadItem: { |
||
328 | label: "Download", |
||
329 | "action": function(obj) { |
||
24 | office | 330 | $("<img id='item-download-texture' width='100%' height='100%'>") |
331 | .attr('src', '/pack-rat/img/loader.svg') |
||
332 | .appendTo('#item-download-content'); |
||
333 | $('#item-download-modal') |
||
334 | .modal('show') |
||
335 | .on('hidden.bs.modal', function (e) { |
||
336 | $('#item-download-content') |
||
337 | .html(''); |
||
338 | }); |
||
10 | office | 339 | $.ajax({ |
340 | type: 'POST', |
||
24 | office | 341 | url: '/', |
10 | office | 342 | data: { |
24 | office | 343 | command: 'download', |
344 | item: node.id, |
||
345 | type: 'Sound', |
||
346 | format: 'wav' |
||
347 | }, |
||
348 | dataType: 'json' |
||
349 | }).done(function(response) { |
||
26 | office | 350 | $('#item-download-content') |
24 | office | 351 | .html(''); |
352 | |||
353 | // Create HTML5 audio tags and load the data. |
||
26 | office | 354 | $('#item-download-content') |
355 | .html("<audio controls='' preload='auto'><source src='" + 'data:audio/x-wav;base64,' + response.data + "' type='audio/x-wav'></audio>"); |
||
10 | office | 356 | }); |
357 | } |
||
358 | } |
||
359 | }); |
||
360 | } |
||
361 | |||
362 | return items; |
||
363 | } |
||
364 | |||
365 | $("#tree").jstree({ |
||
366 | // - sort will sort items by date |
||
367 | // - state will store the open / closed state of the jstree |
||
368 | 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"], |
||
15 | office | 369 | 'contextmenu': { |
10 | office | 370 | "items": function(node) { |
371 | return customMenu(node); |
||
372 | } |
||
15 | office | 373 | }, |
10 | office | 374 | 'dnd': { |
375 | // Do not copy items. |
||
376 | 'copy': false, |
||
377 | // Do not execute the check callback whilst dragging. |
||
16 | office | 378 | 'check_while_dragging': true |
10 | office | 379 | }, |
380 | 'sort': function(a, b) { |
||
16 | office | 381 | return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1; |
10 | office | 382 | }, |
383 | 'core': { |
||
15 | office | 384 | 'check_callback': function(operation, node, parent, position, more) { |
16 | office | 385 | // Only allow move operations |
386 | if (operation !== 'move_node' || |
||
387 | // Do not move system folders. |
||
388 | node.data.system !== false || |
||
389 | // Do not allow moves above the root node. |
||
390 | parent.id === "#" || |
||
391 | // Do not allow moving an item over another item. |
||
392 | (node.data.type !== 'folder' && parent.data.type !== 'folder')) |
||
10 | office | 393 | return false; |
15 | office | 394 | |
395 | var source = node.id; |
||
396 | var target = parent.id; |
||
397 | |||
398 | // Normalize source and target. |
||
399 | if(source === '#') |
||
400 | source = '/'; |
||
401 | |||
402 | if(target === '#') |
||
403 | target = '/'; |
||
404 | |||
405 | if(source == '/' && target == '/') |
||
16 | office | 406 | return false; |
15 | office | 407 | |
408 | // Check if source path is sane. |
||
409 | if(source.split('/').some( |
||
410 | function(part) { |
||
411 | 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); |
||
412 | })) { |
||
16 | office | 413 | return false; |
15 | office | 414 | } |
415 | |||
416 | // Check if target path is sane. |
||
417 | if(target.split('/').some( |
||
418 | function(part) { |
||
419 | 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); |
||
420 | })) { |
||
16 | office | 421 | return false; |
15 | office | 422 | } |
423 | |||
16 | office | 424 | return true; |
15 | office | 425 | }, |
10 | office | 426 | data: function(node, callback) { |
427 | if(node.id === '#') { |
||
428 | callback.call(this, [ |
||
429 | { |
||
430 | "id" : "/My Inventory", |
||
431 | "parent" : "#", |
||
432 | "text" : "My Inventory", |
||
433 | "data" : { |
||
16 | office | 434 | "type" : "folder", |
435 | 'time' : Date.now(), |
||
436 | 'system' : true |
||
10 | office | 437 | }, |
438 | "children" : true, |
||
439 | "opened" : false |
||
440 | }, |
||
441 | { |
||
442 | "id" : "/Library", |
||
443 | "parent" : "#", |
||
444 | "text" : "Library", |
||
445 | "data" : { |
||
16 | office | 446 | "type" : "folder", |
447 | 'time' : Date.now(), |
||
448 | 'system' : true |
||
10 | office | 449 | }, |
450 | "children" : true, |
||
451 | "opened" : false |
||
452 | } |
||
453 | ]); |
||
454 | return; |
||
455 | } |
||
456 | $.ajax({ |
||
457 | //async: false, |
||
458 | type: 'POST', |
||
459 | url: '/', |
||
460 | dataType: 'json', |
||
461 | data: { |
||
462 | command: 'inventory', |
||
463 | action: 'ls', |
||
464 | path: node.id |
||
465 | } |
||
466 | }).done(function(response) { |
||
14 | office | 467 | var list = []; |
468 | $.each(wasCSVToArray(response.data) |
||
16 | office | 469 | .chunk(10), |
470 | function(i, e) { |
||
471 | e = wasKeyValueObjectify(e); |
||
472 | //alert(node.id + " to " + JSON.stringify(e, 4, null)); |
||
473 | list.push({ |
||
474 | 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'], |
||
475 | 'parent' : node.id, |
||
476 | 'data' : { |
||
477 | 'type' : e['type'], |
||
478 | 'time' : Date.parse(e['time']), |
||
479 | // Check if this folder is a system folder. |
||
480 | 'system' : node.id === '/My Inventory' && ( |
||
481 | e['name'] === 'Trash' || |
||
482 | e['name'] === 'Notecards' || |
||
483 | e['name'] === 'Scripts' || |
||
484 | e['name'] === 'Lost And Found' || |
||
485 | e['name'] === 'Landmarks' || |
||
486 | e['name'] === 'Current Outfit' || |
||
487 | e['name'] === 'Calling Cards' || |
||
488 | e['name'] === 'Textures' || |
||
489 | e['name'] === 'Objects' || |
||
490 | e['name'] === 'My Outfits' || |
||
491 | e['name'] === 'Clothing' || |
||
492 | e['name'] === 'Body Parts' || |
||
493 | e['name'] === 'Photo Album' || |
||
494 | e['name'] === 'Favorites' || |
||
495 | e['name'] === 'Gestures' || |
||
496 | e['name'] === 'Animations' |
||
497 | ) |
||
498 | }, |
||
499 | 'text' : e['name'], |
||
500 | 'children' : e['type'] === 'folder', |
||
501 | 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif', |
||
502 | 'opened' : 'false' |
||
14 | office | 503 | }); |
13 | office | 504 | }); |
14 | office | 505 | callback.call(this, list); |
10 | office | 506 | }); |
507 | } |
||
508 | } |
||
509 | }).bind('move_node.jstree', function(e, data) { |
||
16 | office | 510 | $.ajax({ |
511 | //async: false, |
||
512 | type: 'POST', |
||
513 | url: '/', |
||
514 | dataType: 'json', |
||
515 | data: { |
||
516 | command: 'inventory', |
||
517 | action: 'mv', |
||
518 | source: data.node.id, |
||
519 | target: data.parent |
||
520 | } |
||
521 | }).done(function(response) { |
||
522 | if(response.success !== 'True') { |
||
523 | alert('Error moving item: ' + response.error); |
||
524 | } |
||
525 | }); |
||
10 | office | 526 | // Once the node is moved, update the node ID to reflect the path change. |
527 | var parentPath = data.parent != '/' ? data.parent : ""; |
||
528 | var item = data.node.id.split(/[\/]+/).pop(); |
||
529 | data.instance.set_id(data.node, parentPath + '/' + item); |
||
530 | }); |
||
26 | office | 531 | |
532 | // Move context menu to top-most. |
||
533 | $('#tree').on('contextmenu', '.jstree-anchor', function (e) { |
||
534 | $('.vakata-context').css('z-index', getTopWindowIndex() + 1); |
||
535 | }); |
||
10 | office | 536 | }); |
537 | </script> |
||
538 | </body> |
||
539 | </html> |