},
loadDaemonPrefs: function(async) {
- var tr = this;
this.remote.loadDaemonPrefs(function(data) {
var o = data['arguments'];
Prefs.getClutchPrefs(o);
- tr.updatePrefs(o);
- }, async);
+ this.updatePrefs(o);
+ }, this, async);
},
loadDaemonStats: function(async) {
- var tr = this;
this.remote.loadDaemonStats(function(data) {
- tr.updateStats(data['arguments']);
- }, async);
+ this.updateStats(data['arguments']);
+ }, this, async);
},
checkPort: function(async) {
$('#port_test').text('checking ...');
- var tr = this;
this.remote.checkPort(function(data) {
- tr.updatePortStatus(data['arguments']);
- }, async);
+ this.updatePortStatus(data['arguments']);
+ }, this, async);
},
preloadImages: function() {
},
removeTorrents: function(torrents) {
- var tr = this;
var ids = $.map(torrents, function(t) { return t.getId(); });
- this.remote.removeTorrents(ids, function() { tr.refreshTorrents();});
+ this.remote.removeTorrents(ids, this.refreshTorrents, this);
},
removeTorrentsAndData: function(torrents) {
this.startTorrents([ torrent ], false);
},
startTorrents: function(torrents, force) {
- var tr = this;
- var ids = $.map(torrents, function(t) { return t.getId(); });
- this.remote.startTorrents(ids, force, function() { tr.refreshTorrents(); });
+ this.remote.startTorrents($.map(torrents, function(t) {return t.getId();}),
+ force, this.refreshTorrents, this);
},
verifyTorrent: function(torrent) {
this.verifyTorrents([ torrent ]);
},
verifyTorrents: function(torrents) {
- var tr = this;
- var ids = $.map(torrents, function(t) { return t.getId(); });
- this.remote.verifyTorrents(ids, function() { tr.refreshTorrents(); });
+ this.remote.verifyTorrents($.map(torrents, function(t) {return t.getId();}),
+ this.refreshTorrents, this);
},
reannounceTorrent: function(torrent) {
this.reannounceTorrents([ torrent ]);
},
reannounceTorrents: function(torrents) {
- var tr = this;
- var ids = $.map(torrents, function(t) { return t.getId(); });
- this.remote.reannounceTorrents(ids, function() { tr.refreshTorrents(); });
+ this.remote.reannounceTorrents($.map(torrents, function(t) {return t.getId();}),
+ this.refreshTorrents, this);
},
stopSelectedTorrents: function() {
this.stopTorrents([ torrent ]);
},
stopTorrents: function(torrents) {
- var tr = this;
- var ids = $.map(torrents, function(t) { return t.getId(); });
- this.remote.stopTorrents(ids, function() { tr.refreshTorrents();});
+ this.remote.stopTorrents($.map(torrents.slice(0), function(t) {return t.getId();}),
+ this.refreshTorrents, this);
},
changeFileCommand: function(command, rows) {
this.remote.changeFileCommand(command, rows);
// Queue
moveTop: function() {
- var tr = this;
- var ids = this.getSelectedTorrentIds();
- this.remote.moveTorrentsToTop(ids, function() { tr.refreshTorrents();});
+ this.remote.moveTorrentsToTop(this.getSelectedTorrentIds(),
+ this.refreshTorrents, this);
},
moveUp: function() {
- var tr = this;
- var ids = this.getSelectedTorrentIds();
- this.remote.moveTorrentsUp(ids, function() { tr.refreshTorrents();});
+ this.remote.moveTorrentsUp(this.getSelectedTorrentIds(),
+ this.refreshTorrents, this);
},
moveDown: function() {
- var tr = this;
- var ids = this.getSelectedTorrentIds();
- this.remote.moveTorrentsDown(ids, function() { tr.refreshTorrents();});
+ this.remote.moveTorrentsDown(this.getSelectedTorrentIds(),
+ this.refreshTorrents, this);
},
moveBottom: function() {
- var tr = this;
- var ids = this.getSelectedTorrentIds();
- this.remote.moveTorrentsToBottom(ids, function() { tr.refreshTorrents();});
+ this.remote.moveTorrentsToBottom(this.getSelectedTorrentIds(),
+ this.refreshTorrents, this);
},
-
/***
****
***/
if (!$(this._inspector_trackers_list).is(':visible'))
return;
- var tr = this;
var html = [ ];
var na = 'N/A';
var torrents = this.getSelectedTorrents();
'<ul class="tier_list">');
}
- var lastAnnounceStatusHash = tr.lastAnnounceStatus(tracker);
- var announceState = tr.announceState(tracker);
- var lastScrapeStatusHash = tr.lastScrapeStatus(tracker);
+ var lastAnnounceStatusHash = this.lastAnnounceStatus(tracker);
+ var announceState = this.announceState(tracker);
+ var lastScrapeStatusHash = this.lastScrapeStatus(tracker);
// Display construction
var parity = ((j+1) % 2 == 0 ? 'even' : 'odd');
XHR.setRequestHeader('X-Transmission-Session-Id', this._token);
},
- sendRequest: function(data, success, async) {
+ sendRequest: function(data, callback, context, async) {
remote = this;
if (typeof async != 'boolean')
async = true;
data: $.toJSON(data),
beforeSend: function(XHR){ remote.appendSessionId(XHR); },
error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings); },
- success: success,
+ success: callback,
+ context: context,
async: async
};
$.ajax(ajaxSettings);
},
- loadDaemonPrefs: function(callback, async) {
+ loadDaemonPrefs: function(callback, context, async) {
var o = { method: 'session-get' };
- this.sendRequest(o, callback, async);
+ this.sendRequest(o, callback, context, async);
},
- checkPort: function(callback, async) {
+ checkPort: function(callback, context, async) {
var o = { method: 'port-test' };
- this.sendRequest(o, callback, async);
+ this.sendRequest(o, callback, context, async);
},
- loadDaemonStats: function(callback, async) {
+ loadDaemonStats: function(callback, context, async) {
var o = { method: 'session-stats' };
- this.sendRequest(o, callback, async);
+ this.sendRequest(o, callback, context, async);
},
updateTorrents: function(torrentIds, fields, callback, context) {
var o = {
method: 'torrent-get',
- 'arguments': {
+ 'arguments': {
'fields': fields,
}
};
});
},
- sendTorrentSetRequests: function(method, torrent_ids, args, callback) {
+ sendTorrentSetRequests: function(method, torrent_ids, args, callback, context) {
if (!args) args = { };
args['ids'] = torrent_ids;
var o = {
method: method,
arguments: args
};
-
- this.sendRequest(o, function(data) {
- callback();
- });
+ this.sendRequest(o, callback, context);
},
- sendTorrentActionRequests: function(method, torrent_ids, callback) {
- this.sendTorrentSetRequests(method, torrent_ids, null, callback);
+ sendTorrentActionRequests: function(method, torrent_ids, callback, context) {
+ this.sendTorrentSetRequests(method, torrent_ids, null, callback, context);
},
- startTorrents: function(torrent_ids, noqueue, callback) {
+ startTorrents: function(torrent_ids, noqueue, callback, context) {
var name = noqueue ? 'torrent-start-now' : 'torrent-start';
- this.sendTorrentActionRequests(name, torrent_ids, callback);
+ this.sendTorrentActionRequests(name, torrent_ids, callback, context);
},
- stopTorrents: function(torrent_ids, callback) {
- this.sendTorrentActionRequests('torrent-stop', torrent_ids, callback);
+ stopTorrents: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests('torrent-stop', torrent_ids, callback, context);
},
- removeTorrents: function(torrent_ids, callback) {
- this.sendTorrentActionRequests('torrent-remove', torrent_ids, callback);
+ removeTorrents: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests('torrent-remove', torrent_ids, callback, context);
},
removeTorrentsAndData: function(torrents) {
var remote = this;
remote._controller.refreshTorrents();
});
},
- verifyTorrents: function(torrent_ids, callback) {
- this.sendTorrentActionRequests('torrent-verify', torrent_ids, callback);
+ verifyTorrents: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests('torrent-verify', torrent_ids, callback, context);
},
reannounceTorrents: function(torrent_ids, callback) {
this.sendTorrentActionRequests('torrent-reannounce', torrent_ids, callback);
},
// Added queue calls
- moveTorrentsToTop: function(torrent_ids, callback) {
- this.sendTorrentActionRequests(RPC._QueueMoveTop, torrent_ids, callback);
+ moveTorrentsToTop: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests(RPC._QueueMoveTop, torrent_ids, callback, context);
},
- moveTorrentsToBottom: function(torrent_ids, callback) {
- this.sendTorrentActionRequests(RPC._QueueMoveBottom, torrent_ids, callback);
+ moveTorrentsToBottom: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests(RPC._QueueMoveBottom, torrent_ids, callback, context);
},
- moveTorrentsUp: function(torrent_ids, callback) {
- this.sendTorrentActionRequests(RPC._QueueMoveUp, torrent_ids, callback);
+ moveTorrentsUp: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests(RPC._QueueMoveUp, torrent_ids, callback, context);
},
- moveTorrentsDown: function(torrent_ids, callback) {
- this.sendTorrentActionRequests(RPC._QueueMoveDown, torrent_ids, callback);
+ moveTorrentsDown: function(torrent_ids, callback, context) {
+ this.sendTorrentActionRequests(RPC._QueueMoveDown, torrent_ids, callback, context);
}
};