corrade-nucleus-nucleons – Diff between revs 26 and 28

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 26 Rev 28
Line 1... Line -...
1 <!DOCTYPE html> -  
2   -  
3 <html lang="en"> 1 <div id="pack-rat">
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="/node_modules/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 <!-- Manager for Windows. --> -  
21 <link href="/css/wm/wm.css" rel="stylesheet" type="text/css"> -  
22   -  
23 <!-- jsTree style --> -  
24 <link href="/pack-rat/node_modules/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css"> -  
25 <!-- Bootstrap table --> -  
26 <link href="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet" type="text/css"> -  
27 </script> -  
28 </head> -  
29   -  
30 <body> -  
31 <!-- Bootstrap Modal --> 2 <!-- Bootstrap Modal -->
32 <div id="item-info-modal" class="modal fade bs-example-modal-lg" role="dialog"> 3 <div id="pack-rat-item-info-modal" class="modal fade bs-example-modal-lg" role="dialog">
33 <div class="modal-dialog modal-lg"> 4 <div class="modal-dialog modal-lg">
34 <!-- Modal content--> 5 <!-- Modal content-->
Line 35... Line 6...
35   6  
36 <div class="modal-content"> 7 <div class="modal-content">
37 <div class="modal-header"> 8 <div class="modal-header">
Line 38... Line 9...
38 <button type="button" class="close" data-dismiss="modal">&times;</button> 9 <button type="button" class="close" data-dismiss="modal">&times;</button>
39   10  
Line 40... Line 11...
40 <h1 class="modal-title">Item Information</h1> 11 <h1 class="modal-title">Item Information</h1>
41 </div> 12 </div>
42   13  
43 <div id="item-info-content" class="modal-body"> 14 <div class="modal-body">
44 <table id="info" data-height="460"> 15 <table id="pack-rat-item-info" data-height="460">
45 <thead> 16 <thead>
46 <tr> 17 <tr>
Line 57... Line 28...
57 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 28 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
58 </div> 29 </div>
59 </div> 30 </div>
60 </div> 31 </div>
61 </div> 32 </div>
62 33  
63 <!-- Give Inventory Item Destination Dialog --> 34 <!-- Give Inventory Item Destination Dialog -->
64 <div id="avatar-select-modal" class="modal fade bs-example-modal-lg" role="dialog"> 35 <div id="pack-rat-avatar-select-modal" class="modal fade bs-example-modal-lg" role="dialog">
65 <div class="modal-dialog modal-lg"> 36 <div class="modal-dialog modal-lg">
66 <!-- Modal content--> 37 <!-- Modal content-->
Line 67... Line 38...
67   38  
68 <div class="modal-content"> 39 <div class="modal-content">
69 <div class="modal-header"> 40 <div class="modal-header">
Line 70... Line 41...
70 <button type="button" class="close" data-dismiss="modal">&times;</button> 41 <button type="button" class="close" data-dismiss="modal">&times;</button>
71   42  
Line 72... Line 43...
72 <h1 class="modal-title">Avatar Selection</h1> 43 <h1 class="modal-title">Avatar Selection</h1>
73 </div> 44 </div>
74   45  
75 <form id="avatar-select-form" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();"> 46 <form class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();">
76 <div id="avatar-select-content" class="modal-body"> 47 <div class="modal-body">
77 <p>Please enter the avatar firstname and lastname to send the script to.</p> 48 <p>Please enter the avatar firstname and lastname to send the script to.</p>
78 <div class="form-group has-feedback"> 49 <div class="form-group has-feedback">
79 <label for="avatar-firstname">First Name</label> 50 <label for="pack-rat-avatar-firstname">First Name</label>
80 <input id="avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required> 51 <input id="pack-rat-avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required>
81 <label for="avatar-lastname">Last Name</label> 52 <label for="pack-rat-avatar-lastname">Last Name</label>
82 <input id="avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required> 53 <input id="pack-rat-avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required>
83 </div> 54 </div>
84 </div> 55 </div>
85 <div class="modal-footer"> 56 <div class="modal-footer">
86 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 57 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
87 <button id="send-item" type="button" class="btn btn-primary">Confirm</button> 58 <button id="pack-rat-send-item" type="button" class="btn btn-primary">Confirm</button>
88 </div> 59 </div>
89 </form> 60 </form>
90 </div> 61 </div>
91 </div> 62 </div>
92 </div> 63 </div>
93 64  
94 <!-- Inventory Item Download Dialog --> 65 <!-- Inventory Item Download Dialog -->
Line 95... Line 66...
95 <div id="item-download-modal" class="modal fade bs-example-modal-lg" role="dialog"> 66 <div id="pack-rat-item-download-modal" class="modal fade bs-example-modal-lg" role="dialog">
96 <div class="modal-dialog modal-lg"> 67 <div class="modal-dialog modal-lg">
97 <!-- Modal content--> 68 <!-- Modal content-->
Line 98... Line 69...
98   69  
99 <div class="modal-content"> 70 <div class="modal-content">
100 <div class="modal-header"> 71 <div class="modal-header">
101 <button type="button" class="close" data-dismiss="modal">&times;</button> 72 <button type="button" class="close" data-dismiss="modal">&times;</button>
102   -  
103 <h1 class="modal-title">Download</h1> 73  
104 </div> 74 <h1 class="modal-title">Download</h1>
105 75 </div>
106 <div id="item-download-content" class="modal-body"> 76
107 <!-- <img width="100%" height="100%" src="" align="middle" id="texture"> --> 77 <div id="pack-rat-item-download-content" class="modal-body">
108 </div> 78 </div>
109 79
110 <div class="modal-footer"> 80 <div class="modal-footer">
Line 141... Line 476...
141 </div> 476 // Move context menu to top-most.
142 </div> -  
143   -  
144 <footer class="footer"> -  
145 <p>&copy; 2017 Wizardry and Steamworks</p> -  
146 </footer> -  
147 </div> -  
148 <!-- jQuery --> -  
149 <script src="/node_modules/jquery/dist/jquery.min.js" type="text/javascript"></script> -  
150 <!-- Wizardry and Steamworks JavaScript Includes --> -  
151 <script src="/node_modules/was/dist/was.min.js" type="text/javascript"></script> -  
152 <!-- Bootstrap Javascript --> -  
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> -  
155 <!-- Bootstrap Form Validator --> -  
156 <script src="/node_modules/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script> -  
157 <!-- Forge --> -  
158 <script src="/node_modules/node-forge/dist/forge.all.min.js" type="text/javascript"></script> -  
159 <!-- Moment JS --> -  
160 <script src="/pack-rat/node_modules/moment/min/moment.min.js" type="text/javascript"></script> -  
161 <!-- JsTree --> -  
162 <script src="/pack-rat/node_modules/jstree/dist/jstree.min.js" type="text/javascript"></script> -  
163 <!-- JSON to Table --> -  
164 <script src="/pack-rat/node_modules/json-to-table/json-to-table.js" type="text/javascript"></script> -  
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> -  
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({ -  
182 //async: false, -  
183 type: 'POST', -  
184 url: '/', -  
185 dataType: 'json', -  
186 data: { -  
187 command: 'getinventorydata', -  
188 item: node.id, -  
189 data: wasArrayToCSV([ -  
190 'AssetUUID', -  
191 'CreationDate', -  
192 'Description', -  
193 'Permissions', -  
194 'UUID' // part of InventoryBase -  
195 ]) -  
196 } -  
197 }).done(function(response) { -  
198 if(response.success !== 'True') { -  
199 alert('Error moving item: ' + response.error); -  
200 return; -  
201 } -  
202 $('#info').bootstrapTable({ -  
203 data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ] -  
204 }); -  
205 $('#item-info-modal').modal('show'); -  
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) { -  
220 $('#avatar-select-modal') -  
221 .modal('show') -  
222 .on('click', '#send-item', function(e) { -  
223 $('#avatar-select-modal').modal('hide').unbind('click'); -  
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); -  
238 return; -  
239 } -  
240 }); -  
241 }); -  
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) { -  
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) { -  
259 $('#item-download-content') -  
260 .html(''); -  
261 }); -  
262 $.ajax({ -  
263 type: 'POST', -  
264 url: '/', -  
265 data: { -  
266 command: 'download', -  
267 item: node.id, -  
268 format: 'Png', -  
269 type: 'Texture' -  
270 }, -  
271 dataType: 'json' -  
272 }).done(function(response) { -  
273 // Create the image tag and set the content. -  
274 $("#item-download-texture") -  
275 .attr('src', "data:image/png;base64," + response.data); -  
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) { -  
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 }); -  
297 $.ajax({ -  
298 type: 'POST', -  
299 url: '/', -  
300 data: { -  
301 command: 'download', -  
302 item: node.id, -  
303 type: 'Notecard' -  
304 }, -  
305 dataType: 'json' -  
306 }).done(function(response) { -  
307 $('#item-download-content') -  
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 ); -  
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) { -  
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 }); -  
339 $.ajax({ -  
340 type: 'POST', -  
341 url: '/', -  
342 data: { -  
343 command: 'download', -  
344 item: node.id, -  
345 type: 'Sound', -  
346 format: 'wav' -  
347 }, -  
348 dataType: 'json' -  
349 }).done(function(response) { -  
350 $('#item-download-content') -  
351 .html(''); -  
352 -  
353 // Create HTML5 audio tags and load the data. -  
354 $('#item-download-content') -  
355 .html("<audio controls='' preload='auto'><source src='" + 'data:audio/x-wav;base64,' + response.data + "' type='audio/x-wav'></audio>"); -  
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"], -  
369 'contextmenu': { -  
370 "items": function(node) { -  
371 return customMenu(node); -  
372 } -  
373 }, -  
374 'dnd': { -  
375 // Do not copy items. -  
376 'copy': false, -  
377 // Do not execute the check callback whilst dragging. -  
378 'check_while_dragging': true -  
379 }, -  
380 'sort': function(a, b) { -  
381 return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1; -  
382 }, -  
383 'core': { -  
384 'check_callback': function(operation, node, parent, position, more) { -  
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')) -  
393 return false; -  
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 == '/') -  
406 return false; -  
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 })) { -  
413 return false; -  
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 })) { -  
421 return false; -  
422 } -  
423 -  
424 return true; -  
425 }, -  
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" : { -  
434 "type" : "folder", -  
435 'time' : Date.now(), -  
436 'system' : true -  
437 }, -  
438 "children" : true, -  
439 "opened" : false -  
440 }, -  
441 { -  
442 "id" : "/Library", -  
443 "parent" : "#", -  
444 "text" : "Library", -  
445 "data" : { -  
446 "type" : "folder", -  
447 'time' : Date.now(), -  
448 'system' : true -  
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) { -  
467 var list = []; -  
468 $.each(wasCSVToArray(response.data) -  
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' -  
503 }); -  
504 }); -  
505 callback.call(this, list); -  
506 }); -  
507 } -  
508 } -  
509 }).bind('move_node.jstree', function(e, data) { -  
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 }); -  
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 }); -  
531 -  
532 // Move context menu to top-most. -  
533 $('#tree').on('contextmenu', '.jstree-anchor', function (e) { 477 $('#pack-rat-tree').on('contextmenu', '.jstree-anchor', function (e) {
534 $('.vakata-context').css('z-index', getTopWindowIndex() + 1); 478 $('.vakata-context').css('z-index', getTopWindowIndex() + 1);