@ -36,9 +36,9 @@ var ProgressColumnWidth = -1;
@@ -36,9 +36,9 @@ var ProgressColumnWidth = -1;
var DynamicTable = new Class ( {
initialize : function ( ) { } ,
initialize : function ( ) { } ,
setup : function ( dynamicTableDivId , dynamicTableFixedHeaderDivId , contextMenu ) {
setup : function ( dynamicTableDivId , dynamicTableFixedHeaderDivId , contextMenu ) {
this . dynamicTableDivId = dynamicTableDivId ;
this . dynamicTableFixedHeaderDivId = dynamicTableFixedHeaderDivId ;
this . fixedTableHeader = $ ( dynamicTableFixedHeaderDivId ) . getElements ( 'tr' ) [ 0 ] ;
@ -58,10 +58,9 @@ var DynamicTable = new Class({
@@ -58,10 +58,9 @@ var DynamicTable = new Class({
this . setupHeaderMenu ( ) ;
} ,
setupCommonEvents : function ( ) {
setupCommonEvents : function ( ) {
var scrollFn = function ( ) {
$ ( this . dynamicTableFixedHeaderDivId ) . getElements ( 'table' ) [ 0 ] . style . left =
- $ ( this . dynamicTableDivId ) . scrollLeft + 'px' ;
$ ( this . dynamicTableFixedHeaderDivId ) . getElements ( 'table' ) [ 0 ] . style . left = - $ ( this . dynamicTableDivId ) . scrollLeft + 'px' ;
} . bind ( this ) ;
$ ( this . dynamicTableDivId ) . addEvent ( 'scroll' , scrollFn ) ;
@ -101,11 +100,11 @@ var DynamicTable = new Class({
@@ -101,11 +100,11 @@ var DynamicTable = new Class({
setInterval ( checkResizeFn , 500 ) ;
} ,
setupHeaderEvents : function ( ) {
setupHeaderEvents : function ( ) {
this . currentHeaderAction = '' ;
this . canResize = false ;
var resetElementBorderStyle = function ( el , side ) {
var resetElementBorderStyle = function ( el , side ) {
if ( side === 'left' || side !== 'right' ) {
el . setStyle ( 'border-left-style' , '' ) ;
el . setStyle ( 'border-left-color' , '' ) ;
@ -118,7 +117,7 @@ var DynamicTable = new Class({
@@ -118,7 +117,7 @@ var DynamicTable = new Class({
}
} ;
var mouseMoveFn = function ( e ) {
var mouseMoveFn = function ( e ) {
var brect = e . target . getBoundingClientRect ( ) ;
var mouseXRelative = e . event . clientX - brect . left ;
if ( this . currentHeaderAction === '' ) {
@ -131,7 +130,8 @@ var DynamicTable = new Class({
@@ -131,7 +130,8 @@ var DynamicTable = new Class({
this . resizeTh = e . target . getPrevious ( '[class=""]' ) ;
this . canResize = true ;
e . target . getParent ( "tr" ) . style . cursor = 'col-resize' ;
} else {
}
else {
this . canResize = false ;
e . target . getParent ( "tr" ) . style . cursor = '' ;
}
@ -164,7 +164,7 @@ var DynamicTable = new Class({
@@ -164,7 +164,7 @@ var DynamicTable = new Class({
resetElementBorderStyle ( borderChangeElement , changeBorderSide === 'right' ? 'left' : 'right' ) ;
borderChangeElement . getSiblings ( '[class=""]' ) . each ( function ( el ) {
borderChangeElement . getSiblings ( '[class=""]' ) . each ( function ( el ) {
resetElementBorderStyle ( el ) ;
} ) ;
}
@ -172,18 +172,18 @@ var DynamicTable = new Class({
@@ -172,18 +172,18 @@ var DynamicTable = new Class({
this . lastClientX = e . event . clientX ;
} . bind ( this ) ;
var mouseOutFn = function ( e ) {
var mouseOutFn = function ( e ) {
resetElementBorderStyle ( e . target ) ;
} . bind ( this ) ;
var onBeforeStart = function ( el ) {
var onBeforeStart = function ( el ) {
this . clickedTh = el ;
this . currentHeaderAction = 'start' ;
this . dragMovement = false ;
this . dragStartX = this . lastClientX ;
} . bind ( this ) ;
var onStart = function ( el , event ) {
var onStart = function ( el , event ) {
if ( this . canResize ) {
this . currentHeaderAction = 'resize' ;
this . startWidth = this . resizeTh . getStyle ( 'width' ) . toFloat ( ) ;
@ -194,7 +194,7 @@ var DynamicTable = new Class({
@@ -194,7 +194,7 @@ var DynamicTable = new Class({
}
} . bind ( this ) ;
var onDrag = function ( el , event ) {
var onDrag = function ( el , event ) {
if ( this . currentHeaderAction === 'resize' ) {
var width = this . startWidth + ( event . page . x - this . dragStartX ) ;
if ( width < 16 )
@ -204,7 +204,7 @@ var DynamicTable = new Class({
@@ -204,7 +204,7 @@ var DynamicTable = new Class({
}
} . bind ( this ) ;
var onComplete = function ( el , event ) {
var onComplete = function ( el , event ) {
resetElementBorderStyle ( this . lastHoverTh ) ;
el . setStyle ( 'background-color' , '' ) ;
if ( this . currentHeaderAction === 'resize' )
@ -225,14 +225,14 @@ var DynamicTable = new Class({
@@ -225,14 +225,14 @@ var DynamicTable = new Class({
}
if ( this . currentHeaderAction === 'drag' ) {
resetElementBorderStyle ( el ) ;
el . getSiblings ( '[class=""]' ) . each ( function ( el ) {
el . getSiblings ( '[class=""]' ) . each ( function ( el ) {
resetElementBorderStyle ( el ) ;
} ) ;
}
this . currentHeaderAction = '' ;
} . bind ( this ) ;
var onCancel = function ( el ) {
var onCancel = function ( el ) {
this . currentHeaderAction = '' ;
this . setSortedColumn ( el . columnName ) ;
} . bind ( this ) ;
@ -244,21 +244,24 @@ var DynamicTable = new Class({
@@ -244,21 +244,24 @@ var DynamicTable = new Class({
th . addEvent ( 'mousemove' , mouseMoveFn ) ;
th . addEvent ( 'mouseout' , mouseOutFn ) ;
th . makeResizable ( {
modifiers : { x : '' , y : '' } ,
onBeforeStart : onBeforeStart ,
onStart : onStart ,
onDrag : onDrag ,
onComplete : onComplete ,
onCancel : onCancel
modifiers : {
x : '' ,
y : ''
} ,
onBeforeStart : onBeforeStart ,
onStart : onStart ,
onDrag : onDrag ,
onComplete : onComplete ,
onCancel : onCancel
} ) ;
}
} ,
setupDynamicTableHeaderContextMenuClass : function ( ) {
setupDynamicTableHeaderContextMenuClass : function ( ) {
if ( ! DynamicTableHeaderContextMenuClass ) {
DynamicTableHeaderContextMenuClass = new Class ( {
Extends : ContextMenu ,
updateMenuItems : function ( ) {
updateMenuItems : function ( ) {
for ( var i = 0 ; i < this . dynamicTable . columns . length ; i ++ ) {
if ( this . dynamicTable . columns [ i ] . caption === '' )
continue ;
@ -272,27 +275,32 @@ var DynamicTable = new Class({
@@ -272,27 +275,32 @@ var DynamicTable = new Class({
}
} ,
showColumn : function ( columnName , show ) {
showColumn : function ( columnName , show ) {
this . columns [ columnName ] . visible = show ? '1' : '0' ;
localStorage . setItem ( 'column_' + columnName + '_visible_' + this . dynamicTableDivId , show ? '1' : '0' ) ;
this . updateColumn ( columnName ) ;
} ,
setupHeaderMenu : function ( ) {
setupHeaderMenu : function ( ) {
this . setupDynamicTableHeaderContextMenuClass ( ) ;
var menuId = this . dynamicTableDivId + '_headerMenu' ;
var ul = new Element ( 'ul' , { id : menuId , class : 'contextMenu scrollableMenu' } ) ;
var ul = new Element ( 'ul' , {
id : menuId ,
class : 'contextMenu scrollableMenu'
} ) ;
var createLi = function ( columnName , text ) {
var html = '<a href="#' + columnName + '" ><img src="theme/checked"/>' + escapeHtml ( text ) + '</a>' ;
return new Element ( 'li' , { html : html } ) ;
return new Element ( 'li' , {
html : html
} ) ;
} ;
var actions = { } ;
var onMenuItemClicked = function ( element , ref , action ) {
var onMenuItemClicked = function ( element , ref , action ) {
this . showColumn ( action , this . columns [ action ] . visible === '0' ) ;
} . bind ( this ) ;
@ -309,19 +317,19 @@ var DynamicTable = new Class({
@@ -309,19 +317,19 @@ var DynamicTable = new Class({
this . headerContextMenu = new DynamicTableHeaderContextMenuClass ( {
targets : '#' + this . dynamicTableFixedHeaderDivId + ' tr' ,
actions : actions ,
menu : menuId ,
offsets : {
x : - 15 ,
y : 2
menu : menuId ,
offsets : {
x : - 15 ,
y : 2
}
} ) ;
this . headerContextMenu . dynamicTable = this ;
} ,
initColumns : function ( ) { } ,
initColumns : function ( ) { } ,
newColumn : function ( name , style , caption , defaultWidth , defaultVisible ) {
newColumn : function ( name , style , caption , defaultWidth , defaultVisible ) {
var column = { } ;
column [ 'name' ] = name ;
column [ 'visible' ] = getLocalStorageItem ( 'column_' + name + '_visible_' + this . dynamicTableDivId , defaultVisible ? '1' : '0' ) ;
@ -330,19 +338,19 @@ var DynamicTable = new Class({
@@ -330,19 +338,19 @@ var DynamicTable = new Class({
column [ 'style' ] = style ;
column [ 'width' ] = getLocalStorageItem ( 'column_' + name + '_width_' + this . dynamicTableDivId , defaultWidth ) ;
column [ 'dataProperties' ] = [ name ] ;
column [ 'getRowValue' ] = function ( row , pos ) {
column [ 'getRowValue' ] = function ( row , pos ) {
if ( pos === undefined )
pos = 0 ;
return row [ 'full_data' ] [ this . dataProperties [ pos ] ] ;
} ;
column [ 'compareRows' ] = function ( row1 , row2 ) {
column [ 'compareRows' ] = function ( row1 , row2 ) {
if ( this . getRowValue ( row1 ) < this . getRowValue ( row2 ) )
return - 1 ;
else if ( this . getRowValue ( row1 ) > this . getRowValue ( row2 ) )
return 1 ;
else return 0 ;
} ;
column [ 'updateTd' ] = function ( td , row ) {
column [ 'updateTd' ] = function ( td , row ) {
td . innerHTML = this . getRowValue ( row ) ;
} ;
column [ 'onResize' ] = null ;
@ -353,7 +361,7 @@ var DynamicTable = new Class({
@@ -353,7 +361,7 @@ var DynamicTable = new Class({
this . fixedTableHeader . appendChild ( new Element ( 'th' ) ) ;
} ,
loadColumnsOrder : function ( ) {
loadColumnsOrder : function ( ) {
var columnsOrder = [ ] ;
var val = localStorage . getItem ( 'columns_order_' + this . dynamicTableDivId ) ;
if ( val === null || val === undefined ) return ;
@ -370,7 +378,7 @@ var DynamicTable = new Class({
@@ -370,7 +378,7 @@ var DynamicTable = new Class({
this . columns [ i ] = this . columns [ columnsOrder [ i ] ] ;
} ,
saveColumnsOrder : function ( ) {
saveColumnsOrder : function ( ) {
val = '' ;
for ( i = 0 ; i < this . columns . length ; i ++ ) {
if ( i > 0 )
@ -380,12 +388,12 @@ var DynamicTable = new Class({
@@ -380,12 +388,12 @@ var DynamicTable = new Class({
localStorage . setItem ( 'columns_order_' + this . dynamicTableDivId , val ) ;
} ,
updateTableHeaders : function ( ) {
updateTableHeaders : function ( ) {
this . updateHeader ( this . hiddenTableHeader ) ;
this . updateHeader ( this . fixedTableHeader ) ;
} ,
updateHeader : function ( header ) {
updateHeader : function ( header ) {
var ths = header . getElements ( 'th' ) ;
for ( var i = 0 ; i < ths . length ; i ++ ) {
@ -402,14 +410,14 @@ var DynamicTable = new Class({
@@ -402,14 +410,14 @@ var DynamicTable = new Class({
}
} ,
getColumnPos : function ( columnName ) {
getColumnPos : function ( columnName ) {
for ( var i = 0 ; i < this . columns . length ; i ++ )
if ( this . columns [ i ] . name == columnName )
return i ;
return - 1 ;
} ,
updateColumn : function ( columnName ) {
updateColumn : function ( columnName ) {
var pos = this . getColumnPos ( columnName ) ;
var visible = ( ( this . columns [ pos ] . visible != '0' ) && ! this . columns [ pos ] . force _hide ) ;
var ths = this . hiddenTableHeader . getElements ( 'th' ) ;
@ -432,13 +440,12 @@ var DynamicTable = new Class({
@@ -432,13 +440,12 @@ var DynamicTable = new Class({
for ( var j = 0 ; j < trs . length ; j ++ )
trs [ j ] . getElements ( 'td' ) [ pos ] . addClass ( 'invisible' ) ;
}
if ( this . columns [ pos ] . onResize !== null )
{
if ( this . columns [ pos ] . onResize !== null ) {
this . columns [ pos ] . onResize ( columnName ) ;
}
} ,
setSortedColumn : function ( column ) {
setSortedColumn : function ( column ) {
if ( column != this . sortedColumn ) {
this . sortedColumn = column ;
this . reverseSort = '0' ;
@ -452,27 +459,28 @@ var DynamicTable = new Class({
@@ -452,27 +459,28 @@ var DynamicTable = new Class({
this . updateTable ( false ) ;
} ,
getSelectedRowId : function ( ) {
getSelectedRowId : function ( ) {
if ( this . selectedRows . length > 0 )
return this . selectedRows [ 0 ] ;
return '' ;
} ,
altRow : function ( ) {
altRow : function ( ) {
if ( ! MUI . ieLegacySupport )
return ;
var trs = this . tableBody . getElements ( 'tr' ) ;
trs . each ( function ( el , i ) {
trs . each ( function ( el , i ) {
if ( i % 2 ) {
el . addClass ( 'alt' ) ;
} else {
}
else {
el . removeClass ( 'alt' ) ;
}
} . bind ( this ) ) ;
} ,
selectAll : function ( ) {
selectAll : function ( ) {
this . selectedRows . empty ( ) ;
var trs = this . tableBody . getElements ( 'tr' ) ;
@ -484,11 +492,11 @@ var DynamicTable = new Class({
@@ -484,11 +492,11 @@ var DynamicTable = new Class({
}
} ,
deselectAll : function ( ) {
deselectAll : function ( ) {
this . selectedRows . empty ( ) ;
} ,
selectRow : function ( rowId ) {
selectRow : function ( rowId ) {
this . deselectAll ( ) ;
this . selectedRows . push ( rowId ) ;
this . tableBody . getElements ( 'tr' ) . each ( function ( tr ) {
@ -500,7 +508,7 @@ var DynamicTable = new Class({
@@ -500,7 +508,7 @@ var DynamicTable = new Class({
this . onSelectedRowChanged ( ) ;
} ,
reselectRows : function ( rowIds ) {
reselectRows : function ( rowIds ) {
this . deselectAll ( ) ;
this . selectedRows = rowIds . slice ( ) ;
this . tableBody . getElements ( 'tr' ) . each ( function ( tr ) {
@ -509,9 +517,9 @@ var DynamicTable = new Class({
@@ -509,9 +517,9 @@ var DynamicTable = new Class({
} ) ;
} ,
onSelectedRowChanged : function ( ) { } ,
onSelectedRowChanged : function ( ) { } ,
updateRowData : function ( data ) {
updateRowData : function ( data ) {
var rowId = data [ 'rowId' ] ;
var row ;
@ -526,22 +534,21 @@ var DynamicTable = new Class({
@@ -526,22 +534,21 @@ var DynamicTable = new Class({
row [ 'data' ] = data ;
for ( var x in data )
for ( var x in data )
row [ 'full_data' ] [ x ] = data [ x ] ;
} ,
getFilteredAndSortedRows : function ( ) {
getFilteredAndSortedRows : function ( ) {
var filteredRows = [ ] ;
var rows = this . rows . getValues ( ) ;
for ( i = 0 ; i < rows . length ; i ++ )
{
for ( i = 0 ; i < rows . length ; i ++ ) {
filteredRows . push ( rows [ i ] ) ;
filteredRows [ rows [ i ] . rowId ] = rows [ i ] ;
}
filteredRows . sort ( function ( row1 , row2 ) {
filteredRows . sort ( function ( row1 , row2 ) {
var column = this . columns [ this . sortedColumn ] ;
res = column . compareRows ( row1 , row2 ) ;
if ( this . reverseSort == '0' )
@ -552,7 +559,7 @@ var DynamicTable = new Class({
@@ -552,7 +559,7 @@ var DynamicTable = new Class({
return filteredRows ;
} ,
getTrByRowId : function ( rowId ) {
getTrByRowId : function ( rowId ) {
trs = this . tableBody . getElements ( 'tr' ) ;
for ( var i = 0 ; i < trs . length ; i ++ )
if ( trs [ i ] . rowId == rowId )
@ -560,7 +567,7 @@ var DynamicTable = new Class({
@@ -560,7 +567,7 @@ var DynamicTable = new Class({
return null ;
} ,
updateTable : function ( fullUpdate ) {
updateTable : function ( fullUpdate ) {
if ( fullUpdate === undefined )
fullUpdate = false ;
@ -596,12 +603,12 @@ var DynamicTable = new Class({
@@ -596,12 +603,12 @@ var DynamicTable = new Class({
tr [ 'rowId' ] = rows [ rowPos ] [ 'rowId' ] ;
tr . _this = this ;
tr . addEvent ( 'contextmenu' , function ( e ) {
tr . addEvent ( 'contextmenu' , function ( e ) {
if ( ! this . _this . selectedRows . contains ( this . rowId ) )
this . _this . selectRow ( this . rowId ) ;
return true ;
} ) ;
tr . addEvent ( 'click' , function ( e ) {
tr . addEvent ( 'click' , function ( e ) {
e . stop ( ) ;
if ( e . control ) {
// CTRL key was pressed
@ -642,7 +649,8 @@ var DynamicTable = new Class({
@@ -642,7 +649,8 @@ var DynamicTable = new Class({
tr . removeClass ( 'selected' ) ;
}
}
} else {
}
else {
// Simple selection
this . _this . selectRow ( this . rowId ) ;
}
@ -652,7 +660,7 @@ var DynamicTable = new Class({
@@ -652,7 +660,7 @@ var DynamicTable = new Class({
this . setupTr ( tr ) ;
for ( var k = 0 ; k < this . columns . length ; k ++ ) {
for ( var k = 0 ; k < this . columns . length ; k ++ ) {
var td = new Element ( 'td' ) ;
if ( ( this . columns [ k ] . visible == '0' ) || this . columns [ k ] . force _hide )
td . addClass ( 'invisible' ) ;
@ -685,9 +693,9 @@ var DynamicTable = new Class({
@@ -685,9 +693,9 @@ var DynamicTable = new Class({
}
} ,
setupTr : function ( tr ) { } ,
setupTr : function ( tr ) { } ,
updateRow : function ( tr , fullUpdate ) {
updateRow : function ( tr , fullUpdate ) {
var row = this . rows . get ( tr . rowId ) ;
data = row [ fullUpdate ? 'full_data' : 'data' ] ;
@ -699,7 +707,7 @@ var DynamicTable = new Class({
@@ -699,7 +707,7 @@ var DynamicTable = new Class({
row [ 'data' ] = { } ;
} ,
removeRow : function ( rowId ) {
removeRow : function ( rowId ) {
this . selectedRows . erase ( rowId ) ;
var tr = this . getTrByRowId ( rowId ) ;
if ( tr !== null ) {
@ -710,7 +718,7 @@ var DynamicTable = new Class({
@@ -710,7 +718,7 @@ var DynamicTable = new Class({
return false ;
} ,
clear : function ( ) {
clear : function ( ) {
this . selectedRows . empty ( ) ;
this . rows . empty ( ) ;
var trs = this . tableBody . getElements ( 'tr' ) ;
@ -720,19 +728,19 @@ var DynamicTable = new Class({
@@ -720,19 +728,19 @@ var DynamicTable = new Class({
}
} ,
selectedRowsIds : function ( ) {
selectedRowsIds : function ( ) {
return this . selectedRows . slice ( ) ;
} ,
getRowIds : function ( ) {
getRowIds : function ( ) {
return this . rows . getKeys ( ) ;
} ,
} ) ;
} ) ;
var TorrentsTable = new Class ( {
Extends : DynamicTable ,
initColumns : function ( ) {
initColumns : function ( ) {
this . newColumn ( 'priority' , '' , '#' , 30 , true ) ;
this . newColumn ( 'state_icon' , 'cursor: default' , '' , 22 , true ) ;
this . newColumn ( 'name' , '' , 'QBT_TR(Name)QBT_TR[CONTEXT=TorrentModel]' , 200 , true ) ;
@ -775,10 +783,10 @@ var TorrentsTable = new Class({
@@ -775,10 +783,10 @@ var TorrentsTable = new Class({
this . initColumnsFunctions ( ) ;
} ,
initColumnsFunctions : function ( ) {
initColumnsFunctions : function ( ) {
// state_icon
this . columns [ 'state_icon' ] . updateTd = function ( td , row ) {
this . columns [ 'state_icon' ] . updateTd = function ( td , row ) {
var state = this . getRowValue ( row ) ;
// normalize states
switch ( state ) {
@ -825,13 +833,13 @@ var TorrentsTable = new Class({
@@ -825,13 +833,13 @@ var TorrentsTable = new Class({
}
else
td . adopt ( new Element ( 'img' , {
'src' : img _path ,
'class' : 'stateIcon'
'src' : img _path ,
'class' : 'stateIcon'
} ) ) ;
} ;
// status
this . columns [ 'status' ] . updateTd = function ( td , row ) {
this . columns [ 'status' ] . updateTd = function ( td , row ) {
var state = this . getRowValue ( row ) ;
if ( ! state ) return ;
@ -893,12 +901,12 @@ var TorrentsTable = new Class({
@@ -893,12 +901,12 @@ var TorrentsTable = new Class({
} ;
// priority
this . columns [ 'priority' ] . updateTd = function ( td , row ) {
this . columns [ 'priority' ] . updateTd = function ( td , row ) {
var priority = this . getRowValue ( row ) ;
td . set ( 'html' , priority < 1 ? '*' : priority ) ;
} ;
this . columns [ 'priority' ] . compareRows = function ( row1 , row2 ) {
this . columns [ 'priority' ] . compareRows = function ( row1 , row2 ) {
var row1 _val = this . getRowValue ( row1 ) ;
var row2 _val = this . getRowValue ( row2 ) ;
if ( row1 _val < 1 )
@ -913,19 +921,19 @@ var TorrentsTable = new Class({
@@ -913,19 +921,19 @@ var TorrentsTable = new Class({
} ;
// name, category
this . columns [ 'name' ] . updateTd = function ( td , row ) {
this . columns [ 'name' ] . updateTd = function ( td , row ) {
td . set ( 'html' , escapeHtml ( this . getRowValue ( row ) ) ) ;
} ;
this . columns [ 'category' ] . updateTd = this . columns [ 'name' ] . updateTd ;
// size
this . columns [ 'size' ] . updateTd = function ( td , row ) {
this . columns [ 'size' ] . updateTd = function ( td , row ) {
var size = this . getRowValue ( row ) ;
td . set ( 'html' , friendlyUnit ( size , false ) ) ;
} ;
// progress
this . columns [ 'progress' ] . updateTd = function ( td , row ) {
this . columns [ 'progress' ] . updateTd = function ( td , row ) {
var progress = this . getRowValue ( row ) ;
var progressFormated = ( progress * 100 ) . round ( 1 ) ;
if ( progressFormated == 100.0 && progress != 1.0 )
@ -944,13 +952,13 @@ var TorrentsTable = new Class({
@@ -944,13 +952,13 @@ var TorrentsTable = new Class({
if ( ProgressColumnWidth < 0 )
ProgressColumnWidth = td . offsetWidth ;
td . adopt ( new ProgressBar ( progressFormated . toFloat ( ) , {
'width' : ProgressColumnWidth - 5
'width' : ProgressColumnWidth - 5
} ) ) ;
td . resized = false ;
}
} ;
this . columns [ 'progress' ] . onResize = function ( columnName ) {
this . columns [ 'progress' ] . onResize = function ( columnName ) {
var pos = this . getColumnPos ( columnName ) ;
var trs = this . tableBody . getElements ( 'tr' ) ;
ProgressColumnWidth = - 1 ;
@ -964,7 +972,7 @@ var TorrentsTable = new Class({
@@ -964,7 +972,7 @@ var TorrentsTable = new Class({
} . bind ( this ) ;
// num_seeds
this . columns [ 'num_seeds' ] . updateTd = function ( td , row ) {
this . columns [ 'num_seeds' ] . updateTd = function ( td , row ) {
var num _seeds = this . getRowValue ( row , 0 ) ;
var num _complete = this . getRowValue ( row , 1 ) ;
var html = num _seeds ;
@ -972,7 +980,7 @@ var TorrentsTable = new Class({
@@ -972,7 +980,7 @@ var TorrentsTable = new Class({
html += ' (' + num _complete + ')' ;
td . set ( 'html' , html ) ;
} ;
this . columns [ 'num_seeds' ] . compareRows = function ( row1 , row2 ) {
this . columns [ 'num_seeds' ] . compareRows = function ( row1 , row2 ) {
var num _seeds1 = this . getRowValue ( row1 , 0 ) ;
var num _complete1 = this . getRowValue ( row1 , 1 ) ;
@ -995,7 +1003,7 @@ var TorrentsTable = new Class({
@@ -995,7 +1003,7 @@ var TorrentsTable = new Class({
this . columns [ 'num_leechs' ] . compareRows = this . columns [ 'num_seeds' ] . compareRows ;
// dlspeed
this . columns [ 'dlspeed' ] . updateTd = function ( td , row ) {
this . columns [ 'dlspeed' ] . updateTd = function ( td , row ) {
var speed = this . getRowValue ( row ) ;
td . set ( 'html' , friendlyUnit ( speed , true ) ) ;
} ;
@ -1004,13 +1012,13 @@ var TorrentsTable = new Class({
@@ -1004,13 +1012,13 @@ var TorrentsTable = new Class({
this . columns [ 'upspeed' ] . updateTd = this . columns [ 'dlspeed' ] . updateTd ;
// eta
this . columns [ 'eta' ] . updateTd = function ( td , row ) {
this . columns [ 'eta' ] . updateTd = function ( td , row ) {
var eta = this . getRowValue ( row ) ;
td . set ( 'html' , friendlyDuration ( eta , true ) ) ;
} ;
// ratio
this . columns [ 'ratio' ] . updateTd = function ( td , row ) {
this . columns [ 'ratio' ] . updateTd = function ( td , row ) {
var ratio = this . getRowValue ( row ) ;
var html = null ;
if ( ratio == - 1 )
@ -1024,13 +1032,13 @@ var TorrentsTable = new Class({
@@ -1024,13 +1032,13 @@ var TorrentsTable = new Class({
this . columns [ 'tags' ] . updateTd = this . columns [ 'name' ] . updateTd ;
// added on
this . columns [ 'added_on' ] . updateTd = function ( td , row ) {
this . columns [ 'added_on' ] . updateTd = function ( td , row ) {
var date = new Date ( this . getRowValue ( row ) * 1000 ) . toLocaleString ( ) ;
td . set ( 'html' , date ) ;
} ;
// completion_on
this . columns [ 'completion_on' ] . updateTd = function ( td , row ) {
this . columns [ 'completion_on' ] . updateTd = function ( td , row ) {
var val = this . getRowValue ( row ) ;
if ( val === 0xffffffff || val < 0 )
td . set ( 'html' , '' ) ;
@ -1044,7 +1052,7 @@ var TorrentsTable = new Class({
@@ -1044,7 +1052,7 @@ var TorrentsTable = new Class({
this . columns [ 'seen_complete' ] . updateTd = this . columns [ 'completion_on' ] . updateTd ;
// dl_limit, up_limit
this . columns [ 'dl_limit' ] . updateTd = function ( td , row ) {
this . columns [ 'dl_limit' ] . updateTd = function ( td , row ) {
var speed = this . getRowValue ( row ) ;
if ( speed === 0 )
td . set ( 'html' , '∞' ) ;
@ -1072,7 +1080,7 @@ var TorrentsTable = new Class({
@@ -1072,7 +1080,7 @@ var TorrentsTable = new Class({
this . columns [ 'ratio_limit' ] . updateTd = this . columns [ 'ratio' ] . updateTd ;
// last_activity
this . columns [ 'last_activity' ] . updateTd = function ( td , row ) {
this . columns [ 'last_activity' ] . updateTd = function ( td , row ) {
var val = this . getRowValue ( row ) ;
if ( val < 1 )
td . set ( 'html' , '∞' ) ;
@ -1081,18 +1089,18 @@ var TorrentsTable = new Class({
@@ -1081,18 +1089,18 @@ var TorrentsTable = new Class({
} ;
// time active
this . columns [ 'time_active' ] . updateTd = function ( td , row ) {
this . columns [ 'time_active' ] . updateTd = function ( td , row ) {
var time = this . getRowValue ( row ) ;
td . set ( 'html' , friendlyDuration ( time ) ) ;
} ;
} ,
applyFilter : function ( row , filterName , categoryHash ) {
applyFilter : function ( row , filterName , categoryHash ) {
var state = row [ 'full_data' ] . state ;
var inactive = false ;
var r ;
switch ( filterName ) {
switch ( filterName ) {
case 'downloading' :
if ( state != 'downloading' && ! ~ state . indexOf ( 'DL' ) )
return false ;
@ -1142,7 +1150,7 @@ var TorrentsTable = new Class({
@@ -1142,7 +1150,7 @@ var TorrentsTable = new Class({
return true ;
} ,
getFilteredTorrentsNumber : function ( filterName , categoryHash ) {
getFilteredTorrentsNumber : function ( filterName , categoryHash ) {
var cnt = 0 ;
var rows = this . rows . getValues ( ) ;
@ -1151,7 +1159,7 @@ var TorrentsTable = new Class({
@@ -1151,7 +1159,7 @@ var TorrentsTable = new Class({
return cnt ;
} ,
getFilteredTorrentsHashes : function ( filterName , categoryHash ) {
getFilteredTorrentsHashes : function ( filterName , categoryHash ) {
var rowsHashes = [ ] ;
var rows = this . rows . getValues ( ) ;
@ -1162,7 +1170,7 @@ var TorrentsTable = new Class({
@@ -1162,7 +1170,7 @@ var TorrentsTable = new Class({
return rowsHashes ;
} ,
getFilteredAndSortedRows : function ( ) {
getFilteredAndSortedRows : function ( ) {
var filteredRows = [ ] ;
var rows = this . rows . getValues ( ) ;
@ -1173,7 +1181,7 @@ var TorrentsTable = new Class({
@@ -1173,7 +1181,7 @@ var TorrentsTable = new Class({
filteredRows [ rows [ i ] . rowId ] = rows [ i ] ;
}
filteredRows . sort ( function ( row1 , row2 ) {
filteredRows . sort ( function ( row1 , row2 ) {
var column = this . columns [ this . sortedColumn ] ;
res = column . compareRows ( row1 , row2 ) ;
if ( this . reverseSort == '0' )
@ -1184,8 +1192,8 @@ var TorrentsTable = new Class({
@@ -1184,8 +1192,8 @@ var TorrentsTable = new Class({
return filteredRows ;
} ,
setupTr : function ( tr ) {
tr . addEvent ( 'dblclick' , function ( e ) {
setupTr : function ( tr ) {
tr . addEvent ( 'dblclick' , function ( e ) {
e . stop ( ) ;
this . _this . selectRow ( this . rowId ) ;
var row = this . _this . rows . get ( this . rowId ) ;
@ -1199,19 +1207,19 @@ var TorrentsTable = new Class({
@@ -1199,19 +1207,19 @@ var TorrentsTable = new Class({
tr . addClass ( "torrentsTableContextMenuTarget" ) ;
} ,
getCurrentTorrentHash : function ( ) {
getCurrentTorrentHash : function ( ) {
return this . getSelectedRowId ( ) ;
} ,
onSelectedRowChanged : function ( ) {
onSelectedRowChanged : function ( ) {
updatePropertiesPanel ( ) ;
}
} ) ;
} ) ;
var TorrentPeersTable = new Class ( {
Extends : DynamicTable ,
initColumns : function ( ) {
initColumns : function ( ) {
this . newColumn ( 'country' , '' , 'QBT_TR(Country)QBT_TR[CONTEXT=PeerListWidget]' , 22 , true ) ;
this . newColumn ( 'ip' , '' , 'QBT_TR(IP)QBT_TR[CONTEXT=PeerListWidget]' , 80 , true ) ;
this . newColumn ( 'port' , '' , 'QBT_TR(Port)QBT_TR[CONTEXT=PeerListWidget]' , 35 , true ) ;
@ -1231,11 +1239,11 @@ var TorrentPeersTable = new Class({
@@ -1231,11 +1239,11 @@ var TorrentPeersTable = new Class({
this . initColumnsFunctions ( ) ;
} ,
initColumnsFunctions : function ( ) {
initColumnsFunctions : function ( ) {
// country
this . columns [ 'country' ] . updateTd = function ( td , row ) {
this . columns [ 'country' ] . updateTd = function ( td , row ) {
var country = this . getRowValue ( row , 0 ) ;
var country _code = this . getRowValue ( row , 1 ) ;
@ -1256,23 +1264,23 @@ var TorrentPeersTable = new Class({
@@ -1256,23 +1264,23 @@ var TorrentPeersTable = new Class({
}
else
td . adopt ( new Element ( 'img' , {
'src' : img _path ,
'class' : 'flags' ,
'alt' : country ,
'title' : country
'src' : img _path ,
'class' : 'flags' ,
'alt' : country ,
'title' : country
} ) ) ;
} ;
// ip
this . columns [ 'ip' ] . compareRows = function ( row1 , row2 ) {
this . columns [ 'ip' ] . compareRows = function ( row1 , row2 ) {
var ip1 = this . getRowValue ( row1 ) ;
var ip2 = this . getRowValue ( row2 ) ;
var a = ip1 . split ( "." ) ;
var b = ip2 . split ( "." ) ;
for ( var i = 0 ; i < 4 ; i ++ ) {
for ( var i = 0 ; i < 4 ; i ++ ) {
if ( a [ i ] != b [ i ] )
return a [ i ] - b [ i ] ;
}
@ -1282,7 +1290,7 @@ var TorrentPeersTable = new Class({
@@ -1282,7 +1290,7 @@ var TorrentPeersTable = new Class({
// progress, relevance
this . columns [ 'progress' ] . updateTd = function ( td , row ) {
this . columns [ 'progress' ] . updateTd = function ( td , row ) {
var progress = this . getRowValue ( row ) ;
var progressFormated = ( progress * 100 ) . round ( 1 ) ;
if ( progressFormated == 100.0 && progress != 1.0 )
@ -1295,7 +1303,7 @@ var TorrentPeersTable = new Class({
@@ -1295,7 +1303,7 @@ var TorrentPeersTable = new Class({
// dl_speed, up_speed
this . columns [ 'dl_speed' ] . updateTd = function ( td , row ) {
this . columns [ 'dl_speed' ] . updateTd = function ( td , row ) {
var speed = this . getRowValue ( row ) ;
if ( speed === 0 )
td . set ( 'html' , '' ) ;
@ -1307,7 +1315,7 @@ var TorrentPeersTable = new Class({
@@ -1307,7 +1315,7 @@ var TorrentPeersTable = new Class({
// downloaded, uploaded
this . columns [ 'downloaded' ] . updateTd = function ( td , row ) {
this . columns [ 'downloaded' ] . updateTd = function ( td , row ) {
var downloaded = this . getRowValue ( row ) ;
td . set ( 'html' , friendlyUnit ( downloaded , false ) ) ;
} ;
@ -1316,19 +1324,19 @@ var TorrentPeersTable = new Class({
@@ -1316,19 +1324,19 @@ var TorrentPeersTable = new Class({
// flags
this . columns [ 'flags' ] . updateTd = function ( td , row ) {
this . columns [ 'flags' ] . updateTd = function ( td , row ) {
td . innerHTML = this . getRowValue ( row , 0 ) ;
td . title = this . getRowValue ( row , 1 ) ;
} ;
// files
this . columns [ 'files' ] . updateTd = function ( td , row ) {
this . columns [ 'files' ] . updateTd = function ( td , row ) {
td . innerHTML = escapeHtml ( this . getRowValue ( row , 0 ) . replace ( '\n' , ';' ) ) ;
td . title = escapeHtml ( this . getRowValue ( row , 0 ) ) ;
} ;
}
} ) ;
} ) ;
/*************************************************************/