]> source.dussan.org Git - nextcloud-server.git/commitdiff
introducing simple file size, only MB as unit, details on hover
authorJan-Christoph Borchardt <JanCBorchardt@fsfe.org>
Wed, 6 Jul 2011 23:27:16 +0000 (01:27 +0200)
committerJan-Christoph Borchardt <JanCBorchardt@fsfe.org>
Wed, 6 Jul 2011 23:27:16 +0000 (01:27 +0200)
files/js/files.js
files/templates/index.php
files/templates/part.list.php
lib/template.php

index b491b90275c595423751ce4c3d67147a54283c1c..2434fceff4334f1d5b51ac8d4044be09ee6b694d 100644 (file)
@@ -128,7 +128,7 @@ $(document).ready(function() {
        $('#file_upload_submit').click(function(){
                var name=$('#file_upload_filename').val();
                if($('#file_upload_start')[0].files[0] && $('#file_upload_start')[0].files[0].size>0){
-                       var size=humanFileSize($('#file_upload_start')[0].files[0].size);
+                       var size=simpleFileSize($('#file_upload_start')[0].files[0].size);
                }else{
                        var size='Pending';
                }
@@ -205,6 +205,14 @@ function humanFileSize(bytes){
        return bytes+' GB';
 }
 
+function simpleFileSize(bytes) {
+       mbytes = Math.round(bytes/(1024*1024),1);
+       if(bytes == 0) { return '0'; }
+       else if(mbytes < 0.1) { return '< 0.1'; }
+       else if(mbytes > 1000) { return '> 1000'; }
+       else { return mbytes.toFixed(1); }
+}
+
 function formatDate(date){
        var monthNames = [ "January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December" ];
index ee5e0900e2ce12f62d09aec5a15ed28a096d3883..b9f8c02c93b65dae4ac2567f8d1307f7e3bdf4f5 100644 (file)
@@ -32,7 +32,7 @@
                <tr>
                        <th><input type="checkbox" id="select_all" /></th>
                        <th><?php echo $l->t( 'Name' ); ?></th>
-                       <th><?php echo $l->t( 'Size' ); ?></th>
+                       <th><?php echo $l->t( 'Size (MB)' ); ?></th>
                        <th><?php echo $l->t( 'Modified' ); ?></th>
                        <th></th>
                </tr>
index 443990af34fe0c56ee8d2d20b0ff0111593711cd..fd7f3f644df375776799958d9d3022360e4a623a 100644 (file)
@@ -1,9 +1,9 @@
-               <?php foreach($_["files"] as $file): ?>
-                       <tr data-file='<?php echo $file['name'];?>' data-type='<?php echo ($file["type"] == "dir")?'dir':'file'?>' data-mime='<?php echo $file["mime"]?>'>
+               <?php foreach($_['files'] as $file): ?>
+                       <tr data-file="<?php echo $file['name'];?>" data-type="<?php echo ($file['type'] == 'dir')?'dir':'file'?>" data-mime="<?php echo $file['mime']?>">
                                <td class="selection"><input type="checkbox" /></td>
-                               <td class="filename"><a style="background-image:url(<?php if($file["type"] == "dir") echo mimetype_icon("dir"); else echo mimetype_icon($file["mime"]); ?>)" href="<?php if($file["type"] == "dir") echo link_to("files", "index.php?dir=".$file["directory"]."/".$file["name"]); else echo link_to("files", "download.php?file=".$file["directory"]."/".$file["name"]); ?>" title=""><?php if($file["type"] == "dir") echo "<strong>"; echo htmlspecialchars($file["name"]); if($file["type"] == "dir") echo "</strong>"; ?></a></td>
-                               <td class="filesize"><?php echo human_file_size($file["size"]); ?></td>
-                               <td class="date"><?php echo $file["date"]; ?></td>
-                               <td class="fileaction"><a href="" title="+" class='dropArrow'></a></td>
+                               <td class="filename"><a style="background-image:url(<?php if($file['type'] == 'dir') echo mimetype_icon('dir'); else echo mimetype_icon($file['mime']); ?>)" href="<?php if($file['type'] == 'dir') echo link_to('files', 'index.php?dir='.$file['directory'].'/'.$file['name']); else echo link_to('files', 'download.php?file='.$file['directory'].'/'.$file['name']); ?>" title=""><?php if($file['type'] == 'dir') echo "<strong>"; echo htmlspecialchars($file['name']); if($file['type'] == 'dir') echo "</strong>"; ?></a></td>
+                               <td class="filesize" title="<?php echo human_file_size($file['size']); ?>"><?php echo simple_file_size($file['size']); ?></td>
+                               <td class="date"><?php echo $file['date']; ?></td>
+                               <td class="fileaction"><a href="" title="+" class="dropArrow"></a></td>
                        </tr>
                <?php endforeach; ?>
index 9393fe6908e709de6942c979ae4bd1e1ac881a89..3c0cdf7e16198aa52748717396397439d75603bb 100644 (file)
@@ -67,6 +67,14 @@ function human_file_size( $bytes ){
        return OC_HELPER::humanFileSize( $bytes );
 }
 
+function simple_file_size($bytes) {
+       $mbytes = round($bytes/(1024*1024),1);
+       if($bytes == 0) { return '0'; }
+       else if($mbytes < 0.1) { return '< 0.1'; }
+       else if($mbytes > 1000) { return '> 1000'; }
+       else { return number_format($mbytes, 1); }
+}
+
 /**
  * This class provides the templates for owncloud.
  */