@ -23,7 +23,6 @@
@@ -23,7 +23,6 @@
* /
myTable = new dynamicTable ( ) ;
ajaxfn = function ( ) { } ;
window . addEvent ( 'load' , function ( ) {
@ -77,8 +76,6 @@ window.addEvent('load', function () {
@@ -77,8 +76,6 @@ window.addEvent('load', function () {
} ) ;
initializeWindows ( ) ;
var r = 0 ;
var waiting = false ;
var waitingTrInfo = false ;
var stateToImg = function ( state ) {
if ( state == "pausedUP" || state == "pausedDL" ) {
@ -94,18 +91,17 @@ window.addEvent('load', function () {
@@ -94,18 +91,17 @@ window.addEvent('load', function () {
}
return 'images/skin/' + state + '.png' ;
} ;
var loadTransferInfoTimer ;
var loadTransferInfo = function ( ) {
var url = 'json/transferInfo' ;
if ( ! waitingTrInfo ) {
waitingTrInfo = true ;
var request = new Request . JSON ( {
url : url ,
noCache : true ,
method : 'get' ,
onFailure : function ( ) {
$ ( 'error_div' ) . set ( 'html' , '_(qBittorrent client is not reachable)' ) ;
waitingTrInfo = false ;
loadTransferInfo . delay ( 4000 ) ;
loadTransferInfoTimer = loadTransferInfo . delay ( 4000 ) ;
} ,
onSuccess : function ( info ) {
if ( info ) {
@ -119,32 +115,37 @@ window.addEvent('load', function () {
@@ -119,32 +115,37 @@ window.addEvent('load', function () {
document . title = "_(D:%1 U:%2)" . replace ( "%1" , friendlyUnit ( info . dl _info _speed , true ) ) . replace ( "%2" , friendlyUnit ( info . up _info _speed , true ) ) ;
else
document . title = "_(qBittorrent web User Interface)" ;
waitingTrInfo = false ;
loadTransferInfo . delay ( 3000 ) ;
loadTransferInfoTimer = loadTransferInfo . delay ( 3000 ) ;
}
}
} ) . send ( ) ;
}
} ;
var updateTransferInfo = function ( ) {
clearTimeout ( loadTransferInfoTimer ) ;
loadTransferInfoTimer = loadTransferInfo ( ) ;
}
// Start fetching data now
loadTransferInfo ( ) ;
$ ( 'DlInfos' ) . addEvent ( 'click' , globalDownloadLimitFN ) ;
$ ( 'UpInfos' ) . addEvent ( 'click' , globalUploadLimitFN ) ;
var ajaxfnTimer ;
var ajaxfn = function ( ) {
var queueing _enabled = false ;
var url = new URI ( 'json/torrents' ) ;
url . setData ( 'filter' , filter ) ;
url . setData ( 'sort' , myTable . table . sortedColumn ) ;
url . setData ( 'reverse' , myTable . table . reverseSort ) ;
if ( ! waiting ) {
waiting = true ;
var request = new Request . JSON ( {
url : url ,
noCache : true ,
method : 'get' ,
onFailure : function ( ) {
$ ( 'error_div' ) . set ( 'html' , '_(qBittorrent client is not reachable)' ) ;
waiting = false ;
ajaxfn . delay ( 2000 ) ;
ajaxfnTimer = ajaxfn . delay ( 2000 ) ;
} ,
onSuccess : function ( events ) {
$ ( 'error_div' ) . set ( 'html' , '' ) ;
@ -217,17 +218,19 @@ window.addEvent('load', function () {
@@ -217,17 +218,19 @@ window.addEvent('load', function () {
myTable . altRow ( ) ;
}
waiting = false ;
ajaxfn . delay ( 1500 ) ;
ajaxfnTimer = ajaxfn . delay ( 1500 ) ;
}
} ) . send ( ) ;
}
} ;
var updateTransferList = function ( ) {
clearTimeout ( ajaxfnTimer ) ;
ajaxfnTimer = ajaxfn ( ) ;
}
setSortedColumn = function ( column ) {
myTable . setSortedColumn ( column ) ;
// reload torrents
ajaxfn ( ) ;
updateTransferList ( ) ;
} ;
new MochaUI . Panel ( {
@ -243,7 +246,7 @@ window.addEvent('load', function () {
@@ -243,7 +246,7 @@ window.addEvent('load', function () {
loadMethod : 'xhr' ,
contentURL : 'transferlist.html' ,
onContentLoaded : function ( ) {
ajaxfn ( ) ;
updateTransferList ( ) ;
} ,
column : 'mainColumn' ,
onResize : saveColumnSizes ,
@ -272,8 +275,6 @@ window.addEvent('load', function () {
@@ -272,8 +275,6 @@ window.addEvent('load', function () {
column : 'mainColumn' ,
height : prop _h
} ) ;
//ajaxfn();
loadTransferInfo ( ) ;
setFilter = function ( f ) {
// Visually Select the right filter
@ -287,7 +288,7 @@ window.addEvent('load', function () {
@@ -287,7 +288,7 @@ window.addEvent('load', function () {
filter = f ;
localStorage . setItem ( 'selected_filter' , f ) ;
// Reload torrents
ajaxfn ( ) ;
updateTransferList ( ) ;
}
} ) ;