corrade-nucleus-nucleons – Blame information for rev 24

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