@ -1,4 +1,3 @@
var waitingTorrentFiles = false ;
var is _seed = true ;
var is _seed = true ;
var current _hash = "" ;
var current _hash = "" ;
@ -273,6 +272,7 @@ var filesDynTable = new Class({
} ,
} ,
} ) ;
} ) ;
var loadTorrentFilesDataTimer ;
var loadTorrentFilesData = function ( ) {
var loadTorrentFilesData = function ( ) {
if ( $ ( 'prop_files' ) . hasClass ( 'invisible' ) ) {
if ( $ ( 'prop_files' ) . hasClass ( 'invisible' ) ) {
// Tab changed, don't do anything
// Tab changed, don't do anything
@ -281,7 +281,7 @@ var loadTorrentFilesData = function() {
var new _hash = myTable . getCurrentTorrentHash ( ) ;
var new _hash = myTable . getCurrentTorrentHash ( ) ;
if ( new _hash == "" ) {
if ( new _hash == "" ) {
fTable . removeAllRows ( ) ;
fTable . removeAllRows ( ) ;
loadTorrentFilesData . delay ( 1500 ) ;
loadTorrentFilesDataTimer = loadTorrentFilesData . delay ( 1500 ) ;
return ;
return ;
}
}
if ( new _hash != current _hash ) {
if ( new _hash != current _hash ) {
@ -289,16 +289,13 @@ var loadTorrentFilesData = function() {
current _hash = new _hash ;
current _hash = new _hash ;
}
}
var url = 'json/propertiesFiles/' + current _hash ;
var url = 'json/propertiesFiles/' + current _hash ;
if ( ! waitingTorrentFiles ) {
waitingTorrentFiles = true ;
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 ( ) {
$ ( 'error_div' ) . set ( 'html' , '_(qBittorrent client is not reachable)' ) ;
$ ( 'error_div' ) . set ( 'html' , '_(qBittorrent client is not reachable)' ) ;
waitingTorrentFiles = false ;
loadTorrentFilesDataTimer = loadTorrentFilesData . delay ( 2000 ) ;
loadTorrentFilesData . delay ( 2000 ) ;
} ,
} ,
onSuccess : function ( files ) {
onSuccess : function ( files ) {
$ ( 'error_div' ) . set ( 'html' , '' ) ;
$ ( 'error_div' ) . set ( 'html' , '' ) ;
@ -337,12 +334,15 @@ var loadTorrentFilesData = function() {
else {
else {
fTable . removeAllRows ( ) ;
fTable . removeAllRows ( ) ;
}
}
waitingTorrentFiles = false ;
loadTorrentFilesDataTimer = loadTorrentFilesData . delay ( 1500 ) ;
loadTorrentFilesData . delay ( 1500 ) ;
}
}
} ) . send ( ) ;
} ) . send ( ) ;
}
}
var updateTorrentFilesData = function ( ) {
clearTimeout ( loadTorrentFilesDataTimer ) ;
loadTorrentFilesData ( ) ;
}
}
fTable = new filesDynTable ( ) ;
fTable = new filesDynTable ( ) ;
fTable . setup ( $ ( 'filesTable' ) ) ;
fTable . setup ( $ ( 'filesTable' ) ) ;