Changeset 12778
- Timestamp:
- Aug 28, 2011, 6:05:46 AM (12 years ago)
- Location:
- trunk/web/javascript
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/javascript/transmission.js
r12777 r12778 150 150 151 151 loadDaemonPrefs: function(async) { 152 var tr = this;153 152 this.remote.loadDaemonPrefs(function(data) { 154 153 var o = data['arguments']; 155 154 Prefs.getClutchPrefs(o); 156 t r.updatePrefs(o);157 }, async);155 this.updatePrefs(o); 156 }, this, async); 158 157 }, 159 158 160 159 loadDaemonStats: function(async) { 161 var tr = this;162 160 this.remote.loadDaemonStats(function(data) { 163 t r.updateStats(data['arguments']);164 }, async);161 this.updateStats(data['arguments']); 162 }, this, async); 165 163 }, 166 164 checkPort: function(async) { 167 165 $('#port_test').text('checking ...'); 168 var tr = this;169 166 this.remote.checkPort(function(data) { 170 t r.updatePortStatus(data['arguments']);171 }, async);167 this.updatePortStatus(data['arguments']); 168 }, this, async); 172 169 }, 173 170 … … 1279 1276 1280 1277 removeTorrents: function(torrents) { 1281 var tr = this;1282 1278 var ids = $.map(torrents, function(t) { return t.getId(); }); 1283 this.remote.removeTorrents(ids, function() { tr.refreshTorrents();});1279 this.remote.removeTorrents(ids, this.refreshTorrents, this); 1284 1280 }, 1285 1281 … … 1306 1302 }, 1307 1303 startTorrents: function(torrents, force) { 1308 var tr = this; 1309 var ids = $.map(torrents, function(t) { return t.getId(); }); 1310 this.remote.startTorrents(ids, force, function() { tr.refreshTorrents(); }); 1304 this.remote.startTorrents($.map(torrents, function(t) {return t.getId();}), 1305 force, this.refreshTorrents, this); 1311 1306 }, 1312 1307 verifyTorrent: function(torrent) { … … 1314 1309 }, 1315 1310 verifyTorrents: function(torrents) { 1316 var tr = this; 1317 var ids = $.map(torrents, function(t) { return t.getId(); }); 1318 this.remote.verifyTorrents(ids, function() { tr.refreshTorrents(); }); 1311 this.remote.verifyTorrents($.map(torrents, function(t) {return t.getId();}), 1312 this.refreshTorrents, this); 1319 1313 }, 1320 1314 … … 1323 1317 }, 1324 1318 reannounceTorrents: function(torrents) { 1325 var tr = this; 1326 var ids = $.map(torrents, function(t) { return t.getId(); }); 1327 this.remote.reannounceTorrents(ids, function() { tr.refreshTorrents(); }); 1319 this.remote.reannounceTorrents($.map(torrents, function(t) {return t.getId();}), 1320 this.refreshTorrents, this); 1328 1321 }, 1329 1322 … … 1338 1331 }, 1339 1332 stopTorrents: function(torrents) { 1340 var tr = this; 1341 var ids = $.map(torrents, function(t) { return t.getId(); }); 1342 this.remote.stopTorrents(ids, function() { tr.refreshTorrents();}); 1333 this.remote.stopTorrents($.map(torrents.slice(0), function(t) {return t.getId();}), 1334 this.refreshTorrents, this); 1343 1335 }, 1344 1336 changeFileCommand: function(command, rows) { … … 1363 1355 // Queue 1364 1356 moveTop: function() { 1365 var tr = this; 1366 var ids = this.getSelectedTorrentIds(); 1367 this.remote.moveTorrentsToTop(ids, function() { tr.refreshTorrents();}); 1357 this.remote.moveTorrentsToTop(this.getSelectedTorrentIds(), 1358 this.refreshTorrents, this); 1368 1359 }, 1369 1360 moveUp: function() { 1370 var tr = this; 1371 var ids = this.getSelectedTorrentIds(); 1372 this.remote.moveTorrentsUp(ids, function() { tr.refreshTorrents();}); 1361 this.remote.moveTorrentsUp(this.getSelectedTorrentIds(), 1362 this.refreshTorrents, this); 1373 1363 }, 1374 1364 moveDown: function() { 1375 var tr = this; 1376 var ids = this.getSelectedTorrentIds(); 1377 this.remote.moveTorrentsDown(ids, function() { tr.refreshTorrents();}); 1365 this.remote.moveTorrentsDown(this.getSelectedTorrentIds(), 1366 this.refreshTorrents, this); 1378 1367 }, 1379 1368 moveBottom: function() { 1380 var tr = this; 1381 var ids = this.getSelectedTorrentIds(); 1382 this.remote.moveTorrentsToBottom(ids, function() { tr.refreshTorrents();}); 1383 }, 1384 1369 this.remote.moveTorrentsToBottom(this.getSelectedTorrentIds(), 1370 this.refreshTorrents, this); 1371 }, 1385 1372 1386 1373 /*** … … 1740 1727 return; 1741 1728 1742 var tr = this;1743 1729 var html = [ ]; 1744 1730 var na = 'N/A'; … … 1770 1756 } 1771 1757 1772 var lastAnnounceStatusHash = t r.lastAnnounceStatus(tracker);1773 var announceState = t r.announceState(tracker);1774 var lastScrapeStatusHash = t r.lastScrapeStatus(tracker);1758 var lastAnnounceStatusHash = this.lastAnnounceStatus(tracker); 1759 var announceState = this.announceState(tracker); 1760 var lastScrapeStatusHash = this.lastScrapeStatus(tracker); 1775 1761 1776 1762 // Display construction -
trunk/web/javascript/transmission.remote.js
r12767 r12778 97 97 }, 98 98 99 sendRequest: function(data, success, async) {99 sendRequest: function(data, callback, context, async) { 100 100 remote = this; 101 101 if (typeof async != 'boolean') … … 111 111 beforeSend: function(XHR){ remote.appendSessionId(XHR); }, 112 112 error: function(request, error_string, exception){ remote.ajaxError(request, error_string, exception, ajaxSettings); }, 113 success: success, 113 success: callback, 114 context: context, 114 115 async: async 115 116 }; … … 118 119 }, 119 120 120 loadDaemonPrefs: function(callback, async) {121 loadDaemonPrefs: function(callback, context, async) { 121 122 var o = { method: 'session-get' }; 122 this.sendRequest(o, callback, async);123 this.sendRequest(o, callback, context, async); 123 124 }, 124 125 125 checkPort: function(callback, async) {126 checkPort: function(callback, context, async) { 126 127 var o = { method: 'port-test' }; 127 this.sendRequest(o, callback, async);128 this.sendRequest(o, callback, context, async); 128 129 }, 129 130 130 loadDaemonStats: function(callback, async) {131 loadDaemonStats: function(callback, context, async) { 131 132 var o = { method: 'session-stats' }; 132 this.sendRequest(o, callback, async);133 this.sendRequest(o, callback, context, async); 133 134 }, 134 135 … … 136 137 var o = { 137 138 method: 'torrent-get', 138 'arguments': {139 'arguments': { 139 140 'fields': fields, 140 141 } … … 164 165 }, 165 166 166 sendTorrentSetRequests: function(method, torrent_ids, args, callback ) {167 sendTorrentSetRequests: function(method, torrent_ids, args, callback, context) { 167 168 if (!args) args = { }; 168 169 args['ids'] = torrent_ids; … … 171 172 arguments: args 172 173 }; 173 174 this.sendRequest(o, function(data) { 175 callback(); 176 }); 177 }, 178 179 sendTorrentActionRequests: function(method, torrent_ids, callback) { 180 this.sendTorrentSetRequests(method, torrent_ids, null, callback); 181 }, 182 183 startTorrents: function(torrent_ids, noqueue, callback) { 174 this.sendRequest(o, callback, context); 175 }, 176 177 sendTorrentActionRequests: function(method, torrent_ids, callback, context) { 178 this.sendTorrentSetRequests(method, torrent_ids, null, callback, context); 179 }, 180 181 startTorrents: function(torrent_ids, noqueue, callback, context) { 184 182 var name = noqueue ? 'torrent-start-now' : 'torrent-start'; 185 this.sendTorrentActionRequests(name, torrent_ids, callback );186 }, 187 stopTorrents: function(torrent_ids, callback ) {188 this.sendTorrentActionRequests('torrent-stop', torrent_ids, callback );189 }, 190 removeTorrents: function(torrent_ids, callback ) {191 this.sendTorrentActionRequests('torrent-remove', torrent_ids, callback );183 this.sendTorrentActionRequests(name, torrent_ids, callback, context); 184 }, 185 stopTorrents: function(torrent_ids, callback, context) { 186 this.sendTorrentActionRequests('torrent-stop', torrent_ids, callback, context); 187 }, 188 removeTorrents: function(torrent_ids, callback, context) { 189 this.sendTorrentActionRequests('torrent-remove', torrent_ids, callback, context); 192 190 }, 193 191 removeTorrentsAndData: function(torrents) { … … 210 208 }); 211 209 }, 212 verifyTorrents: function(torrent_ids, callback ) {213 this.sendTorrentActionRequests('torrent-verify', torrent_ids, callback );210 verifyTorrents: function(torrent_ids, callback, context) { 211 this.sendTorrentActionRequests('torrent-verify', torrent_ids, callback, context); 214 212 }, 215 213 reannounceTorrents: function(torrent_ids, callback) { … … 253 251 254 252 // Added queue calls 255 moveTorrentsToTop: function(torrent_ids, callback ) {256 this.sendTorrentActionRequests(RPC._QueueMoveTop, torrent_ids, callback );257 }, 258 moveTorrentsToBottom: function(torrent_ids, callback ) {259 this.sendTorrentActionRequests(RPC._QueueMoveBottom, torrent_ids, callback );260 }, 261 moveTorrentsUp: function(torrent_ids, callback ) {262 this.sendTorrentActionRequests(RPC._QueueMoveUp, torrent_ids, callback );263 }, 264 moveTorrentsDown: function(torrent_ids, callback ) {265 this.sendTorrentActionRequests(RPC._QueueMoveDown, torrent_ids, callback );253 moveTorrentsToTop: function(torrent_ids, callback, context) { 254 this.sendTorrentActionRequests(RPC._QueueMoveTop, torrent_ids, callback, context); 255 }, 256 moveTorrentsToBottom: function(torrent_ids, callback, context) { 257 this.sendTorrentActionRequests(RPC._QueueMoveBottom, torrent_ids, callback, context); 258 }, 259 moveTorrentsUp: function(torrent_ids, callback, context) { 260 this.sendTorrentActionRequests(RPC._QueueMoveUp, torrent_ids, callback, context); 261 }, 262 moveTorrentsDown: function(torrent_ids, callback, context) { 263 this.sendTorrentActionRequests(RPC._QueueMoveDown, torrent_ids, callback, context); 266 264 } 267 265 };
Note: See TracChangeset
for help on using the changeset viewer.