display the speed in the title bar
This commit is contained in:
parent
c6da126f55
commit
38802245b6
|
@ -64,10 +64,11 @@ Deluge.Formatters = {
|
||||||
* Formats the bytes value into a string with KiB, MiB or GiB units.
|
* Formats the bytes value into a string with KiB, MiB or GiB units.
|
||||||
*
|
*
|
||||||
* @param {Number} bytes the filesize in bytes
|
* @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.
|
* @return {String} formatted string with KiB, MiB or GiB units.
|
||||||
*/
|
*/
|
||||||
size: function(bytes) {
|
size: function(bytes, showZero) {
|
||||||
if (!bytes) return '';
|
if (!bytes && !showZero) return '';
|
||||||
bytes = bytes / 1024.0;
|
bytes = bytes / 1024.0;
|
||||||
|
|
||||||
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; }
|
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}
|
* Formats a string to display a transfer speed utilizing {@link #size}
|
||||||
*
|
*
|
||||||
* @param {Number} bits the number of bits per second
|
* @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.
|
* @return {String} formatted string with KiB, MiB or GiB units.
|
||||||
*/
|
*/
|
||||||
speed: function(bits) {
|
speed: function(bits, showZero) {
|
||||||
return (!bits) ? '' : fsize(bits) + '/s';
|
return (!bits && !showZero) ? '' : fsize(bits, showZero) + '/s';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,6 +87,8 @@ Deluge.UI = {
|
||||||
}, this, {single: true});
|
}, this, {single: true});
|
||||||
|
|
||||||
this.update = this.update.createDelegate(this);
|
this.update = this.update.createDelegate(this);
|
||||||
|
|
||||||
|
this.originalTitle = document.title;
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
|
@ -118,6 +120,12 @@ Deluge.UI = {
|
||||||
*/
|
*/
|
||||||
onUpdate: function(data) {
|
onUpdate: function(data) {
|
||||||
if (!data['connected']) Deluge.Events.fire('disconnect');
|
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.Torrents.update(data['torrents']);
|
||||||
Deluge.Statusbar.update(data['stats']);
|
Deluge.Statusbar.update(data['stats']);
|
||||||
Deluge.Sidebar.update(data['filters']);
|
Deluge.Sidebar.update(data['filters']);
|
||||||
|
|
Loading…
Reference in New Issue