diff options
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r-- | apps/files/js/files.js | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 2f06f15f896..daa250c9bd4 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -506,23 +506,27 @@ $(document).ready(function() { localName=(localName.match(/:\/\/(.[^/]+)/)[1]).replace('www.',''); } localName = getUniqueName(localName); - $.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{ - OC.dialogs.alert(result.data.message, 'Error'); - } - } - ); + $('#uploadprogressbar').progressbar({value:0}); + $('#uploadprogressbar').fadeIn(); + + var eventSource=new OC.EventSource(OC.filePath('files','ajax','newfile.php'),{dir:$('#dir').val(),source:name,filename:localName}); + eventSource.listen('progress',function(progress){ + $('#uploadprogressbar').progressbar('value',progress); + }); + eventSource.listen('success',function(mime){ + $('#uploadprogressbar').fadeOut(); + var date=new Date(); + FileList.addFile(localName,0,date); + var tr=$('tr').filterAttr('data-file',localName); + tr.data('mime',mime); + getMimeIcon(mime,function(path){ + tr.find('td.filename').attr('style','background-image:url('+path+')'); + }); + }); + eventSource.listen('error',function(error){ + $('#uploadprogressbar').fadeOut(); + alert(error); + }); break; } var li=$(this).parent(); |