From 39d874cd902a4e3d4f7ae313ec5e15bafe35df13 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 20 Dec 2012 17:16:01 +0100 Subject: the maximum upload size is now part of the response of the upload and delete operation. the maximum upload size is updated within the browser once an upload or delete operation has been finished --- apps/files/js/files.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..e35dbe673d9 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,6 +26,23 @@ Files={ }); procesSelection(); }, + updateMaxUploadFilesize:function(response) { + if(response == undefined) { + return; + } + if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { + $('#max_upload').val(response.data.uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + } + if(response[0] == undefined) { + return; + } + if(response[0].uploadMaxFilesize !== undefined) { + $('#max_upload').val(response[0].uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + } + + }, containsInvalidCharacters:function (name) { var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { @@ -304,6 +321,7 @@ $(document).ready(function() { $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); } + Files.updateMaxUploadFilesize(response); var file=response[0]; // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; @@ -354,7 +372,9 @@ $(document).ready(function() { .success(function(result, textStatus, jqXHR) { var response; response=jQuery.parseJSON(result); - if(response[0] != undefined && response[0].status == 'success') { + Files.updateMaxUploadFilesize(response); + + 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).data('id',file.id); @@ -384,7 +404,8 @@ $(document).ready(function() { data.submit().success(function(data, status) { // 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') { + Files.updateMaxUploadFilesize(response); + 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).data('id',file.id); @@ -712,6 +733,7 @@ scanFiles.scanning=false; function boolOperationFinished(data, callback) { result = jQuery.parseJSON(data.responseText); + Files.updateMaxUploadFilesize(result); if(result.status == 'success'){ callback.call(); } else { -- cgit v1.2.3 From 48f6dccdb768126ae71a1e4de4eca184891a6115 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 2 Jan 2013 15:09:40 +0100 Subject: notifications are now shown/hidden using the js functions hideNotification and showNotification. storage warnings are displayed in a notification. as soon as a notification is hidden the storage warning will come back. --- apps/files/js/filelist.js | 33 +++++++++++------------- apps/files/js/files.js | 65 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 38 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 96dd0323d29..031c58e724c 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -195,15 +195,14 @@ var FileList={ }, checkName:function(oldName, newName, isNewFile) { if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) { - if (isNewFile) { - $('#notification').html(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); - } else { - $('#notification').html(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); - } $('#notification').data('oldName', oldName); $('#notification').data('newName', newName); $('#notification').data('isNewFile', isNewFile); - $('#notification').fadeIn(); + if (isNewFile) { + Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); + } else { + Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); + } return true; } else { return false; @@ -245,11 +244,10 @@ var FileList={ FileList.finishReplace(); }; if (isNewFile) { - $('#notification').html(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); } else { - $('#notification').html(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); } - $('#notification').fadeIn(); }, finishReplace:function() { if (!FileList.replaceCanceled && FileList.replaceOldName && FileList.replaceNewName) { @@ -279,11 +277,10 @@ var FileList={ } else { // 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}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'unshared {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } else { - $('#notification').html(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + Files.showHtmlNotification(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } - $('#notification').fadeIn(); } }, finishDelete:function(ready,sync){ @@ -296,7 +293,7 @@ var FileList={ data: {dir:$('#dir').val(),files:fileNames}, complete: function(data){ boolOperationFinished(data, function(){ - $('#notification').fadeOut('400'); + Files.hideNotification(); $.each(FileList.deleteFiles,function(index,file){ FileList.remove(file); }); @@ -356,16 +353,16 @@ $(document).ready(function(){ FileList.replaceIsNewFile = null; } FileList.lastAction = null; - $('#notification').fadeOut('400'); + Files.hideNotification(); }); $('#notification .replace').live('click', function() { - $('#notification').fadeOut('400', function() { - FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile')); - }); + Files.hideNotification(function() { + FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile')); + }); }); $('#notification .suggest').live('click', function() { $('tr').filterAttr('data-file', $('#notification').data('oldName')).show(); - $('#notification').fadeOut('400'); + Files.hideNotification(); }); $('#notification .cancel').live('click', function() { if ($('#notification').data('isNewFile')) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..6023cf78e79 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -30,14 +30,45 @@ Files={ var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { - $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); - $('#notification').fadeIn(); + Files.showNotification(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); return true; } } - $('#notification').fadeOut(); + Files.hideNotification(); return false; - } + }, + displayStorageWarnings: function() { + var usedSpacePercent = $('#usedSpacePercent').val(); + if (usedSpacePercent > 98) { + Files.showNotification(t('files', 'Your storage is full, files can not be updated or synced anymore!')); + return; + } + if (usedSpacePercent > 90) { + Files.showNotification(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); + } + }, + hideNotification: function(callback) { + $("#notification").text(''); + $('#notification').fadeOut('400', function(){ + if ($("#notification").text() === '') { + Files.displayStorageWarnings(); + } + if (callback) { + callback.call(); + } + }); + }, + showHtmlNotification: function(html) { + $('#notification').hide(); + $("#notification").html(html); + $("#notification").fadeIn(); + }, + showNotification: function(text) { + $('#notification').hide(); + $("#notification").text(text); + $("#notification").fadeIn(); + } + }; $(document).ready(function() { Files.bindKeyboardShortcuts(document, jQuery); @@ -171,8 +202,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - $('#notification').text(t('files','generating ZIP-file, it may take some time.')); - $('#notification').fadeIn(); + Files.showNotification(t('files','generating ZIP-file, it may take some time.')); // use special download URL if provided, e.g. for public shared files if ( (downloadURL = document.getElementById("downloadURL")) ) { window.location=downloadURL.value+"&download&files="+files; @@ -301,8 +331,7 @@ $(document).ready(function() { var response; response=jQuery.parseJSON(result); if(response[0] == undefined || response[0].status != 'success') { - $('#notification').text(t('files', response.data.message)); - $('#notification').fadeIn(); + Files.showNotification(t('files', response.data.message)); } var file=response[0]; // TODO: this doesn't work if the file name has been changed server side @@ -339,9 +368,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } - $('#notification').hide(); - $('#notification').text(t('files', 'Upload cancelled.')); - $('#notification').fadeIn(); + Files.showNotification(t('files', 'Upload cancelled.')); } }); //TODO test with filenames containing slashes @@ -364,17 +391,14 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - $('#notification').text(t('files', response.data.message)); - $('#notification').fadeIn(); + Files.showNotification(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } }) .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { - $('#notification').hide(); - $('#notification').text(t('files', 'Upload cancelled.')); - $('#notification').fadeIn(); + Files.showNotification(t('files', 'Upload cancelled.')); } }); uploadingFiles[uniqueName] = jqXHR; @@ -394,8 +418,7 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - $('#notification').text(t('files', response.data.message)); - $('#notification').fadeIn(); + Files.showNotification(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -512,8 +535,7 @@ $(document).ready(function() { if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { return; } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { - $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); - $('#notification').fadeIn(); + Files.showNotification(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); return; } if (FileList.lastAction) { @@ -683,6 +705,9 @@ $(document).ready(function() { }); resizeBreadcrumbs(true); + + // display storage warnings + setTimeout ( "Files.displayStorageWarnings()", 100 ); }); function scanFiles(force,dir){ -- cgit v1.2.3 From 8148c187a32e4952e150dffefecab39f1c5b323e Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Tue, 18 Dec 2012 16:10:48 +0100 Subject: whitespace cleanup --- apps/files/js/files.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..2ce1723f0b4 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -234,12 +234,12 @@ $(document).ready(function() { } }); }else{ - var dropTarget = $(e.originalEvent.target).closest('tr'); - if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder - var dirName = dropTarget.attr('data-file') - } + var dropTarget = $(e.originalEvent.target).closest('tr'); + if(dropTarget && dropTarget.attr('data-type') === 'dir') { // drag&drop upload to folder + var dirName = dropTarget.attr('data-file') + } - var date=new Date(); + var date=new Date(); if(files){ for(var i=0;i0){ @@ -292,9 +292,9 @@ $(document).ready(function() { var jqXHR = $('#file_upload_start').fileupload('send', {files: files[i], formData: function(form) { var formArray = form.serializeArray(); - // array index 0 contains the max files size - // array index 1 contains the request token - // array index 2 contains the directory + // array index 0 contains the max files size + // array index 1 contains the request token + // array index 2 contains the directory formArray[2]['value'] = dirName; return formArray; }}).success(function(result, textStatus, jqXHR) { @@ -305,13 +305,13 @@ $(document).ready(function() { $('#notification').fadeIn(); } var file=response[0]; - // TODO: this doesn't work if the file name has been changed server side + // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; - if ($.assocArraySize(uploadingFiles[dirName]) == 0) { - delete uploadingFiles[dirName]; - } + if ($.assocArraySize(uploadingFiles[dirName]) == 0) { + delete uploadingFiles[dirName]; + } - var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') + var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') var currentUploads = parseInt(uploadtext.attr('currentUploads')); currentUploads -= 1; uploadtext.attr('currentUploads', currentUploads); @@ -434,7 +434,7 @@ $(document).ready(function() { // http://stackoverflow.com/a/6700/11236 var size = 0, key; for (key in obj) { - if (obj.hasOwnProperty(key)) size++; + if (obj.hasOwnProperty(key)) size++; } return size; }; -- cgit v1.2.3 From 32c2b0d50eac5669f64bdbf9256939d1ad046304 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Tue, 18 Dec 2012 16:36:26 +0100 Subject: enable enter in ie by using .submit()+form instead of .change(), use notifications when name is empty --- apps/files/js/files.js | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 2ce1723f0b4..6d1be45cddc 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -496,7 +496,7 @@ $(document).ready(function() { $('#new li').each(function(i,element){ if($(element).children('p').length==0){ - $(element).children('input').remove(); + $(element).children('form').remove(); $(element).append('

'+$(element).data('text')+'

'); } }); @@ -506,22 +506,35 @@ $(document).ready(function() { $(this).data('text',text); $(this).children('p').remove(); var input=$(''); - $(this).append(input); + var form=$('
'); + form.append(input); + $(this).append(form); input.focus(); - input.change(function(){ - if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { - return; - } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { + form.submit(function(event){ + event.stopPropagation(); + event.preventDefault(); + var newname=input.val(); + if(type != 'web' && Files.containsInvalidCharacters(newname)){ + return false; + } else if (newname.length == 0) { + if(type == 'web') { + $('#notification').text(t('files', "URL cannot be empty.")); + } else { + $('#notification').text(t('files', "Name cannot be empty.")); + } + $('#notification').fadeIn(); + return false; + } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') { $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); $('#notification').fadeIn(); - return; + return false; } if (FileList.lastAction) { FileList.lastAction(); } - var name = getUniqueName($(this).val()); - if (name != $(this).val()) { - FileList.checkName(name, $(this).val(), true); + var name = getUniqueName(newname); + if (newname != name) { + FileList.checkName(name, newname, true); var hidden = true; } else { var hidden = false; @@ -604,8 +617,8 @@ $(document).ready(function() { }); break; } - var li=$(this).parent(); - $(this).remove(); + var li=form.parent(); + form.remove(); li.append('

'+li.data('text')+'

'); $('#new>a').click(); }); -- cgit v1.2.3 From 03b8a065cf37c040452b567a2a9050f637cbda94 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Wed, 2 Jan 2013 17:02:55 +0100 Subject: input/form switching cleanup --- apps/files/css/files.css | 2 +- apps/files/js/files.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 99c39f0acdb..f292c5c8c3f 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -21,7 +21,7 @@ #new>ul>li { height:20px; margin:.3em; padding-left:2em; padding-bottom:0.1em; background-repeat:no-repeat; cursor:pointer; } #new>ul>li>p { cursor:pointer; } -#new>ul>li>input { padding:0.3em; margin:-0.3em; } +#new>ul>li>form>input { padding:0.3em; margin:-0.3em; } #upload { height:27px; padding:0; margin-left:0.2em; overflow:hidden; diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6d1be45cddc..c795469e2d5 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -477,7 +477,7 @@ $(document).ready(function() { $('#new').removeClass('active'); $('#new li').each(function(i,element){ if($(element).children('p').length==0){ - $(element).children('input').remove(); + $(element).children('form').remove(); $(element).append('

'+$(element).data('text')+'

'); } }); @@ -505,8 +505,8 @@ $(document).ready(function() { var text=$(this).children('p').text(); $(this).data('text',text); $(this).children('p').remove(); - var input=$(''); var form=$('
'); + var input=$(''); form.append(input); $(this).append(form); input.focus(); -- cgit v1.2.3 From ba475d486258c0b7ea86cd766814053df6c69170 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 4 Jan 2013 23:34:09 +0100 Subject: javascript notification functions have been moved to js.js for common use --- apps/files/js/filelist.js | 20 ++++++++++---------- apps/files/js/files.js | 45 ++++++++++++--------------------------------- core/js/js.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 43 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 031c58e724c..33f35eee6c5 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -199,9 +199,9 @@ var FileList={ $('#notification').data('newName', newName); $('#notification').data('isNewFile', isNewFile); if (isNewFile) { - Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); + OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'suggest name')+''+t('files', 'cancel')+''); } else { - Files.showHtmlNotification(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); + OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+''+t('files', 'replace')+''+t('files', 'cancel')+''); } return true; } else { @@ -244,9 +244,9 @@ var FileList={ FileList.finishReplace(); }; if (isNewFile) { - Files.showHtmlNotification(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'replaced {new_name}', {new_name: newName})+''+t('files', 'undo')+''); } else { - Files.showHtmlNotification(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+''+t('files', 'undo')+''); } }, finishReplace:function() { @@ -277,9 +277,9 @@ var FileList={ } else { // NOTE: Temporary fix to change the text to unshared for files in root of Shared folder if ($('#dir').val() == '/Shared') { - Files.showHtmlNotification(t('files', 'unshared {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'unshared {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } else { - Files.showHtmlNotification(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); + OC.Notification.showHtml(t('files', 'deleted {files}', {'files': escapeHTML(files)})+''+t('files', 'undo')+''); } } }, @@ -293,7 +293,7 @@ var FileList={ data: {dir:$('#dir').val(),files:fileNames}, complete: function(data){ boolOperationFinished(data, function(){ - Files.hideNotification(); + OC.Notification.hide(); $.each(FileList.deleteFiles,function(index,file){ FileList.remove(file); }); @@ -353,16 +353,16 @@ $(document).ready(function(){ FileList.replaceIsNewFile = null; } FileList.lastAction = null; - Files.hideNotification(); + OC.Notification.hide(); }); $('#notification .replace').live('click', function() { - Files.hideNotification(function() { + OC.Notification.hide(function() { FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile')); }); }); $('#notification .suggest').live('click', function() { $('tr').filterAttr('data-file', $('#notification').data('oldName')).show(); - Files.hideNotification(); + OC.Notification.hide(); }); $('#notification .cancel').live('click', function() { if ($('#notification').data('isNewFile')) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6023cf78e79..6166b240e83 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -30,45 +30,23 @@ Files={ var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { - Files.showNotification(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); + OC.Notification.show(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); return true; } } - Files.hideNotification(); + OC.Notification.hide(); return false; }, displayStorageWarnings: function() { var usedSpacePercent = $('#usedSpacePercent').val(); if (usedSpacePercent > 98) { - Files.showNotification(t('files', 'Your storage is full, files can not be updated or synced anymore!')); + OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); return; } if (usedSpacePercent > 90) { - Files.showNotification(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); + OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); } - }, - hideNotification: function(callback) { - $("#notification").text(''); - $('#notification').fadeOut('400', function(){ - if ($("#notification").text() === '') { - Files.displayStorageWarnings(); - } - if (callback) { - callback.call(); - } - }); - }, - showHtmlNotification: function(html) { - $('#notification').hide(); - $("#notification").html(html); - $("#notification").fadeIn(); - }, - showNotification: function(text) { - $('#notification').hide(); - $("#notification").text(text); - $("#notification").fadeIn(); } - }; $(document).ready(function() { Files.bindKeyboardShortcuts(document, jQuery); @@ -202,7 +180,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - Files.showNotification(t('files','generating ZIP-file, it may take some time.')); + OC.Notification.show(t('files','generating ZIP-file, it may take some time.')); // use special download URL if provided, e.g. for public shared files if ( (downloadURL = document.getElementById("downloadURL")) ) { window.location=downloadURL.value+"&download&files="+files; @@ -331,7 +309,7 @@ $(document).ready(function() { var response; response=jQuery.parseJSON(result); if(response[0] == undefined || response[0].status != 'success') { - Files.showNotification(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); } var file=response[0]; // TODO: this doesn't work if the file name has been changed server side @@ -368,7 +346,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } - Files.showNotification(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); //TODO test with filenames containing slashes @@ -391,14 +369,14 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - Files.showNotification(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } }) .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { - Files.showNotification(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); uploadingFiles[uniqueName] = jqXHR; @@ -418,7 +396,7 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { - Files.showNotification(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -535,7 +513,7 @@ $(document).ready(function() { if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { return; } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { - Files.showNotification(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); + OC.Notification.show(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); return; } if (FileList.lastAction) { @@ -708,6 +686,7 @@ $(document).ready(function() { // display storage warnings setTimeout ( "Files.displayStorageWarnings()", 100 ); + OC.Notification.setDefault(Files.displayStorageWarnings); }); function scanFiles(force,dir){ diff --git a/core/js/js.js b/core/js/js.js index 7d967321d93..b57603b7b2f 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -289,6 +289,36 @@ OC.search.lastResults={}; OC.addStyle.loaded=[]; OC.addScript.loaded=[]; +OC.Notification={ + getDefaultNotificationFunction: null, + setDefault: function(callback) { + OC.Notification.getDefaultNotificationFunction = callback; + }, + hide: function(callback) { + $("#notification").text(''); + $('#notification').fadeOut('400', function(){ + if ($("#notification").text() === '') { + if (OC.Notification.getDefaultNotificationFunction) { + OC.Notification.getDefaultNotificationFunction.call(); + } + } + if (callback) { + callback.call(); + } + }); + }, + showHtml: function(html) { + $('#notification').hide(); + $('#notification').html(html); + $('#notification').fadeIn(); + }, + show: function(text) { + $('#notification').hide(); + $('#notification').text(text); + $('#notification').fadeIn(); + } +}; + OC.Breadcrumb={ container:null, crumbs:[], -- cgit v1.2.3 From b4191b7da53f4aaf7e0a80c6513db3499a76aeda Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sun, 6 Jan 2013 12:52:00 +0100 Subject: rename containsInvalidCharacters() to isFileNameValid() - NOTE: semantic has changed! adding file name checks and notifications to isFileNameValid() for . and empty file name --- apps/files/js/filelist.js | 2 +- apps/files/js/files.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index cc47ec2612e..22d701d8ff9 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -149,7 +149,7 @@ var FileList={ event.stopPropagation(); event.preventDefault(); var newname=input.val(); - if (Files.containsInvalidCharacters(newname) || newname === '.') { + if (!Files.isFileNameValid(newname)) { return false; } if (newname != name) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6a37d9e7f53..ba2495eb728 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,17 +26,29 @@ Files={ }); procesSelection(); }, - containsInvalidCharacters:function (name) { + isFileNameValid:function (name) { + if (name === '.') { + $('#notification').text(t('files', "'.' is an invalid file name.")); + $('#notification').fadeIn(); + return false; + } + if (name.length == 0) { + $('#notification').text(t('files', "File name cannot be empty.")); + $('#notification').fadeIn(); + return false; + } + + // check for invalid characters var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { $('#notification').text(t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.")); $('#notification').fadeIn(); - return true; + return false; } } $('#notification').fadeOut(); - return false; + return true; } }; $(document).ready(function() { @@ -509,7 +521,7 @@ $(document).ready(function() { $(this).append(input); input.focus(); input.change(function(){ - if (type != 'web' && Files.containsInvalidCharacters($(this).val())) { + if (type != 'web' && !Files.isFileNameValid($(this).val())) { return; } else if( type == 'folder' && $('#dir').val() == '/' && $(this).val() == 'Shared') { $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); -- cgit v1.2.3 From cbb118d4a3a26c9471ffc40cc387df4333031da1 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Mon, 7 Jan 2013 10:39:35 +0100 Subject: adapt to isFileNameValid, whitespace cleanup --- apps/files/js/filelist.js | 7 +------ apps/files/js/files.js | 40 ++++++++++++++++++---------------------- 2 files changed, 19 insertions(+), 28 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index c4c53ca878a..66697bbbf56 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -151,12 +151,7 @@ var FileList={ var newname=input.val(); if (!Files.isFileNameValid(newname)) { return false; - } else if (newname.length == 0) { - $('#notification').text(t('files', "Name cannot be empty.")); - $('#notification').fadeIn(); - return false; - } - if (newname != name) { + } else if (newname != name) { if (FileList.checkName(name, newname, false)) { newname = name; } else { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a824b9d3059..91204f041e5 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,19 +26,19 @@ Files={ }); procesSelection(); }, - isFileNameValid:function (name) { - if (name === '.') { - $('#notification').text(t('files', "'.' is an invalid file name.")); - $('#notification').fadeIn(); - return false; - } - if (name.length == 0) { - $('#notification').text(t('files', "File name cannot be empty.")); - $('#notification').fadeIn(); - return false; - } - - // check for invalid characters + isFileNameValid:function (name) { + if (name === '.') { + $('#notification').text(t('files', '\'.\' is an invalid file name.')); + $('#notification').fadeIn(); + return false; + } + if (name.length == 0) { + $('#notification').text(t('files', 'File name cannot be empty.')); + $('#notification').fadeIn(); + return false; + } + + // check for invalid characters var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*']; for (var i = 0; i < invalid_characters.length; i++) { if (name.indexOf(invalid_characters[i]) != -1) { @@ -526,18 +526,14 @@ $(document).ready(function() { event.stopPropagation(); event.preventDefault(); var newname=input.val(); - if(type != 'web' && !Files.isFileNameValid(newname)){ - return false; - } else if (newname.length == 0) { - if(type == 'web') { - $('#notification').text(t('files', "URL cannot be empty.")); - } else { - $('#notification').text(t('files', "Name cannot be empty.")); - } + if(type == 'web' && newname.length == 0) { + $('#notification').text(t('files', 'URL cannot be empty.')); $('#notification').fadeIn(); return false; + } else if (type != 'web' && !Files.isFileNameValid(newname)) { + return false; } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') { - $('#notification').text(t('files','Invalid folder name. Usage of "Shared" is reserved by Owncloud')); + $('#notification').text(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud')); $('#notification').fadeIn(); return false; } -- cgit v1.2.3 From da442b024c50160be58281975a6fabe2d86a61a7 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Mon, 7 Jan 2013 11:11:21 +0100 Subject: remove aborted uploads --- apps/files/js/files.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 91204f041e5..6d19a341e9e 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -351,6 +351,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } + delete uploadingFiles[dirName][fileName]; $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); $('#notification').fadeIn(); @@ -376,6 +377,7 @@ $(document).ready(function() { } FileList.loadingDone(file.name, file.id); } else { + Files.cancelUpload(this.files[0].name); $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); $('#fileList > tr').not('[data-mime]').fadeOut(); @@ -384,6 +386,7 @@ $(document).ready(function() { }) .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { + Files.cancelUpload(this.files[0].name); $('#notification').hide(); $('#notification').text(t('files', 'Upload cancelled.')); $('#notification').fadeIn(); -- cgit v1.2.3 From 3bb7ee521f38e1ab1fc7cd160dc3d0ae77f0433e Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Mon, 7 Jan 2013 12:23:29 +0100 Subject: attach max upload tipsy to div instead of a to fix tooltip not showing due to new z-index --- apps/files/js/files.js | 4 ++++ apps/files/templates/index.php | 6 +++--- core/js/js.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 6d19a341e9e..038660e6e49 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -322,6 +322,7 @@ $(document).ready(function() { if ($.assocArraySize(uploadingFiles[dirName]) == 0) { delete uploadingFiles[dirName]; } + //TODO update file upload size limit var uploadtext = $('tr').filterAttr('data-type', 'dir').filterAttr('data-file', dirName).find('.uploadtext') var currentUploads = parseInt(uploadtext.attr('currentUploads')); @@ -375,6 +376,7 @@ $(document).ready(function() { if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } + //TODO update file upload size limit FileList.loadingDone(file.name, file.id); } else { Files.cancelUpload(this.files[0].name); @@ -407,8 +409,10 @@ $(document).ready(function() { if(size==t('files','Pending')){ $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); } + //TODO update file upload size limit FileList.loadingDone(file.name, file.id); } else { + //TODO Files.cancelUpload(/*where do we get the filename*/); $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); $('#fileList > tr').not('[data-mime]').fadeOut(); diff --git a/apps/files/templates/index.php b/apps/files/templates/index.php index 3bcb865ccdb..2e0772443f2 100644 --- a/apps/files/templates/index.php +++ b/apps/files/templates/index.php @@ -14,7 +14,8 @@ data-type='web'>

t('From link');?>

-
+
- +
diff --git a/core/js/js.js b/core/js/js.js index 9f3e8f92100..95889ac8a27 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -622,7 +622,7 @@ $(document).ready(function(){ $('.jp-controls .jp-previous').tipsy({gravity:'nw', fade:true, live:true}); $('.jp-controls .jp-next').tipsy({gravity:'n', fade:true, live:true}); $('.password .action').tipsy({gravity:'se', fade:true, live:true}); - $('#upload a').tipsy({gravity:'w', fade:true}); + $('#upload').tipsy({gravity:'w', fade:true}); $('.selectedActions a').tipsy({gravity:'s', fade:true, live:true}); $('a.delete').tipsy({gravity: 'e', fade:true, live:true}); $('a.action').tipsy({gravity:'s', fade:true, live:true}); -- cgit v1.2.3 From 7b9e6d2f2ce1503b113017db4dbe43c68da0101b Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Tue, 8 Jan 2013 00:32:41 +0100 Subject: fixing string concatenation in javascript refs https://github.com/owncloud/core/commit/ae54364d7c8baf5138d166855db6431190963886 --- apps/files/js/files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 038660e6e49..bb298431e84 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -593,7 +593,7 @@ $(document).ready(function() { break; case 'web': if(name.substr(0,8)!='https://' && name.substr(0,7)!='http://'){ - name='http://'.name; + name='http://'+name; } var localName=name; if(localName.substr(localName.length-1,1)=='/'){//strip / -- cgit v1.2.3 From 780fb37758ac16fc8d9eacee99dda8a80c88921f Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Wed, 9 Jan 2013 15:21:55 +0100 Subject: allow default click behaviour --- apps/files/js/files.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index bb298431e84..a4260c43285 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -87,8 +87,8 @@ $(document).ready(function() { // Sets the file link behaviour : $('td.filename a').live('click',function(event) { - event.preventDefault(); if (event.ctrlKey || event.shiftKey) { + event.preventDefault(); if (event.shiftKey) { var last = $(lastChecked).parent().parent().prevAll().length; var first = $(this).parent().parent().prevAll().length; @@ -130,6 +130,7 @@ $(document).ready(function() { var permissions = $(this).parent().parent().data('permissions'); var action=FileActions.getDefault(mime,type, permissions); if(action){ + event.preventDefault(); action(filename); } } -- cgit v1.2.3 From 9afdc14d4050917bf4e0f8cbe7e97d922213a487 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 14:55:49 +0100 Subject: adding accidentally removed line - THX @bartv2 --- apps/files/js/files.js | 1 + 1 file changed, 1 insertion(+) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 81f596d6647..c1c88d1c72b 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -359,6 +359,7 @@ $(document).ready(function() { } else { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } + delete uploadingFiles[dirName][fileName]; OC.Notification.show(t('files', 'Upload cancelled.')); } }); -- cgit v1.2.3 From 3d33e8f8453f49c15d539cce3448465f330cf9c0 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 15:02:34 +0100 Subject: fixing indent - sorryy wrong setting on the IDE :-( replace missing calls to OC.Notification.show --- apps/files/js/files.js | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index c1c88d1c72b..426f91c7928 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -28,13 +28,11 @@ Files={ }, isFileNameValid:function (name) { if (name === '.') { - $('#notification').text(t('files', '\'.\' is an invalid file name.')); - $('#notification').fadeIn(); + OC.Notification.show(t('files', '\'.\' is an invalid file name.')); return false; } if (name.length == 0) { - $('#notification').text(t('files', 'File name cannot be empty.')); - $('#notification').fadeIn(); + OC.Notification.show(t('files', 'File name cannot be empty.')); return false; } @@ -46,17 +44,17 @@ Files={ return false; } } - OC.Notification.hide(); + OC.Notification.hide(); return true; }, displayStorageWarnings: function() { var usedSpacePercent = $('#usedSpacePercent').val(); if (usedSpacePercent > 98) { - OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); - return; + OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); + return; } if (usedSpacePercent > 90) { - OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); + OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', {usedSpacePercent: usedSpacePercent})); } } }; @@ -192,7 +190,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - OC.Notification.show(t('files','generating ZIP-file, it may take some time.')); + OC.Notification.show(t('files','generating ZIP-file, it may take some time.')); // use special download URL if provided, e.g. for public shared files if ( (downloadURL = document.getElementById("downloadURL")) ) { window.location=downloadURL.value+"&download&files="+files; @@ -360,7 +358,7 @@ $(document).ready(function() { uploadtext.text(t('files', '{count} files uploading', {count: currentUploads})); } delete uploadingFiles[dirName][fileName]; - OC.Notification.show(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); //TODO test with filenames containing slashes @@ -385,7 +383,7 @@ $(document).ready(function() { FileList.loadingDone(file.name, file.id); } else { Files.cancelUpload(this.files[0].name); - OC.Notification.show(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -393,7 +391,7 @@ $(document).ready(function() { .error(function(jqXHR, textStatus, errorThrown) { if(errorThrown === 'abort') { Files.cancelUpload(this.files[0].name); - OC.Notification.show(t('files', 'Upload cancelled.')); + OC.Notification.show(t('files', 'Upload cancelled.')); } }); uploadingFiles[uniqueName] = jqXHR; @@ -415,7 +413,7 @@ $(document).ready(function() { FileList.loadingDone(file.name, file.id); } else { //TODO Files.cancelUpload(/*where do we get the filename*/); - OC.Notification.show(t('files', response.data.message)); + OC.Notification.show(t('files', response.data.message)); $('#fileList > tr').not('[data-mime]').fadeOut(); $('#fileList > tr').not('[data-mime]').remove(); } @@ -541,7 +539,7 @@ $(document).ready(function() { } else if (type != 'web' && !Files.isFileNameValid(newname)) { return false; } else if( type == 'folder' && $('#dir').val() == '/' && newname == 'Shared') { - OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud')); + OC.Notification.show(t('files','Invalid folder name. Usage of \'Shared\' is reserved by Owncloud')); return false; } if (FileList.lastAction) { @@ -712,9 +710,9 @@ $(document).ready(function() { resizeBreadcrumbs(true); - // display storage warnings - setTimeout ( "Files.displayStorageWarnings()", 100 ); - OC.Notification.setDefault(Files.displayStorageWarnings); + // display storage warnings + setTimeout ( "Files.displayStorageWarnings()", 100 ); + OC.Notification.setDefault(Files.displayStorageWarnings); }); function scanFiles(force,dir){ -- cgit v1.2.3 From e560cba76beb918a2c127b931b6d409abd9f03ab Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 11 Jan 2013 16:47:28 +0100 Subject: adding a ajax call to get the current file storage stats like free space logic to call it every 5 minutes make use of visibility API/jquery-visibility to perform the ajax call only if the browser is visible/in use --- apps/files/ajax/getstoragestats.php | 16 ++++++++++++++++ apps/files/js/files.js | 26 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 apps/files/ajax/getstoragestats.php (limited to 'apps/files/js/files.js') diff --git a/apps/files/ajax/getstoragestats.php b/apps/files/ajax/getstoragestats.php new file mode 100644 index 00000000000..e55e346ed67 --- /dev/null +++ b/apps/files/ajax/getstoragestats.php @@ -0,0 +1,16 @@ +t('Upload') . ' max. ' . $maxHumanFilesize; + +// send back json +OCP\JSON::success(array('data' => array('uploadMaxFilesize' => $maxUploadFilesize, + 'maxHumanFilesize' => $maxHumanFilesize +))); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 96b3cc5b627..440aeeaf6a6 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -732,6 +732,32 @@ $(document).ready(function() { }); resizeBreadcrumbs(true); + + // file space size sync + function update_storage_statistics() { + $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) { + Files.updateMaxUploadFilesize(response); + }); + } + + // start on load - we ask the server every 5 minutes + var update_storage_statistics_interval = 5*60*1000; + var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); + + // Use jquery-visibility to de-/re-activate file stats sync + if ($.support.pageVisibility) { + $(document).on({ + 'show.visibility': function() { + if (!update_storage_statistics_interval_id) { + update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval); + } + }, + 'hide.visibility': function() { + clearInterval(update_storage_statistics_interval_id); + update_storage_statistics_interval_id = 0; + } + }); + } }); function scanFiles(force,dir){ -- cgit v1.2.3 From 5bfe4adbaa9c402db5bd0d0f74fd9ad7bb037129 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 14 Jan 2013 20:30:39 +0100 Subject: Whitespace cleanup --- apps/files/css/files.css | 4 ++-- apps/files/js/fileactions.js | 14 +++++------ apps/files/js/files.js | 2 +- apps/files_external/lib/amazons3.php | 2 +- apps/files_external/lib/config.php | 14 +++++------ apps/files_external/templates/settings.php | 4 ++-- apps/files_sharing/js/share.js | 2 +- apps/files_sharing/public.php | 12 +++++----- lib/MDB2/Driver/sqlite3.php | 2 +- lib/api.php | 22 ++++++++--------- lib/app.php | 2 +- lib/backgroundjob.php | 2 +- lib/connector/sabre/node.php | 6 ++--- lib/filecache.php | 4 ++-- lib/fileproxy/quota.php | 2 +- lib/files.php | 2 +- lib/filesystem.php | 14 +++++------ lib/filesystemview.php | 38 +++++++++++++++--------------- lib/helper.php | 2 +- lib/image.php | 2 +- lib/json.php | 2 +- lib/log.php | 4 ++-- lib/ocs/cloud.php | 6 ++--- lib/ocs/config.php | 4 ++-- lib/ocs/person.php | 2 +- lib/ocs/privatedata.php | 4 ++-- lib/ocs/result.php | 14 +++++------ lib/public/constants.php | 1 - lib/public/db.php | 6 ++--- lib/public/share.php | 8 +++---- lib/public/user.php | 2 +- lib/request.php | 4 ++-- lib/setup.php | 2 +- lib/vcategories.php | 1 - 34 files changed, 105 insertions(+), 107 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 36a1e5c954b..0c97b009b88 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -23,7 +23,7 @@ #new>ul>li>p { cursor:pointer; } #new>ul>li>form>input { padding:0.3em; margin:-0.3em; } -#upload { +#upload { height:27px; padding:0; margin-left:0.2em; overflow:hidden; } #upload a { @@ -35,7 +35,7 @@ } .file_upload_target { display:none; } .file_upload_form { display:inline; float:left; margin:0; padding:0; cursor:pointer; overflow:visible; } -#file_upload_start { +#file_upload_start { left:0; top:0; width:28px; height:27px; padding:0; font-size:1em; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter:alpha(opacity=0); opacity:0; diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 80b9c01f838..f5ee363a4c8 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -70,23 +70,23 @@ var FileActions = { } parent.children('a.name').append(''); var defaultAction = FileActions.getDefault(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions()); - + var actionHandler = function (event) { event.stopPropagation(); event.preventDefault(); FileActions.currentFile = event.data.elem; var file = FileActions.getCurrentFile(); - + event.data.actionFunc(file); }; - + $.each(actions, function (name, action) { // NOTE: Temporary fix to prevent rename action in root of Shared directory if (name === 'Rename' && $('#dir').val() === '/Shared') { return true; } - + if ((name === 'Download' || action !== defaultAction) && name !== 'Delete') { var img = FileActions.icons[name]; if (img.call) { @@ -97,16 +97,16 @@ var FileActions = { html += ' '; } html += t('files', name) + ''; - + var element = $(html); element.data('action', name); //alert(element); element.on('click',{a:null, elem:parent, actionFunc:actions[name]},actionHandler); parent.find('a.name>span.fileactions').append(element); } - + }); - + if (actions['Delete']) { var img = FileActions.icons['Delete']; if (img.call) { diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a4260c43285..3a4af6416e9 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -52,7 +52,7 @@ Files={ } }; $(document).ready(function() { - Files.bindKeyboardShortcuts(document, jQuery); + Files.bindKeyboardShortcuts(document, jQuery); $('#fileList tr').each(function(){ //little hack to set unescape filenames in attribute $(this).attr('data-file',decodeURIComponent($(this).attr('data-file'))); diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 235ade06db6..e5ef4eb097c 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -108,7 +108,7 @@ class OC_Filestorage_AmazonS3 extends OC_Filestorage_Common { $stat['atime'] = time(); $stat['mtime'] = $stat['atime']; $stat['ctime'] = $stat['atime']; - } else { + } else { $object = $this->getObject($path); if ($object) { $stat['size'] = $object['Size']; diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 1be544fbc07..fd3dc2ca0d0 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -38,7 +38,7 @@ class OC_Mount_Config { * @return array */ public static function getBackends() { - + $backends['OC_Filestorage_Local']=array( 'backend' => 'Local', 'configuration' => array( @@ -77,7 +77,7 @@ class OC_Mount_Config { 'token' => '#token', 'token_secret' => '#token secret'), 'custom' => 'google'); - + $backends['OC_Filestorage_SWIFT']=array( 'backend' => 'OpenStack Swift', 'configuration' => array( @@ -86,7 +86,7 @@ class OC_Mount_Config { 'token' => '*Token', 'root' => '&Root', 'secure' => '!Secure ftps://')); - + if(OC_Mount_Config::checksmbclient()) $backends['OC_Filestorage_SMB']=array( 'backend' => 'SMB / CIFS', 'configuration' => array( @@ -95,7 +95,7 @@ class OC_Mount_Config { 'password' => '*Password', 'share' => 'Share', 'root' => '&Root')); - + $backends['OC_Filestorage_DAV']=array( 'backend' => 'ownCloud / WebDAV', 'configuration' => array( @@ -103,7 +103,7 @@ class OC_Mount_Config { 'user' => 'Username', 'password' => '*Password', 'root' => '&Root', - 'secure' => '!Secure https://')); + 'secure' => '!Secure https://')); return($backends); } @@ -403,7 +403,7 @@ class OC_Mount_Config { } /** - * check if smbclient is installed + * check if smbclient is installed */ public static function checksmbclient() { if(function_exists('shell_exec')) { @@ -415,7 +415,7 @@ class OC_Mount_Config { } /** - * check if php-ftp is installed + * check if php-ftp is installed */ public static function checkphpftp() { if(function_exists('ftp_login')) { diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index ebfcbfdc42f..78ca1c87fee 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -47,7 +47,7 @@ class="remove" style="visibility:hidden;" - ><?php echo $l->t('Delete'); ?>><?php echo $l->t('Delete'); ?> diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js index 8a546d62163..a46d0179801 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -1,7 +1,7 @@ $(document).ready(function() { if (typeof OC.Share !== 'undefined' && typeof FileActions !== 'undefined' && !publicListView) { - + FileActions.register('all', 'Share', OC.PERMISSION_READ, OC.imagePath('core', 'actions/share'), function(filename) { if ($('#dir').val() == '/') { var item = $('#dir').val() + filename; diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index 487b9e79961..efd977a1b6a 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -66,12 +66,12 @@ if (isset($_GET['t'])) { $type = $linkItem['item_type']; $fileSource = $linkItem['file_source']; $shareOwner = $linkItem['uid_owner']; - + if (OCP\User::userExists($shareOwner) && $fileSource != -1 ) { - + $pathAndUser = getPathAndUser($linkItem['file_source']); $fileOwner = $pathAndUser['user']; - + //if this is a reshare check the file owner also exists if ($shareOwner != $fileOwner && ! OCP\User::userExists($fileOwner)) { OCP\Util::writeLog('share', 'original file owner '.$fileOwner @@ -81,7 +81,7 @@ if (isset($_GET['t'])) { $tmpl->printPage(); exit(); } - + //mount filesystem of file owner OC_Util::setupFS($fileOwner); } @@ -104,7 +104,7 @@ if (isset($_GET['t'])) { } } $shareOwner = substr($path, 1, strpos($path, '/', 1) - 1); - + if (OCP\User::userExists($shareOwner)) { OC_Util::setupFS($shareOwner); $fileSource = getId($path); @@ -159,7 +159,7 @@ if ($linkItem) { $tmpl->printPage(); exit(); } - + } else { // Check if item id is set in session if (!isset($_SESSION['public_link_authenticated']) diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php index 9839dafbce1..8f057cfb6e8 100644 --- a/lib/MDB2/Driver/sqlite3.php +++ b/lib/MDB2/Driver/sqlite3.php @@ -98,7 +98,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common if ($this->connection) { $native_code = $this->connection->lastErrorCode(); } - $native_msg = html_entity_decode($this->_lasterror); + $native_msg = html_entity_decode($this->_lasterror); // PHP 5.2+ prepends the function name to $php_errormsg, so we need // this hack to work around it, per bug #9599. diff --git a/lib/api.php b/lib/api.php index c464cd04913..8d728d4311f 100644 --- a/lib/api.php +++ b/lib/api.php @@ -42,12 +42,12 @@ class OC_API { private static function init() { self::$server = new OC_OAuth_Server(new OC_OAuth_Store()); } - + /** * api actions */ protected static $actions = array(); - + /** * registers an api call * @param string $method the http method @@ -58,7 +58,7 @@ class OC_API { * @param array $defaults * @param array $requirements */ - public static function register($method, $url, $action, $app, + public static function register($method, $url, $action, $app, $authLevel = OC_API::USER_AUTH, $defaults = array(), $requirements = array()) { @@ -73,7 +73,7 @@ class OC_API { } self::$actions[$name] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel); } - + /** * handles an api call * @param array $parameters @@ -92,7 +92,7 @@ class OC_API { $response = call_user_func(self::$actions[$name]['action'], $parameters); } else { $response = new OC_OCS_Result(null, 998, 'Api method not found'); - } + } } else { $response = new OC_OCS_Result(null, 997, 'Unauthorised'); } @@ -103,7 +103,7 @@ class OC_API { // logout the user to be stateless OC_User::logout(); } - + /** * authenticate the api call * @param array $action the action details as supplied to OC_API::register() @@ -148,18 +148,18 @@ class OC_API { return false; break; } - } - + } + /** * http basic auth * @return string|false (username, or false on failure) */ - private static function loginUser(){ + private static function loginUser(){ $authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : ''; $authPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : ''; return OC_User::login($authUser, $authPw) ? $authUser : false; } - + /** * respond to a call * @param int|array $result the result from the api method @@ -195,5 +195,5 @@ class OC_API { } } } - + } diff --git a/lib/app.php b/lib/app.php index 3b039733fe5..410cb4c12fc 100644 --- a/lib/app.php +++ b/lib/app.php @@ -137,7 +137,7 @@ class OC_App{ OC_Appconfig::setValue($app, 'types', $appTypes); } - + /** * check if app is shipped * @param string $appid the id of the app to check diff --git a/lib/backgroundjob.php b/lib/backgroundjob.php index 28b5ce3af20..9619dcb732c 100644 --- a/lib/backgroundjob.php +++ b/lib/backgroundjob.php @@ -34,7 +34,7 @@ class OC_BackgroundJob{ public static function getExecutionType() { return OC_Appconfig::getValue( 'core', 'backgroundjobs_mode', 'ajax' ); } - + /** * @brief sets the background jobs execution type * @param $type execution type diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 52350072fb2..026ec9f7ec5 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -176,9 +176,9 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @brief Returns a list of properties for this nodes.; * @param array $properties * @return array - * @note The properties list is a list of propertynames the client - * requested, encoded as xmlnamespace#tagName, for example: - * http://www.example.org/namespace#author If the array is empty, all + * @note The properties list is a list of propertynames the client + * requested, encoded as xmlnamespace#tagName, for example: + * http://www.example.org/namespace#author If the array is empty, all * properties should be returned */ public function getProperties($properties) { diff --git a/lib/filecache.php b/lib/filecache.php index c3256c783e6..bde70757d31 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -59,7 +59,7 @@ class OC_FileCache{ * @param string $path * @param array data * @param string root (optional) - * @note $data is an associative array in the same format as returned + * @note $data is an associative array in the same format as returned * by get */ public static function put($path, $data, $root=false) { @@ -206,7 +206,7 @@ class OC_FileCache{ OC_Cache::remove('fileid/'.$root.$path); } - + /** * return array of filenames matching the querty * @param string $query diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index 742e02d471b..503288142aa 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -76,7 +76,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{ $usedSpace=isset($sharedInfo['size'])?$usedSpace-$sharedInfo['size']:$usedSpace; return $totalSpace-$usedSpace; } - + public function postFree_space($path, $space) { $free=$this->getFreeSpace($path); if($free==-1) { diff --git a/lib/files.php b/lib/files.php index 69097e41074..f4e0f140a44 100644 --- a/lib/files.php +++ b/lib/files.php @@ -141,7 +141,7 @@ class OC_Files { */ public static function get($dir, $files, $only_header = false) { $xsendfile = false; - if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || + if (isset($_SERVER['MOD_X_SENDFILE_ENABLED']) || isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) { $xsendfile = true; } diff --git a/lib/filesystem.php b/lib/filesystem.php index aa03593908d..f185d777def 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -179,11 +179,11 @@ class OC_Filesystem{ $internalPath=substr($path, strlen($mountPoint)); return $internalPath; } - + static private function mountPointsLoaded($user) { return in_array($user, self::$loadedUsers); } - + /** * get the storage object for a path * @param string path @@ -216,7 +216,7 @@ class OC_Filesystem{ self::mount($options['class'], $options['options'], $mountPoint); } } - + if(isset($mountConfig['group'])) { foreach($mountConfig['group'] as $group=>$mounts) { if(OC_Group::inGroup($user, $group)) { @@ -230,7 +230,7 @@ class OC_Filesystem{ } } } - + if(isset($mountConfig['user'])) { foreach($mountConfig['user'] as $mountUser=>$mounts) { if($user==='all' or strtolower($mountUser)===strtolower($user)) { @@ -244,16 +244,16 @@ class OC_Filesystem{ } } } - + $mtime=filemtime(OC::$SERVERROOT.'/config/mount.php'); $previousMTime=OC_Appconfig::getValue('files', 'mountconfigmtime', 0); if($mtime>$previousMTime) {//mount config has changed, filecache needs to be updated OC_FileCache::triggerUpdate(); OC_Appconfig::setValue('files', 'mountconfigmtime', $mtime); } - } + } } - + static public function init($root, $user = '') { if(self::$defaultInstance) { return false; diff --git a/lib/filesystemview.php b/lib/filesystemview.php index e944ae5045d..ea9cbecee0e 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -430,10 +430,10 @@ class OC_FilesystemView { $target = $this->fopen($path2.$postFix2, 'w'); $result = OC_Helper::streamCopy($source, $target); } - if( $this->fakeRoot==OC_Filesystem::getRoot() ) { - // If the file to be copied originates within + if( $this->fakeRoot==OC_Filesystem::getRoot() ) { + // If the file to be copied originates within // the user's data directory - + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_copy, @@ -454,33 +454,33 @@ class OC_FilesystemView { OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path2) ); - - } else { - // If this is not a normal file copy operation - // and the file originates somewhere else - // (e.g. a version rollback operation), do not + + } else { + // If this is not a normal file copy operation + // and the file originates somewhere else + // (e.g. a version rollback operation), do not // perform all the other post_write actions - + // Update webdav properties OC_Filesystem::removeETagHook(array("path" => $path2), $this->fakeRoot); - + $splitPath2 = explode( '/', $path2 ); - - // Only cache information about files - // that are being copied from within - // the user files directory. Caching + + // Only cache information about files + // that are being copied from within + // the user files directory. Caching // other files, like VCS backup files, // serves no purpose if ( $splitPath2[1] == 'files' ) { - + OC_FileCache_Update::update($path2, $this->fakeRoot); - + } - + } - + return $result; - + } } } diff --git a/lib/helper.php b/lib/helper.php index 7f34d895821..5d7e3fa4894 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -553,7 +553,7 @@ class OC_Helper { fclose($fh); return $file; } - + /** * create a temporary folder with an unique filename * @return string diff --git a/lib/image.php b/lib/image.php index 2043a452541..cfc6d477395 100644 --- a/lib/image.php +++ b/lib/image.php @@ -646,7 +646,7 @@ class OC_Image { fclose($fh); return $im; } - + /** * @brief Resizes the image preserving ratio. * @param $maxsize The maximum size of either the width or height. diff --git a/lib/json.php b/lib/json.php index c87de3e200b..f929e958957 100644 --- a/lib/json.php +++ b/lib/json.php @@ -74,7 +74,7 @@ class OC_JSON{ exit(); } } - + /** * Send json error msg */ diff --git a/lib/log.php b/lib/log.php index e9cededa5c0..e869282e88c 100644 --- a/lib/log.php +++ b/lib/log.php @@ -39,7 +39,7 @@ class OC_Log { $log_class::write($app, $message, $level); } } - + //Fatal errors handler public static function onShutdown() { $error = error_get_last(); @@ -50,7 +50,7 @@ class OC_Log { return true; } } - + // Uncaught exception handler public static function onException($exception) { self::write('PHP', $exception->getMessage() . ' at ' . $exception->getFile() . '#' . $exception->getLine(), self::FATAL); diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php index faafe9a62dd..2d18b1db3f2 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -37,7 +37,7 @@ class OC_OCS_Cloud { } return new OC_OCS_Result($values); } - + public static function getUserQuota($parameters) { $user = OC_User::getUser(); if(OC_User::isAdminUser($user) or ($user==$parameters['user'])) { @@ -68,7 +68,7 @@ class OC_OCS_Cloud { return new OC_OCS_Result(null, 300); } } - + public static function getUserPublickey($parameters) { if(OC_User::userExists($parameters['user'])) { @@ -79,7 +79,7 @@ class OC_OCS_Cloud { return new OC_OCS_Result(null, 300); } } - + public static function getUserPrivatekey($parameters) { $user = OC_User::getUser(); if(OC_User::isAdminUser($user) or ($user==$parameters['user'])) { diff --git a/lib/ocs/config.php b/lib/ocs/config.php index 03c54aa2314..f19121f4b2b 100644 --- a/lib/ocs/config.php +++ b/lib/ocs/config.php @@ -23,7 +23,7 @@ */ class OC_OCS_Config { - + public static function apiConfig($parameters) { $xml['version'] = '1.7'; $xml['website'] = 'ownCloud'; @@ -32,5 +32,5 @@ class OC_OCS_Config { $xml['ssl'] = 'false'; return new OC_OCS_Result($xml); } - + } diff --git a/lib/ocs/person.php b/lib/ocs/person.php index 169cc8211db..1c8210d0825 100644 --- a/lib/ocs/person.php +++ b/lib/ocs/person.php @@ -38,5 +38,5 @@ class OC_OCS_Person { return new OC_OCS_Result(null, 101); } } - + } diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php index e01ed5e8b07..311b24269dd 100644 --- a/lib/ocs/privatedata.php +++ b/lib/ocs/privatedata.php @@ -39,7 +39,7 @@ class OC_OCS_Privatedata { return new OC_OCS_Result($xml); //TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it } - + public static function set($parameters) { OC_Util::checkLoggedIn(); $user = OC_User::getUser(); @@ -50,7 +50,7 @@ class OC_OCS_Privatedata { return new OC_OCS_Result(null, 100); } } - + public static function delete($parameters) { OC_Util::checkLoggedIn(); $user = OC_User::getUser(); diff --git a/lib/ocs/result.php b/lib/ocs/result.php index b08d911f785..65b2067fc3f 100644 --- a/lib/ocs/result.php +++ b/lib/ocs/result.php @@ -21,9 +21,9 @@ */ class OC_OCS_Result{ - + private $data, $message, $statusCode, $items, $perPage; - + /** * create the OCS_Result object * @param $data mixed the data to return @@ -33,7 +33,7 @@ class OC_OCS_Result{ $this->statusCode = $code; $this->message = $message; } - + /** * optionally set the total number of items available * @param $items int @@ -41,7 +41,7 @@ class OC_OCS_Result{ public function setTotalItems(int $items) { $this->items = $items; } - + /** * optionally set the the number of items per page * @param $items int @@ -49,7 +49,7 @@ class OC_OCS_Result{ public function setItemsPerPage(int $items) { $this->perPage = $items; } - + /** * returns the data associated with the api result * @return array @@ -70,6 +70,6 @@ class OC_OCS_Result{ // Return the result data. return $return; } - - + + } \ No newline at end of file diff --git a/lib/public/constants.php b/lib/public/constants.php index bc979c9031f..1495c620dc9 100644 --- a/lib/public/constants.php +++ b/lib/public/constants.php @@ -35,4 +35,3 @@ const PERMISSION_UPDATE = 2; const PERMISSION_DELETE = 8; const PERMISSION_SHARE = 16; const PERMISSION_ALL = 31; - diff --git a/lib/public/db.php b/lib/public/db.php index 5d4aadd22ae..932e79d9ef1 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -49,9 +49,9 @@ class DB { * @brief Insert a row if a matching row doesn't exists. * @param $table string The table name (will replace *PREFIX*) to perform the replace on. * @param $input array - * + * * The input array if in the form: - * + * * array ( 'id' => array ( 'value' => 6, * 'key' => true * ), @@ -65,7 +65,7 @@ class DB { public static function insertIfNotExist($table, $input) { return(\OC_DB::insertIfNotExist($table, $input)); } - + /** * @brief gets last value of autoincrement * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix diff --git a/lib/public/share.php b/lib/public/share.php index 7ed1c42490d..cda583aa073 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -351,14 +351,14 @@ class Share { //delete the old share self::delete($checkExists['id']); } - + // Generate hash of password - same method as user passwords if (isset($shareWith)) { $forcePortable = (CRYPT_BLOWFISH != 1); $hasher = new \PasswordHash(8, $forcePortable); $shareWith = $hasher->HashPassword($shareWith.\OC_Config::getValue('passwordsalt', '')); } - + // Generate token if (isset($oldToken)) { $token = $oldToken; @@ -415,7 +415,7 @@ class Share { if ($parentFolder && $files = \OC_Files::getDirectoryContent($itemSource)) { for ($i = 0; $i < count($files); $i++) { $name = substr($files[$i]['name'], strpos($files[$i]['name'], $itemSource) - strlen($itemSource)); - if ($files[$i]['mimetype'] == 'httpd/unix-directory' + if ($files[$i]['mimetype'] == 'httpd/unix-directory' && $children = \OC_Files::getDirectoryContent($name, '/') ) { // Continue scanning into child folders @@ -864,7 +864,7 @@ class Share { } } else { if ($fileDependent) { - if (($itemType == 'file' || $itemType == 'folder') + if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT ) { diff --git a/lib/public/user.php b/lib/public/user.php index e297b716dc2..204d8e4c0f1 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -65,7 +65,7 @@ class User { /** * @brief check if a user exists * @param string $uid the username - * @param string $excludingBackend (default none) + * @param string $excludingBackend (default none) * @return boolean */ public static function userExists( $uid, $excludingBackend = null ) { diff --git a/lib/request.php b/lib/request.php index 99a77e1b59e..f2f15c21103 100755 --- a/lib/request.php +++ b/lib/request.php @@ -19,7 +19,7 @@ class OC_Request { return 'localhost'; } if(OC_Config::getValue('overwritehost', '')<>'') { - return OC_Config::getValue('overwritehost'); + return OC_Config::getValue('overwritehost'); } if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { if (strpos($_SERVER['HTTP_X_FORWARDED_HOST'], ",") !== false) { @@ -44,7 +44,7 @@ class OC_Request { */ public static function serverProtocol() { if(OC_Config::getValue('overwriteprotocol', '')<>'') { - return OC_Config::getValue('overwriteprotocol'); + return OC_Config::getValue('overwriteprotocol'); } if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { $proto = strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']); diff --git a/lib/setup.php b/lib/setup.php index fdd10be6824..b88bc4b52ce 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -153,7 +153,7 @@ class OC_Setup { if (isset($_SERVER['SERVER_SOFTWARE']) && strstr($_SERVER['SERVER_SOFTWARE'], 'Apache')) { self::createHtaccess(); } - + //and we are done OC_Config::setValue('installed', true); } diff --git a/lib/vcategories.php b/lib/vcategories.php index 406a4eb1074..1700870f91f 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -763,4 +763,3 @@ class OC_VCategories { return array_search(strtolower($needle), array_map('strtolower', $haystack)); } } - -- cgit v1.2.3 From 5ff29b4348a1dcb9ed32273133b1c787aaf5c72c Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 18 Jan 2013 20:09:03 +0100 Subject: fixing indent --- apps/files/ajax/delete.php | 12 ++++++------ apps/files/ajax/upload.php | 36 ++++++++++++++++++------------------ apps/files/js/files.js | 46 +++++++++++++++++++++++----------------------- lib/helper.php | 32 ++++++++++++++++---------------- lib/public/util.php | 20 ++++++++++---------- 5 files changed, 73 insertions(+), 73 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php index bb1f3fff87b..293543c547f 100644 --- a/apps/files/ajax/delete.php +++ b/apps/files/ajax/delete.php @@ -29,12 +29,12 @@ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; if($success) { OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files, - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } else { OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError, - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); } diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 35463095988..93398019608 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -18,9 +18,9 @@ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; if (!isset($_FILES['files'])) { OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } @@ -38,9 +38,9 @@ foreach ($_FILES['files']['error'] as $error) { UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'), ); OCP\JSON::error(array('data' => array( 'message' => $errors[$error], - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ))); exit(); } } @@ -55,8 +55,8 @@ foreach($files['size'] as $size) { } if($totalSize>OC_Filesystem::free_space($dir)) { OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize))); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize))); exit(); } @@ -70,19 +70,19 @@ if(strpos($dir, '..') === false) { if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) { $meta = OC_FileCache::get($target); $id = OC_FileCache::getId($target); - // updated max file size after upload - $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); - $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); - $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; + // updated max file size after upload + $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); + $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize); + $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize; - $result[]=array( 'status' => 'success', + $result[]=array( 'status' => 'success', 'mime'=>$meta['mimetype'], 'size'=>$meta['size'], 'id'=>$id, 'name'=>basename($target), - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize - ); + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize + ); } } OCP\JSON::encodedPrint($result); @@ -92,6 +92,6 @@ if(strpos($dir, '..') === false) { } OCP\JSON::error(array('data' => array('message' => $error, - 'uploadMaxFilesize'=>$maxUploadFilesize, - 'maxHumanFilesize'=>$maxHumanFilesize + 'uploadMaxFilesize'=>$maxUploadFilesize, + 'maxHumanFilesize'=>$maxHumanFilesize ))); diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 440aeeaf6a6..a4836e6c504 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -26,23 +26,23 @@ Files={ }); procesSelection(); }, - updateMaxUploadFilesize:function(response) { - if(response == undefined) { - return; - } - if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { - $('#max_upload').val(response.data.uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); - } - if(response[0] == undefined) { - return; - } - if(response[0].uploadMaxFilesize !== undefined) { - $('#max_upload').val(response[0].uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); - } - - }, + updateMaxUploadFilesize:function(response) { + if(response == undefined) { + return; + } + if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { + $('#max_upload').val(response.data.uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + } + if(response[0] == undefined) { + return; + } + if(response[0].uploadMaxFilesize !== undefined) { + $('#max_upload').val(response[0].uploadMaxFilesize); + $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + } + + }, isFileNameValid:function (name) { if (name === '.') { $('#notification').text(t('files', '\'.\' is an invalid file name.')); @@ -333,7 +333,7 @@ $(document).ready(function() { $('#notification').text(t('files', response.data.message)); $('#notification').fadeIn(); } - Files.updateMaxUploadFilesize(response); + Files.updateMaxUploadFilesize(response); var file=response[0]; // TODO: this doesn't work if the file name has been changed server side delete uploadingFiles[dirName][file.name]; @@ -386,9 +386,9 @@ $(document).ready(function() { .success(function(result, textStatus, jqXHR) { var response; response=jQuery.parseJSON(result); - Files.updateMaxUploadFilesize(response); + Files.updateMaxUploadFilesize(response); - if(response[0] != undefined && response[0].status == 'success') { + 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).data('id',file.id); @@ -421,8 +421,8 @@ $(document).ready(function() { data.submit().success(function(data, status) { // in safari data is a string response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText); - Files.updateMaxUploadFilesize(response); - if(response[0] != undefined && response[0].status == 'success') { + Files.updateMaxUploadFilesize(response); + 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).data('id',file.id); @@ -787,7 +787,7 @@ scanFiles.scanning=false; function boolOperationFinished(data, callback) { result = jQuery.parseJSON(data.responseText); - Files.updateMaxUploadFilesize(result); + Files.updateMaxUploadFilesize(result); if(result.status == 'success'){ callback.call(); } else { diff --git a/lib/helper.php b/lib/helper.php index eb07550d229..f19ab529bfe 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -695,8 +695,8 @@ class OC_Helper { $start = intval($start); $length = intval($length); $string = mb_substr($string, 0, $start, $encoding) . - $replacement . - mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding); + $replacement . + mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding); return $string; } @@ -764,22 +764,22 @@ class OC_Helper { return $str; } - /** - * @brief calculates the maximum upload size respecting system settings, free space and user quota - * - * @param $dir the current folder where the user currently operates - * @return number of bytes representing - */ - public static function maxUploadFilesize($dir) { - $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); - $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); - $maxUploadFilesize = min($upload_max_filesize, $post_max_size); + /** + * @brief calculates the maximum upload size respecting system settings, free space and user quota + * + * @param $dir the current folder where the user currently operates + * @return number of bytes representing + */ + public static function maxUploadFilesize($dir) { + $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); + $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); + $maxUploadFilesize = min($upload_max_filesize, $post_max_size); - $freeSpace = OC_Filesystem::free_space($dir); - $freeSpace = max($freeSpace, 0); + $freeSpace = OC_Filesystem::free_space($dir); + $freeSpace = max($freeSpace, 0); - return min($maxUploadFilesize, $freeSpace); - } + return min($maxUploadFilesize, $freeSpace); + } /** * Checks if a function is available diff --git a/lib/public/util.php b/lib/public/util.php index 2dcf11faa75..c4ac2715f31 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -203,7 +203,7 @@ class Util { $host_name = self::getServerHostName(); // handle localhost installations if ($host_name === 'localhost') { - $host_name = "example.com"; + $host_name = "example.com"; } return $user_part.'@'.$host_name; } @@ -368,13 +368,13 @@ class Util { return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index)); } - /** - * @brief calculates the maximum upload size respecting system settings, free space and user quota - * - * @param $dir the current folder where the user currently operates - * @return number of bytes representing - */ - public static function maxUploadFilesize($dir) { - return \OC_Helper::maxUploadFilesize($dir); - } + /** + * @brief calculates the maximum upload size respecting system settings, free space and user quota + * + * @param $dir the current folder where the user currently operates + * @return number of bytes representing + */ + public static function maxUploadFilesize($dir) { + return \OC_Helper::maxUploadFilesize($dir); + } } -- cgit v1.2.3 From ad57db3e876b9fb7831ccd43a60815d88ef9a45f Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 18 Jan 2013 22:35:26 +0100 Subject: Make the message friendlier --- apps/files/js/files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 3a4af6416e9..f8d276a079d 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -184,7 +184,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - $('#notification').text(t('files','generating ZIP-file, it may take some time.')); + $('#notification').text(t('files','Your download is being prepared. Thanks for your patience.')); $('#notification').fadeIn(); // use special download URL if provided, e.g. for public shared files if ( (downloadURL = document.getElementById("downloadURL")) ) { -- cgit v1.2.3 From 1dd70ac506982d230d18059ba3626ef2a92664fd Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sat, 19 Jan 2013 00:31:49 +0100 Subject: update used space percent after each ajax call and display the notification --- apps/files/js/files.js | 12 ++++++++++-- core/js/js.js | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index f4d572b6954..843c6e3fc4a 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -32,14 +32,18 @@ Files={ } if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) { $('#max_upload').val(response.data.uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize); + $('#upload.button').attr('original-title', response.data.maxHumanFilesize); + $('#usedSpacePercent').val(response.data.usedSpacePercent); + Files.displayStorageWarnings(); } if(response[0] == undefined) { return; } if(response[0].uploadMaxFilesize !== undefined) { $('#max_upload').val(response[0].uploadMaxFilesize); - $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize); + $('#upload.button').attr('original-title', response[0].maxHumanFilesize); + $('#usedSpacePercent').val(response[0].usedSpacePercent); + Files.displayStorageWarnings(); } }, @@ -65,6 +69,10 @@ Files={ return true; }, displayStorageWarnings: function() { + if (!OC.Notification.isHidden()) { + return; + } + var usedSpacePercent = $('#usedSpacePercent').val(); if (usedSpacePercent > 98) { OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); diff --git a/core/js/js.js b/core/js/js.js index 3160159e287..2daf63af9d8 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -297,7 +297,7 @@ OC.Notification={ hide: function(callback) { $("#notification").text(''); $('#notification').fadeOut('400', function(){ - if ($("#notification").text() === '') { + if (OC.Notification.isHidden()) { if (OC.Notification.getDefaultNotificationFunction) { OC.Notification.getDefaultNotificationFunction.call(); } @@ -318,7 +318,10 @@ OC.Notification={ notification.hide(); notification.text(text); notification.fadeIn().css("display","inline"); - } + }, + isHidden: function() { + return ($("#notification").text() === ''); + } }; OC.Breadcrumb={ -- cgit v1.2.3 From 02bd8dd45a66a8ed0323af56fcafd44df2babd7e Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Sat, 19 Jan 2013 13:12:27 +0100 Subject: Change the second part of the notification --- apps/files/js/files.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index f8d276a079d..b58ff4b65ff 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -184,7 +184,7 @@ $(document).ready(function() { $('.download').click('click',function(event) { var files=getSelectedFiles('name').join(';'); var dir=$('#dir').val()||'/'; - $('#notification').text(t('files','Your download is being prepared. Thanks for your patience.')); + $('#notification').text(t('files','Your download is being prepared. This might take some time if the files are big.')); $('#notification').fadeIn(); // use special download URL if provided, e.g. for public shared files if ( (downloadURL = document.getElementById("downloadURL")) ) { -- cgit v1.2.3 From 5d6c1d52bdb5aa3addc26d1e105749a8eda35301 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sat, 19 Jan 2013 21:37:05 +0100 Subject: replace #notification with OC.Notification call --- apps/files/js/files.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'apps/files/js/files.js') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index ce5a8096bf9..6486468eafd 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -563,8 +563,7 @@ $(document).ready(function() { event.preventDefault(); var newname=input.val(); if(type == 'web' && newname.length == 0) { - $('#notification').text(t('files', 'URL cannot be empty.')); - $('#notification').fadeIn(); + OC.Notification.show(t('files', 'URL cannot be empty.')); return false; } else if (type != 'web' && !Files.isFileNameValid(newname)) { return false; -- cgit v1.2.3