diff --git a/deluge/ui/web/js/deluge-all/.build b/deluge/ui/web/js/deluge-all/.build index 8002f0dda..4eaaec9d7 100644 --- a/deluge/ui/web/js/deluge-all/.build +++ b/deluge/ui/web/js/deluge-all/.build @@ -4,6 +4,7 @@ add_file "Deluge.js" add_file "Deluge.Formatters.js" add_file "Deluge.Keys.js" add_file "Deluge.Menus.js" +add_file "Deluge.Sorters.js" add_file "Deluge.EventsManager.js" add_file "Deluge.OptionsManager.js" add_file "Deluge.MultiOptionsManager.js" diff --git a/deluge/ui/web/js/deluge-all/Deluge.Sorters.js b/deluge/ui/web/js/deluge-all/Deluge.Sorters.js new file mode 100644 index 000000000..33ad9d684 --- /dev/null +++ b/deluge/ui/web/js/deluge-all/Deluge.Sorters.js @@ -0,0 +1,50 @@ +/* +Script: Deluge.data.Peer.js + Contains the definition for a Peer record. + +Copyright: + (C) Damien Churchill 2009-2010 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the OpenSSL + library. + You must obey the GNU General Public License in all respects for all of + the code used other than OpenSSL. If you modify file(s) with this + exception, you may extend this exception to your version of the file(s), + but you are not obligated to do so. If you do not wish to do so, delete + this exception statement from your version. If you delete this exception + statement from all source files in the program, then also delete it here. +*/ + +Ext.namespace('Deluge'); + +/** + * Common sort functions that can be used for data Stores. + * + * @author Damien Churchill + * @version 1.3 + * + * @class Deluge.Sorters + * @singleton + */ +Deluge.Sorters = { + ipAddress: function(value) { + var d = value.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/); + return ((((((+d[1])*256)+(+d[2]))*256)+(+d[3]))*256)+(+d[4]); + } +} diff --git a/deluge/ui/web/js/deluge-all/Deluge.Torrents.js b/deluge/ui/web/js/deluge-all/Deluge.Torrents.js index 4aae0b71b..6a2caa6c9 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Torrents.js +++ b/deluge/ui/web/js/deluge-all/Deluge.Torrents.js @@ -273,7 +273,7 @@ Copyright: } record.endEdit(); } else { - var record = new Deluge.Torrent(torrent); + var record = new Deluge.data.Torrent(torrent); record.id = t; this.torrents[t] = 1; newTorrents.push(record); diff --git a/deluge/ui/web/js/deluge-all/Deluge.data.Peer.js b/deluge/ui/web/js/deluge-all/Deluge.data.Peer.js new file mode 100644 index 000000000..4b5e52a2a --- /dev/null +++ b/deluge/ui/web/js/deluge-all/Deluge.data.Peer.js @@ -0,0 +1,71 @@ +/* +Script: Deluge.data.Peer.js + Contains the definition for a Peer record. + +Copyright: + (C) Damien Churchill 2009-2010 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the OpenSSL + library. + You must obey the GNU General Public License in all respects for all of + the code used other than OpenSSL. If you modify file(s) with this + exception, you may extend this exception to your version of the file(s), + but you are not obligated to do so. If you do not wish to do so, delete + this exception statement from your version. If you delete this exception + statement from all source files in the program, then also delete it here. +*/ + +Ext.namespace('Deluge.data'); + +/** + * Deluge.data.Peer record + * + * @author Damien Churchill + * @version 1.3 + * + * @class Deluge.data.Peer + * @extends Ext.data.Record + * @constructor + * @param {Object} data The peer data + */ +Deluge.data.Peer = Ext.data.Record.create([ + { + name: 'country', + type: 'string' + }, { + name: 'address', + type: 'string', + sortType: Deluge.Sorters.ipSorter + }, { + name: 'client', + type: 'string' + }, { + name: 'progress', + type: 'float' + }, { + name: 'downspeed', + type: 'int' + }, { + name: 'upspeed', + type: 'int' + }, { + name: 'seed', + type: 'int' + } +]); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Torrent.js b/deluge/ui/web/js/deluge-all/Deluge.data.Torrent.js similarity index 92% rename from deluge/ui/web/js/deluge-all/Deluge.Torrent.js rename to deluge/ui/web/js/deluge-all/Deluge.data.Torrent.js index 979587ae3..7f8ffc6b9 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Torrent.js +++ b/deluge/ui/web/js/deluge-all/Deluge.data.Torrent.js @@ -1,5 +1,5 @@ /* -Script: Deluge.Torrent.js +Script: Deluge.data.Torrent.js Contains the Deluge.Torrent record. Copyright: @@ -31,18 +31,20 @@ Copyright: statement from all source files in the program, then also delete it here. */ +Ext.namespace('Deluge.data'); + /** - * Deluge.Torrent record + * Deluge.data.Torrent record * * @author Damien Churchill * @version 1.3 * - * @class Deluge.Torrent + * @class Deluge.data.Torrent * @extends Ext.data.Record * @constructor * @param {Object} data The torrents data */ -Deluge.Torrent = Ext.data.Record.create([{ +Deluge.data.Torrent = Ext.data.Record.create([{ name: 'queue', type: 'int' }, { diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 3072c2ac4..1638277a4 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -325,9 +325,12 @@ class TopLevel(resource.Resource): "js/deluge-all/Deluge.js", "js/deluge-all/Deluge.Formatters.js", "js/deluge-all/Deluge.Menus.js", + "js/deluge-all/Deluge.Sorters.js", "js/deluge-all/Deluge.EventsManager.js", "js/deluge-all/Deluge.OptionsManager.js", "js/deluge-all/Deluge.MultiOptionsManager.js", + "js/deluge-all/Deluge.data.Peer.js", + "js/deluge-all/Deluge.data.Torrent.js", "js/deluge-all/Deluge.Add.js", "js/deluge-all/Deluge.Add.File.js", "js/deluge-all/Deluge.Add.Url.js", @@ -362,7 +365,6 @@ class TopLevel(resource.Resource): "js/deluge-all/Deluge.Sidebar.js", "js/deluge-all/Deluge.Statusbar.js", "js/deluge-all/Deluge.Toolbar.js", - "js/deluge-all/Deluge.Torrent.js", "js/deluge-all/Deluge.Torrents.js", "js/deluge-all/Deluge.UI.js" ]