2011-03-03 01:06:23 +03:00
|
|
|
$(document).ready(function() {
|
2011-04-17 19:49:56 +04:00
|
|
|
$('#file_action_panel').attr('activeAction', false);
|
|
|
|
|
2011-03-03 01:06:23 +03:00
|
|
|
// Sets browser table behaviour :
|
|
|
|
$('.browser tr').hover(
|
|
|
|
function() {
|
|
|
|
$(this).addClass('mouseOver');
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
$(this).removeClass('mouseOver');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sets logs table behaviour :
|
|
|
|
$('.logs tr').hover(
|
|
|
|
function() {
|
|
|
|
$(this).addClass('mouseOver');
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
$(this).removeClass('mouseOver');
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Sets the file-action buttons behaviour :
|
|
|
|
$('td.fileaction a').click(function() {
|
|
|
|
$(this).parent().append($('#file_menu'));
|
|
|
|
$('#file_menu').slideToggle(250);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Sets the select_all checkbox behaviour :
|
|
|
|
$('#select_all').click(function() {
|
|
|
|
|
|
|
|
if($(this).attr('checked'))
|
|
|
|
// Check all
|
|
|
|
$('.browser input:checkbox').attr('checked', true);
|
|
|
|
else
|
|
|
|
// Uncheck all
|
|
|
|
$('.browser input:checkbox').attr('checked', false);
|
|
|
|
});
|
2011-04-17 00:56:40 +04:00
|
|
|
|
|
|
|
$('#file_upload_start').click(function() {
|
|
|
|
$('#file_upload_target').load(uploadFinished);
|
|
|
|
});
|
2011-04-17 19:49:56 +04:00
|
|
|
|
|
|
|
$('#file_new_dir_submit').click(function() {
|
|
|
|
$.ajax({
|
|
|
|
url: 'ajax/newfolder.php',
|
|
|
|
data: "dir="+$('#dir').val()+"&foldername="+$('#file_new_dir_name').val(),
|
|
|
|
complete: boolOpFinished
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.upload').click(function(){
|
|
|
|
if($('#file_action_panel').attr('activeAction') != 'upload') {
|
|
|
|
$('#file_action_panel').attr('activeAction', 'upload');
|
|
|
|
$('#fileSelector').replaceWith('<input type="file" name="file" id="fileSelector">');
|
|
|
|
$('#file_action_panel form').css({"display":"none"});
|
|
|
|
$('#file_upload_form').css({"display":"block"});
|
|
|
|
} else {
|
|
|
|
$('#file_action_panel').attr('activeAction', 'false');
|
|
|
|
$('#file_upload_form').css({"display":"none"})
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.new-dir').click(function(){
|
|
|
|
if($('#file_action_panel').attr('activeAction') != 'new-dir') {
|
|
|
|
$('#file_action_panel').attr('activeAction', 'new-dir');
|
|
|
|
$('#file_new_dir_name').val('');
|
|
|
|
$('#file_action_panel form').css({"display":"none"});
|
|
|
|
$('#file_newfolder_form').css({"display":"block"})
|
|
|
|
} else {
|
|
|
|
$('#file_newfolder_form').css({"display":"none"})
|
|
|
|
$('#file_action_panel').attr('activeAction', false);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2011-03-03 01:06:23 +03:00
|
|
|
});
|
2011-04-17 00:56:40 +04:00
|
|
|
|
|
|
|
function uploadFinished() {
|
|
|
|
result = $('#file_upload_target').contents().text();
|
|
|
|
result = eval("(" + result + ");");
|
|
|
|
if(result.status == "error") {
|
2011-04-17 01:28:50 +04:00
|
|
|
alert('An error occcured, upload failed.\nError code: ' + result.data.error);
|
2011-04-17 00:56:40 +04:00
|
|
|
} else {
|
2011-04-17 17:59:06 +04:00
|
|
|
dir = $('#dir').val();
|
|
|
|
$.ajax({
|
|
|
|
url: 'ajax/list.php',
|
|
|
|
data: "dir="+dir,
|
|
|
|
complete: refreshContents
|
|
|
|
});
|
2011-04-17 00:56:40 +04:00
|
|
|
}
|
|
|
|
}
|
2011-04-17 17:59:06 +04:00
|
|
|
|
2011-04-17 19:49:56 +04:00
|
|
|
function resetFileActionPanel() {
|
|
|
|
$('#file_action_panel form').css({"display":"none"});
|
|
|
|
$('#file_action_panel').attr('activeAction', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function boolOpFinished(data) {
|
|
|
|
result = eval("("+data.responseText+");");
|
|
|
|
if(result.status == 'success'){
|
|
|
|
$.ajax({
|
|
|
|
url: 'ajax/list.php',
|
|
|
|
data: "dir="+$('#dir').val(),
|
|
|
|
complete: refreshContents
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
alert(result.data.message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-17 17:59:06 +04:00
|
|
|
function refreshContents(data) {
|
|
|
|
result = eval("("+data.responseText+");");
|
|
|
|
if(typeof(result.data.breadcrumb) != 'undefined'){
|
|
|
|
updateBreadcrumb(result.data.breadcrumb);
|
|
|
|
}
|
|
|
|
updateFileList(result.data.files);
|
|
|
|
$('#file_upload_button').click();
|
2011-04-17 19:49:56 +04:00
|
|
|
resetFileActionPanel();
|
2011-04-17 17:59:06 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateBreadcrumb(breadcrumbHtml) {
|
|
|
|
$('p.nav').empty().html(breadcrumbHtml);
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateFileList(fileListHtml) {
|
|
|
|
$('#fileList').empty().html(fileListHtml);
|
|
|
|
}
|