corrade-nucleus-nucleons

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 15  →  ?path2? @ 16
/pack-rat/003_pack_rat/pack-rat/index.html
@@ -287,16 +287,21 @@
// Do not copy items.
'copy': false,
// Do not execute the check callback whilst dragging.
'check_while_dragging': false
'check_while_dragging': true
},
'sort': function(a, b) {
return Date.parse(this.get_node(a).data.time) <
Date.parse(this.get_node(b).data.time) ? 1 : -1;
return this.get_node(a).data.time < 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 === "#")
// 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;
@@ -310,7 +315,7 @@
target = '/';
if(source == '/' && target == '/')
return;
return false;
// Check if source path is sane.
if(source.split('/').some(
@@ -317,7 +322,7 @@
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;
return false;
}
// Check if target path is sane.
@@ -325,70 +330,10 @@
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;
return false;
}
// Check that the source and target items are not system folders.
var data = {};
[ { type: 'source', value: source },
{ type: 'target', value: target }].forEach(function(e) {
$.ajax({
//async: false,
type: 'POST',
url: '/',
dataType: 'json',
async: false,
data: {
command: 'getinventorydata',
item: e.value,
data: wasArrayToCSV([
'InventoryType',
'PreferredType'
])
}
}).done(function(response) {
if(response.success !== 'True') {
return;
}
data[e.type] = wasKeyValueObjectify(
wasCSVToArray(
response.data
)
);
});
});
// Do not move the item if:
// ... the retrieved data is empty.
if($.isEmptyObject(data) ||
// ... we are trying to move a system folder.
('PreferredType' in data['source'] && data['source'].PreferredType !== 'Unknown') ||
// ... we are trying to move an inventory item over an inventory item.
('InventoryType' in data['source'] && 'InventoryType' in data['target']))
return false;
// Move the inventory item.
var moved = false;
$.ajax({
//async: false,
type: 'POST',
url: '/',
dataType: 'json',
async: false,
data: {
command: 'inventory',
action: 'mv',
source: source,
target: target
}
}).done(function(response) {
if(response.success !== 'True') {
return;
}
moved = true;
});
return moved;
return true;
},
data: function(node, callback) {
if(node.id === '#') {
@@ -398,8 +343,9 @@
"parent" : "#",
"text" : "My Inventory",
"data" : {
"type" :
"folder"
"type" : "folder",
'time' : Date.now(),
'system' : true
},
"children" : true,
"opened" : false
@@ -409,8 +355,9 @@
"parent" : "#",
"text" : "Library",
"data" : {
"type" :
"folder"
"type" : "folder",
'time' : Date.now(),
'system' : true
},
"children" : true,
"opened" : false
@@ -431,19 +378,40 @@
}).done(function(response) {
var list = [];
$.each(wasCSVToArray(response.data)
.chunk(10), function(i, e) {
e = wasKeyValueObjectify(e);
list.push({
'id' : node.id === '/' ? '/' + e['item'] : node.id + '/' + e['item'],
'parent' : node.id,
'data' : {
'type' : e['type'],
'time' : e['time']
},
'text' : e['name'],
'children' : e['type'] === 'folder',
'icon' : '/pack-rat/img/icons/' + e['type'] + '.png',
'opened' : 'false'
.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);
@@ -451,6 +419,22 @@
}
}
}).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();