diff --git a/helpers/DropboxFunctions.php b/helpers/DropboxFunctions.php index e8c52ef..3603eb2 100644 --- a/helpers/DropboxFunctions.php +++ b/helpers/DropboxFunctions.php @@ -47,7 +47,11 @@ function dropbox_dir_list($directory) foreach ($iter as $fileEntry) { if ($fileEntry->isFile()) { - $filenames[] = $fileEntry->getFilename(); + $filenames[] = array( + $fileEntry->getFilename(), + $fileEntry->getExtension(), + $fileEntry->getSize() + ); } } diff --git a/views/admin/index/dropboxlist.php b/views/admin/index/dropboxlist.php index be1c012..63dea15 100644 --- a/views/admin/index/dropboxlist.php +++ b/views/admin/index/dropboxlist.php @@ -55,7 +55,23 @@ function dropboxNoEnter(e) { jQuery('.dropbox-js').show(); jQuery('#dropbox-show-all').hide(); + + jQuery('th').click(function(){ + var table = jQuery(this).parents('table').eq(0) + var rows = table.find('tr:gt(0)').toArray().sort(comparer(jQuery(this).index())) + this.asc = !this.asc + if (!this.asc){rows = rows.reverse()} + for (var i = 0; i < rows.length; i++){table.append(rows[i])} + }) }); + + function comparer(index) { + return function(a, b) { + var valA = getCellValue(a, index), valB = getCellValue(b, index) + return jQuery.isNumeric(valA) && jQuery.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB) + } + } + function getCellValue(row, index){ return jQuery(row).children('td').eq(index).text() }