corrade-nucleus-nucleons – Blame information for rev 29

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