B2G/gaia/apps/system/js/storage_watcher.js
/**
   * Helper function to format the value returned by the
   * nsIDOMDeviceStorage.freeSpace call in a more readable way.
   */
Helper function to format the value returned by the
nsIDOMDeviceStorage.freeSpace call in a more readable way.
Helper function to format the value returned by the nsIDOMDeviceStorage . freeSpace call in a more readable way .
function dsw_formatSize(size) {
    if (size === undefined || isNaN(size)) {
      return;
    }
    var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
    var i = 0;
    while (size >= 1024 && i < units.length) {
      size /= 1024;
      ++i;
    }
    var sizeString = size.toFixed((size < 1024 * 1024) ? 0 : 1);
    var sizeDecimal = parseFloat(sizeString);
    return {
      size: sizeDecimal,
      unit: this._('byteUnit-' + units[i])
    };
  }
function dsw_formatSize ( size ) { if ( size === undefined || isNaN ( size ) ) { return ; } var units = [ 'B' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ] ; var i = 0 ; while ( size >= 1024 && i < units . length ) { size /= 1024 ; ++ i ; } var sizeString = size . toFixed ( ( size < 1024 * 1024 ) ? 0 : 1 ) ; var sizeDecimal = parseFloat ( sizeString ) ; return { size : sizeDecimal , unit : this . _ ( 'byteUnit-' + units [ i ] ) } ; }
Helper function to format the value returned by the
 nsIDOMDeviceStorage.freeSpace call in a more readable way.
Helper function to format the value returned by the nsIDOMDeviceStorage . freeSpace call in a more readable way .