diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-07-25 20:24:59 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-07-25 20:25:53 +0200 |
commit | e03340b04dca9d0513af0f4c2257d77e4d2e2a48 (patch) | |
tree | a06f7845a56f5311d5c4e998314b7d1fa950f12f /files/js/files.js | |
parent | edec37b402e3f7afbf767c398fc6aca2670fe3d1 (diff) | |
download | nextcloud-server-e03340b04dca9d0513af0f4c2257d77e4d2e2a48.tar.gz nextcloud-server-e03340b04dca9d0513af0f4c2257d77e4d2e2a48.zip |
add getSelectedFiles() to files.js
Diffstat (limited to 'files/js/files.js')
-rw-r--r-- | files/js/files.js | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/files/js/files.js b/files/js/files.js index d4191215972..7750842dd5a 100644 --- a/files/js/files.js +++ b/files/js/files.js @@ -108,11 +108,7 @@ $(document).ready(function() { }); $('.download').live('click',function(event) { - var files=''; - $('td.selection input:checkbox:checked').parent().parent().each(function(i,element){ - files+=';'+$(element).attr('data-file'); - }); - files=files.substr(1);//remove leading ; + var files=getSelectedFiles('name').join(';'); //send the browser to the download location var dir=$('#dir').val()||'/'; @@ -122,11 +118,7 @@ $(document).ready(function() { }); $('.delete').live('click',function(event) { - var files=''; - $('td.selection input:checkbox:checked').parent().parent().each(function(i,element){ - files+=';'+$(element).attr('data-file'); - }); - files=files.substr(1);//remove leading ; + var files=getSelectedFiles('name').join(';'); $.ajax({ url: 'ajax/delete.php', @@ -282,4 +274,30 @@ var folderDropOptions={ });} }); } +} + +/** + * @brief get a list of selected files + * @param string property (option) the property of the file requested + * @return array + * + * possible values for property: name, mime + * if property is set, an array with that property for each file is returnd + * if it's ommited an array of objects with all properties is returned + */ +function getSelectedFiles(property){ + var elements=$('td.selection input:checkbox:checked').parent().parent(); + var files=[]; + elements.each(function(i,element){ + var file={ + name:$(element).attr('data-file'), + mime:$(element).attr('data-mime') + }; + if(property){ + files.push(file[property]); + }else{ + files.push(); + } + }); + return files; }
\ No newline at end of file |