mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk web) very minor optimizations
This commit is contained in:
parent
aadd7b9eaf
commit
d9623ef597
2 changed files with 56 additions and 56 deletions
|
@ -101,23 +101,24 @@ Torrent.prototype =
|
||||||
if ($.browser.safari)
|
if ($.browser.safari)
|
||||||
this._element.css('margin-top', '7px');
|
this._element.css('margin-top', '7px');
|
||||||
|
|
||||||
// insert the element
|
|
||||||
domParent.appendChild(top_e);
|
|
||||||
|
|
||||||
this.initializeTorrentFilesInspectorGroup();
|
this.initializeTorrentFilesInspectorGroup();
|
||||||
|
|
||||||
for( var i=0; data.files!=null && i<data.files.length; ++i ) {
|
if( data.files ) {
|
||||||
var src = data.files[i];
|
for( var i=0, row; row=data.files[i]; ++i ) {
|
||||||
this._file_model[i] = {
|
this._file_model[i] = {
|
||||||
'index': i,
|
'index': i,
|
||||||
'torrent': this,
|
'torrent': this,
|
||||||
'length': src.length,
|
'length': row.length,
|
||||||
'name': src.name
|
'name': row.name
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update all the labels etc
|
// Update all the labels etc
|
||||||
this.refresh(data);
|
this.refresh(data);
|
||||||
|
|
||||||
|
// insert the element
|
||||||
|
domParent.appendChild(top_e);
|
||||||
},
|
},
|
||||||
|
|
||||||
initializeTorrentFilesInspectorGroup: function(length) {
|
initializeTorrentFilesInspectorGroup: function(length) {
|
||||||
|
|
|
@ -79,6 +79,14 @@ Transmission.prototype =
|
||||||
this._inspector_file_list = $('#inspector_file_list')[0];
|
this._inspector_file_list = $('#inspector_file_list')[0];
|
||||||
this._inspector_tab_files = $('#inspector_tab_files')[0];
|
this._inspector_tab_files = $('#inspector_tab_files')[0];
|
||||||
this._toolbar_buttons = $('#torrent_global_menu ul li');
|
this._toolbar_buttons = $('#torrent_global_menu ul li');
|
||||||
|
this._toolbar_pause_button = $('li#pause_selected')[0];
|
||||||
|
this._toolbar_pause_all_button = $('li#pause_all')[0];
|
||||||
|
this._toolbar_start_button = $('li#resume_selected')[0];
|
||||||
|
this._toolbar_start_all_button = $('li#resume_all')[0];
|
||||||
|
this._toolbar_remove_button = $('li#remove')[0];
|
||||||
|
this._toolbar_delete_button = $('li#removedata')[0];
|
||||||
|
this._context_pause_button = $('li#context_pause_selected')[0];
|
||||||
|
this._context_start_button = $('li#context_resume_selected')[0];
|
||||||
|
|
||||||
// Setup the preference box
|
// Setup the preference box
|
||||||
this.setupPrefConstraints();
|
this.setupPrefConstraints();
|
||||||
|
@ -287,10 +295,9 @@ Transmission.prototype =
|
||||||
getVisibleTorrents: function()
|
getVisibleTorrents: function()
|
||||||
{
|
{
|
||||||
var torrents = [ ];
|
var torrents = [ ];
|
||||||
for( var i=0, len=this._rows.length; i<len; ++i )
|
for( var i=0, row; row=this._rows[i]; ++i )
|
||||||
if( this._rows[i]._torrent )
|
if( row._torrent && ( row[0].style.display != 'none' ) )
|
||||||
if( this._rows[i][0].style.display != 'none' )
|
torrents.push( row._torrent );
|
||||||
torrents.push( this._rows[i]._torrent );
|
|
||||||
return torrents;
|
return torrents;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -298,9 +305,9 @@ Transmission.prototype =
|
||||||
{
|
{
|
||||||
var v = this.getVisibleTorrents( );
|
var v = this.getVisibleTorrents( );
|
||||||
var s = [ ];
|
var s = [ ];
|
||||||
for( var i=0, len=v.length; i<len; ++i )
|
for( var i=0, row; row=v[i]; ++i )
|
||||||
if( v[i].isSelected( ) )
|
if( row.isSelected( ) )
|
||||||
s.push( v[i] );
|
s.push( row );
|
||||||
return s;
|
return s;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -318,16 +325,16 @@ Transmission.prototype =
|
||||||
getVisibleRows: function()
|
getVisibleRows: function()
|
||||||
{
|
{
|
||||||
var rows = [ ];
|
var rows = [ ];
|
||||||
for( var i=0, len=this._rows.length; i<len; ++i )
|
for( var i=0, row; row=this._rows[i]; ++i )
|
||||||
if( this._rows[i][0].style.display != 'none' )
|
if( row[0].style.display != 'none' )
|
||||||
rows.push( this._rows[i] );
|
rows.push( row );
|
||||||
return rows;
|
return rows;
|
||||||
},
|
},
|
||||||
|
|
||||||
getTorrentIndex: function( rows, torrent )
|
getTorrentIndex: function( rows, torrent )
|
||||||
{
|
{
|
||||||
for( var i=0, len=rows.length; i<len; ++i )
|
for( var i=0, row; row=rows[i]; ++i )
|
||||||
if( rows[i]._torrent == torrent )
|
if( row._torrent == torrent )
|
||||||
return i;
|
return i;
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
@ -394,15 +401,15 @@ Transmission.prototype =
|
||||||
|
|
||||||
selectAll: function( doUpdate ) {
|
selectAll: function( doUpdate ) {
|
||||||
var tr = this;
|
var tr = this;
|
||||||
for( var i=0, len=tr._rows.length; i<len; ++i )
|
for( var i=0, row; row=tr._rows[i]; ++i )
|
||||||
tr.selectElement( tr._rows[i] );
|
tr.selectElement( row );
|
||||||
if( doUpdate )
|
if( doUpdate )
|
||||||
tr.selectionChanged();
|
tr.selectionChanged();
|
||||||
},
|
},
|
||||||
deselectAll: function( doUpdate ) {
|
deselectAll: function( doUpdate ) {
|
||||||
var tr = this;
|
var tr = this;
|
||||||
for( var i=0, len=tr._rows.length; i<len; ++i )
|
for( var i=0, row; row=tr._rows[i]; ++i )
|
||||||
tr.deselectElement( tr._rows[i] );
|
tr.deselectElement( row );
|
||||||
tr._last_torrent_clicked = null;
|
tr._last_torrent_clicked = null;
|
||||||
if( doUpdate )
|
if( doUpdate )
|
||||||
tr.selectionChanged( );
|
tr.selectionChanged( );
|
||||||
|
@ -951,8 +958,7 @@ Transmission.prototype =
|
||||||
date_created = Math.formatTimestamp( t._creator_date );
|
date_created = Math.formatTimestamp( t._creator_date );
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = 0; i < torrents.length; ++i ) {
|
for( var i=0, t; t=torrents[i]; ++i ) {
|
||||||
var t = torrents[i];
|
|
||||||
sizeWhenDone += t._sizeWhenDone;
|
sizeWhenDone += t._sizeWhenDone;
|
||||||
sizeDone += t._sizeWhenDone - t._leftUntilDone;
|
sizeDone += t._sizeWhenDone - t._leftUntilDone;
|
||||||
total_completed += t.completed();
|
total_completed += t.completed();
|
||||||
|
@ -1194,15 +1200,11 @@ Transmission.prototype =
|
||||||
setTorrentBgColors: function( )
|
setTorrentBgColors: function( )
|
||||||
{
|
{
|
||||||
var rows = this.getVisibleRows( );
|
var rows = this.getVisibleRows( );
|
||||||
for( var i=0, len=rows.length; i<len; ++i ) {
|
for( var i=0, row; row=rows[i]; ++i ) {
|
||||||
var wasEven = rows[i][0].className.indexOf('even') != -1;
|
var wasEven = row[0].className.indexOf('even') != -1;
|
||||||
var isEven = ((i+1) % 2 == 0);
|
var isEven = ((i+1) % 2 == 0);
|
||||||
if( wasEven != isEven ) {
|
if( wasEven != isEven )
|
||||||
if( wasEven )
|
row.toggleClass('even', isEven);
|
||||||
rows[i].removeClass('even');
|
|
||||||
else
|
|
||||||
rows[i].addClass('even');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1215,9 +1217,9 @@ Transmission.prototype =
|
||||||
// calculate the overall speed
|
// calculate the overall speed
|
||||||
var upSpeed = 0;
|
var upSpeed = 0;
|
||||||
var downSpeed = 0;
|
var downSpeed = 0;
|
||||||
for( var i=0; i<torrentCount; ++i ) {
|
for( var i=0, row; row=torrents[i]; ++i ) {
|
||||||
upSpeed += torrents[i].uploadSpeed( );
|
upSpeed += row.uploadSpeed( );
|
||||||
downSpeed += torrents[i].downloadSpeed( );
|
downSpeed += row.downloadSpeed( );
|
||||||
}
|
}
|
||||||
|
|
||||||
// update torrent count label
|
// update torrent count label
|
||||||
|
@ -1432,10 +1434,7 @@ Transmission.prototype =
|
||||||
|
|
||||||
setEnabled: function( key, flag )
|
setEnabled: function( key, flag )
|
||||||
{
|
{
|
||||||
if( flag )
|
$(key).toggleClass( 'disabled', !flag );
|
||||||
$(key + '.disabled').removeClass('disabled');
|
|
||||||
else
|
|
||||||
$(key).addClass('disabled');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateButtonStates: function()
|
updateButtonStates: function()
|
||||||
|
@ -1462,14 +1461,14 @@ Transmission.prototype =
|
||||||
if( isSelected && !isActive ) havePausedSelection = true;
|
if( isSelected && !isActive ) havePausedSelection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setEnabled( 'li#pause_selected', haveActiveSelection );
|
this.setEnabled( this._toolbar_pause_button, haveActiveSelection );
|
||||||
this.setEnabled( 'li.context_pause_selected', haveActiveSelection );
|
this.setEnabled( this._context_pause_button, haveActiveSelection );
|
||||||
this.setEnabled( 'li#resume_selected', havePausedSelection );
|
this.setEnabled( this._toolbar_start_button, havePausedSelection );
|
||||||
this.setEnabled( 'li.context_resume_selected', havePausedSelection );
|
this.setEnabled( this._context_start_button, havePausedSelection );
|
||||||
this.setEnabled( 'li#remove', haveSelection );
|
this.setEnabled( this._toolbar_remove_button, haveSelection );
|
||||||
this.setEnabled( 'li#removedata', haveSelection );
|
this.setEnabled( this._toolbar_delete_button, haveSelection );
|
||||||
this.setEnabled( 'li#pause_all', haveActive );
|
this.setEnabled( this._toolbar_pause_all_button, haveActive );
|
||||||
this.setEnabled( 'li#resume_all', havePaused );
|
this.setEnabled( this._toolbar_start_all_button, havePaused );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue