corrade-nucleus-nucleons – Blame information for rev 38

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