display the speed in the title bar

This commit is contained in:
Damien Churchill 2010-03-09 22:48:33 +00:00
parent c6da126f55
commit 38802245b6
2 changed files with 14 additions and 4 deletions

View File

@ -64,10 +64,11 @@ Deluge.Formatters = {
* Formats the bytes value into a string with KiB, MiB or GiB units.
*
* @param {Number} bytes the filesize in bytes
* @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with KiB, MiB or GiB units.
*/
size: function(bytes) {
if (!bytes) return '';
size: function(bytes, showZero) {
if (!bytes && !showZero) return '';
bytes = bytes / 1024.0;
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; }
@ -83,10 +84,11 @@ Deluge.Formatters = {
* Formats a string to display a transfer speed utilizing {@link #size}
*
* @param {Number} bits the number of bits per second
* @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with KiB, MiB or GiB units.
*/
speed: function(bits) {
return (!bits) ? '' : fsize(bits) + '/s';
speed: function(bits, showZero) {
return (!bits && !showZero) ? '' : fsize(bits, showZero) + '/s';
},
/**

View File

@ -87,6 +87,8 @@ Deluge.UI = {
}, this, {single: true});
this.update = this.update.createDelegate(this);
this.originalTitle = document.title;
},
update: function() {
@ -118,6 +120,12 @@ Deluge.UI = {
*/
onUpdate: function(data) {
if (!data['connected']) Deluge.Events.fire('disconnect');
if (Deluge.config.show_session_speed) {
document.title = this.originalTitle +
' (Down: ' + fspeed(data['stats'].download_rate, true) +
' Up: ' + fspeed(data['stats'].upload_rate, true) + ')';
}
Deluge.Torrents.update(data['torrents']);
Deluge.Statusbar.update(data['stats']);
Deluge.Sidebar.update(data['filters']);