corrade-nucleus-nucleons – Blame information for rev 23

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  
38 <h1 id="title" class="modal-title"></h1>
39 </div>
40  
41 <div id="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  
70 <h1 id="title" class="modal-title">Avatar Selection</h1>
71 </div>
72  
73 <form id="avatar-select-form" class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();">
74 <div id="content" class="modal-body">
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>
85 <button id="send-script" type="submit" class="btn btn-primary">Confirm</button>
86 </div>
87 </form>
88 </div>
89 </div>
90 </div>
91  
92 <!-- Texture Download Dialog -->
93 <div id="texture-download-modal" class="modal fade bs-example-modal-lg" role="dialog">
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  
101 <h1 id="title" class="modal-title">Avatar Selection</h1>
102 </div>
103  
104 <div id="content" class="modal-body">
105 <img src="" align="middle" id="texture">
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>
138 <!-- Moment JS -->
139 <script src="/pack-rat/node_modules/moment/min/moment.min.js" type="text/javascript"></script>
23 office 140 <!-- JsTree -->
20 office 141 <script src="/pack-rat/node_modules/jstree/dist/jstree.min.js" type="text/javascript"></script>
23 office 142 <!-- JSON to Table -->
20 office 143 <script src="/pack-rat/node_modules/json-to-table/json-to-table.js" type="text/javascript"></script>
10 office 144 <!-- Main script -->
145 <script type="text/javascript">
146 $(function() {
147 function customMenu(node) {
148 // The default set of menu items for all types
149 var items = {
150 // Grab information about the item.
151 infoItem: {
152 label: "Get Info",
153 action: function(obj) {
154 $.ajax({
17 office 155 //async: false,
10 office 156 type: 'POST',
157 url: '/',
158 dataType: 'json',
159 data: {
160 command: 'getinventorydata',
17 office 161 item: node.id,
162 data: wasArrayToCSV([
10 office 163 'AssetUUID',
164 'CreationDate',
165 'Description',
166 'Permissions',
167 'UUID' // part of InventoryBase
17 office 168 ])
10 office 169 }
18 office 170 }).done(function(response) {
171 if(response.success !== 'True') {
172 alert('Error moving item: ' + response.error);
173 return;
174 }
17 office 175 $('#info').bootstrapTable({
176 data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ]
177 });
18 office 178 $('#item-info-modal').modal('show');
10 office 179 });
180 }
181 }
182 };
183  
184 // Give inventory items menu for anything but folders.
185 // They could be supported too but would require first
186 // counting the number of items inside the folder and
187 // only accepting to send if the number is below max.
188 if (node.data.type != "folder") {
189 $.extend(items, {
190 giveItem: {
191 label: "Give",
192 action: function(obj) {
18 office 193 $('#avatar-select-modal')
194 .modal('show')
195 .on('click', '#send-script', function(e) {
196 $('#avatar-select-modal').modal('hide');
197 $.ajax({
198 type: 'POST',
199 url: '/',
200 data: {
201 command: 'give',
202 entity: 'avatar',
203 item: node.id,
204 firstname: $('#avatar-firstname').val(),
205 lastname: $('#avatar-lastname').val()
206 },
207 dataType: 'json'
208 }).done(function(response) {
209 if(response.success !== 'True') {
210 alert('Error sending item: ' + response.error);
10 office 211 return;
18 office 212 }
213 });
214 });
10 office 215 }
216 }
217 });
218 }
219  
220 // The "download" menu item for textures.
221 if (node.data.type == "texture" || node.data.type == "snapshot") {
222 $.extend(items, {
223 downloadItem: {
224 label: "Download",
225 "action": function(obj) {
18 office 226 $('#texture').attr('src', '/pack-rat/img/loader.gif');
227 $('#texture-download-modal').modal('show');
10 office 228 $.ajax({
229 type: 'POST',
18 office 230 url: '/',
10 office 231 data: {
18 office 232 command: 'download',
233 item: node.id,
234 format: 'Png',
235 type: 'Texture'
236 },
237 dataType: 'json'
238 }).done(function(response) {
239 $('#texture').attr('src', "data:image/png;base64," + response.data);
10 office 240 });
241 }
242 }
243 });
244 }
245  
246 // The "download" menu item for notecards.
247 if (node.data.type == "notecard") {
248 $.extend(items, {
249 downloadItem: {
250 label: "Download",
251 "action": function(obj) {
252 $('#texture').attr('src', 'images/loader.gif');
253 $('#popup').dialog({
254 width: 800,
255 height: 600,
256 modal: true,
257 resizable: false,
258 dialogClass: 'no-close texture-dialog'
259 }).on('dialogclose', function(event) {
260 $('#content').html('');
261 });
262 $.ajax({
263 type: 'POST',
264 url: "downloadNotecard.php?t=" + Math.random(),
265 data: {
266 uuid: node.id.split(/[\/]+/).pop()
267 }
268 }).done(function(data) {
269 $.base64.utf8decode = true;
270 $('#content').html('<pre>' + $.base64.atob(data) + '</pre>');
271 });
272 }
273 }
274 });
275 }
276  
277 // The "download" menu item for sounds.
278 if (node.data.type == "sound") {
279 $.extend(items, {
280 downloadItem: {
281 label: "Download",
282 "action": function(obj) {
283 $('#texture').attr('src', 'images/loader.gif');
284 $('#popup').dialog({
285 width: 800,
286 height: 600,
287 modal: true,
288 resizable: false,
289 dialogClass: 'no-close texture-dialog'
290 }).on('dialogclose', function(event) {
291 $('#content').html('');
292 });
293 $.ajax({
294 type: 'POST',
295 url: "downloadSound.php?t=" + Math.random(),
296 data: {
297 uuid: node.id.split(/[\/]+/).pop()
298 }
299 }).done(function(data) {
300 $('#content').html('<audio controls="controls"><source id="source" src="" type="audio/mp3"></source></audio>');
301 $('#source').attr('src', "data:audio/mp3;base64," + data);
302 });
303 }
304 }
305 });
306 }
307  
308 return items;
309 }
310  
311 $("#tree").jstree({
312 // - sort will sort items by date
313 // - state will store the open / closed state of the jstree
314 'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"],
15 office 315 'contextmenu': {
10 office 316 "items": function(node) {
317 return customMenu(node);
318 }
15 office 319 },
10 office 320 'dnd': {
321 // Do not copy items.
322 'copy': false,
323 // Do not execute the check callback whilst dragging.
16 office 324 'check_while_dragging': true
10 office 325 },
326 'sort': function(a, b) {
16 office 327 return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1;
10 office 328 },
329 'core': {
15 office 330 'check_callback': function(operation, node, parent, position, more) {
16 office 331 // Only allow move operations
332 if (operation !== 'move_node' ||
333 // Do not move system folders.
334 node.data.system !== false ||
335 // Do not allow moves above the root node.
336 parent.id === "#" ||
337 // Do not allow moving an item over another item.
338 (node.data.type !== 'folder' && parent.data.type !== 'folder'))
10 office 339 return false;
15 office 340  
341 var source = node.id;
342 var target = parent.id;
343  
344 // Normalize source and target.
345 if(source === '#')
346 source = '/';
347  
348 if(target === '#')
349 target = '/';
350  
351 if(source == '/' && target == '/')
16 office 352 return false;
15 office 353  
354 // Check if source path is sane.
355 if(source.split('/').some(
356 function(part) {
357 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);
358 })) {
16 office 359 return false;
15 office 360 }
361  
362 // Check if target path is sane.
363 if(target.split('/').some(
364 function(part) {
365 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);
366 })) {
16 office 367 return false;
15 office 368 }
369  
16 office 370 return true;
15 office 371 },
10 office 372 data: function(node, callback) {
373 if(node.id === '#') {
374 callback.call(this, [
375 {
376 "id" : "/My Inventory",
377 "parent" : "#",
378 "text" : "My Inventory",
379 "data" : {
16 office 380 "type" : "folder",
381 'time' : Date.now(),
382 'system' : true
10 office 383 },
384 "children" : true,
385 "opened" : false
386 },
387 {
388 "id" : "/Library",
389 "parent" : "#",
390 "text" : "Library",
391 "data" : {
16 office 392 "type" : "folder",
393 'time' : Date.now(),
394 'system' : true
10 office 395 },
396 "children" : true,
397 "opened" : false
398 }
399 ]);
400 return;
401 }
402 $.ajax({
403 //async: false,
404 type: 'POST',
405 url: '/',
406 dataType: 'json',
407 data: {
408 command: 'inventory',
409 action: 'ls',
410 path: node.id
411 }
412 }).done(function(response) {
14 office 413 var list = [];
414 $.each(wasCSVToArray(response.data)
16 office 415 .chunk(10),
416 function(i, e) {
417 e = wasKeyValueObjectify(e);
418 //alert(node.id + " to " + JSON.stringify(e, 4, null));
419 list.push({
420 'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'],
421 'parent' : node.id,
422 'data' : {
423 'type' : e['type'],
424 'time' : Date.parse(e['time']),
425 // Check if this folder is a system folder.
426 'system' : node.id === '/My Inventory' && (
427 e['name'] === 'Trash' ||
428 e['name'] === 'Notecards' ||
429 e['name'] === 'Scripts' ||
430 e['name'] === 'Lost And Found' ||
431 e['name'] === 'Landmarks' ||
432 e['name'] === 'Current Outfit' ||
433 e['name'] === 'Calling Cards' ||
434 e['name'] === 'Textures' ||
435 e['name'] === 'Objects' ||
436 e['name'] === 'My Outfits' ||
437 e['name'] === 'Clothing' ||
438 e['name'] === 'Body Parts' ||
439 e['name'] === 'Photo Album' ||
440 e['name'] === 'Favorites' ||
441 e['name'] === 'Gestures' ||
442 e['name'] === 'Animations'
443 )
444 },
445 'text' : e['name'],
446 'children' : e['type'] === 'folder',
447 'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif',
448 'opened' : 'false'
14 office 449 });
13 office 450 });
14 office 451 callback.call(this, list);
10 office 452 });
453 }
454 }
455 }).bind('move_node.jstree', function(e, data) {
16 office 456 $.ajax({
457 //async: false,
458 type: 'POST',
459 url: '/',
460 dataType: 'json',
461 data: {
462 command: 'inventory',
463 action: 'mv',
464 source: data.node.id,
465 target: data.parent
466 }
467 }).done(function(response) {
468 if(response.success !== 'True') {
469 alert('Error moving item: ' + response.error);
470 }
471 });
10 office 472 // Once the node is moved, update the node ID to reflect the path change.
473 var parentPath = data.parent != '/' ? data.parent : "";
474 var item = data.node.id.split(/[\/]+/).pop();
475 data.instance.set_id(data.node, parentPath + '/' + item);
476 });
477 });
478 </script>
479 </body>
480 </html>