|
|
|
@ -1,132 +1,66 @@ |
|
|
|
|
$(document).ready(function() { |
|
|
|
|
$('#file_action_panel').attr('activeAction', false); |
|
|
|
|
$('#file_upload_start').attr('mode', 'menu'); |
|
|
|
|
$('#file_upload_form').attr('uploading', false); |
|
|
|
|
$('#file_newfolder_name').css('width', '14em'); |
|
|
|
|
$('#file_newfolder_submit').css('width', '3em'); |
|
|
|
|
|
|
|
|
|
// 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() { |
|
|
|
|
// Sets browser table behaviour :
|
|
|
|
|
$('.browser tr').hover( |
|
|
|
|
function() { |
|
|
|
|
$(this).addClass('mouseOver'); |
|
|
|
|
}, |
|
|
|
|
function() { |
|
|
|
|
$(this).removeClass('mouseOver'); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if($(this).attr('checked')) |
|
|
|
|
// Check all
|
|
|
|
|
$('td.selection input:checkbox').attr('checked', true); |
|
|
|
|
else |
|
|
|
|
// Uncheck all
|
|
|
|
|
$('td.selection input:checkbox').attr('checked', false); |
|
|
|
|
}); |
|
|
|
|
// Sets the file-action buttons behaviour :
|
|
|
|
|
$('td.fileaction a').live('click',function(event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
FileActions.display($(this).parent()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('td.selection input:checkbox').click(function() { |
|
|
|
|
if(!$(this).attr('checked')){ |
|
|
|
|
$('#select_all').attr('checked',false); |
|
|
|
|
}else{ |
|
|
|
|
if($('td.selection input:checkbox:checked').length==$('td.selection input:checkbox').length){ |
|
|
|
|
$('#select_all').attr('checked',true); |
|
|
|
|
} |
|
|
|
|
// Sets the file link behaviour :
|
|
|
|
|
$('td.filename a').live('click',function(event) { |
|
|
|
|
event.preventDefault(); |
|
|
|
|
var filename=$(this).text(); |
|
|
|
|
var mime=$(this).parent().parent().attr('data-mime'); |
|
|
|
|
var type=$(this).parent().parent().attr('data-type'); |
|
|
|
|
var action=FileActions.getDefault(mime,type); |
|
|
|
|
if(action){ |
|
|
|
|
action(filename); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Download current file
|
|
|
|
|
$('#download_single_file').click(function() { |
|
|
|
|
filename = $('#file_menu').parents('tr:first').find('.filename:first').children('a:first').text(); |
|
|
|
|
window.location='ajax/download.php?files='+filename+'&dir='+$('#dir').val(); |
|
|
|
|
$('#file_menu').slideToggle(250); |
|
|
|
|
return false; |
|
|
|
|
// Sets the select_all checkbox behaviour :
|
|
|
|
|
$('#select_all').click(function() { |
|
|
|
|
if($(this).attr('checked')) |
|
|
|
|
// Check all
|
|
|
|
|
$('td.selection input:checkbox').attr('checked', true); |
|
|
|
|
else |
|
|
|
|
// Uncheck all
|
|
|
|
|
$('td.selection input:checkbox').attr('checked', false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Delete current file
|
|
|
|
|
$('#delete_single_file').click(function() { |
|
|
|
|
filename = $('#file_menu').parents('tr:first').find('.filename:first').children('a:first').text(); |
|
|
|
|
$.ajax({ |
|
|
|
|
url: 'ajax/delete.php', |
|
|
|
|
data: "dir="+$('#dir').val()+"&file="+filename, |
|
|
|
|
complete: function(data){ |
|
|
|
|
boolOperationFinished(data, true, $('#file_menu').parents('tr:first')); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#file_upload_start').click(function() { |
|
|
|
|
if($('#file_upload_start').attr('mode') == 'menu') { |
|
|
|
|
$('#file_upload_form')[0].reset(); |
|
|
|
|
$('#fileSelector').change(function() { |
|
|
|
|
//Chromium prepends C:\fakepath....
|
|
|
|
|
bspos = $('#fileSelector').val().lastIndexOf('\\')+1; |
|
|
|
|
filename = $('#fileSelector').val().substr(bspos); |
|
|
|
|
|
|
|
|
|
$('#file_upload_start').val('Upload ' + filename); |
|
|
|
|
$('#fileSelector').hide(); |
|
|
|
|
$('#file_upload_cancel').slideDown(250); |
|
|
|
|
$('#file_upload_start').attr('mode', 'action'); |
|
|
|
|
}); |
|
|
|
|
$('#file_upload_start').focusin(function() { |
|
|
|
|
if($('#fileSelector').val() == '') { |
|
|
|
|
$('#fileSelector').hide(); |
|
|
|
|
$('#file_upload_start').unbind('focusin'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$('#fileSelector').focusout(function() { |
|
|
|
|
if($('#fileSelector').val() == '') { |
|
|
|
|
$('#fileSelector').hide(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$('#fileSelector').show(); //needed for Chromium compatibility
|
|
|
|
|
//rekonq does not call change-event, when click() is executed by script
|
|
|
|
|
if(navigator.userAgent.indexOf('rekonq') == -1){
|
|
|
|
|
$('#fileSelector').click(); |
|
|
|
|
$('td.selection input:checkbox').live('click',function() { |
|
|
|
|
if(!$(this).attr('checked')){ |
|
|
|
|
$('#select_all').attr('checked',false); |
|
|
|
|
}else{ |
|
|
|
|
if($('td.selection input:checkbox:checked').length==$('td.selection input:checkbox').length){ |
|
|
|
|
$('#select_all').attr('checked',true); |
|
|
|
|
} |
|
|
|
|
$('#fileSelector').focus(); |
|
|
|
|
} else if($('#file_upload_start').attr('mode') == 'action') { |
|
|
|
|
$('#file_upload_cancel').slideUp(250); |
|
|
|
|
$('#file_upload_form').attr('uploading', true); |
|
|
|
|
$('#file_upload_target').load(uploadFinished); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#file_upload_cancel').click(function() { |
|
|
|
|
$('#file_upload_form')[0].reset(); |
|
|
|
|
$('#file_upload_start').val('Upload ' + $('.max_human_file_size:first').val()); |
|
|
|
|
$('#file_upload_start').attr('mode', 'menu'); |
|
|
|
|
$('#file_upload_cancel').hide(); |
|
|
|
|
// $('#file_action_panel').attr('activeAction', 'false');
|
|
|
|
|
// $('#file_upload_form').hide();
|
|
|
|
|
// $('p.actions a.upload:first').show();
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#file_new_dir_submit').click(function() { |
|
|
|
|
$('#file_newfolder_submit').click(function() { |
|
|
|
|
$.ajax({ |
|
|
|
|
url: 'ajax/newfolder.php', |
|
|
|
|
data: "dir="+$('#dir').val()+"&foldername="+$('#file_new_dir_name').val(), |
|
|
|
|
complete: function(data){boolOperationFinished(data, false);} |
|
|
|
|
data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(), |
|
|
|
|
complete: function(data){boolOperationFinished(data, function(){ |
|
|
|
|
var date=formatDate(new Date()); |
|
|
|
|
FileList.addDir($('#file_newfolder_name').val(),'0 B',date) |
|
|
|
|
});} |
|
|
|
|
}); |
|
|
|
|
$('#file_newfolder_submit').fadeOut(250).trigger('vanish'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#file_newfolder_name').click(function(){ |
|
|
|
@ -149,60 +83,10 @@ $(document).ready(function() { |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#file_newfolder_submit').click(function() { |
|
|
|
|
if($('#file_newfolder_name').val() != '') { |
|
|
|
|
$.ajax({ |
|
|
|
|
url: 'ajax/newfolder.php', |
|
|
|
|
data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(), |
|
|
|
|
complete: function(data){ |
|
|
|
|
boolOperationFinished(data, false); |
|
|
|
|
$('#file_newfolder_form')[0].reset(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
$('#file_newfolder_submit').fadeOut(250).trigger('vanish'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// $('.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">');
|
|
|
|
|
// $('#fileSelector').change(function() {
|
|
|
|
|
// $('#file_upload_start').val('Upload ' + $('#fileSelector').val());
|
|
|
|
|
// $('p.actions a.upload:first').after($('#file_upload_form'));
|
|
|
|
|
// $('#file_upload_form').css('display', 'inline');
|
|
|
|
|
// $('p.actions a.upload:first').hide();
|
|
|
|
|
// $('#fileSelector').hide();
|
|
|
|
|
// });
|
|
|
|
|
// $('#file_action_panel form').slideUp(250);
|
|
|
|
|
// // $('#file_upload_form').slideDown(250);
|
|
|
|
|
// $('#fileSelector').click();
|
|
|
|
|
// } else {
|
|
|
|
|
// $('#file_action_panel').attr('activeAction', 'false');
|
|
|
|
|
// $('#file_upload_form').slideUp(250);
|
|
|
|
|
// }
|
|
|
|
|
// 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').slideUp(250);
|
|
|
|
|
// $('#file_newfolder_form').slideDown(250);
|
|
|
|
|
// } else {
|
|
|
|
|
// $('#file_newfolder_form').slideUp(250);
|
|
|
|
|
// $('#file_action_panel').attr('activeAction', false);
|
|
|
|
|
// }
|
|
|
|
|
// return false;
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
$('.download').click(function(event) { |
|
|
|
|
$('.download').live('click',function(event) { |
|
|
|
|
var files=''; |
|
|
|
|
$('td.selection input:checkbox:checked').parent().parent().children('.filename').each(function(i,element){ |
|
|
|
|
files+=';'+$(element).text(); |
|
|
|
|
$('td.selection input:checkbox:checked').parent().parent().each(function(i,element){ |
|
|
|
|
files+=';'+$(element).attr('data-file'); |
|
|
|
|
}); |
|
|
|
|
files=files.substr(1);//remove leading ;
|
|
|
|
|
|
|
|
|
@ -213,10 +97,10 @@ $(document).ready(function() { |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('.delete').click(function(event) { |
|
|
|
|
$('.delete').live('click',function(event) { |
|
|
|
|
var files=''; |
|
|
|
|
$('td.selection input:checkbox:checked').parent().parent().children('.filename').each(function(i,element){ |
|
|
|
|
files+=';'+$(element).text(); |
|
|
|
|
$('td.selection input:checkbox:checked').parent().parent().each(function(i,element){ |
|
|
|
|
files+=';'+$(element).attr('data-file'); |
|
|
|
|
}); |
|
|
|
|
files=files.substr(1);//remove leading ;
|
|
|
|
|
|
|
|
|
@ -224,12 +108,47 @@ $(document).ready(function() { |
|
|
|
|
url: 'ajax/delete.php', |
|
|
|
|
data: "dir="+$('#dir').val()+"&files="+files, |
|
|
|
|
complete: function(data){ |
|
|
|
|
boolOperationFinished(data, false); |
|
|
|
|
boolOperationFinished(data, function(){ |
|
|
|
|
$('td.selection input:checkbox:checked').parent().parent().each(function(i,element){ |
|
|
|
|
FileList.remove($(element).attr('data-file')); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('#file_upload_start').change(function(){ |
|
|
|
|
var filename=$(this).val(); |
|
|
|
|
filename=filename.replace(/^.*[\/\\]/g, ''); |
|
|
|
|
$('#file_upload_filename').val(filename); |
|
|
|
|
$('#file_upload_submit').show(); |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
$('#file_upload_submit').click(function(){ |
|
|
|
|
var name=$('#file_upload_filename').val(); |
|
|
|
|
if($('#file_upload_start')[0].files[0] && $('#file_upload_start')[0].files[0].size>0){ |
|
|
|
|
var size=humanFileSize($('#file_upload_start')[0].files[0].size); |
|
|
|
|
}else{ |
|
|
|
|
var size='Pending'; |
|
|
|
|
} |
|
|
|
|
$('#file_upload_target').load(function(){ |
|
|
|
|
var response=jQuery.parseJSON($('#file_upload_target').contents().find('body').text()); |
|
|
|
|
//set mimetype and if needed filesize
|
|
|
|
|
$('tr[data-file="'+name+'"]').attr('data-mime',response.mime); |
|
|
|
|
if(size=='Pending'){ |
|
|
|
|
$('tr[data-file='+name+'] td.filesize').text(response.size); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
$('#file_upload_form').submit(); |
|
|
|
|
var date=new Date(); |
|
|
|
|
var uploadTime=formatDate(date); |
|
|
|
|
FileList.addFile(name,size,uploadTime); |
|
|
|
|
$('#file_upload_filename').val($('#file_upload_filename').data('upload_text')); |
|
|
|
|
}); |
|
|
|
|
//save the original upload button text
|
|
|
|
|
$('#file_upload_filename').data('upload_text',$('#file_upload_filename').val()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
var adjustNewFolderSize = function() { |
|
|
|
@ -251,74 +170,44 @@ function unsplitSize(stayingEl, vanishingEl) { |
|
|
|
|
$(vanishingEl).fadeOut(250); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function uploadFinished() { |
|
|
|
|
result = $('#file_upload_target').contents().text(); |
|
|
|
|
result = eval("(" + result + ");"); |
|
|
|
|
$('#file_upload_target').load(function(){}); |
|
|
|
|
if(result.status == "error") { |
|
|
|
|
if($('#file_upload_form').attr('uploading') == true) { |
|
|
|
|
alert('An error occcured, upload failed.\nError code: ' + result.data.error + '\nFilename: ' + result.data.file); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
dir = $('#dir').val(); |
|
|
|
|
$.ajax({ |
|
|
|
|
url: 'ajax/list.php', |
|
|
|
|
data: "dir="+dir, |
|
|
|
|
complete: function(data) { |
|
|
|
|
refreshContents(data); |
|
|
|
|
// $('#file_action_panel').prepend($('#file_upload_form'));
|
|
|
|
|
// $('#file_upload_form').css('display', 'block').hide();
|
|
|
|
|
// $('p.actions a.upload:first').show();
|
|
|
|
|
$('#file_upload_start').val('Upload ' + $('.max_human_file_size:first').val()); |
|
|
|
|
$('#file_upload_start').attr('mode', 'menu'); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
$('#file_upload_form').attr('uploading', false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function resetFileActionPanel() { |
|
|
|
|
$('#file_action_panel form').css({"display":"none"}); |
|
|
|
|
$('#file_action_panel').attr('activeAction', false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function boolOperationFinished(data, single, el) { |
|
|
|
|
result = eval("("+data.responseText+");"); |
|
|
|
|
function boolOperationFinished(data, callback) { |
|
|
|
|
result = jQuery.parseJSON(data.responseText); |
|
|
|
|
if(result.status == 'success'){ |
|
|
|
|
if(single) { |
|
|
|
|
$('#file_menu').slideToggle(0); |
|
|
|
|
$('body').append($('#file_menu')); |
|
|
|
|
$(el).remove(); |
|
|
|
|
} else { |
|
|
|
|
$.ajax({ |
|
|
|
|
url: 'ajax/list.php', |
|
|
|
|
data: "dir="+$('#dir').val(), |
|
|
|
|
complete: refreshContents |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
callback.call(); |
|
|
|
|
} else { |
|
|
|
|
alert(result.data.message); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function refreshContents(data) { |
|
|
|
|
result = eval("("+data.responseText+");"); |
|
|
|
|
if(typeof(result.data.breadcrumb) != 'undefined'){ |
|
|
|
|
updateBreadcrumb(result.data.breadcrumb); |
|
|
|
|
} |
|
|
|
|
updateFileList(result.data.files); |
|
|
|
|
$('td.fileaction a').click(function() { |
|
|
|
|
$(this).parent().append($('#file_menu')); |
|
|
|
|
$('#file_menu').slideToggle(250); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
resetFileActionPanel(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateBreadcrumb(breadcrumbHtml) { |
|
|
|
|
$('p.nav').empty().html(breadcrumbHtml); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateFileList(fileListHtml) { |
|
|
|
|
$('#fileList').empty().html(fileListHtml); |
|
|
|
|
function humanFileSize(bytes){ |
|
|
|
|
if( bytes < 1024 ){ |
|
|
|
|
return bytes+' B'; |
|
|
|
|
} |
|
|
|
|
bytes = Math.round(bytes / 1024, 1 ); |
|
|
|
|
if( bytes < 1024 ){ |
|
|
|
|
return bytes+' kB'; |
|
|
|
|
} |
|
|
|
|
bytes = Math.round( bytes / 1024, 1 ); |
|
|
|
|
if( bytes < 1024 ){ |
|
|
|
|
return bytes+' MB'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Wow, heavy duty for owncloud
|
|
|
|
|
bytes = Math.round( bytes / 1024, 1 ); |
|
|
|
|
return bytes+' GB'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function formatDate(date){ |
|
|
|
|
var monthNames = [ "January", "February", "March", "April", "May", "June", |
|
|
|
|
"July", "August", "September", "October", "November", "December" ]; |
|
|
|
|
return monthNames[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear()+', '+((date.getHours()<10)?'0':'')+date.getHours()+':'+date.getMinutes(); |
|
|
|
|
} |