corrade-nucleus-nucleons – Blame information for rev 18

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