add a new namespace for data records, Deluge.data

rename Deluge.Torrent to Deluge.data.Torrent
add new file Deluge.data.Peer that contains records in the Peers grid
add a singleton that contains sort functions
This commit is contained in:
Damien Churchill 2010-03-27 12:40:16 +00:00
parent ce0dc49572
commit 323638a751
6 changed files with 132 additions and 6 deletions

View File

@ -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"

View File

@ -0,0 +1,50 @@
/*
Script: Deluge.data.Peer.js
Contains the definition for a Peer record.
Copyright:
(C) Damien Churchill 2009-2010 <damoxc@gmail.com>
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 <damoxc@gmail.com>
* @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]);
}
}

View File

@ -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);

View File

@ -0,0 +1,71 @@
/*
Script: Deluge.data.Peer.js
Contains the definition for a Peer record.
Copyright:
(C) Damien Churchill 2009-2010 <damoxc@gmail.com>
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 <damoxc@gmail.com>
* @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'
}
]);

View File

@ -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 <damoxc@gmail.com>
* @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'
}, {

View File

@ -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"
]