(trunk web) A lot of web cleanup, refactoring, bugfixes, and probably new breakage. Filterbar/statusbar has been reworked. Added filter-by-tracker. Compact mode now works in "iPhone" mode.

This commit is contained in:
Jordan Lee
2011-08-24 02:04:35 +00:00
parent 25ca73dca5
commit 2dc746a7b6
14 changed files with 2140 additions and 2149 deletions

View File

@@ -30,8 +30,9 @@ Transmission.fmt = (function()
return {
updateUnits: function( u )
updateUnits: function(u)
{
/*
speed_K = u['speed-bytes'];
speed_K_str = u['speed-units'][0];
speed_M_str = u['speed-units'][1];
@@ -49,30 +50,31 @@ Transmission.fmt = (function()
mem_M_str = u['memory-units'][1];
mem_G_str = u['memory-units'][2];
mem_T_str = u['memory-units'][3];
*/
},
/*
* Format a percentage to a string
*/
percentString: function( x ) {
if( x < 10.0 )
return x.toTruncFixed( 2 );
else if( x < 100.0 )
return x.toTruncFixed( 1 );
percentString: function(x) {
if (x < 10.0)
return x.toTruncFixed(2);
else if (x < 100.0)
return x.toTruncFixed(1);
else
return x.toTruncFixed( 0 );
return x.toTruncFixed(0);
},
/*
* Format a ratio to a string
*/
ratioString: function( x ) {
if( x == -1 )
ratioString: function(x) {
if (x == -1)
return "None";
else if( x == -2 )
else if (x == -2)
return '&infin;';
else
return this.percentString( x );
return this.percentString(x);
},
/**
@@ -80,32 +82,32 @@ Transmission.fmt = (function()
* @param {Number} bytes the filesize in bytes
* @return {String} human-readable string
*/
mem: function( bytes )
mem: function(bytes)
{
if( bytes < mem_K )
if (bytes < mem_K)
return [ bytes, mem_B_str ].join(' ');
var convertedSize;
var unit;
if( bytes < Math.pow( mem_K, 2 ) )
if (bytes < Math.pow(mem_K, 2))
{
convertedSize = bytes / mem_K;
unit = mem_K_str;
}
else if( bytes < Math.pow( mem_K, 3 ) )
else if (bytes < Math.pow(mem_K, 3))
{
convertedSize = bytes / Math.pow( mem_K, 2 );
convertedSize = bytes / Math.pow(mem_K, 2);
unit = mem_M_str;
}
else if( bytes < Math.pow( mem_K, 4 ) )
else if (bytes < Math.pow(mem_K, 4))
{
convertedSize = bytes / Math.pow( mem_K, 3 );
convertedSize = bytes / Math.pow(mem_K, 3);
unit = mem_G_str;
}
else
{
convertedSize = bytes / Math.pow( mem_K, 4 );
convertedSize = bytes / Math.pow(mem_K, 4);
unit = mem_T_str;
}
@@ -119,32 +121,32 @@ Transmission.fmt = (function()
* @param {Number} bytes the filesize in bytes
* @return {String} human-readable string
*/
size: function( bytes )
size: function(bytes)
{
if( bytes < size_K )
if (bytes < size_K)
return [ bytes, size_B_str ].join(' ');
var convertedSize;
var unit;
if( bytes < Math.pow( size_K, 2 ) )
if (bytes < Math.pow(size_K, 2))
{
convertedSize = bytes / size_K;
unit = size_K_str;
}
else if( bytes < Math.pow( size_K, 3 ) )
else if (bytes < Math.pow(size_K, 3))
{
convertedSize = bytes / Math.pow( size_K, 2 );
convertedSize = bytes / Math.pow(size_K, 2);
unit = size_M_str;
}
else if( bytes < Math.pow( size_K, 4 ) )
else if (bytes < Math.pow(size_K, 4))
{
convertedSize = bytes / Math.pow( size_K, 3 );
convertedSize = bytes / Math.pow(size_K, 3);
unit = size_G_str;
}
else
{
convertedSize = bytes / Math.pow( size_K, 4 );
convertedSize = bytes / Math.pow(size_K, 4);
unit = size_T_str;
}
@@ -153,22 +155,22 @@ Transmission.fmt = (function()
: [ convertedSize.toTruncFixed(1), unit ].join(' ');
},
speedBps: function( Bps )
speedBps: function(Bps)
{
return this.speed( this.toKBps( Bps ) );
return this.speed(this.toKBps(Bps));
},
toKBps: function( Bps )
toKBps: function(Bps)
{
return Math.floor( Bps / speed_K );
return Math.floor(Bps / speed_K);
},
speed: function( KBps )
speed: function(KBps)
{
var speed = KBps;
if (speed <= 999.95) // 0 KBps to 999.9 K
return [ speed.toTruncFixed(1), speed_K_str ].join(' ');
if (speed <= 999.95) // 0 KBps to 999 K
return [ speed.toTruncFixed(0), speed_K_str ].join(' ');
speed /= speed_K;
@@ -182,7 +184,7 @@ Transmission.fmt = (function()
return [ speed.toTruncFixed(2), speed_G_str ].join(' ');
},
timeInterval: function( seconds )
timeInterval: function(seconds)
{
var result;
var days = Math.floor(seconds / 86400);
@@ -208,9 +210,9 @@ Transmission.fmt = (function()
return result.join(' ');
},
timestamp: function( seconds )
timestamp: function(seconds)
{
if( !seconds )
if (!seconds)
return 'N/A';
var myDate = new Date(seconds*1000);
@@ -223,11 +225,11 @@ Transmission.fmt = (function()
var sameMonth = now.getMonth() == myDate.getMonth();
var dateDiff = now.getDate() - myDate.getDate();
if(sameYear && sameMonth && Math.abs(dateDiff) <= 1){
if(dateDiff == 0){
if (sameYear && sameMonth && Math.abs(dateDiff) <= 1){
if (dateDiff == 0){
date = "Today";
}
else if(dateDiff == 1){
else if (dateDiff == 1){
date = "Yesterday";
}
else{
@@ -240,22 +242,22 @@ Transmission.fmt = (function()
var hours = myDate.getHours();
var period = "AM";
if(hours > 12){
if (hours > 12){
hours = hours - 12;
period = "PM";
}
if(hours == 0){
if (hours == 0){
hours = 12;
}
if(hours < 10){
if (hours < 10){
hours = "0" + hours;
}
var minutes = myDate.getMinutes();
if(minutes < 10){
if (minutes < 10){
minutes = "0" + minutes;
}
var seconds = myDate.getSeconds();
if(seconds < 10){
if (seconds < 10){
seconds = "0" + seconds;
}
@@ -264,7 +266,7 @@ Transmission.fmt = (function()
return [date, time, period].join(' ');
},
plural: function( i, word )
plural: function(i, word)
{
return [ i, ' ', word, (word==1?'':'s') ].join('');
}