corrade-nucleus-nucleons – Rev 39
?pathlinks?
<div id="pack-rat">
<!-- jsTree style -->
<link href="/pack-rat/node_modules/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css">
<!-- Bootstrap table -->
<link href="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.css" rel="stylesheet" type="text/css">
<!-- Bootstrap Modal -->
<div id="pack-rat-item-info-modal" class="modal fade bs-example-modal-lg" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h1 class="modal-title">Item Information</h1>
</div>
<div class="modal-body">
<table id="pack-rat-item-info" data-height="460">
<thead>
<tr>
<th data-field="AssetUUID">Asset UUID</th>
<th data-field="CreationDate">Creation Date</th>
<th data-field="Description">Description</th>
<th data-field="Permissions">Permissions</th>
<th data-field="UUID">Inventory UUID</th>
</tr>
</thead>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Give Inventory Item Destination Dialog -->
<div id="pack-rat-avatar-select-modal" class="modal fade bs-example-modal-lg" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h1 class="modal-title">Avatar Selection</h1>
</div>
<form class="form-inline" data-toggle="validator" onSubmit="event.preventDefault();">
<div class="modal-body">
<p>Please enter the avatar firstname and lastname to send the script to.</p>
<div class="form-group has-feedback">
<label for="pack-rat-avatar-firstname">First Name</label>
<input id="pack-rat-avatar-firstname" type="text" class="form-control" aria-describedby="basic-addon1" required>
<label for="pack-rat-avatar-lastname">Last Name</label>
<input id="pack-rat-avatar-lastname" type="text" class="form-control" aria-describedby="basic-addon1" required>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="pack-rat-send-item" type="button" class="btn btn-primary">Confirm</button>
</div>
</form>
</div>
</div>
</div>
<!-- Inventory Item Download Dialog -->
<div id="pack-rat-item-download-modal" class="modal fade bs-example-modal-lg" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h1 class="modal-title">Download</h1>
</div>
<div id="pack-rat-item-download-content" class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Main nucleon panel. -->
<div class="panel panel-default window-manager-window" data-target="pack-rat">
<div class="panel-heading">
Pack-Rat
<button type="button" class="close window-manager-close-button" data-target="pack-rat"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
</div>
<div class="panel-body">
<!-- Will hold the inventory tree (completed dynamically). -->
<div id="pack-rat-tree">
</div>
</div>
<!-- Bootstrap Table -->
<script src="/pack-rat/node_modules/bootstrap-table/dist/bootstrap-table.min.js" type="text/javascript"></script>
<!-- Bootstrap Form Validator -->
<script src="/node_modules/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script>
<!-- Forge -->
<script src="/node_modules/node-forge/dist/forge.all.min.js" type="text/javascript"></script>
<!-- Moment JS -->
<script src="/pack-rat/node_modules/moment/min/moment.min.js" type="text/javascript"></script>
<!-- JsTree -->
<script src="/pack-rat/node_modules/jstree/dist/jstree.min.js" type="text/javascript"></script>
<!-- Main script -->
<script type="text/javascript">
$(function() {
function customMenu(node) {
// The default set of menu items for all types
var items = {
// Grab information about the item.
infoItem: {
label: "Get Info",
action: function(obj) {
$.ajax({
//async: false,
type: 'POST',
url: '/',
dataType: 'json',
data: {
command: 'getinventorydata',
item: node.id,
data: wasArrayToCSV([
'AssetUUID',
'CreationDate',
'Description',
'Permissions',
'UUID' // part of InventoryBase
])
}
}).done(function(response) {
if(response.success !== 'True') {
alert('Error moving item: ' + response.error);
return;
}
$('#pack-rat-item-info').bootstrapTable({
data: [ wasKeyValueObjectify(wasCSVToArray(response.data)) ]
});
$('#pack-rat-item-info-modal').modal('show');
});
}
}
};
// Give inventory items menu for anything but folders.
// They could be supported too but would require first
// counting the number of items inside the folder and
// only accepting to send if the number is below max.
if (node.data.type != "folder") {
$.extend(items, {
giveItem: {
label: "Give",
action: function(obj) {
$('#pack-rat-avatar-select-modal')
.modal('show')
.on('click', '#pack-rat-send-item', function(e) {
$('#pack-rat-avatar-select-modal').modal('hide').unbind('click');
$.ajax({
type: 'POST',
url: '/',
data: {
command: 'give',
entity: 'avatar',
item: node.id,
firstname: $('#pack-rat-avatar-firstname').val(),
lastname: $('#pack-rat-avatar-lastname').val()
},
dataType: 'json'
}).done(function(response) {
if(response.success !== 'True') {
alert('Error sending item: ' + response.error);
return;
}
});
});
}
}
});
}
// The "download" menu item for textures.
if (node.data.type == "texture" || node.data.type == "snapshot") {
$.extend(items, {
downloadItem: {
label: "Download",
"action": function(obj) {
$("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
.attr('src', '/img/loader.gif')
.appendTo('#pack-rat-item-download-content');
$('#pack-rat-item-download-modal')
.modal('show')
.on('hidden.bs.modal', function (e) {
$('#pack-rat-item-download-content')
.html('');
});
$.ajax({
type: 'POST',
url: '/',
data: {
command: 'download',
item: node.id,
format: 'Png',
type: 'Texture'
},
dataType: 'json'
}).done(function(response) {
// Create the image tag and set the content.
$("#pack-rat-item-download-texture")
.attr('src', "data:image/png;base64," + response.data);
});
}
}
});
}
// The "download" menu item for notecards.
if (node.data.type == "notecard") {
$.extend(items, {
downloadItem: {
label: "Download",
"action": function(obj) {
$("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
.attr('src', '/img/loader.gif')
.appendTo('#pack-rat-item-download-content');
$('#pack-rat-item-download-modal')
.modal('show')
.on('hidden.bs.modal', function (e) {
$('#pack-rat-item-download-content')
.html('');
});
$.ajax({
type: 'POST',
url: '/',
data: {
command: 'download',
item: node.id,
type: 'Notecard'
},
dataType: 'json'
}).done(function(response) {
$('#pack-rat-item-download-content')
.html('');
// Decode notecard and display it.
$('#pack-rat-item-download-content').html(
'<pre>' +
forge.util.decodeUtf8(
forge.util.decode64(response.data)
) +
'</pre>'
);
});
}
}
});
}
// The "download" menu item for sounds.
if (node.data.type == "sound") {
$.extend(items, {
downloadItem: {
label: "Download",
"action": function(obj) {
$("<img id='pack-rat-item-download-texture' width='100%' height='100%'>")
.attr('src', '/img/loader.gif')
.appendTo('#pack-rat-item-download-content');
$('#pack-rat-item-download-modal')
.modal('show')
.on('hidden.bs.modal', function (e) {
$('#pack-rat-item-download-content')
.html('');
});
$.ajax({
type: 'POST',
url: '/',
data: {
command: 'download',
item: node.id,
type: 'Sound',
format: 'wav'
},
dataType: 'json'
}).done(function(response) {
$('#pack-rat-item-download-content')
.html('');
// Create HTML5 audio tags and load the data.
$('#pack-rat-item-download-content')
.html("<audio controls='' preload='auto'><source src='" + 'data:audio/x-wav;base64,' + response.data + "' type='audio/x-wav'></audio>");
});
}
}
});
}
return items;
}
$("#pack-rat-tree").jstree({
// - sort will sort items by date
// - state will store the open / closed state of the jstree
'plugins': ["themes", "json_data", "ui", "contextmenu", "sort", "dnd", "state"],
'contextmenu': {
"items": function(node) {
return customMenu(node);
}
},
'dnd': {
// Do not copy items.
'copy': false,
// Do not execute the check callback whilst dragging.
'check_while_dragging': true
},
'sort': function(a, b) {
return this.get_node(a).data.time < this.get_node(b).data.time ? 1 : -1;
},
'core': {
'check_callback': function(operation, node, parent, position, more) {
// Only allow move operations
if (operation !== 'move_node' ||
// Do not move system folders.
node.data.system !== false ||
// Do not allow moves above the root node.
parent.id === "#" ||
// Do not allow moving an item over another item.
(node.data.type !== 'folder' && parent.data.type !== 'folder'))
return false;
var source = node.id;
var target = parent.id;
// Normalize source and target.
if(source === '#')
source = '/';
if(target === '#')
target = '/';
if(source == '/' && target == '/')
return false;
// Check if source path is sane.
if(source.split('/').some(
function(part) {
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);
})) {
return false;
}
// Check if target path is sane.
if(target.split('/').some(
function(part) {
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);
})) {
return false;
}
return true;
},
data: function(node, callback) {
if(node.id === '#') {
callback.call(this, [
{
"id" : "/My Inventory",
"parent" : "#",
"text" : "My Inventory",
"data" : {
"type" : "folder",
'time' : Date.now(),
'system' : true
},
"children" : true,
"opened" : false
},
{
"id" : "/Library",
"parent" : "#",
"text" : "Library",
"data" : {
"type" : "folder",
'time' : Date.now(),
'system' : true
},
"children" : true,
"opened" : false
}
]);
return;
}
$.ajax({
//async: false,
type: 'POST',
url: '/',
dataType: 'json',
data: {
command: 'inventory',
action: 'ls',
path: node.id
}
}).done(function(response) {
var list = [];
$.each(wasCSVToArray(response.data)
.chunk(10),
function(i, e) {
e = wasKeyValueObjectify(e);
//alert(node.id + " to " + JSON.stringify(e, 4, null));
list.push({
'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'],
'parent' : node.id,
'data' : {
'type' : e['type'],
'time' : Date.parse(e['time']),
// Check if this folder is a system folder.
'system' : node.id === '/My Inventory' && (
e['name'] === 'Trash' ||
e['name'] === 'Notecards' ||
e['name'] === 'Scripts' ||
e['name'] === 'Lost And Found' ||
e['name'] === 'Landmarks' ||
e['name'] === 'Current Outfit' ||
e['name'] === 'Calling Cards' ||
e['name'] === 'Textures' ||
e['name'] === 'Objects' ||
e['name'] === 'My Outfits' ||
e['name'] === 'Clothing' ||
e['name'] === 'Body Parts' ||
e['name'] === 'Photo Album' ||
e['name'] === 'Favorites' ||
e['name'] === 'Gestures' ||
e['name'] === 'Animations'
)
},
'text' : e['name'],
'children' : e['type'] === 'folder',
'icon' : '/pack-rat/img/icons/' + e['type'] + '.gif',
'opened' : 'false'
});
});
callback.call(this, list);
});
}
}
}).bind('move_node.jstree', function(e, data) {
$.ajax({
//async: false,
type: 'POST',
url: '/',
dataType: 'json',
data: {
command: 'inventory',
action: 'mv',
source: data.node.id,
target: data.parent
}
}).done(function(response) {
if(response.success !== 'True') {
alert('Error moving item: ' + response.error);
}
});
// Once the node is moved, update the node ID to reflect the path change.
var parentPath = data.parent != '/' ? data.parent : "";
var item = data.node.id.split(/[\/]+/).pop();
data.instance.set_id(data.node, parentPath + '/' + item);
});
// Move context menu to top-most.
$('#pack-rat-tree').on('contextmenu', '.jstree-anchor', function (e) {
$('.vakata-context').css('z-index', getTopWindowIndex() + 1);
});
});
</script>
</div>
</div>
Generated by GNU Enscript 1.6.5.90.