@ -25,15 +25,15 @@
torrentsTable = new TorrentsTable ( ) ;
torrentsTable = new TorrentsTable ( ) ;
torrentPeersTable = new TorrentPeersTable ( ) ;
torrentPeersTable = new TorrentPeersTable ( ) ;
var updatePropertiesPanel = function ( ) { } ;
var updatePropertiesPanel = function ( ) { } ;
var updateTorrentData = function ( ) { } ;
var updateTorrentData = function ( ) { } ;
var updateTrackersData = function ( ) { } ;
var updateTrackersData = function ( ) { } ;
var updateTorrentPeersData = function ( ) { } ;
var updateTorrentPeersData = function ( ) { } ;
var updateWebSeedsData = function ( ) { } ;
var updateWebSeedsData = function ( ) { } ;
var updateTorrentFilesData = function ( ) { } ;
var updateTorrentFilesData = function ( ) { } ;
var updateMainData = function ( ) { } ;
var updateMainData = function ( ) { } ;
var alternativeSpeedLimits = false ;
var alternativeSpeedLimits = false ;
var queueing _enabled = true ;
var queueing _enabled = true ;
var syncMainDataTimerPeriod = 1500 ;
var syncMainDataTimerPeriod = 1500 ;
@ -46,12 +46,12 @@ var CATEGORIES_UNCATEGORIZED = 2;
var category _list = { } ;
var category _list = { } ;
var selected _category = CATEGORIES _ALL ;
var selected _category = CATEGORIES _ALL ;
var setCategoryFilter = function ( ) { } ;
var setCategoryFilter = function ( ) { } ;
var selected _filter = getLocalStorageItem ( 'selected_filter' , 'all' ) ;
var selected _filter = getLocalStorageItem ( 'selected_filter' , 'all' ) ;
var setFilter = function ( ) { } ;
var setFilter = function ( ) { } ;
var loadSelectedCategory = function ( ) {
var loadSelectedCategory = function ( ) {
selected _category = getLocalStorageItem ( 'selected_category' , CATEGORIES _ALL ) ;
selected _category = getLocalStorageItem ( 'selected_category' , CATEGORIES _ALL ) ;
} ;
} ;
loadSelectedCategory ( ) ;
loadSelectedCategory ( ) ;
@ -65,9 +65,9 @@ function genHash(string) {
return hash ;
return hash ;
}
}
window . addEvent ( 'load' , function ( ) {
window . addEvent ( 'load' , function ( ) {
var saveColumnSizes = function ( ) {
var saveColumnSizes = function ( ) {
var filters _width = $ ( 'Filters' ) . getSize ( ) . x ;
var filters _width = $ ( 'Filters' ) . getSize ( ) . x ;
var properties _height _rel = $ ( 'propertiesPanel' ) . getSize ( ) . y / Window . getSize ( ) . y ;
var properties _height _rel = $ ( 'propertiesPanel' ) . getSize ( ) . y / Window . getSize ( ) . y ;
localStorage . setItem ( 'filters_width' , filters _width ) ;
localStorage . setItem ( 'filters_width' , filters _width ) ;
@ -92,17 +92,17 @@ window.addEvent('load', function () {
else
else
filt _w = 120 ;
filt _w = 120 ;
new MochaUI . Column ( {
new MochaUI . Column ( {
id : 'filtersColumn' ,
id : 'filtersColumn' ,
placement : 'left' ,
placement : 'left' ,
onResize : saveColumnSizes ,
onResize : saveColumnSizes ,
width : filt _w ,
width : filt _w ,
resizeLimit : [ 100 , 300 ]
resizeLimit : [ 100 , 300 ]
} ) ;
} ) ;
new MochaUI . Column ( {
new MochaUI . Column ( {
id : 'mainColumn' ,
id : 'mainColumn' ,
placement : 'main' ,
placement : 'main' ,
width : null ,
width : null ,
resizeLimit : [ 100 , 300 ]
resizeLimit : [ 100 , 300 ]
} ) ;
} ) ;
setCategoryFilter = function ( hash ) {
setCategoryFilter = function ( hash ) {
@ -113,7 +113,7 @@ window.addEvent('load', function () {
updateMainData ( ) ;
updateMainData ( ) ;
} ;
} ;
setFilter = function ( f ) {
setFilter = function ( f ) {
// Visually Select the right filter
// Visually Select the right filter
$ ( "all_filter" ) . removeClass ( "selectedFilter" ) ;
$ ( "all_filter" ) . removeClass ( "selectedFilter" ) ;
$ ( "downloading_filter" ) . removeClass ( "selectedFilter" ) ;
$ ( "downloading_filter" ) . removeClass ( "selectedFilter" ) ;
@ -133,22 +133,22 @@ window.addEvent('load', function () {
} ;
} ;
new MochaUI . Panel ( {
new MochaUI . Panel ( {
id : 'Filters' ,
id : 'Filters' ,
title : 'Panel' ,
title : 'Panel' ,
header : false ,
header : false ,
padding : {
padding : {
top : 0 ,
top : 0 ,
right : 0 ,
right : 0 ,
bottom : 0 ,
bottom : 0 ,
left : 0
left : 0
} ,
} ,
loadMethod : 'xhr' ,
loadMethod : 'xhr' ,
contentURL : 'filters.html' ,
contentURL : 'filters.html' ,
onContentLoaded : function ( ) {
onContentLoaded : function ( ) {
setFilter ( selected _filter ) ;
setFilter ( selected _filter ) ;
} ,
} ,
column : 'filtersColumn' ,
column : 'filtersColumn' ,
height : 300
height : 300
} ) ;
} ) ;
initializeWindows ( ) ;
initializeWindows ( ) ;
@ -203,7 +203,10 @@ window.addEvent('load', function () {
}
}
var categoryHash = genHash ( category ) ;
var categoryHash = genHash ( category ) ;
if ( category _list [ categoryHash ] === null ) // This should not happen
if ( category _list [ categoryHash ] === null ) // This should not happen
category _list [ categoryHash ] = { name : category , torrents : [ ] } ;
category _list [ categoryHash ] = {
name : category ,
torrents : [ ]
} ;
if ( ! Object . contains ( category _list [ categoryHash ] . torrents , torrent [ 'hash' ] ) ) {
if ( ! Object . contains ( category _list [ categoryHash ] . torrents , torrent [ 'hash' ] ) ) {
removeTorrentFromCategoryList ( torrent [ 'hash' ] ) ;
removeTorrentFromCategoryList ( torrent [ 'hash' ] ) ;
category _list [ categoryHash ] . torrents = category _list [ categoryHash ] . torrents . combine ( [ torrent [ 'hash' ] ] ) ;
category _list [ categoryHash ] . torrents = category _list [ categoryHash ] . torrents . combine ( [ torrent [ 'hash' ] ] ) ;
@ -235,10 +238,13 @@ window.addEvent('load', function () {
categoryList . empty ( ) ;
categoryList . empty ( ) ;
var create _link = function ( hash , text , count ) {
var create _link = function ( hash , text , count ) {
var html = '<a href="#" onclick="setCategoryFilter(' + hash + ');return false;">' +
var html = '<a href="#" onclick="setCategoryFilter(' + hash + ');return false;">'
'<img src="theme/inode-directory"/>' +
+ '<img src="theme/inode-directory"/>'
escapeHtml ( text ) + ' (' + count + ')' + '</a>' ;
+ escapeHtml ( text ) + ' (' + count + ')' + '</a>' ;
var el = new Element ( 'li' , { id : hash , html : html } ) ;
var el = new Element ( 'li' , {
id : hash ,
html : html
} ) ;
categoriesFilterContextMenu . addTarget ( el ) ;
categoriesFilterContextMenu . addTarget ( el ) ;
return el ;
return el ;
} ;
} ;
@ -281,21 +287,21 @@ window.addEvent('load', function () {
} ;
} ;
var syncMainDataTimer ;
var syncMainDataTimer ;
var syncMainData = function ( ) {
var syncMainData = function ( ) {
var url = new URI ( 'api/v2/sync/maindata' ) ;
var url = new URI ( 'api/v2/sync/maindata' ) ;
url . setData ( 'rid' , syncMainDataLastResponseId ) ;
url . setData ( 'rid' , syncMainDataLastResponseId ) ;
var request = new Request . JSON ( {
var request = new Request . JSON ( {
url : url ,
url : url ,
noCache : true ,
noCache : true ,
method : 'get' ,
method : 'get' ,
onFailure : function ( ) {
onFailure : function ( ) {
var errorDiv = $ ( 'error_div' ) ;
var errorDiv = $ ( 'error_div' ) ;
if ( errorDiv )
if ( errorDiv )
errorDiv . set ( 'html' , 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]' ) ;
errorDiv . set ( 'html' , 'QBT_TR(qBittorrent client is not reachable)QBT_TR[CONTEXT=HttpServer]' ) ;
clearTimeout ( syncMainDataTimer ) ;
clearTimeout ( syncMainDataTimer ) ;
syncMainDataTimer = syncMainData . delay ( 2000 ) ;
syncMainDataTimer = syncMainData . delay ( 2000 ) ;
} ,
} ,
onSuccess : function ( response ) {
onSuccess : function ( response ) {
$ ( 'error_div' ) . set ( 'html' , '' ) ;
$ ( 'error_div' ) . set ( 'html' , '' ) ;
if ( response ) {
if ( response ) {
var torrentsTableSelectedRows ;
var torrentsTableSelectedRows ;
@ -312,7 +318,10 @@ window.addEvent('load', function () {
if ( response [ 'categories' ] ) {
if ( response [ 'categories' ] ) {
response [ 'categories' ] . each ( function ( category ) {
response [ 'categories' ] . each ( function ( category ) {
var categoryHash = genHash ( category ) ;
var categoryHash = genHash ( category ) ;
category _list [ categoryHash ] = { name : category , torrents : [ ] } ;
category _list [ categoryHash ] = {
name : category ,
torrents : [ ]
} ;
} ) ;
} ) ;
update _categories = true ;
update _categories = true ;
}
}
@ -341,7 +350,7 @@ window.addEvent('load', function () {
setupCopyEventHandler ( ) ;
setupCopyEventHandler ( ) ;
}
}
if ( response [ 'torrents_removed' ] )
if ( response [ 'torrents_removed' ] )
response [ 'torrents_removed' ] . each ( function ( hash ) {
response [ 'torrents_removed' ] . each ( function ( hash ) {
torrentsTable . removeRow ( hash ) ;
torrentsTable . removeRow ( hash ) ;
removeTorrentFromCategoryList ( hash ) ;
removeTorrentFromCategoryList ( hash ) ;
update _categories = true ; // Always to update All category
update _categories = true ; // Always to update All category
@ -350,7 +359,7 @@ window.addEvent('load', function () {
torrentsTable . altRow ( ) ;
torrentsTable . altRow ( ) ;
if ( response [ 'server_state' ] ) {
if ( response [ 'server_state' ] ) {
var tmp = response [ 'server_state' ] ;
var tmp = response [ 'server_state' ] ;
for ( var k in tmp )
for ( var k in tmp )
serverState [ k ] = tmp [ k ] ;
serverState [ k ] = tmp [ k ] ;
processServerState ( ) ;
processServerState ( ) ;
}
}
@ -376,7 +385,7 @@ window.addEvent('load', function () {
syncMainDataTimer = syncMainData . delay ( 100 ) ;
syncMainDataTimer = syncMainData . delay ( 100 ) ;
} ;
} ;
var processServerState = function ( ) {
var processServerState = function ( ) {
var transfer _info = friendlyUnit ( serverState . dl _info _speed , true ) ;
var transfer _info = friendlyUnit ( serverState . dl _info _speed , true ) ;
if ( serverState . dl _rate _limit > 0 )
if ( serverState . dl _rate _limit > 0 )
transfer _info += " [" + friendlyUnit ( serverState . dl _rate _limit , true ) + "]" ;
transfer _info += " [" + friendlyUnit ( serverState . dl _rate _limit , true ) + "]" ;
@ -390,7 +399,8 @@ window.addEvent('load', function () {
if ( speedInTitle ) {
if ( speedInTitle ) {
document . title = "QBT_TR([D: %1, U: %2] qBittorrent %3)QBT_TR[CONTEXT=MainWindow]" . replace ( "%1" , friendlyUnit ( serverState . dl _info _speed , true ) ) . replace ( "%2" , friendlyUnit ( serverState . up _info _speed , true ) ) . replace ( "%3" , "${VERSION}" ) ;
document . title = "QBT_TR([D: %1, U: %2] qBittorrent %3)QBT_TR[CONTEXT=MainWindow]" . replace ( "%1" , friendlyUnit ( serverState . dl _info _speed , true ) ) . replace ( "%2" , friendlyUnit ( serverState . up _info _speed , true ) ) . replace ( "%3" , "${VERSION}" ) ;
document . title += " QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]" ;
document . title += " QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]" ;
} else
}
else
document . title = "qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]" ;
document . title = "qBittorrent ${VERSION} QBT_TR(Web UI)QBT_TR[CONTEXT=OptionsDialog]" ;
$ ( 'DHTNodes' ) . set ( 'html' , 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]' . replace ( "%1" , serverState . dht _nodes ) ) ;
$ ( 'DHTNodes' ) . set ( 'html' , 'QBT_TR(DHT: %1 nodes)QBT_TR[CONTEXT=StatusBar]' . replace ( "%1" , serverState . dht _nodes ) ) ;
@ -460,16 +470,17 @@ window.addEvent('load', function () {
// Change icon immediately to give some feedback
// Change icon immediately to give some feedback
updateAltSpeedIcon ( ! alternativeSpeedLimits ) ;
updateAltSpeedIcon ( ! alternativeSpeedLimits ) ;
new Request ( { url : 'api/v2/transfer/toggleSpeedLimitsMode' ,
new Request ( {
method : 'post' ,
url : 'api/v2/transfer/toggleSpeedLimitsMode' ,
onComplete : function ( ) {
method : 'post' ,
alternativeSpeedLimits = ! alternativeSpeedLimits ;
onComplete : function ( ) {
updateMainData ( ) ;
alternativeSpeedLimits = ! alternativeSpeedLimits ;
} ,
updateMainData ( ) ;
onFailure : function ( ) {
} ,
// Restore icon in case of failure
onFailure : function ( ) {
updateAltSpeedIcon ( alternativeSpeedLimits ) ;
// Restore icon in case of failure
}
updateAltSpeedIcon ( alternativeSpeedLimits ) ;
}
} ) . send ( ) ;
} ) . send ( ) ;
} ) ;
} ) ;
@ -517,23 +528,23 @@ window.addEvent('load', function () {
$ ( 'StatisticsLink' ) . addEvent ( 'click' , StatisticsLinkFN ) ;
$ ( 'StatisticsLink' ) . addEvent ( 'click' , StatisticsLinkFN ) ;
new MochaUI . Panel ( {
new MochaUI . Panel ( {
id : 'transferList' ,
id : 'transferList' ,
title : 'Panel' ,
title : 'Panel' ,
header : false ,
header : false ,
padding : {
padding : {
top : 0 ,
top : 0 ,
right : 0 ,
right : 0 ,
bottom : 0 ,
bottom : 0 ,
left : 0
left : 0
} ,
} ,
loadMethod : 'xhr' ,
loadMethod : 'xhr' ,
contentURL : 'transferlist.html' ,
contentURL : 'transferlist.html' ,
onContentLoaded : function ( ) {
onContentLoaded : function ( ) {
updateMainData ( ) ;
updateMainData ( ) ;
} ,
} ,
column : 'mainColumn' ,
column : 'mainColumn' ,
onResize : saveColumnSizes ,
onResize : saveColumnSizes ,
height : null
height : null
} ) ;
} ) ;
var prop _h = localStorage . getItem ( 'properties_height_rel' ) ;
var prop _h = localStorage . getItem ( 'properties_height_rel' ) ;
if ( $defined ( prop _h ) )
if ( $defined ( prop _h ) )
@ -541,22 +552,22 @@ window.addEvent('load', function () {
else
else
prop _h = Window . getSize ( ) . y / 2.0 ;
prop _h = Window . getSize ( ) . y / 2.0 ;
new MochaUI . Panel ( {
new MochaUI . Panel ( {
id : 'propertiesPanel' ,
id : 'propertiesPanel' ,
title : 'Panel' ,
title : 'Panel' ,
header : true ,
header : true ,
padding : {
padding : {
top : 0 ,
top : 0 ,
right : 0 ,
right : 0 ,
bottom : 0 ,
bottom : 0 ,
left : 0
left : 0
} ,
} ,
contentURL : 'properties_content.html' ,
contentURL : 'properties_content.html' ,
require : {
require : {
css : [ 'css/Tabs.css' , 'css/dynamicTable.css' ] ,
css : [ 'css/Tabs.css' , 'css/dynamicTable.css' ] ,
js : [ 'scripts/prop-general.js' , 'scripts/prop-trackers.js' , 'scripts/prop-webseeds.js' , 'scripts/prop-files.js' ] ,
js : [ 'scripts/prop-general.js' , 'scripts/prop-trackers.js' , 'scripts/prop-webseeds.js' , 'scripts/prop-files.js' ] ,
} ,
} ,
tabsURL : 'properties.html' ,
tabsURL : 'properties.html' ,
tabsOnload : function ( ) {
tabsOnload : function ( ) {
MochaUI . initializeTabs ( 'propertiesTabs' ) ;
MochaUI . initializeTabs ( 'propertiesTabs' ) ;
updatePropertiesPanel = function ( ) {
updatePropertiesPanel = function ( ) {
@ -572,7 +583,7 @@ window.addEvent('load', function () {
updateTorrentFilesData ( ) ;
updateTorrentFilesData ( ) ;
} ;
} ;
$ ( 'PropGeneralLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'PropGeneralLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'prop_general' ) . removeClass ( "invisible" ) ;
$ ( 'prop_general' ) . removeClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
$ ( 'prop_webseeds' ) . addClass ( "invisible" ) ;
$ ( 'prop_webseeds' ) . addClass ( "invisible" ) ;
@ -582,7 +593,7 @@ window.addEvent('load', function () {
localStorage . setItem ( 'selected_tab' , this . id ) ;
localStorage . setItem ( 'selected_tab' , this . id ) ;
} ) ;
} ) ;
$ ( 'PropTrackersLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'PropTrackersLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'prop_trackers' ) . removeClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . removeClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_webseeds' ) . addClass ( "invisible" ) ;
$ ( 'prop_webseeds' ) . addClass ( "invisible" ) ;
@ -592,7 +603,7 @@ window.addEvent('load', function () {
localStorage . setItem ( 'selected_tab' , this . id ) ;
localStorage . setItem ( 'selected_tab' , this . id ) ;
} ) ;
} ) ;
$ ( 'PropPeersLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'PropPeersLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'prop_peers' ) . removeClass ( "invisible" ) ;
$ ( 'prop_peers' ) . removeClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
@ -602,7 +613,7 @@ window.addEvent('load', function () {
localStorage . setItem ( 'selected_tab' , this . id ) ;
localStorage . setItem ( 'selected_tab' , this . id ) ;
} ) ;
} ) ;
$ ( 'PropWebSeedsLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'PropWebSeedsLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'prop_webseeds' ) . removeClass ( "invisible" ) ;
$ ( 'prop_webseeds' ) . removeClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
@ -612,7 +623,7 @@ window.addEvent('load', function () {
localStorage . setItem ( 'selected_tab' , this . id ) ;
localStorage . setItem ( 'selected_tab' , this . id ) ;
} ) ;
} ) ;
$ ( 'PropFilesLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'PropFilesLink' ) . addEvent ( 'click' , function ( e ) {
$ ( 'prop_files' ) . removeClass ( "invisible" ) ;
$ ( 'prop_files' ) . removeClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_general' ) . addClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
$ ( 'prop_trackers' ) . addClass ( "invisible" ) ;
@ -622,12 +633,12 @@ window.addEvent('load', function () {
localStorage . setItem ( 'selected_tab' , this . id ) ;
localStorage . setItem ( 'selected_tab' , this . id ) ;
} ) ;
} ) ;
$ ( 'propertiesPanel_collapseToggle' ) . addEvent ( 'click' , function ( e ) {
$ ( 'propertiesPanel_collapseToggle' ) . addEvent ( 'click' , function ( e ) {
updatePropertiesPanel ( ) ;
updatePropertiesPanel ( ) ;
} ) ;
} ) ;
} ,
} ,
column : 'mainColumn' ,
column : 'mainColumn' ,
height : prop _h
height : prop _h
} ) ;
} ) ;
} ) ;
} ) ;
@ -679,9 +690,9 @@ keyboardEvents.activate();
var loadTorrentPeersTimer ;
var loadTorrentPeersTimer ;
var syncTorrentPeersLastResponseId = 0 ;
var syncTorrentPeersLastResponseId = 0 ;
var show _flags = true ;
var show _flags = true ;
var loadTorrentPeersData = function ( ) {
var loadTorrentPeersData = function ( ) {
if ( $ ( 'prop_peers' ) . hasClass ( 'invisible' ) ||
if ( $ ( 'prop_peers' ) . hasClass ( 'invisible' )
$ ( 'propertiesPanel_collapseToggle' ) . hasClass ( 'panel-expand' ) ) {
|| $ ( 'propertiesPanel_collapseToggle' ) . hasClass ( 'panel-expand' ) ) {
syncTorrentPeersLastResponseId = 0 ;
syncTorrentPeersLastResponseId = 0 ;
torrentPeersTable . clear ( ) ;
torrentPeersTable . clear ( ) ;
return ;
return ;
@ -727,7 +738,7 @@ var loadTorrentPeersData = function(){
}
}
}
}
if ( response [ 'peers_removed' ] )
if ( response [ 'peers_removed' ] )
response [ 'peers_removed' ] . each ( function ( hash ) {
response [ 'peers_removed' ] . each ( function ( hash ) {
torrentPeersTable . removeRow ( hash ) ;
torrentPeersTable . removeRow ( hash ) ;
} ) ;
} ) ;
torrentPeersTable . updateTable ( full _update ) ;
torrentPeersTable . updateTable ( full _update ) ;
@ -750,7 +761,7 @@ var loadTorrentPeersData = function(){
} ) . send ( ) ;
} ) . send ( ) ;
} ;
} ;
updateTorrentPeersData = function ( ) {
updateTorrentPeersData = function ( ) {
clearTimeout ( loadTorrentPeersTimer ) ;
clearTimeout ( loadTorrentPeersTimer ) ;
loadTorrentPeersData ( ) ;
loadTorrentPeersData ( ) ;
} ;
} ;