less magic in oxd, files returns files with path,stats,oshash and info a dict with oshash keys and related info
This commit is contained in:
parent
05a922defb
commit
edc69304e0
3 changed files with 67 additions and 81 deletions
|
|
@ -17,7 +17,7 @@ pandora.request = function(fn, data, callback) {
|
|||
success: function(response) {
|
||||
if (typeof callback != "undefined")
|
||||
callback(response);
|
||||
console.log(response);
|
||||
//console.log(response);
|
||||
},
|
||||
error: function (xhr, ajaxOptions, thrownError){
|
||||
var response = {};
|
||||
|
|
@ -112,42 +112,32 @@ function update() {
|
|||
var volumes = JSON.parse(result);
|
||||
for(volume in volumes) {
|
||||
ox.files(volume, function(result) {
|
||||
var _files = [];
|
||||
var _info = {};
|
||||
var data = JSON.parse(result);
|
||||
$.each(data, function(folder, files) {
|
||||
$.each(files, function(f, info) {
|
||||
var f = {
|
||||
oshash: info.oshash,
|
||||
name: f,
|
||||
folder: folder,
|
||||
ctime: info.ctime, atime: info.atime, mtime: info.mtime
|
||||
};
|
||||
_files.push(f);
|
||||
_info[info.oshash] = info;
|
||||
});
|
||||
});
|
||||
pandora.request('update', {
|
||||
'volume': volume, 'files': _files
|
||||
'volume': volume, 'files': data.files
|
||||
}, function(result) {
|
||||
var data = {'info': {}};
|
||||
if (result.data.info.length>0) {
|
||||
$.each(_info, function(oshash, info) {
|
||||
if($.inArray(oshash, result.data.info) >= 0) {
|
||||
data.info[oshash] = info;
|
||||
}
|
||||
var post = {'info': {}};
|
||||
function highlight_resulsts(result) {
|
||||
$.each(result.data.data, function(i, oshash) {
|
||||
$('#' + oshash).css('background', 'red');
|
||||
$('#' + oshash).parent().css('background', 'orange');
|
||||
});
|
||||
pandora.request('update', data, function(result) {
|
||||
console.log(result);
|
||||
$.each(result.data.file, function(i, oshash) {
|
||||
$('#' + oshash).css('background', 'blue');
|
||||
});
|
||||
}
|
||||
$.each(result.data.data, function(i, oshash) {
|
||||
$('#' + oshash).css('background', 'red');
|
||||
$('#' + oshash).parent().css('background', 'orange');
|
||||
});
|
||||
$.each(result.data.file, function(i, oshash) {
|
||||
$('#' + oshash).css('background', 'blue');
|
||||
});
|
||||
if (result.data.info.length>0) {
|
||||
$.each(data.info, function(oshash, info) {
|
||||
if($.inArray(oshash, result.data.info) >= 0) {
|
||||
post.info[oshash] = info;
|
||||
}
|
||||
});
|
||||
pandora.request('update', post, function(result) {
|
||||
highlight_resulsts(result);
|
||||
});
|
||||
} else {
|
||||
highlight_resulsts(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -168,8 +158,17 @@ function update() {
|
|||
ox.files(volume, function(result) {
|
||||
var data = JSON.parse(result);
|
||||
var _files = [];
|
||||
$.each(data, function(folder, files) {
|
||||
if(!folder) folder = "rootfolder";
|
||||
$.each(data.files, function(i, file) {
|
||||
var folder = file.path.split('/');
|
||||
folder.pop();
|
||||
if(folder.length==0) {
|
||||
folder.push("rootfolder");
|
||||
}
|
||||
//FIXME: this is also done on the backend but might require more sub options
|
||||
if (folder[folder.length-1] == "Extras" || folder[folder.length-1] == "Versions")
|
||||
folder.pop();
|
||||
folder = folder.join('/');
|
||||
|
||||
var folderId = 'folder_'+safe_id(folder);
|
||||
var $folder = $('#'+folderId);
|
||||
if($folder.length==0) {
|
||||
|
|
@ -177,14 +176,12 @@ function update() {
|
|||
$folder.find('h3').click(function() { $(this).parent().find('div').toggle();});
|
||||
$volume.append($folder);
|
||||
}
|
||||
for_each_sorted(files, function(f, info) {
|
||||
var fileId = info.oshash;
|
||||
var $file = $('#'+fileId);
|
||||
if($file.length==0) {
|
||||
$file = $('<div>').attr('id', fileId).html(f).hide();
|
||||
$folder.append($file);
|
||||
}
|
||||
});
|
||||
var fileId = file.oshash;
|
||||
var $file = $('#'+fileId);
|
||||
if($file.length==0) {
|
||||
$file = $('<div>').attr('id', fileId).html(file.path).hide();
|
||||
$folder.append($file);
|
||||
}
|
||||
});
|
||||
});
|
||||
}(volume));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue