diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-03-19 08:33:36 +0100 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-03-19 08:33:36 +0100 |
commit | 33b06c448443bb0085ff986c341594d80903f43b (patch) | |
tree | e80977f084f5f149471995976edb4a01eee886a9 /files/js/files.js | |
parent | 097ce76fc4383c68856ee70db0c87f0e9f5fefb4 (diff) | |
parent | de09883d860d6507a2d287d0b8bae394963c4b94 (diff) | |
download | nextcloud-server-33b06c448443bb0085ff986c341594d80903f43b.tar.gz nextcloud-server-33b06c448443bb0085ff986c341594d80903f43b.zip |
Merge branch 'master' into sabredav_1.6
Diffstat (limited to 'files/js/files.js')
-rw-r--r-- | files/js/files.js | 133 |
1 files changed, 58 insertions, 75 deletions
diff --git a/files/js/files.js b/files/js/files.js index 9f1f5368df0..539d5598899 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -3,11 +3,11 @@ $(document).ready(function() { //little hack to set unescape filenames in attribute $(this).attr('data-file',decodeURIComponent($(this).attr('data-file'))); }); - + if($('tr[data-file]').length==0){ $('.file_upload_filename').addClass('highlight'); } - + $('#file_action_panel').attr('activeAction', false); //drag/drop of files @@ -16,7 +16,7 @@ $(document).ready(function() { $('div.crumb').droppable(crumbDropOptions); $('ul#apps>li:first-child').data('dir',''); $('ul#apps>li:first-child').droppable(crumbDropOptions); - + // Triggers invisible file input $('.file_upload_button_wrapper').live('click', function() { $(this).parent().children('.file_upload_start').trigger('click'); @@ -81,9 +81,9 @@ $(document).ready(function() { } } } - + }); - + // Sets the select_all checkbox behaviour : $('#select_all').click(function() { if($(this).attr('checked')){ @@ -97,7 +97,7 @@ $(document).ready(function() { } procesSelection(); }); - + $('td.filename input:checkbox').live('click',function(event) { if (event.shiftKey) { var last = $(lastChecked).parent().parent().prevAll().length; @@ -126,37 +126,22 @@ $(document).ready(function() { } procesSelection(); }); - - $('#file_newfolder_form').submit(function(event) { - event.preventDefault(); - $.ajax({ - url: 'ajax/newfolder.php', - data: "dir="+$('#dir').val()+"&foldername="+$('#file_newfolder_name').val(), - complete: function(data){boolOperationFinished(data, function(){ - var date=new Date(); - FileList.addDir($('#file_newfolder_name').val(),0,date); - $('#file_newfolder_name').val('New Folder'); - $('#file_newfolder_name').blur(); - });} - }); - }); - + $('#file_newfolder_name').click(function(){ if($('#file_newfolder_name').val() == 'New Folder'){ $('#file_newfolder_name').val(''); } }); - + $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); - - //send the browser to the download location var dir=$('#dir').val()||'/'; -// alert(files); + $('#notification').text(t('files','generating ZIP-file, it may take some time.')); + $('#notification').fadeIn(); window.location='ajax/download.php?files='+encodeURIComponent(files)+'&dir='+encodeURIComponent(dir); return false; }); - + $('.delete').click(function(event) { var files=getSelectedFiles('name'); event.preventDefault(); @@ -242,7 +227,7 @@ $(document).ready(function() { form.hide(); } }); - + //add multiply file upload attribute to all browsers except konqueror (which crashes when it's used) if(navigator.userAgent.search(/konqueror/i)==-1){ $('.file_upload_start').attr('multiple','multiple') @@ -269,7 +254,7 @@ $(document).ready(function() { text=text.substr(0,text.length-6)+'...'; crumb.text(text); } - + $(window).click(function(){ $('#new>ul').hide(); $('#new').removeClass('active'); @@ -293,14 +278,14 @@ $(document).ready(function() { if($(this).children('p').length==0){ return; } - + $('#new li').each(function(i,element){ if($(element).children('p').length==0){ $(element).children('input').remove(); $(element).append('<p>'+$(element).data('text')+'</p>'); } }); - + var type=$(this).data('type'); var text=$(this).children('p').text(); $(this).data('text',text); @@ -312,10 +297,10 @@ $(document).ready(function() { var name=$(this).val(); switch(type){ case 'file': - $.ajax({ - url: OC.filePath('files','ajax','newfile.php'), - data: "dir="+encodeURIComponent($('#dir').val())+"&filename="+encodeURIComponent(name)+'&content=%20%0A', - complete: function(data){boolOperationFinished(data, function(){ + $.post( + OC.filePath('files','ajax','newfile.php'), + {dir:$('#dir').val(),filename:name,content:" \n"}, + function(data){ var date=new Date(); FileList.addFile(name,0,date); var tr=$('tr').filterAttr('data-file',name); @@ -323,18 +308,49 @@ $(document).ready(function() { getMimeIcon('text/plain',function(path){ tr.find('td.filename').attr('style','background-image:url('+path+')'); }); - });} - }); + } + ); break; case 'folder': - $.ajax({ - url: OC.filePath('files','ajax','newfolder.php'), - data: "dir="+encodeURIComponent($('#dir').val())+"&foldername="+encodeURIComponent(name), - complete: function(data){boolOperationFinished(data, function(){ + $.post( + OC.filePath('files','ajax','newfolder.php'), + {dir:$('#dir').val(),foldername:name}, + function(data){ var date=new Date(); FileList.addDir(name,0,date); - });} - }); + } + ); + break; + case 'web': + if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){ + name='http://'.name; + } + var localName=name; + if(localName.substr(localName.length-1,1)=='/'){//strip / + localName=localName.substr(0,localName.length-1) + } + if(localName.indexOf('/')){//use last part of url + localName=localName.split('/').pop(); + }else{//or the domain + localName=(localName.match(/:\/\/(.[^/]+)/)[1]).replace('www.',''); + } + $.post( + OC.filePath('files','ajax','newfile.php'), + {dir:$('#dir').val(),source:name,filename:localName}, + function(result){ + if(result.status == 'success'){ + var date=new Date(); + FileList.addFile(localName,0,date); + var tr=$('tr').filterAttr('data-file',localName); + tr.data('mime',result.data.mime); + getMimeIcon(result.data.mime,function(path){ + tr.find('td.filename').attr('style','background-image:url('+path+')'); + }); + }else{ + + } + } + ); break; } var li=$(this).parent(); @@ -387,39 +403,6 @@ function updateBreadcrumb(breadcrumbHtml) { $('p.nav').empty().html(breadcrumbHtml); } -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 simpleFileSize(bytes) { - mbytes = Math.round(bytes/(1024*1024/10))/10; - if(bytes == 0) { return '0'; } - else if(mbytes < 0.1) { return '< 0.1'; } - else if(mbytes > 1000) { return '> 1000'; } - else { return mbytes.toFixed(1); } -} - -function formatDate(date){ - var monthNames = [ t('files','January'), t('files','February'), t('files','March'), t('files','April'), t('files','May'), t('files','June'), - t('files','July'), t('files','August'), t('files','September'), t('files','October'), t('files','November'), t('files','December') ]; - return monthNames[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear()+', '+((date.getHours()<10)?'0':'')+date.getHours()+':'+date.getMinutes(); -} - - //options for file drag/dropp var dragOptions={ distance: 20, revert: 'invalid', opacity: 0.7, |