Welcome Guest, Not a member yet? Register   Sign In
Directory Tree file actions
#1

[eluser]Unknown[/eluser]
I have been experimenting with the directory helper today and built a browser application. Now the only problem is I cant figure out how to do anything with the files. Can someone tell me how to either turn files into clickable objects so I can save them to the local computer or how to add the ability to save, open and delete from the javascript code?


[removed]
$(document).ready(function(){
var files = <?php echo json_encode($files); ?>;
var file_tree = build_file_tree(files);


file_tree.appendTo('#files');
function build_file_tree(files){
var tree = $('<ul>');

for (x in files){
if(typeof files[x] == "object"){
// Folders
var span = $('<span>').html(x).appendTo(
$('<li>').appendTo(tree).addClass('folder')
);
var subtree = build_file_tree(files[x]).hide();
span.after(subtree);
span.click(function(){
$(this).parent().find('ul:first').toggle();
});
}else{
// Files

$('<li>').html(files[x]).appendTo(tree).addClass('file').click(function(){
[removed]=$(this).find("a").attr("href");
return false;
});




}
}

return tree;
}
});
[removed]




Theme © iAndrew 2016 - Forum software by © MyBB