Module: deluge Branch: master Commit: b4404feed7c4808692d34863c0a41bc382832f48
Author: Damien Churchill <[email protected]> Date: Sun Apr 25 21:18:29 2010 +0100 add 2 new methods that return the torrent ids to make rpc calls easier --- deluge/ui/web/js/deluge-all/Menus.js | 6 +----- deluge/ui/web/js/deluge-all/Torrents.js | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/deluge/ui/web/js/deluge-all/Menus.js b/deluge/ui/web/js/deluge-all/Menus.js index 6951633..37041e5 100644 --- a/deluge/ui/web/js/deluge-all/Menus.js +++ b/deluge/ui/web/js/deluge-all/Menus.js @@ -32,11 +32,7 @@ deluge.menus = { onTorrentAction: function(item, e) { - var selection = deluge.torrents.getSelections(); - var ids = []; - Ext.each(selection, function(record) { - ids.push(record.id); - }); + var ids = deluge.torrents.getSelectedIds(); var action = item.initialConfig.torrentAction; switch (action) { diff --git a/deluge/ui/web/js/deluge-all/Torrents.js b/deluge/ui/web/js/deluge-all/Torrents.js index 70e57d6..14d7976 100644 --- a/deluge/ui/web/js/deluge-all/Torrents.js +++ b/deluge/ui/web/js/deluge-all/Torrents.js @@ -243,7 +243,7 @@ * @ return {Array/Ext.data.Record} The record(s) representing the rows */ getSelected: function() { - return this.getSelectionModel().getSelected(); + return this.getSelectionModel().getSelected(); }, /** @@ -253,6 +253,26 @@ return this.getSelectionModel().getSelections(); }, + /** + * Return the currently selected torrent id. + * @return {String} The currently selected id. + */ + getSelectedId: function() { + return this.getSelectionModel().getSelected().id + }, + + /** + * Return the currently selected torrent ids. + * @return {Array} The currently selected ids. + */ + getSelectedIds: function() { + var ids = []; + Ext.each(this.getSelectionModel().getSelections(), function(r) { + ids.push(r.id); + }); + return ids; + }, + update: function(torrents) { var store = this.getStore(); var newTorrents = []; -- You received this message because you are subscribed to the Google Groups "deluge-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/deluge-commit?hl=en.
