From 7da3492ab5afc2b3df95ddbc30be13edf6db6c32 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 16 Sep 2012 17:05:08 +0200 Subject: show the size of new files when using New->From Url --- apps/files/js/files.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 101e2bad2e4..30c9b848434 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -556,10 +556,12 @@ $(document).ready(function() { eventSource.listen('progress',function(progress){ $('#uploadprogressbar').progressbar('value',progress); }); - eventSource.listen('success',function(mime){ + eventSource.listen('success',function(data){ + var mime=data.mime; + var size=data.size; $('#uploadprogressbar').fadeOut(); var date=new Date(); - FileList.addFile(localName,0,date,false,hidden); + FileList.addFile(localName,size,date,false,hidden); var tr=$('tr').filterAttr('data-file',localName); tr.data('mime',mime); getMimeIcon(mime,function(path){ -- cgit v1.2.3 From 7a7d2a06b3884839d570cb426f91563edc5b8177 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 17 Sep 2012 10:54:06 +0300 Subject: Adding a few more string to translation --- apps/files/js/files.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 30c9b848434..55b48ff075b 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -253,10 +253,10 @@ $(document).ready(function() { var img = OC.imagePath('core', 'loading.gif'); var tr=$('tr').filterAttr('data-file',dirName); tr.find('td.filename').attr('style','background-image:url('+img+')'); - uploadtext.text('1 file uploading'); + uploadtext.text(t('files', '1 file uploading')); uploadtext.show(); } else { - uploadtext.text(currentUploads + ' files uploading') + uploadtext.text(currentUploads + t('files', ' files uploading')); } } } @@ -301,7 +301,7 @@ $(document).ready(function() { uploadtext.text(''); uploadtext.hide(); } else { - uploadtext.text(currentUploads + ' files uploading') + uploadtext.text(currentUploads + t('files', ' files uploading')); } }) .error(function(jqXHR, textStatus, errorThrown) { @@ -316,7 +316,7 @@ $(document).ready(function() { uploadtext.text(''); uploadtext.hide(); } else { - uploadtext.text(currentUploads + ' files uploading') + uploadtext.text(currentUploads + t('files', ' files uploading')); } $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); @@ -663,7 +663,7 @@ function scanFiles(force,dir){ var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force,dir:dir}); scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource); scannerEventSource.listen('scanning',function(data){ - $('#scan-count').text(data.count+' files scanned'); + $('#scan-count').text(data.count+t('files',' files scanned')); $('#scan-current').text(data.file+'/'); }); scannerEventSource.listen('success',function(success){ @@ -671,7 +671,7 @@ function scanFiles(force,dir){ if(success){ window.location.reload(); }else{ - alert('error while scanning'); + alert(t('files', 'error while scanning')); } }); } -- cgit v1.2.3 From 21bffbfb6964d46e36240d2001dd8bb4533b6d3d Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 17 Sep 2012 11:14:44 +0300 Subject: Enhanced space handling - thx fmms --- apps/files/js/files.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 55b48ff075b..aefd6f20bec 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -256,7 +256,7 @@ $(document).ready(function() { uploadtext.text(t('files', '1 file uploading')); uploadtext.show(); } else { - uploadtext.text(currentUploads + t('files', ' files uploading')); + uploadtext.text(currentUploads + ' ' + t('files', 'files uploading')); } } } @@ -301,7 +301,7 @@ $(document).ready(function() { uploadtext.text(''); uploadtext.hide(); } else { - uploadtext.text(currentUploads + t('files', ' files uploading')); + uploadtext.text(currentUploads + ' ' + t('files', 'files uploading')); } }) .error(function(jqXHR, textStatus, errorThrown) { @@ -316,7 +316,7 @@ $(document).ready(function() { uploadtext.text(''); uploadtext.hide(); } else { - uploadtext.text(currentUploads + t('files', ' files uploading')); + uploadtext.text(currentUploads + ' ' + t('files', 'files uploading')); } $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); @@ -663,7 +663,7 @@ function scanFiles(force,dir){ var scannerEventSource=new OC.EventSource(OC.filePath('files','ajax','scan.php'),{force:force,dir:dir}); scanFiles.cancel=scannerEventSource.close.bind(scannerEventSource); scannerEventSource.listen('scanning',function(data){ - $('#scan-count').text(data.count+t('files',' files scanned')); + $('#scan-count').text(data.count + ' ' + t('files', 'files scanned')); $('#scan-current').text(data.file+'/'); }); scannerEventSource.listen('success',function(success){ -- cgit v1.2.3 From 597fed4fde9d1e3e39b8ca492dbfd324b17ffd58 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 17 Sep 2012 15:28:13 +0000 Subject: Fix oc-1726, cannot delete multiple files one by one without refresh --- apps/files/js/filelist.js | 1 - 1 file changed, 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 7ebfd4b68bb..f2b558496e0 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -260,7 +260,6 @@ var FileList={ FileList.prepareDeletion(files); } FileList.lastAction(); - return; } FileList.prepareDeletion(files); // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder -- cgit v1.2.3 From 8a74a39c4240f41799b333f65db66587ef5ad8b7 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Tue, 18 Sep 2012 22:08:34 +0000 Subject: Fix oc-1769, renaming folders with extensions --- apps/files/js/filelist.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index f2b558496e0..6d4d5399639 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -157,7 +157,7 @@ var FileList={ tr.attr('data-file', newname); var path = td.children('a.name').attr('href'); td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname))); - if (newname.indexOf('.') > 0) { + if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { var basename=newname.substr(0,newname.lastIndexOf('.')); } else { var basename=newname; @@ -166,7 +166,7 @@ var FileList={ var span=$(''); span.text(basename); td.children('a.name').append(span); - if (newname.indexOf('.') > 0) { + if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { span.append($(''+newname.substr(newname.lastIndexOf('.'))+'')); } tr.data('renaming',false); -- cgit v1.2.3 From 1e880feab1300eb54e9ce82438733ef3c5548a8c Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Wed, 19 Sep 2012 11:56:31 +0200 Subject: execute lastAction() before add new one --- apps/files/js/filelist.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index f2b558496e0..f2e04256231 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -255,20 +255,23 @@ var FileList={ }, do_delete:function(files){ // Finish any existing actions - if (FileList.lastAction || !FileList.useUndo) { - if(!FileList.deleteFiles) { - FileList.prepareDeletion(files); - } + if (FileList.lastAction) { FileList.lastAction(); } + FileList.prepareDeletion(files); - // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder - if ($('#dir').val() == '/Shared') { - $('#notification').html(t('files', 'unshared')+' '+files+''+t('files', 'undo')+''); + + if (!FileList.useUndo) { + FileList.lastAction(); } else { - $('#notification').html(t('files', 'deleted')+' '+files+''+t('files', 'undo')+''); + // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder + if ($('#dir').val() == '/Shared') { + $('#notification').html(t('files', 'unshared')+' '+files+''+t('files', 'undo')+''); + } else { + $('#notification').html(t('files', 'deleted')+' '+files+''+t('files', 'undo')+''); + } + $('#notification').fadeIn(); } - $('#notification').fadeIn(); }, finishDelete:function(ready,sync){ if(!FileList.deleteCanceled && FileList.deleteFiles){ -- cgit v1.2.3 From 6596094a284f8e800a2b50f9cf82973ce7daea2f Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Wed, 19 Sep 2012 12:02:36 +0200 Subject: add generated unique file name to the uploadingFiles list instead of the original name --- apps/files/js/files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index aefd6f20bec..824b04cebb0 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -356,7 +356,7 @@ $(document).ready(function() { $('#notification').fadeIn(); } }); - uploadingFiles[files[i].name] = jqXHR; + uploadingFiles[uniqueName] = jqXHR; } } }else{ -- cgit v1.2.3 From 223bf3e47cbcb5ed6f7353b7dc5737b6d28452b7 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Wed, 19 Sep 2012 14:05:09 +0200 Subject: fix for bug #1752 (Renaming of folders in files view does not work correctly in firefox 15) --- apps/files/js/filelist.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index fd4cee90fd1..bbdccb49c5f 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -145,31 +145,33 @@ var FileList={ if (newname != name) { if (FileList.checkName(name, newname, false)) { newname = name; - } else { + } else { $.get(OC.filePath('files','ajax','rename.php'), { dir : $('#dir').val(), newname: newname, file: name },function(result) { if (!result || result.status == 'error') { OC.dialogs.alert(result.data.message, 'Error moving file'); newname = name; } + tr.data('renaming',false); }); + + } + + tr.attr('data-file', newname); + var path = td.children('a.name').attr('href'); + td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname))); + if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { + var basename=newname.substr(0,newname.lastIndexOf('.')); + } else { + var basename=newname; + } + td.children('a.name').empty(); + var span=$(''); + span.text(basename); + td.children('a.name').append(span); + if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { + span.append($(''+newname.substr(newname.lastIndexOf('.'))+'')); } } - tr.attr('data-file', newname); - var path = td.children('a.name').attr('href'); - td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname))); - if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { - var basename=newname.substr(0,newname.lastIndexOf('.')); - } else { - var basename=newname; - } - td.children('a.name').empty(); - var span=$(''); - span.text(basename); - td.children('a.name').append(span); - if (newname.indexOf('.') > 0 && tr.data('type') != 'dir') { - span.append($(''+newname.substr(newname.lastIndexOf('.'))+'')); - } - tr.data('renaming',false); return false; }); input.click(function(event){ -- cgit v1.2.3 From aee8949c92b2e0a194e724fabe766be0a273f9b6 Mon Sep 17 00:00:00 2001 From: scambra Date: Fri, 8 Jun 2012 14:29:51 +0200 Subject: fix js success callback on safari when uploading files --- apps/files/js/files.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apps/files/js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index aefd6f20bec..9f71891abb0 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -361,7 +361,8 @@ $(document).ready(function() { } }else{ data.submit().success(function(data, status) { - response = jQuery.parseJSON(data[0].body.innerText); + // in safari data is a string + response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText); if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; -- cgit v1.2.3 From 1b411df83e652a6459e712d32eb1fc1b9c1cfd1d Mon Sep 17 00:00:00 2001 From: scambra Date: Thu, 14 Jun 2012 17:43:21 +0200 Subject: use post to delete files, get has a limit and fails with many files --- apps/files/ajax/delete.php | 6 +++--- apps/files/js/filelist.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php index e9bcea18932..57c8c15c197 100644 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -7,15 +7,15 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); // Get data -$dir = stripslashes($_GET["dir"]); -$files = isset($_GET["file"]) ? stripslashes($_GET["file"]) : stripslashes($_GET["files"]); +$dir = stripslashes($_POST["dir"]); +$files = isset($_POST["file"]) ? stripslashes($_POST["file"]) : stripslashes($_POST["files"]); $files = explode(';', $files); $filesWithError = ''; $success = true; //Now delete foreach($files as $file) { - if( !OC_Files::delete( $dir, $file )) { + if( !OC_Files::delete( $dir, $file )) { $filesWithError .= $file . "\n"; $success = false; } diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 6d4d5399639..383ade997c5 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -276,6 +276,7 @@ var FileList={ $.ajax({ url: OC.filePath('files', 'ajax', 'delete.php'), async:!sync, + type:'post', data: {dir:$('#dir').val(),files:fileNames}, complete: function(data){ boolOperationFinished(data, function(){ -- cgit v1.2.3 From 107b641708d07414f01894fba4561a0c4e500e7d Mon Sep 17 00:00:00 2001 From: scambra Date: Fri, 21 Sep 2012 12:30:13 +0200 Subject: translate rename and history actions --- apps/files/js/fileactions.js | 1 + apps/files_versions/js/versions.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 1403d345e8a..f579d8530ed 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -179,6 +179,7 @@ FileActions.register('all','Delete', OC.PERMISSION_DELETE, function(){return OC. $('.tipsy').remove(); }); +// t('files', 'Rename') FileActions.register('all','Rename', OC.PERMISSION_UPDATE, function(){return OC.imagePath('core','actions/rename');},function(filename){ FileList.rename(filename); }); diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index 495848b8226..9075095d286 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -10,10 +10,10 @@ $(document).ready(function() { $(document).ready(function(){ if (typeof FileActions !== 'undefined') { - // Add history button to files/index.php + // Add history button to 'files/index.php' FileActions.register( 'file' - ,'History' + , t('files_versions', 'History') , OC.PERMISSION_UPDATE , function() { // Specify icon for hitory button @@ -147,4 +147,4 @@ $(this).click( } -); \ No newline at end of file +); -- cgit v1.2.3 From a22a5d6807ca3f98dbfea66e1b1ec0e133e79740 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 23 Sep 2012 03:16:52 +0200 Subject: some js style fixes --- apps/files/js/filelist.js | 42 +++++++-------- core/js/js.js | 127 ++++++++++++++++++++++++---------------------- 2 files changed, 87 insertions(+), 82 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 261d0d76890..683f7db8678 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -4,14 +4,15 @@ var FileList={ $('#fileList').empty().html(fileListHtml); }, addFile:function(name,size,lastModified,loading,hidden){ - var img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png'); - var html=''; + var basename, extension, simpleSize, sizeColor, lastModifiedTime, modifiedColor, + img=(loading)?OC.imagePath('core', 'loading.gif'):OC.imagePath('core', 'filetypes/file.png'), + html=''; if(name.indexOf('.')!=-1){ - var basename=name.substr(0,name.lastIndexOf('.')); - var extension=name.substr(name.lastIndexOf('.')); + basename=name.substr(0,name.lastIndexOf('.')); + extension=name.substr(name.lastIndexOf('.')); }else{ - var basename=name; - var extension=false; + basename=name; + extension=false; } html+=''; html+=''+basename; @@ -41,10 +42,11 @@ var FileList={ } }, addDir:function(name,size,lastModified,hidden){ + var html, td, link_elem, sizeColor, lastModifiedTime, modifiedColor; html = $('').attr({ "data-type": "dir", "data-size": size, "data-file": name, "data-permissions": $('#permissions').val()}); td = $('').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' }); td.append(''); - var link_elem = $('').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); + link_elem = $('').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); link_elem.append($('').addClass('nametext').text(name)); link_elem.append($('').attr({'class': 'uploadtext', 'currentUploads': 0})); td.append(link_elem); @@ -71,7 +73,7 @@ var FileList={ } }, refresh:function(data) { - result = jQuery.parseJSON(data.responseText); + var result = jQuery.parseJSON(data.responseText); if(typeof(result.data.breadcrumb) != 'undefined'){ updateBreadcrumb(result.data.breadcrumb); } @@ -88,14 +90,13 @@ var FileList={ }, insertElement:function(name,type,element){ //find the correct spot to insert the file or folder - var fileElements=$('tr[data-file][data-type="'+type+'"]:visible'); - var pos; + var pos, fileElements=$('tr[data-file][data-type="'+type+'"]:visible'); if(name.localeCompare($(fileElements[0]).attr('data-file'))<0){ pos=-1; }else if(name.localeCompare($(fileElements[fileElements.length-1]).attr('data-file'))>0){ pos=fileElements.length-1; }else{ - for(var pos=0;pos0 && name.localeCompare($(fileElements[pos+1]).attr('data-file'))<0){ break; } @@ -116,9 +117,9 @@ var FileList={ $('.file_upload_filename').removeClass('highlight'); }, loadingDone:function(name){ - var tr=$('tr').filterAttr('data-file',name); + var mime, tr=$('tr').filterAttr('data-file',name); tr.data('loading',false); - var mime=tr.data('mime'); + mime=tr.data('mime'); tr.attr('data-mime',mime); getMimeIcon(mime,function(path){ tr.find('td.filename').attr('style','background-image:url('+path+')'); @@ -129,14 +130,15 @@ var FileList={ return $('tr').filterAttr('data-file',name).data('loading'); }, rename:function(name){ - var tr=$('tr').filterAttr('data-file',name); + var tr, td, input, form; + tr=$('tr').filterAttr('data-file',name); tr.data('renaming',true); - var td=tr.children('td.filename'); - var input=$('').val(name); - var form=$('
') + td=tr.children('td.filename'); + input=$('').val(name); + form=$('
'); form.append(input); td.children('a.name').text(''); - td.children('a.name').append(form) + td.children('a.name').append(form); input.focus(); form.submit(function(event){ event.stopPropagation(); @@ -317,7 +319,7 @@ var FileList={ FileList.finishDelete(null, true); }; } -} +}; $(document).ready(function(){ $('#notification').hide(); @@ -363,7 +365,7 @@ $(document).ready(function(){ FileList.finishDelete(null, true); } }); - FileList.useUndo=('onbeforeunload' in window) + FileList.useUndo=(window.onbeforeunload)?true:false; $(window).bind('beforeunload', function (){ if (FileList.lastAction) { FileList.lastAction(); diff --git a/core/js/js.js b/core/js/js.js index e3c3716e055..71aaedccc29 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -4,21 +4,20 @@ * @param text the string to translate * @return string */ -var OC; function t(app,text){ - if( !( app in t.cache )){ + if( !( t.cache[app] )){ $.ajax(OC.filePath('core','ajax','translations.php'),{ async:false,//todo a proper sollution for this without sync ajax calls data:{'app': app}, type:'POST', success:function(jsondata){ t.cache[app] = jsondata.data; - }, + } }); // Bad answer ... - if( !( app in t.cache )){ + if( !( t.cache[app] )){ t.cache[app] = []; } } @@ -41,7 +40,7 @@ function fileDownloadPath(dir, file) { return OC.filePath('files', 'ajax', 'download.php')+encodeURIComponent('?files='+encodeURIComponent(file)+'&dir='+encodeURIComponent(dir)); } -OC={ +var OC={ PERMISSION_CREATE:4, PERMISSION_READ:1, PERMISSION_UPDATE:2, @@ -68,9 +67,9 @@ OC={ * @return string */ filePath:function(app,type,file){ - var isCore=OC.coreApps.indexOf(app)!=-1; - var link=OC.webroot; - if((file.substring(file.length-3) == 'php' || file.substring(file.length-3) == 'css') && !isCore){ + var isCore=OC.coreApps.indexOf(app)!==-1, + link=OC.webroot; + if((file.substring(file.length-3) === 'php' || file.substring(file.length-3) === 'css') && !isCore){ link+='/?app=' + app; if (file != 'index.php') { link+='&getfile='; @@ -79,20 +78,21 @@ OC={ } link+= file; } - }else if(file.substring(file.length-3) != 'php' && !isCore){ + }else if(file.substring(file.length-3) !== 'php' && !isCore){ link=OC.appswebroots[app]; if(type){ link+= '/'+type+'/'; } - if(link.substring(link.length-1) != '/') + if(link.substring(link.length-1) !== '/'){ link+='/'; + } link+=file; }else{ link+='/'; if(!isCore){ link+='apps/'; } - if (app != '') { + if (app !== '') { app+='/'; link+=app; } @@ -126,12 +126,12 @@ OC={ * if the script is already loaded, the event handeler will be called directly */ addScript:function(app,script,ready){ - var path=OC.filePath(app,'js',script+'.js'); + var deferred, path=OC.filePath(app,'js',script+'.js'); if(!OC.addScript.loaded[path]){ if(ready){ - var deferred=$.getScript(path,ready); + deferred=$.getScript(path,ready); }else{ - var deferred=$.getScript(path); + deferred=$.getScript(path); } OC.addScript.loaded[path]=deferred; }else{ @@ -148,9 +148,9 @@ OC={ */ addStyle:function(app,style){ var path=OC.filePath(app,'css',style+'.css'); - if(OC.addStyle.loaded.indexOf(path)==-1){ + if(OC.addStyle.loaded.indexOf(path)===-1){ OC.addStyle.loaded.push(path); - var style=$(''); + style=$(''); $('head').append(style); } }, @@ -158,7 +158,7 @@ OC={ return path.replace(/\\/g,'/').replace( /.*\//, '' ); }, dirname: function(path) { - return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');; + return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); }, /** * do a search query and display the results @@ -175,10 +175,9 @@ OC={ }, dialogs:OCdialogs, mtime2date:function(mtime) { - mtime = parseInt(mtime); + mtime = parseInt(mtime,10); var date = new Date(1000*mtime); - var ret = date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes(); - return ret; + return date.getDate()+'.'+(date.getMonth()+1)+'.'+date.getFullYear()+', '+date.getHours()+':'+date.getMinutes(); }, /** * Opens a popup with the setting for an app. @@ -285,33 +284,33 @@ OC.Breadcrumb={ OC.Breadcrumb.container.find('div.crumb').remove(); OC.Breadcrumb.crumbs=[]; } -} +}; -if(typeof localStorage !='undefined' && localStorage != null){ - //user and instance awere localstorage +if(typeof localStorage !=='undefined' && localStorage !== null){ + //user and instance aware localstorage OC.localStorage={ namespace:'oc_'+OC.currentUser+'_'+OC.webroot+'_', hasItem:function(name){ - return OC.localStorage.getItem(name)!=null; + return OC.localStorage.getItem(name)!==null; }, setItem:function(name,item){ return localStorage.setItem(OC.localStorage.namespace+name,JSON.stringify(item)); }, getItem:function(name){ - if(localStorage.getItem(OC.localStorage.namespace+name)==null){return null;} + if(localStorage.getItem(OC.localStorage.namespace+name)===null){return null;} return JSON.parse(localStorage.getItem(OC.localStorage.namespace+name)); } }; }else{ //dummy localstorage OC.localStorage={ - hasItem:function(name){ + hasItem:function(){ return false; }, - setItem:function(name,item){ + setItem:function(){ return false; }, - getItem:function(name){ + getItem:function(){ return null; } }; @@ -323,8 +322,9 @@ if(typeof localStorage !='undefined' && localStorage != null){ if (!Array.prototype.filter) { Array.prototype.filter = function(fun /*, thisp*/) { var len = this.length >>> 0; - if (typeof fun != "function") + if (typeof fun !== "function"){ throw new TypeError(); + } var res = []; var thisp = arguments[1]; @@ -347,17 +347,16 @@ if (!Array.prototype.indexOf){ var len = this.length; var from = Number(arguments[1]) || 0; - from = (from < 0) - ? Math.ceil(from) - : Math.floor(from); - if (from < 0) + from = (from < 0) ? Math.ceil(from) : Math.floor(from); + if (from < 0){ from += len; + } for (; from < len; from++) { - if (from in this && - this[from] === elt) + if (from in this && this[from] === elt){ return from; + } } return -1; }; @@ -378,16 +377,16 @@ SVGSupport.checkMimeType=function(){ $.each(headerParts,function(i,text){ if(text){ var parts=text.split(':',2); - if(parts.length==2){ + if(parts.length===2){ var value=parts[1].trim(); - if(value[0]=='"'){ + if(value[0]==='"'){ value=value.substr(1,value.length-2); } headers[parts[0]]=value; } } }); - if(headers["Content-Type"]!='image/svg+xml'){ + if(headers["Content-Type"]!=='image/svg+xml'){ replaceSVG(); SVGSupport.checkMimeType.correct=false; } @@ -444,27 +443,29 @@ function object(o) { * Fills height of window. (more precise than height: 100%;) */ function fillHeight(selector) { - if (selector.length == 0) { + if (selector.length === 0) { return; } var height = parseFloat($(window).height())-selector.offset().top; selector.css('height', height + 'px'); - if(selector.outerHeight() > selector.height()) + if(selector.outerHeight() > selector.height()){ selector.css('height', height-(selector.outerHeight()-selector.height()) + 'px'); + } } /** * Fills height and width of window. (more precise than height: 100%; or width: 100%;) */ function fillWindow(selector) { - if (selector.length == 0) { + if (selector.length === 0) { return; } fillHeight(selector); var width = parseFloat($(window).width())-selector.offset().left; selector.css('width', width + 'px'); - if(selector.outerWidth() > selector.width()) + if(selector.outerWidth() > selector.width()){ selector.css('width', width-(selector.outerWidth()-selector.width()) + 'px'); + } } $(document).ready(function(){ @@ -485,26 +486,26 @@ $(document).ready(function(){ event.preventDefault(); }); $('#searchbox').keyup(function(event){ - if(event.keyCode==13){//enter + if(event.keyCode===13){//enter if(OC.search.currentResult>-1){ var result=$('#searchresults tr.result a')[OC.search.currentResult]; window.location = $(result).attr('href'); } - }else if(event.keyCode==38){//up + }else if(event.keyCode===38){//up if(OC.search.currentResult>0){ OC.search.currentResult--; OC.search.renderCurrent(); } - }else if(event.keyCode==40){//down + }else if(event.keyCode===40){//down if(OC.search.lastResults.length>OC.search.currentResult+1){ OC.search.currentResult++; OC.search.renderCurrent(); } - }else if(event.keyCode==27){//esc + }else if(event.keyCode===27){//esc OC.search.hide(); }else{ var query=$('#searchbox').val(); - if(OC.search.lastQuery!=query){ + if(OC.search.lastQuery!==query){ OC.search.lastQuery=query; OC.search.currentResult=-1; if(query.length>2){ @@ -524,10 +525,10 @@ $(document).ready(function(){ //use infield labels $("label.infield").inFieldLabels(); - checkShowCredentials = function() { + var checkShowCredentials = function() { var empty = false; $('input#user, input#password').each(function() { - if ($(this).val() == '') { + if ($(this).val() === '') { empty = true; } }); @@ -540,14 +541,14 @@ $(document).ready(function(){ $('#remember_login').show(); $('#remember_login+label').fadeIn(); } - } + }; // hide log in button etc. when form fields not filled // commented out due to some browsers having issues with it // checkShowCredentials(); // $('input#user, input#password').keyup(checkShowCredentials); $('#settings #expand').keydown(function(event) { - if (event.which == 13 || event.which == 32) { + if (event.which === 13 || event.which === 32) { $('#expand').click() } }); @@ -558,8 +559,8 @@ $(document).ready(function(){ $('#settings #expanddiv').click(function(event){ event.stopPropagation(); }); - $(window).click(function(){//hide the settings menu when clicking oustide it - if($('body').attr("id")=="body-user"){ + $(window).click(function(){//hide the settings menu when clicking outside it + if($('body').attr("id")==="body-user"){ $('#settings #expanddiv').slideUp(); } }); @@ -586,13 +587,15 @@ if (!Array.prototype.map){ Array.prototype.map = function(fun /*, thisp */){ "use strict"; - if (this === void 0 || this === null) + if (this === void 0 || this === null){ throw new TypeError(); + } var t = Object(this); var len = t.length >>> 0; - if (typeof fun !== "function") + if (typeof fun !== "function"){ throw new TypeError(); + } var res = new Array(len); var thisp = arguments[1]; @@ -614,13 +617,13 @@ $.fn.filterAttr = function(attr_name, attr_value) { }; function humanFileSize(size) { - humanList = ['B', 'kB', 'MB', 'GB', 'TB']; + var humanList = ['B', 'kB', 'MB', 'GB', 'TB']; // Calculate Log with base 1024: size = 1024 ** order - order = Math.floor(Math.log(size) / Math.log(1024)); + var order = Math.floor(Math.log(size) / Math.log(1024)); // Stay in range of the byte sizes that are defined order = Math.min(humanList.length - 1, order); - readableFormat = humanList[order]; - relativeSize = (size / Math.pow(1024, order)).toFixed(1); + var readableFormat = humanList[order]; + var relativeSize = (size / Math.pow(1024, order)).toFixed(1); if(relativeSize.substr(relativeSize.length-2,2)=='.0'){ relativeSize=relativeSize.substr(0,relativeSize.length-2); } @@ -628,7 +631,7 @@ function humanFileSize(size) { } function simpleFileSize(bytes) { - mbytes = Math.round(bytes/(1024*1024/10))/10; + var 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'; } @@ -660,7 +663,7 @@ OC.get=function(name) { } } return context[tail]; -} +}; /** * set a variable by name @@ -679,4 +682,4 @@ OC.set=function(name, value) { context = context[namespaces[i]]; } context[tail]=value; -} +}; -- cgit v1.2.3 From cfbca40fbee14812a69ceb5fda4db7c23645fa9c Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Wed, 26 Sep 2012 13:24:41 +0200 Subject: fix sharing for newly uploaded or created files --- apps/files/ajax/newfile.php | 14 ++++++++++---- apps/files/ajax/upload.php | 3 ++- apps/files/js/files.js | 9 +++++---- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'apps/files/js') diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php index 495c8212163..c2d65d718c5 100644 --- a/apps/files/ajax/newfile.php +++ b/apps/files/ajax/newfile.php @@ -66,8 +66,10 @@ if($source) { $target=$dir.'/'.$filename; $result=OC_Filesystem::file_put_contents($target, $sourceStream); if($result) { - $mime=OC_Filesystem::getMimetype($target); - $eventSource->send('success', array('mime'=>$mime, 'size'=>OC_Filesystem::filesize($target))); + $meta = OC_FileCache::get($target); + $mime=$meta['mimetype']; + $id = OC_FileCache::getId($target); + $eventSource->send('success', array('mime'=>$mime, 'size'=>OC_Filesystem::filesize($target), 'id' => $id)); } else { $eventSource->send('error', "Error while downloading ".$source. ' to '.$target); } @@ -76,11 +78,15 @@ if($source) { } else { if($content) { if(OC_Filesystem::file_put_contents($dir.'/'.$filename, $content)) { - OCP\JSON::success(array("data" => array('content'=>$content))); + $meta = OC_FileCache::get($dir.'/'.$filename); + $id = OC_FileCache::getId($dir.'/'.$filename); + OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id))); exit(); } }elseif(OC_Files::newFile($dir, $filename, 'file')) { - OCP\JSON::success(array("data" => array('content'=>$content))); + $meta = OC_FileCache::get($dir.'/'.$filename); + $id = OC_FileCache::getId($dir.'/'.$filename); + OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id))); exit(); } } diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index fb3e277a215..a4dcd80a2e2 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -50,7 +50,8 @@ if(strpos($dir, '..') === false) { $target = OCP\Files::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]); if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = OC_FileCache::get($target); - $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target)); + $id = OC_FileCache::getId($target); + $result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target)); } } OCP\JSON::encodedPrint($result); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index ec2f159b4ca..0c00fe8c922 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -336,7 +336,7 @@ $(document).ready(function() { if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; - $('tr').filterAttr('data-file',file.name).data('mime',file.mime); + $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id); var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text(); if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); @@ -366,7 +366,7 @@ $(document).ready(function() { if(response[0] != undefined && response[0].status == 'success') { var file=response[0]; delete uploadingFiles[file.name]; - $('tr').filterAttr('data-file',file.name).data('mime',file.mime); + $('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id); var size = $('tr').filterAttr('data-file',file.name).find('td.filesize').text(); if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); @@ -512,7 +512,7 @@ $(document).ready(function() { var date=new Date(); FileList.addFile(name,0,date,false,hidden); var tr=$('tr').filterAttr('data-file',name); - tr.data('mime','text/plain'); + tr.data('mime','text/plain').data('id',result.data.id); getMimeIcon('text/plain',function(path){ tr.find('td.filename').attr('style','background-image:url('+path+')'); }); @@ -560,11 +560,12 @@ $(document).ready(function() { eventSource.listen('success',function(data){ var mime=data.mime; var size=data.size; + var id=data.id; $('#uploadprogressbar').fadeOut(); var date=new Date(); FileList.addFile(localName,size,date,false,hidden); var tr=$('tr').filterAttr('data-file',localName); - tr.data('mime',mime); + tr.data('mime',mime).data('id',id); getMimeIcon(mime,function(path){ tr.find('td.filename').attr('style','background-image:url('+path+')'); }); -- cgit v1.2.3