corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 9  →  ?path2? @ 10
/pack-rat/003_pack_rat/pack-rat/index.html
@@ -0,0 +1,382 @@
<!DOCTYPE html>
 
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Corrade Nucleon">
<meta name="author" content="Wizardry and Steamworks">
<link rel="icon" href="favicon.ico">
 
<title>Corrade Nucleus - Pack Rat Inventory Manager</title>
 
<!-- Bootstrap core CSS -->
<link href="/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<!-- Corrade Nucleus Fonts -->
<link href="/css/nucleus/fonts.css" rel="stylesheet" type="text/css">
<!-- Customized bootstrap style. -->
<link href="/css/nucleus/nucleus.css" rel="stylesheet" type="text/css">
 
<!-- jsTree style -->
<link href="/pack-rat/bower_components/jstree/dist/themes/default/style.min.css" rel="stylesheet" type="text/css">
</script>
</head>
 
<body>
<!-- Bootstrap Modal -->
<div id="popup" 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">&times;</button>
 
<h1 id="title" class="modal-title"></h1>
</div>
 
<div id="content" class="modal-body">
<div class="progress">
<div id="progressbar" class="progress-bar" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="min-width: 2em; width: 2%;">
0%
</div>
</div>
 
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
 
<div class="container">
<div class="jumbotron">
<h1>Corrade Pack Rat</h1>
<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>
<img src="/pack-rat/img/pack-rat.png"></div>
 
<!-- Will hold the inventory tree (completed dynamically). -->
<div id="tree">
</div>
 
<footer class="footer">
<p>&copy; 2017 Wizardry and Steamworks</p>
</footer>
</div>
<!-- jQuery -->
<script src="/bower_components/jquery/dist/jquery.min.js" type="text/javascript"></script>
<!-- Wizardry and Steamworks JavaScript Includes -->
<script src="/bower_components/was/dist/was.min.js" type="text/javascript"></script>
<!-- Bootstrap Javascript -->
<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Bootstrap Form Validator -->
<script src="/pack-rat/bower_components/bootstrap-validator/dist/validator.min.js" type="text/javascript"></script>
<!-- XML <-> JSON -->
<!-- <script src="/bootstrap/bower_components/x2js/xml2json.min.js" type="text/javascript"></script> -->
<!-- CryptoJS -->
<script src="/bower_components/cryptojslib/components/core.js" type="text/javascript"></script>
<script src="/bower_components/cryptojslib/rollups/md5.js" type="text/javascript"></script>
<!-- Form To Object -->
<!-- <script src="/bootstrap/node_modules/form_to_object/dist/formToObject.min.js" type="text/javascript"></script> -->
<!-- Load form processor. -->
<!-- <script src="/bootstrap/js/corrade-bootstrap-processor.js" type="text/javascript"></script> -->
<!-- Moment JS -->
<script src="/pack-rat/bower_components/moment/min/moment.min.js" type="text/javascript"></script>
<!-- JsTree -->
<script src="/pack-rat/bower_components/jstree/dist/jstree.min.js" type="text/javascript"></script>
<!-- JSON to Table -->
<script src="/pack-rat/bower_components/json-to-table/json-to-table.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) {
$('#popup').dialog({
width: 800,
height: 600,
modal: true,
resizable: false,
dialogClass: 'no-close texture-dialog'
}).on('dialogclose', function(event) {
$('#content').html('');
});
$.ajax({
type: 'POST',
url: '/',
dataType: 'json',
data: {
command: 'getinventorydata',
item: node.id.split(/[\/]+/).pop(),
data: [
'AssetUUID',
'CreationDate',
'Description',
'Permissions',
'UUID' // part of InventoryBase
]
}
}).done(function(data) {
$('#content').html(ConvertJsonToTable(data, null, null, null));
});
}
}
};
 
// 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) {
$("#content").html('<form><fieldset class="ui-helper-reset"><label for="firstname">Firstname</label><input type="text" name="firstname" id="firstname" value="" class="ui-widget-content ui-corner-all"><br/><label for="lastname">Lastname</label><input type="text" name="lastname" id="lastname" value="" class="ui-widget-content ui-corner-all"></fieldset></form>');
$("#popup").dialog({
width: 320,
height: 180,
modal: true,
resizable: false,
buttons: {
Select: function() {
if ($.trim($("#firstname").val()) == '' ||
$.trim($("#lastname").val()) == '')
return;
var firstName = $("#firstname").val();
var lastName = $("#lastname").val();
$.ajax({
type: 'POST',
url: "giveInventoryItem.php?t=" + Math.random(),
data: {
uuid: node.id.split(/[\/]+/).pop(),
firstname: firstName,
lastname: lastName
}
}).done(function(data) {
$("#popup").dialog("close");
if ($.trim(data) != '')
alert(data);
});
},
Cancel: function() {
$("#popup").dialog("close");
}
}
}).on('dialogclose', function(event) {
$('#content').html('');
$('#popup').dialog('option', 'buttons', {});
});
}
}
});
}
 
// The "download" menu item for textures.
if (node.data.type == "texture" || node.data.type == "snapshot") {
$.extend(items, {
downloadItem: {
label: "Download",
"action": function(obj) {
$('#texture').attr('src', 'images/loader.gif');
$('#popup').dialog({
width: 800,
height: 600,
modal: true,
resizable: false,
dialogClass: 'no-close texture-dialog'
}).on('dialogclose', function(event) {
$('#content').html('');
});
$.ajax({
type: 'POST',
url: "downloadTexture.php?t=" + Math.random(),
data: {
uuid: node.id.split(/[\/]+/).pop()
}
}).done(function(data) {
$('#content').html('<img src="" align="middle" id="texture">');
$('#texture').attr('src', "data:image/png;base64," + data);
});
}
}
});
}
 
// The "download" menu item for notecards.
if (node.data.type == "notecard") {
$.extend(items, {
downloadItem: {
label: "Download",
"action": function(obj) {
$('#texture').attr('src', 'images/loader.gif');
$('#popup').dialog({
width: 800,
height: 600,
modal: true,
resizable: false,
dialogClass: 'no-close texture-dialog'
}).on('dialogclose', function(event) {
$('#content').html('');
});
$.ajax({
type: 'POST',
url: "downloadNotecard.php?t=" + Math.random(),
data: {
uuid: node.id.split(/[\/]+/).pop()
}
}).done(function(data) {
$.base64.utf8decode = true;
$('#content').html('<pre>' + $.base64.atob(data) + '</pre>');
});
}
}
});
}
 
// The "download" menu item for sounds.
if (node.data.type == "sound") {
$.extend(items, {
downloadItem: {
label: "Download",
"action": function(obj) {
$('#texture').attr('src', 'images/loader.gif');
$('#popup').dialog({
width: 800,
height: 600,
modal: true,
resizable: false,
dialogClass: 'no-close texture-dialog'
}).on('dialogclose', function(event) {
$('#content').html('');
});
$.ajax({
type: 'POST',
url: "downloadSound.php?t=" + Math.random(),
data: {
uuid: node.id.split(/[\/]+/).pop()
}
}).done(function(data) {
$('#content').html('<audio controls="controls"><source id="source" src="" type="audio/mp3"></source></audio>');
$('#source').attr('src', "data:audio/mp3;base64," + data);
});
}
}
});
}
 
return items;
}
 
$("#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': false
},
'sort': function(a, b) {
return Date.parse(this.get_node(a).data.time) <
Date.parse(this.get_node(b).data.time) ? 1 : -1;
},
'core': {
/*'check_callback': function(operation, node, parent, position, more) {
// Do not allow moves above the root node.
if (parent.id == "#")
return false;
 
var moved = false;
$.ajax({
// A synchronous reply is needed so we know what to tell the tree.
async: false,
type: 'POST',
url: "moveInventoryItem.php?t=" + Math.random(),
data: {
source: node.id,
target: parent.id
}
}).done(function(data) {
if ($.trim(data) != 'success') {
if ($.trim(data) != '')
alert(data);
return;
}
moved = true;
});
return moved;
},*/
data: function(node, callback) {
if(node.id === '#') {
callback.call(this, [
{
"id" : "/My Inventory",
"parent" : "#",
"text" : "My Inventory",
"data" : {
"type" :
"folder"
},
"children" : true,
"opened" : false
},
{
"id" : "/Library",
"parent" : "#",
"text" : "Library",
"data" : {
"type" :
"folder"
},
"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 data = wasCSVToArray(response.data);
alert(JSON.stringify(data.chunk(10), 4, null));
/*$.each($.stride(data, 10), function(i, e) {
alert(e);
data.push({
x: time + ++j * updateInterval,
y: parseInt(e)
});
});*/
});
}
}
}).bind('move_node.jstree', function(e, data) {
// 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);
});
});
</script>
</body>
</html>