diff --git a/deluge/ui/web/docs/files.html b/deluge/ui/web/docs/files.html new file mode 100644 index 000000000..e2d1ffff5 --- /dev/null +++ b/deluge/ui/web/docs/files.html @@ -0,0 +1,620 @@ + + + + + + JsDoc Reference - File Index + + + + + + + + +
+
Class Index +| File Index
+
+

Classes

+ +
+
+ +
+

File Index

+ + +
+

Deluge.Add.File.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Add.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Add.Url.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Client.js

+ +
+ + + + +
+
+
+ +
+

Deluge.ConnectionManager.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Details.Details.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Details.Files.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Details.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Details.Options.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Details.Peers.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Details.Status.js

+ +
+ + + + +
+
+
+ +
+

Deluge.EditTrackers.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Events.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Formatters.js

+ +
+ + + + +
+
+
+ +
+

Deluge.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Keys.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Login.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Menus.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Bandwidth.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Daemon.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Downloads.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Interface.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Network.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Notification.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Other.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Plugins.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Proxy.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Preferences.Queue.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Sidebar.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Statusbar.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Toolbar.js

+ +
+ + + + +
+
+
+ +
+

Deluge.Torrents.js

+ +
+ + + + +
+
+
+ +
+

Deluge.UI.js

+ +
+ + + + +
+
+
+ + +
+
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:57 GMT+0100 (BST) +
+ + \ No newline at end of file diff --git a/deluge/ui/web/docs/index.html b/deluge/ui/web/docs/index.html new file mode 100644 index 000000000..cb29a53bf --- /dev/null +++ b/deluge/ui/web/docs/index.html @@ -0,0 +1,242 @@ + + + + + + JsDoc Reference - Index + + + + + + + + +
+
Class Index +| File Index
+
+

Classes

+ +
+
+ +
+

Class Index

+ + +
+

_global_

+ +
+
+ +
+

Deluge.Events

+ Deluge.Events +
+
+ +
+

Deluge.Formatters

+ Deluge.Formatters +
+
+ +
+

Deluge.Keys

+ Deluge.Keys +
+
+ +
+

Ext.deluge.TorrentGrid

+ Ext.deluge.TorrentGrid +
+
+ + +
+
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:57 GMT+0100 (BST) +
+ + \ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/Deluge.Events.html b/deluge/ui/web/docs/symbols/Deluge.Events.html new file mode 100644 index 000000000..9c796613f --- /dev/null +++ b/deluge/ui/web/docs/symbols/Deluge.Events.html @@ -0,0 +1,306 @@ + + + + + + + JsDoc Reference - Deluge.Events + + + + + + + + + + + +
+ +
Class Index +| File Index
+
+

Classes

+ +
+ +
+ +
+ +

+ + Namespace Deluge.Events +

+ + +

+ + + Deluge.Events + + +
Defined in: Deluge.Events.js. + +

+ + + + + + + + + + + + + + + + + +
Namespace Summary
Constructor AttributesConstructor Name and Description
  + +
Class for holding global events that occur within the UI.
+
+ + + + + + + + + + + + +
+
+ Namespace Detail +
+ +
+ Deluge.Events +
+ +
+ Class for holding global events that occur within the UI. + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:56 GMT+0100 (BST) +
+ + diff --git a/deluge/ui/web/docs/symbols/Deluge.Formatters.html b/deluge/ui/web/docs/symbols/Deluge.Formatters.html new file mode 100644 index 000000000..bd37290ce --- /dev/null +++ b/deluge/ui/web/docs/symbols/Deluge.Formatters.html @@ -0,0 +1,592 @@ + + + + + + + JsDoc Reference - Deluge.Formatters + + + + + + + + + + + +
+ +
Class Index +| File Index
+
+

Classes

+ +
+ +
+ +
+ +

+ + Namespace Deluge.Formatters +

+ + +

+ + + Deluge.Formatters + + +
Defined in: Deluge.Formatters.js. + +

+ + + + + + + + + + + + + + + + + +
Namespace Summary
Constructor AttributesConstructor Name and Description
  + +
A collection of functions for string formatting values.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
Method AttributesMethod Name and Description
<static>   +
Deluge.Formatters.date(timestamp) +
+
Formats a date string in the locale's date representation based on the +systems timezone.
+
<static>   +
Deluge.Formatters.plain(value,) +
+
Simply returns the value untouched, for when no formatting is required.
+
<static>   +
Deluge.Formatters.size(bytes) +
+
Formats the bytes value into a string with KiB, MiB or GiB units.
+
<static>   +
Deluge.Formatters.speed(bytes) +
+
Formats a string to display a transfer speed utilizing Deluge.Formatters.size
+
<static>   +
Deluge.Formatters.timeRemaining(time) +
+
Formats a string to show time in a human readable form.
+
+ + + + + + + + + +
+
+ Namespace Detail +
+ +
+ Deluge.Formatters +
+ +
+ A collection of functions for string formatting values. + +
+ + + + + + + + + + + + +
+ + + + + + + +
+ Method Detail +
+ + +
<static> + + {string} + Deluge.Formatters.date(timestamp) + +
+
+ Formats a date string in the locale's date representation based on the +systems timezone. + + +
+ + + + +
+
Parameters:
+ +
+ {number} timestamp + +
+
time in seconds since the Epoch
+ +
+ + + + + +
+
Returns:
+ +
{string} a string in the locale's date representation or "" +if seconds < 0
+ +
+ + + + +
+ + +
<static> + + + Deluge.Formatters.plain(value,) + +
+
+ Simply returns the value untouched, for when no formatting is required. + + +
+ + + + +
+
Parameters:
+ +
+ value, + +
+
the value to be displayed
+ +
+ + + + + +
+
Returns:
+ +
the untouched value.
+ +
+ + + + +
+ + +
<static> + + {string} + Deluge.Formatters.size(bytes) + +
+
+ Formats the bytes value into a string with KiB, MiB or GiB units. + + +
+ + + + +
+
Parameters:
+ +
+ {number} bytes + +
+
the filesize in bytes
+ +
+ + + + + +
+
Returns:
+ +
{string} formatted string with KiB, MiB or GiB units.
+ +
+ + + + +
+ + +
<static> + + {string} + Deluge.Formatters.speed(bytes) + +
+
+ Formats a string to display a transfer speed utilizing Deluge.Formatters.size + + +
+ + + + +
+
Parameters:
+ +
+ {number} bytes + +
+
the filesize in bytes
+ +
+ + + + + +
+
Returns:
+ +
{string} formatted string with KiB, MiB or GiB units.
+ +
+ + + + +
+ + +
<static> + + {string} + Deluge.Formatters.timeRemaining(time) + +
+
+ Formats a string to show time in a human readable form. + + +
+ + + + +
+
Parameters:
+ +
+ {number} time + +
+
the number of seconds
+ +
+ + + + + +
+
Returns:
+ +
{string} a formatted time string. will return '' if seconds == 0
+ +
+ + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:57 GMT+0100 (BST) +
+ + diff --git a/deluge/ui/web/docs/symbols/Deluge.Keys.html b/deluge/ui/web/docs/symbols/Deluge.Keys.html new file mode 100644 index 000000000..01491c84e --- /dev/null +++ b/deluge/ui/web/docs/symbols/Deluge.Keys.html @@ -0,0 +1,528 @@ + + + + + + + JsDoc Reference - Deluge.Keys + + + + + + + + + + + +
+ +
Class Index +| File Index
+
+

Classes

+ +
+ +
+ +
+ +

+ + Namespace Deluge.Keys +

+ + +

+ + + Deluge.Keys + + +
Defined in: Deluge.Keys.js. + +

+ + + + + + + + + + + + + + + + + +
Namespace Summary
Constructor AttributesConstructor Name and Description
  + +
The torrent status keys that are commonly used around the UI.
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Field Summary
Field AttributesField Name and Description
<static>   +
+ Deluge.Keys.Details +
+
Keys used in the details tab of the statistics panel.
+
<static>   +
+ Deluge.Keys.Files +
+
Keys used in the files tab of the statistics panel.
+
<static>   +
+ Deluge.Keys.Grid +
+
+
<static>   +
+ Deluge.Keys.Options +
+
Keys used in the options tab of the statistics panel.
+
<static>   +
+ Deluge.Keys.Peers +
+
Keys used in the peers tab of the statistics panel.
+
<static>   +
+ Deluge.Keys.Status +
+
Keys used in the status tab of the statistics panel.
+
+ + + + + + + + + + + + +
+
+ Namespace Detail +
+ +
+ Deluge.Keys +
+ +
+ The torrent status keys that are commonly used around the UI. + +
+ + + + + + + + + + + + +
+ + + + +
+ Field Detail +
+ + +
<static> + + + Deluge.Keys.Details + +
+
+ Keys used in the details tab of the statistics panel. + + +
+ + + + + + + + +
+ + +
<static> + + + Deluge.Keys.Files + +
+
+ Keys used in the files tab of the statistics panel. +
['files', 'file_progress', 'file_priorities']
+ + +
+ + + + + + + + +
+ + +
<static> + + + Deluge.Keys.Grid + +
+
+ + + +
+ + + + + + + + +
+ + +
<static> + + + Deluge.Keys.Options + +
+
+ Keys used in the options tab of the statistics panel. +
['max_download_speed', 'max_upload_speed', 'max_connections', 'max_upload_slots',
+ 'is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'remove_at_ratio', 'private',
+ 'prioritize_first_last']
+ + +
+ + + + + + + + +
+ + +
<static> + + + Deluge.Keys.Peers + +
+
+ Keys used in the peers tab of the statistics panel. +
['peers', 'seed']
+ + +
+ + + + + + + + +
+ + +
<static> + + + Deluge.Keys.Status + +
+
+ Keys used in the status tab of the statistics panel. +These get extended +by Deluge.Keys.Grid. + + +
+ + + + + + + + + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:57 GMT+0100 (BST) +
+ + diff --git a/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html b/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html new file mode 100644 index 000000000..e70350faa --- /dev/null +++ b/deluge/ui/web/docs/symbols/Ext.deluge.TorrentGrid.html @@ -0,0 +1,319 @@ + + + + + + + JsDoc Reference - Ext.deluge.TorrentGrid + + + + + + + + + + + +
+ +
Class Index +| File Index
+
+

Classes

+ +
+ +
+ +
+ +

+ + Class Ext.deluge.TorrentGrid +

+ + +

+
Extends + Ext.grid.GridPanel.
+ + + Ext.deluge.TorrentGrid + + +
Defined in: Deluge.Torrents.js. + +

+ + + + + + + + + + + + + + + + + +
Class Summary
Constructor AttributesConstructor Name and Description
  + +
Ext.deluge.TorrentGrid Class
+
+ + + + + + + + + + + + +
+
+ Class Detail +
+ +
+ Ext.deluge.TorrentGrid(config) +
+ +
+ Ext.deluge.TorrentGrid Class +
Author: Damien Churchill . +
+ + + + + +
+
Parameters:
+ +
+ {Object} config + +
+
Configuration options
+ +
+ + + + + + + + +
+ + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:57 GMT+0100 (BST) +
+ + diff --git a/deluge/ui/web/docs/symbols/_global_.html b/deluge/ui/web/docs/symbols/_global_.html new file mode 100644 index 000000000..a03887b0e --- /dev/null +++ b/deluge/ui/web/docs/symbols/_global_.html @@ -0,0 +1,333 @@ + + + + + + + JsDoc Reference - _global_ + + + + + + + + + + + +
+ +
Class Index +| File Index
+
+

Classes

+ +
+ +
+ +
+ +

+ + Built-In Namespace _global_ +

+ + +

+ + + + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
Method Summary
Method AttributesMethod Name and Description
  +
onLimitChanged(item, checked) +
+
+
+ + + + + + + + + + + + + + + +
+ Method Detail +
+ + +
+ + + onLimitChanged(item, checked) + +
+
+ + +
+ Defined in: Deluge.Menus.js. + + +
+ + + + +
+
Parameters:
+ +
+ item + +
+
+ +
+ checked + +
+
+ +
+ + + + + + + + + + + + + + + +
+
+ + + +
+ + Documentation generated by JsDoc Toolkit 2.1.0 on Tue May 19 2009 23:27:56 GMT+0100 (BST) +
+ + diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Add.File.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Add.File.js.html new file mode 100644 index 000000000..0f5669be1 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Add.File.js.html @@ -0,0 +1,113 @@ +
  1 /*
+  2 Script: Deluge.Add.File.js
+  3     Contains the Add Torrent by file window.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
+ 36 	constructor: function(config) {
+ 37 		config = Ext.apply({
+ 38 			layout: 'fit',
+ 39 			width: 350,
+ 40 			height: 115,
+ 41 			bodyStyle: 'padding: 10px 5px;',
+ 42 			buttonAlign: 'center',
+ 43 			closeAction: 'hide',
+ 44 			modal: true,
+ 45 			plain: true,
+ 46 			title: _('Add from File'),
+ 47 			iconCls: 'x-deluge-add-file',
+ 48 			buttons: [{
+ 49 				text: _('Add'),
+ 50 				handler: this.onAdd,
+ 51 				scope: this
+ 52 			}]
+ 53 		}, config);
+ 54 		Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
+ 55 	},
+ 56 	
+ 57 	initComponent: function() {
+ 58 		Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
+ 59 		this.form = this.add(new Ext.form.FormPanel({
+ 60 			baseCls: 'x-plain',
+ 61 			labelWidth: 55,
+ 62 			autoHeight: true,
+ 63 			fileUpload: true,
+ 64 			items: [{
+ 65 				xtype: 'fileuploadfield',
+ 66 				id: 'torrentFile',
+ 67 				emptyText: _('Select a torrent'),
+ 68 				fieldLabel: _('File'),
+ 69 				name: 'file',
+ 70 				buttonCfg: {
+ 71 					text: _('Browse') + '...'
+ 72 				}
+ 73 			}]
+ 74 		}));
+ 75 	},
+ 76 	
+ 77 	onAdd: function(field, e) {
+ 78 		if (this.form.getForm().isValid()) {
+ 79 			this.torrentId = this.createTorrentId();
+ 80 			this.form.getForm().submit({
+ 81 				url: '/upload',
+ 82 				waitMsg: _('Uploading your torrent...'),
+ 83 				success: this.onUploadSuccess,
+ 84 				scope: this
+ 85 			});
+ 86 			var name = this.form.getForm().findField('torrentFile').value;
+ 87 			this.fireEvent('beforeadd', this.torrentId, name);
+ 88 		}
+ 89 	},
+ 90 	
+ 91 	onGotInfo: function(info, obj, response, request) {
+ 92 		info['filename'] = request.options.filename;
+ 93 		this.fireEvent('add', this.torrentId, info);
+ 94 	},
+ 95 	
+ 96 	onUploadSuccess: function(fp, upload) {
+ 97 		this.hide();
+ 98 		var filename = upload.result.toString();
+ 99 		this.form.getForm().findField('torrentFile').setValue('');
+100 		Deluge.Client.web.get_torrent_info(filename, {
+101 			success: this.onGotInfo,
+102 			scope: this,
+103 			filename: filename
+104 		});
+105 	}
+106 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Add.Url.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Add.Url.js.html new file mode 100644 index 000000000..23232f4b6 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Add.Url.js.html @@ -0,0 +1,116 @@ +
  1 /*
+  2 Script: Deluge.Add.Url.js
+  3     Contains the Add Torrent by url window.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
+ 36 	constructor: function(config) {
+ 37 		config = Ext.apply({
+ 38 			layout: 'fit',
+ 39 			width: 350,
+ 40 			height: 115,
+ 41 			bodyStyle: 'padding: 10px 5px;',
+ 42 			buttonAlign: 'center',
+ 43 			closeAction: 'hide',
+ 44 			modal: true,
+ 45 			plain: true,
+ 46 			title: _('Add from Url'),
+ 47 			iconCls: 'x-deluge-add-url-window-icon',
+ 48 			buttons: [{
+ 49 				text: _('Add'),
+ 50 				handler: this.onAdd,
+ 51 				scope: this
+ 52 			}]
+ 53 		}, config);
+ 54 		Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
+ 55 	},
+ 56 	
+ 57 	initComponent: function() {
+ 58 		Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
+ 59 		this.form = this.add(new Ext.form.FormPanel({
+ 60 			defaultType: 'textfield',
+ 61 			baseCls: 'x-plain',
+ 62 			labelWidth: 55,
+ 63 			items: [{
+ 64 				fieldLabel: _('Url'),
+ 65 				id: 'url',
+ 66 				name: 'url',
+ 67 				inputType: 'url',
+ 68 				anchor: '100%',
+ 69 				listeners: {
+ 70 					'specialkey': {
+ 71 						fn: this.onAdd,
+ 72 						scope: this
+ 73 					}
+ 74 				}
+ 75 			}]
+ 76 		}));
+ 77 	},
+ 78 	
+ 79 	onAdd: function(field, e) {
+ 80 		if (field.id == 'url' && e.getKey() != e.ENTER) return;
+ 81 
+ 82 		var field = this.form.items.get('url');
+ 83 		var url = field.getValue();
+ 84 		var torrentId = this.createTorrentId();
+ 85 		
+ 86 		Deluge.Client.web.download_torrent_from_url(url, {
+ 87 			success: this.onDownload,
+ 88 			scope: this,
+ 89 			torrentId: torrentId
+ 90 		});
+ 91 		this.hide();
+ 92 		this.fireEvent('beforeadd', torrentId, url);
+ 93 	},
+ 94 	
+ 95 	onDownload: function(filename, obj, resp, req) {
+ 96 		this.form.items.get('url').setValue('');
+ 97 		Deluge.Client.web.get_torrent_info(filename, {
+ 98 			success: this.onGotInfo,
+ 99 			scope: this,
+100 			filename: filename,
+101 			torrentId: req.options.torrentId
+102 		});
+103 	},
+104 	
+105 	onGotInfo: function(info, obj, response, request) {
+106 		info['filename'] = request.options.filename;
+107 		this.fireEvent('add', request.options.torrentId, info);
+108 	}
+109 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html new file mode 100644 index 000000000..9576f66f7 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Add.js.html @@ -0,0 +1,389 @@ +
  1 /*
+  2 Script: Deluge.Add.js
+  3     Contains the Add Torrent window.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.namespace('Ext.deluge.add');
+ 36 Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
+ 37 
+ 38 	constructor: function(config) {
+ 39 		config = Ext.apply({
+ 40 			region: 'south',
+ 41 			margins: '5 5 5 5',
+ 42 			activeTab: 0,
+ 43 			height: 220
+ 44 		}, config);
+ 45 		Ext.deluge.add.OptionsPanel.superclass.constructor.call(this, config);
+ 46 	},
+ 47 	
+ 48 	initComponent: function() {
+ 49 		Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);
+ 50 		this.files = this.add(new Ext.tree.ColumnTree({
+ 51 			layout: 'fit',
+ 52 			title: _('Files'),
+ 53 			rootVisible: false,
+ 54 			autoScroll: true,
+ 55 			height: 170,
+ 56 			border: false,
+ 57 			animate: false,
+ 58 			
+ 59 			columns: [{
+ 60 				header: _('Filename'),
+ 61 				width: 275,
+ 62 				dataIndex: 'filename'
+ 63 			},{
+ 64 				header: _('Size'),
+ 65 				width: 80,
+ 66 				dataIndex: 'size'
+ 67 			}],
+ 68 			
+ 69 			root: new Ext.tree.AsyncTreeNode({
+ 70 				text: 'Files'
+ 71 			})
+ 72 		}));
+ 73 		new Ext.tree.TreeSorter(this.files, {
+ 74 			folderSort: true
+ 75 		});
+ 76 		
+ 77 		this.form = this.add({
+ 78 			xtype: 'form',
+ 79 			labelWidth: 1,
+ 80 			frame: false,
+ 81 			title: _('Options'),
+ 82 			bodyStyle: 'padding: 5px;',
+ 83 			border: false,
+ 84 			
+ 85 			
+ 86 			items: [{
+ 87 				xtype: 'fieldset',
+ 88 				title: _('Download Location'),
+ 89 				border: false,
+ 90 				defaultType: 'textfield',
+ 91 				labelWidth: 1,
+ 92 				items: [{
+ 93 					fieldLabel: '',
+ 94 					labelSeperator: '',
+ 95 					name: 'download_location',
+ 96 					width: 330
+ 97 				}]
+ 98 			}]
+ 99 		});
+100 	},
+101 	
+102 	clear: function() {
+103 		this.clearFiles();
+104 	},
+105 	
+106 	clearFiles: function() {
+107 		var root = this.files.getRootNode();
+108 		if (!root.hasChildNodes()) return;
+109 		root.cascade(function(node) {
+110 			if (!node.parentNode || !node.getOwnerTree()) return;
+111 			node.remove();
+112 		});
+113 	},
+114 	
+115 	getDefaults: function() {
+116 		var keys = [
+117             'add_paused',
+118             'compact_allocation',
+119             'download_location',
+120             'max_connections_per_torrent',
+121             'max_download_speed_per_torrent',
+122             'max_upload_slots_per_torrent',
+123             'max_upload_speed_per_torrent',
+124             'prioritize_first_last_pieces'
+125         ]
+126         Deluge.Client.core.get_config_values(keys, {
+127             success: function(config) {
+128 				this.defaults = config;
+129 				for (var key in config) {
+130 					var field = this.form.findField(key);
+131 					if (!field) return;
+132 					field.setValue(config[key]);
+133 				}
+134 				var field = this.form.findField('compact_allocation');
+135 				if (config['compact_allocation']) {
+136 					field.items.get('compact_allocation_true').setValue(true);
+137 					field.items.get('compact_allocation_false').setValue(false);
+138 				} else {
+139 					field.items.get('compact_allocation_false').setValue(true);
+140 					field.items.get('compact_allocation_true').setValue(false);
+141 				}
+142 			},
+143 			scope: this
+144         });
+145 	}
+146 });
+147 
+148 Ext.deluge.add.Window = Ext.extend(Ext.Window, {
+149 	initComponent: function() {
+150 		Ext.deluge.add.Window.superclass.initComponent.call(this);
+151 		this.addEvents(
+152 			'beforeadd',
+153 			'add'
+154 		);
+155 	},
+156 	
+157 	createTorrentId: function() {
+158 		return new Date().getTime();
+159 	}
+160 });
+161 
+162 Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
+163 	
+164 	torrents: {},
+165 	
+166 	constructor: function(config) {
+167 		config = Ext.apply({
+168 			title: _('Add Torrents'),
+169 			layout: 'border',
+170 			width: 470,
+171 			height: 450,
+172 			bodyStyle: 'padding: 10px 5px;',
+173 			buttonAlign: 'right',
+174 			closeAction: 'hide',
+175 			closable: true,
+176 			plain: true,
+177 			iconCls: 'x-deluge-add-window-icon'
+178 		}, config);
+179 		Ext.deluge.add.AddWindow.superclass.constructor.call(this, config);
+180 	},
+181 	
+182 	initComponent: function() {
+183 		Ext.deluge.add.AddWindow.superclass.initComponent.call(this);
+184 		
+185 		this.addButton(_('Cancel'), this.onCancel, this);
+186 		this.addButton(_('Add'), this.onAdd, this);
+187 		
+188 		function torrentRenderer(value, p, r) {
+189 			if (r.data['info_hash']) {
+190 				return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value);
+191 			} else {
+192 				return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>', value);
+193 			}
+194 		}
+195 		
+196 		this.grid = this.add({
+197 			xtype: 'grid',
+198 			region: 'center',
+199 			store: new Ext.data.SimpleStore({
+200 				fields: [
+201 					{name: 'info_hash', mapping: 1},
+202 					{name: 'text', mapping: 2}
+203 				],
+204 				id: 0
+205 			}),
+206 			columns: [{
+207 					id: 'torrent',
+208 					width: 150,
+209 					sortable: true,
+210 					renderer: torrentRenderer,
+211 					dataIndex: 'text'
+212 			}],	
+213 			stripeRows: true,
+214 			selModel: new Ext.grid.RowSelectionModel({
+215 				singleSelect: true,
+216 				listeners: {
+217 					'rowselect': {
+218 						fn: this.onSelect,
+219 						scope: this
+220 					}
+221 				}
+222 			}),
+223 			hideHeaders: true,
+224 			autoExpandColumn: 'torrent',
+225 			deferredRender: false,
+226 			autoScroll: true,
+227 			margins: '5 5 5 5',
+228 			bbar: new Ext.Toolbar({
+229 				items: [{
+230 					id: 'file',
+231 					cls: 'x-btn-text-icon',
+232 					iconCls: 'x-deluge-add-file',
+233 					text: _('File'),
+234 					handler: this.onFile,
+235 					scope: this
+236 				}, {
+237 					id: 'url',
+238 					cls: 'x-btn-text-icon',
+239 					text: _('Url'),
+240 					icon: '/icons/add_url.png',
+241 					handler: this.onUrl,
+242 					scope: this
+243 				}, {
+244 					id: 'infohash',
+245 					cls: 'x-btn-text-icon',
+246 					text: _('Infohash'),
+247 					icon: '/icons/add_magnet.png',
+248 					disabled: true
+249 				}, '->', {
+250 					id: 'remove',
+251 					cls: 'x-btn-text-icon',
+252 					text: _('Remove'),
+253 					icon: '/icons/remove.png',
+254 					handler: this.onRemove,
+255 					scope: this
+256 				}]
+257 			})
+258 		});
+259 		
+260 		this.options = this.add(new Ext.deluge.add.OptionsPanel());
+261 		this.on('show', this.onShow, this);
+262 	},
+263 	
+264 	clear: function() {
+265 		this.torrents = {};
+266 		this.grid.getStore().removeAll();
+267 		this.options.clear();
+268 	},
+269 	
+270 	onAdd: function() {
+271 		torrents = [];
+272 		for (var id in this.torrents) {
+273 			var info = this.torrents[id];
+274 			torrents.push({
+275 				path: info['filename'],
+276 				options: {}
+277 			});
+278 		}
+279 		Deluge.Client.web.add_torrents(torrents, {
+280 			success: function(result) {
+281 			}
+282 		})
+283 		this.clear();
+284 		this.hide();
+285 	},
+286 	
+287 	onCancel: function() {
+288 		this.clear();
+289 		this.hide();
+290 	},
+291 	
+292 	onFile: function() {
+293 		this.file.show();
+294 	},
+295 	
+296 	onRemove: function() {
+297 		var selection = this.grid.getSelectionModel();
+298 		if (!selection.hasSelection()) return;
+299 		var torrent = selection.getSelected();
+300 		
+301 		delete this.torrents[torrent.id];
+302 		this.grid.getStore().remove(torrent);
+303 		this.options.clear();
+304 	},
+305 	
+306 	onSelect: function(selModel, rowIndex, record) {
+307 		var torrentInfo = this.torrents[record.get('info_hash')];
+308 		
+309 		function walk(files, parent) {
+310 			for (var file in files) {
+311 				var item = files[file];
+312 				
+313 				if (Ext.type(item) == 'object') {
+314 					var child = new Ext.tree.TreeNode({
+315 						text: file
+316 					});
+317 					walk(item, child);
+318 					parent.appendChild(child);
+319 				} else {
+320 					parent.appendChild(new Ext.tree.TreeNode({
+321 						filename: file,
+322 						text: file, // this needs to be here for sorting reasons
+323 						size: fsize(item[0]),
+324 						leaf: true,
+325 						checked: item[1],
+326 						iconCls: 'x-deluge-file',
+327 						uiProvider: Ext.tree.ColumnNodeUI
+328 					}));	
+329 				}
+330 			}
+331 		}
+332 		
+333 		this.options.clearFiles();		
+334 		var root = this.options.files.getRootNode();
+335 		walk(torrentInfo['files_tree'], root);
+336 		root.firstChild.expand();
+337 	},
+338 	
+339 	onShow: function() {
+340 		if (!this.url) {
+341 			this.url = new Ext.deluge.add.UrlWindow();
+342 			this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
+343 			this.url.on('add', this.onTorrentAdd, this);
+344 		}
+345 		
+346 		if (!this.file) {
+347 			this.file = new Ext.deluge.add.FileWindow();
+348 			this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
+349 			this.file.on('add', this.onTorrentAdd, this);
+350 		}
+351 	},
+352 	
+353 	onTorrentBeforeAdd: function(torrentId, text) {
+354 		var store = this.grid.getStore();
+355 		store.loadData([[torrentId, null, text]], true);
+356 	},
+357 	
+358 	onTorrentAdd: function(torrentId, info) {
+359 		if (!info) {
+360 			Ext.MessageBox.show({
+361 				title: _('Error'),
+362 				msg: _('Not a valid torrent'),
+363 				buttons: Ext.MessageBox.OK,
+364 				modal: false,
+365 				icon: Ext.MessageBox.ERROR,
+366 				iconCls: 'x-deluge-icon-error'
+367 			});
+368 			return;
+369 		}
+370 		
+371 		var r = this.grid.getStore().getById(torrentId);
+372 		r.set('info_hash', info['info_hash']);
+373 		r.set('text', info['name']);
+374 		this.grid.getStore().commitChanges();
+375 		this.torrents[info['info_hash']] = info;
+376 	},
+377 	
+378 	onUrl: function(button, event) {
+379 		this.url.show();
+380 	}
+381 });
+382 Deluge.Add = new Ext.deluge.add.AddWindow();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html new file mode 100644 index 000000000..6093311ef --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Client.js.html @@ -0,0 +1,191 @@ +
  1 /*
+  2 Script: Deluge.Client.js
+  3     A JSON-RPC proxy built on top of ext-core.
+  4 
+  5 Copyright:
+  6     (C) Damien Churchill 2009 <damoxc@gmail.com>
+  7     This program is free software; you can redistribute it and/or modify
+  8     it under the terms of the GNU General Public License as published by
+  9     the Free Software Foundation; either version 3, or (at your option)
+ 10     any later version.
+ 11 
+ 12     This program is distributed in the hope that it will be useful,
+ 13     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15     GNU General Public License for more details.
+ 16 
+ 17     You should have received a copy of the GNU General Public License
+ 18     along with this program.  If not, write to:
+ 19         The Free Software Foundation, Inc.,
+ 20         51 Franklin Street, Fifth Floor
+ 21         Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.namespace('Ext.ux.util');
+ 36 (function() {
+ 37     Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
+ 38 
+ 39         _components: [],
+ 40         
+ 41         _methods: [],
+ 42         
+ 43         _requests: {},
+ 44         
+ 45         _url: null,
+ 46         
+ 47         _optionKeys: ['scope', 'success', 'failure'],
+ 48         
+ 49         constructor: function(config) {
+ 50             Ext.ux.util.RpcClient.superclass.constructor.call(this, config);
+ 51             this._url = config.url || null;
+ 52             this._id = 0;
+ 53             
+ 54             this.addEvents(
+ 55                 // raw events
+ 56                 /**
+ 57                  * @event connected
+ 58                  * Fires when the client has retrieved the list of methods from the server.
+ 59                  * @param {Ext.ux.util.RpcClient} this
+ 60                  */
+ 61                  'connected'
+ 62             );
+ 63             this.reloadMethods();
+ 64         },
+ 65         
+ 66         reloadMethods: function() {
+ 67             Ext.each(this._components, function(component) {
+ 68                 delete this[component];
+ 69             }, this);
+ 70             this._execute('system.listMethods', {
+ 71                 success: this._setMethods,
+ 72                 scope: this
+ 73             });
+ 74         },
+ 75     
+ 76         _execute: function(method, options) {
+ 77             options = options || {};
+ 78             options.params = options.params || [];
+ 79             options.id = this._id;
+ 80             
+ 81             var request = Ext.encode({
+ 82                 method: method,
+ 83                 params: options.params,
+ 84                 id: options.id
+ 85             });
+ 86             this._id++;
+ 87             
+ 88             return Ext.Ajax.request({
+ 89                 url: this._url,
+ 90                 method: 'POST',
+ 91                 success: this._onSuccess,
+ 92                 failure: this._onFailure,
+ 93                 scope: this,
+ 94                 jsonData: request,
+ 95                 options: options
+ 96             });
+ 97         },
+ 98         
+ 99         _onFailure: function(response, requestOptions) {
+100             var options = requestOptions.options;
+101             errorObj = {
+102                 id: options.id,
+103                 result: null,
+104                 error: 'HTTP' + response.status
+105             }            
+106             if (Ext.type(options.failure) != 'function') return;
+107             if (options.scope) {
+108                 options.failure.call(options.scope, responseObj.error, responseObj, response);
+109             } else {
+110                 options.failure(responseObj.error, responseObj, response);
+111             }
+112         },
+113         
+114         _onSuccess: function(response, requestOptions) {
+115             var responseObj = Ext.decode(response.responseText);
+116             var options = requestOptions.options;
+117             if (responseObj.error) {
+118                 if (Ext.type(options.failure) != 'function') return;
+119                 if (options.scope) {
+120                     options.failure.call(options.scope, responseObj.error, responseObj, response, requestOptions);
+121                 } else {
+122                     options.failure(responseObj.error, responseObj, response, requestOptions);
+123                 }
+124             } else {
+125                 if (Ext.type(options.success) != 'function') return;
+126                 if (options.scope) {
+127                     options.success.call(options.scope, responseObj.result, responseObj, response, requestOptions);
+128                 } else {
+129                     options.success(responseObj.result, responseObj, response, requestOptions);
+130                 }
+131             }
+132         },
+133         
+134         _parseArgs: function(args) {
+135             var params = [];
+136             Ext.each(args, function(arg) {
+137                 params.push(arg);
+138             });
+139             
+140             var options = params[params.length - 1];
+141             if (Ext.type(options) == 'object') {
+142                 var keys = Ext.keys(options), isOption = false;
+143                 
+144                 Ext.each(this._optionKeys, function(key) {
+145                     if (keys.indexOf(key) > -1) isOption = true;
+146                 });
+147                 
+148                 if (isOption) {
+149                     params.remove(options)
+150                 } else {
+151                     options = {}
+152                 }
+153             } else {
+154                 options = {}
+155             }
+156             options.params = params;
+157             return options;
+158         },
+159     
+160         _setMethods: function(methods) {
+161             var components = {}, self = this;
+162             
+163             Ext.each(methods, function(method) {
+164                 var parts = method.split('.');
+165                 var component = components[parts[0]] || {};
+166                 
+167                 var fn = function() {
+168                     var options = self._parseArgs(arguments);
+169                     return self._execute(method, options);
+170                 }
+171                 component[parts[1]] = fn;
+172                 components[parts[0]] = component;
+173             });
+174             
+175             for (var name in components) {
+176                 self[name] = components[name];
+177             }
+178             
+179             this._components = Ext.keys(components);
+180             this.fireEvent('connected', this);
+181         }
+182     });
+183 })();
+184 
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html b/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html new file mode 100644 index 000000000..a9b33f26e --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.ConnectionManager.js.html @@ -0,0 +1,383 @@ +
  1 /*
+  2 Script: deluge-connections.js
+  3     Contains all objects and functions related to the connection manager.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function() {
+ 36 	var hostRenderer = function(value, p, r) {
+ 37 		return value + ':' + r.data['port']
+ 38 	}
+ 39 
+ 40 	Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, {
+ 41 	
+ 42 		layout: 'fit',
+ 43 		width: 300,
+ 44 		height: 220,
+ 45 		bodyStyle: 'padding: 10px 5px;',
+ 46 		buttonAlign: 'right',
+ 47 		closeAction: 'hide',
+ 48 		closable: true,
+ 49 		plain: true,
+ 50 		title: _('Connection Manager'),
+ 51 		iconCls: 'x-deluge-connect-window-icon',
+ 52 		
+ 53 		initComponent: function() {
+ 54 			Ext.deluge.ConnectionManager.superclass.initComponent.call(this);
+ 55 			this.on({
+ 56 				'hide': this.onHide,
+ 57 				'show': this.onShow
+ 58 			});
+ 59 			Deluge.Events.on('login', this.onLogin, this);
+ 60 			Deluge.Events.on('logout', this.onLogout, this);
+ 61 			
+ 62 			this.addButton(_('Close'), this.onClose, this);
+ 63 			this.addButton(_('Connect'), this.onConnect, this);
+ 64 			
+ 65 			this.grid = this.add({
+ 66 				xtype: 'grid',
+ 67 				store: new Ext.data.SimpleStore({
+ 68 					fields: [
+ 69 						{name: 'status', mapping: 3},
+ 70 						{name: 'host', mapping: 1},
+ 71 						{name: 'port', mapping: 2},
+ 72 						{name: 'version', mapping: 4}
+ 73 					],
+ 74 					id: 0
+ 75 				}),
+ 76 				columns: [{
+ 77 					header: _('Status'),
+ 78 					width: 65,
+ 79 					sortable: true,
+ 80 					renderer: fplain,
+ 81 					dataIndex: 'status'
+ 82 				}, {
+ 83 					id:'host',
+ 84 					header: _('Host'),
+ 85 					width: 150,
+ 86 					sortable: true,
+ 87 					renderer: hostRenderer,
+ 88 					dataIndex: 'host'
+ 89 				}, {
+ 90 					header: _('Version'),
+ 91 					width: 75,
+ 92 					sortable: true,
+ 93 					renderer: fplain,
+ 94 					dataIndex: 'version'
+ 95 				}],
+ 96 				stripeRows: true,
+ 97 				selModel: new Ext.grid.RowSelectionModel({
+ 98 					singleSelect: true,
+ 99 					listeners: {
+100 						'rowselect': {fn: this.onSelect, scope: this}
+101 					}
+102 				}),
+103 				autoExpandColumn: 'host',
+104 				deferredRender:false,
+105 				autoScroll:true,
+106 				margins: '0 0 0 0',
+107 				bbar: new Ext.Toolbar({
+108 					items: [
+109 						{
+110 							id: 'add',
+111 							cls: 'x-btn-text-icon',
+112 							text: _('Add'),
+113 							icon: '/icons/add.png',
+114 							handler: this.onAdd,
+115 							scope: this
+116 						}, {
+117 							id: 'remove',
+118 							cls: 'x-btn-text-icon',
+119 							text: _('Remove'),
+120 							icon: '/icons/remove.png',
+121 							handler: this.onRemove,
+122 							scope: this
+123 						}, '->', {
+124 							id: 'stop',
+125 							cls: 'x-btn-text-icon',
+126 							text: _('Stop Daemon'),
+127 							icon: '/icons/error.png',
+128 							handler: this.onStop,
+129 							scope: this
+130 						}
+131 					]
+132 				})
+133 			});
+134 		},
+135 		
+136 		disconnect: function() {
+137 			Deluge.Events.fire('disconnect');
+138 		},
+139 		
+140 		runCheck: function(callback, scope) {
+141 			callback = callback || this.onGetHosts;
+142 			scope = scope || this;
+143 			Deluge.Client.web.get_hosts({
+144 				success: callback,
+145 				scope: scope
+146 			});
+147 		},
+148 		
+149 		onAdd: function(button, e) {
+150 			//Deluge.Connections.Add.show();
+151 		},
+152 		
+153 		onAddHost: function() {
+154 			var form = Deluge.Connections.Add.items.first();
+155 			var host = form.items.get('host').getValue();
+156 			var port = form.items.get('port').getValue();
+157 			var username = form.items.get('username').getValue();
+158 			var password = form.items.get('_password').getValue();
+159 			
+160 			Deluge.Client.web.add_host(host, port, username, password, {
+161 				onSuccess: function(result) {
+162 					if (!result[0]) {
+163 						Ext.MessageBox.show({
+164 							title: _('Error'),
+165 							msg: "Unable to add host: " + result[1],
+166 							buttons: Ext.MessageBox.OK,
+167 							modal: false,
+168 							icon: Ext.MessageBox.ERROR,
+169 							iconCls: 'x-deluge-icon-error'
+170 						});
+171 					} else {
+172 						this.runCheck();
+173 					}
+174 					Deluge.Connections.Add.hide();
+175 				}
+176 			});
+177 		},
+178 		
+179 		onAddWindowHide: function() {
+180 			// Tidy up the form to ensure all the values are default.
+181 			var form = Deluge.Connections.Add.items.first();
+182 			form.items.get('host').reset();
+183 			form.items.get('port').reset();
+184 			form.items.get('username').reset();
+185 			form.items.get('_password').reset();
+186 		},
+187 		
+188 		onClose: function(e) {
+189 			if (this.running) window.clearInterval(this.running);
+190 			this.hide();
+191 		},
+192 		
+193 		onConnect: function(e) {
+194 			var selected = this.grid.getSelectionModel().getSelected();
+195 			if (!selected) return;
+196 			
+197 			if (selected.get('status') == _('Connected')) {
+198 				Deluge.Client.web.disconnect({
+199 					success: function(result) {
+200 						this.runCheck();
+201 						Deluge.Events.fire('disconnect');
+202 					},
+203 					scope: this
+204 				});
+205 			} else {
+206 				var id = selected.id;
+207 				Deluge.Client.web.connect(id, {
+208 					success: function(methods) {
+209 						Deluge.Client.reloadMethods();
+210 						Deluge.Client.on('connected', function(e) {
+211 							Deluge.Events.fire('connect');
+212 						}, this, {single: true});
+213 					}
+214 				});
+215 				if (this.running) window.clearInterval(this.running);
+216 				this.hide();
+217 			}
+218 		},
+219 		
+220 		onGetHosts: function(hosts) {
+221 			this.grid.getStore().loadData(hosts);
+222 			var selection = this.grid.getSelectionModel();
+223 			selection.selectRow(this.selectedRow);
+224 		},
+225 		
+226 		onLogin: function() {
+227 			Deluge.Client.web.connected({
+228 				success: function(connected) {
+229 					if (connected) {
+230 						Deluge.Events.fire('connect');
+231 					} else {
+232 						this.show();
+233 					}
+234 				},
+235 				scope: this
+236 			});
+237 		},
+238 		
+239 		onLogout: function() {
+240 			this.disconnect();
+241 			if (!this.hidden && this.rendered) {
+242 				this.hide();
+243 			}
+244 		},
+245 		
+246 		onRemove: function(button) {
+247 			var connection = Deluge.Connections.Grid.getSelectionModel().getSelected();
+248 			Deluge.Client.web.remove_host(connection.id, {
+249 				onSuccess: function(result) {
+250 					if (!result) {
+251 						Ext.MessageBox.show({
+252 							title: _('Error'),
+253 							msg: result[1],
+254 							buttons: Ext.MessageBox.OK,
+255 							modal: false,
+256 							icon: Ext.MessageBox.ERROR,
+257 							iconCls: 'x-deluge-icon-error'
+258 						});
+259 					} else {
+260 						Deluge.Connections.Grid.store.remove(connection);
+261 					}
+262 				}
+263 			});
+264 		},
+265 		
+266 		onSelect: function(selModel, rowIndex, record) {
+267 			this.selectedRow = rowIndex;
+268 			var button = this.buttons[1];
+269 			if (record.get('status') == _('Connected')) {
+270 				button.setText(_('Disconnect'));
+271 			} else {
+272 				button.setText(_('Connect'));
+273 			}
+274 		},
+275 		
+276 		onShow: function() {
+277 			this.runCheck();
+278 			this.running = window.setInterval(this.runCheck, 2000);
+279 		},
+280 		
+281 		onStop: function(button, e) {
+282 			var connection = this.grid.getSelectionModel().getSelected();
+283 			Deluge.Client.web.stop_daemon(connection.id, {
+284 				success: function(result) {
+285 					if (!result[0]) {
+286 						Ext.MessageBox.show({
+287 							title: _('Error'),
+288 							msg: result[1],
+289 							buttons: Ext.MessageBox.OK,
+290 							modal: false,
+291 							icon: Ext.MessageBox.ERROR,
+292 							iconCls: 'x-deluge-icon-error'
+293 						});
+294 					}
+295 				}
+296 			});
+297 		}
+298 	});
+299 	Deluge.ConnectionManager = new Ext.deluge.ConnectionManager();
+300 })();
+301 
+302 /*Deluge.Connections = {
+303 	
+304 	loginShow: function() {
+305 	},
+306 	
+307 	,
+308 	
+309 	
+310 }
+311 
+312 Deluge.Connections.Store ;
+313 
+314 
+315 
+316 Deluge.Connections.Grid = new Ext.grid.GridPanel();
+317 
+318 Deluge.Connections.Add = new Ext.Window({
+319 	layout: 'fit',
+320     width: 300,
+321     height: 195,
+322     bodyStyle: 'padding: 10px 5px;',
+323     buttonAlign: 'right',
+324     closeAction: 'hide',
+325     closable: true,
+326     plain: true,
+327     title: _('Add Connection'),
+328     iconCls: 'x-deluge-add-window-icon',
+329     items: [new Ext.form.FormPanel({
+330 		defaultType: 'textfield',
+331 		id: 'connectionAddForm',
+332 		baseCls: 'x-plain',
+333 		labelWidth: 55,
+334 		items: [{
+335 			fieldLabel: _('Host'),
+336 			id: 'host',
+337 			name: 'host',
+338 			anchor: '100%',
+339 			listeners: {}
+340 		},{
+341 			fieldLabel: _('Port'),
+342 			id: 'port',
+343 			xtype: 'uxspinner',
+344 			ctCls: 'x-form-uxspinner',
+345 			name: 'port',
+346 			strategy: Ext.ux.form.Spinner.NumberStrategy(),
+347 			value: '58846',
+348 			anchor: '50%',
+349 			listeners: {}
+350 		}, {
+351 			fieldLabel: _('Username'),
+352 			id: 'username',
+353 			name: 'username',
+354 			anchor: '100%',
+355 			listeners: {}
+356 		},{
+357 			fieldLabel: _('Password'),
+358 			anchor: '100%',
+359 			id: '_password',
+360 			name: '_password',
+361 			inputType: 'password'
+362 		}]
+363 	})],
+364     buttons: [{
+365         text: _('Close'),
+366 		handler: function() {
+367 			Deluge.Connections.Add.hide();
+368 		}
+369     },{
+370         text: _('Add'),
+371 		handler: Deluge.Connections.onAddHost
+372     }],
+373 	listeners: {
+374 		'hide': Deluge.Connections.onAddWindowHide
+375 	}
+376 });*/
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.Details.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.Details.js.html new file mode 100644 index 000000000..5b2d99acd --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.Details.js.html @@ -0,0 +1,94 @@ +
  1 /*
+  2 Script: Deluge.Details.Details.js
+  3     The details tab displayed in the details panel.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
+ 36 	title: _('Details'),
+ 37 	cls: 'x-deluge-status',
+ 38 	
+ 39 	onRender: function(ct, position) {
+ 40 		Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
+ 41 		this.load({
+ 42 			url: '/render/tab_details.html',
+ 43 			text: _('Loading') + '...'
+ 44 		});
+ 45 		this.getUpdater().on('update', this.onPanelUpdate, this);
+ 46 	},
+ 47 	
+ 48 	clear: function() {
+ 49 		if (!this.fields) return;
+ 50 		for (var k in this.fields) {
+ 51 			this.fields[k].innerHTML = '';
+ 52 		}
+ 53 	},
+ 54 	
+ 55 	update: function(torrentId) {
+ 56 		Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
+ 57 			success: this.onRequestComplete,
+ 58 			scope: this,
+ 59 			torrentId: torrentId
+ 60 		});
+ 61 	},
+ 62 	
+ 63 	onPanelUpdate: function(el, response) {
+ 64 		this.fields = {};
+ 65 		Ext.each(Ext.query('dd', this.body.dom), function(field) {
+ 66 			this.fields[field.className] = field;
+ 67 		}, this);
+ 68 	},
+ 69 	
+ 70 	onRequestComplete: function(torrent, options) {
+ 71 		var data = {
+ 72 			torrent_name: torrent.name,
+ 73 			hash: options.torrentId,
+ 74 			path: torrent.save_path,
+ 75 			size: fsize(torrent.total_size),
+ 76 			files: torrent.num_files,
+ 77 			status: torrent.tracker_status,
+ 78 			tracker: torrent.tracker,
+ 79 			comment: torrent.comment
+ 80 		};
+ 81 		
+ 82 		for (var field in this.fields) {
+ 83 			this.fields[field].innerHTML = data[field];
+ 84 		}
+ 85 	}
+ 86 });
+ 87 Deluge.Details.add(new Ext.deluge.details.DetailsTab());
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.Files.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.Files.js.html new file mode 100644 index 000000000..df6f0a474 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.Files.js.html @@ -0,0 +1,213 @@ +
  1 /*
+  2 Script: Deluge.Details.Files.js
+  3     The files tab displayed in the details panel.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 (function() {
+ 35 	/* Renderers for the column tree */
+ 36 	function fileProgressRenderer(value) {
+ 37 		var progress = value * 100;
+ 38 		return Deluge.progressBar(progress, this.width - 50, progress.toFixed(2) + '%');
+ 39 	}
+ 40 	function priorityRenderer(value) {
+ 41 		return String.format('<div class="{0}">{1}</div>', FILE_PRIORITY_CSS[value], _(FILE_PRIORITY[value]));
+ 42 	}
+ 43 	
+ 44 	Ext.deluge.details.FilesTab = Ext.extend(Ext.tree.ColumnTree, {
+ 45 		
+ 46 		constructor: function(config) {
+ 47 			config = Ext.apply({
+ 48 				title: _('Files'),
+ 49 				rootVisible: false,
+ 50 				autoScroll: true,
+ 51 				selModel: new Ext.tree.MultiSelectionModel(),
+ 52 				
+ 53 				columns: [{
+ 54 					header: _('Filename'),
+ 55 					width: 330,
+ 56 					dataIndex: 'filename'
+ 57 				}, {
+ 58 					header: _('Size'),
+ 59 					width: 150,
+ 60 					dataIndex: 'size',
+ 61 					renderer: fsize
+ 62 				}, {
+ 63 					header: _('Progress'),
+ 64 					width: 150,
+ 65 					dataIndex: 'progress',
+ 66 					renderer: fileProgressRenderer
+ 67 				}, {
+ 68 					header: _('Priority'),
+ 69 					width: 150,
+ 70 					dataIndex: 'priority',
+ 71 					renderer: priorityRenderer
+ 72 				}],
+ 73 				
+ 74 				root: new Ext.tree.TreeNode({
+ 75 					text: 'Files'
+ 76 				})
+ 77 			}, config);
+ 78 			Ext.deluge.details.FilesTab.superclass.constructor.call(this, config);
+ 79 		},
+ 80 		
+ 81 		onRender: function(ct, position) {
+ 82 			Ext.deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
+ 83 			Deluge.Menus.FilePriorities.on('itemclick', this.onItemClick, this);
+ 84 			this.on('contextmenu', this.onContextMenu, this);
+ 85 			this.sorter = new Ext.tree.TreeSorter(this, {
+ 86 				folderSort: true
+ 87 			});
+ 88 		},
+ 89 		
+ 90 		clear: function() {
+ 91 			var root = this.getRootNode();
+ 92 			if (!root.hasChildNodes()) return;
+ 93 			root.cascade(function(node) {
+ 94 				var parent = node.parentNode;
+ 95 				if (!parent) return;
+ 96 				if (!parent.ownerTree) return;
+ 97 				parent.removeChild(node);
+ 98 			});
+ 99 		},
+100 		
+101 		update: function(torrentId) {
+102 			if (this.torrentId != torrentId) {
+103 				this.clear();
+104 				this.torrentId = torrentId;
+105 			}
+106 			
+107 			Deluge.Client.web.get_torrent_files(torrentId, {
+108 				success: this.onRequestComplete,
+109 				scope: this,
+110 				torrentId: torrentId
+111 			});
+112 		},
+113 		
+114 		onContextMenu: function(node, e) {
+115 			e.stopEvent();
+116 			var selModel = this.getSelectionModel();
+117 			if (selModel.getSelectedNodes().length < 2) {
+118 				selModel.clearSelections();
+119 				node.select();
+120 			}
+121 			Deluge.Menus.FilePriorities.showAt(e.getPoint());
+122 		},
+123 		
+124 		onItemClick: function(baseItem, e) {
+125 			switch (baseItem.id) {
+126 				case 'expandAll':
+127 					this.expandAll();
+128 					break;
+129 				default:
+130 					var indexes = {};
+131 					function walk(node) {
+132 						if (!node.attributes.fileIndex) return;
+133 						indexes[node.attributes.fileIndex] = node.attributes.priority;
+134 					}
+135 					this.getRootNode().cascade(walk);
+136 					
+137 					var nodes = this.getSelectionModel().getSelectedNodes();
+138 					Ext.each(nodes, function(node) {
+139 						if (!node.attributes.fileIndex) return;
+140 						indexes[node.attributes.fileIndex] = baseItem.filePriority;
+141 					});
+142 					
+143 					alert(Ext.keys(indexes));
+144 					
+145 					priorities = new Array(Ext.keys(indexes).length);
+146 					for (var index in indexes) {
+147 						priorities[index] = indexes[index];
+148 					}
+149 					
+150 					alert(this.torrentId);
+151 					alert(priorities);
+152 					Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {
+153 						success: function() {
+154 							Ext.each(nodes, function(node) {
+155 								node.setColumnValue(3, baseItem.filePriority);
+156 							});
+157 						},
+158 						scope: this
+159 					});
+160 					break;
+161 			}
+162 		},
+163 		
+164 		onRequestComplete: function(files, options) {
+165 			function walk(files, parent) {
+166 				for (var file in files) {
+167 					var item = files[file];
+168 					var child = parent.findChild('id', file);
+169 					if (Ext.type(item) == 'object') {
+170 						if (!child) {
+171 							child = new Ext.tree.TreeNode({
+172 								id: file,
+173 								text: file
+174 							});
+175 							parent.appendChild(child);
+176 						}
+177 						walk(item, child);
+178 					} else {
+179 						if (!child) {
+180 							child = new Ext.tree.ColumnTreeNode({
+181 								id: file,
+182 								filename: file,
+183 								text: file, // this needs to be here for sorting
+184 								fileIndex: item[0],
+185 								size: item[1],
+186 								progress: item[2],
+187 								priority: item[3],
+188 								leaf: true,
+189 								iconCls: 'x-deluge-file',
+190 								uiProvider: Ext.tree.ColumnNodeUI
+191 							});
+192 							parent.appendChild(child);
+193 						}
+194 						child.setColumnValue(1, item[1]);
+195 						child.setColumnValue(2, item[2]);
+196 						child.setColumnValue(3, item[3]);
+197 					}
+198 				}
+199 			}
+200 			var root = this.getRootNode();
+201 			walk(files, root);
+202 			root.firstChild.expand();
+203 		}
+204 	});
+205 	Deluge.Details.add(new Ext.deluge.details.FilesTab());
+206 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html new file mode 100644 index 000000000..85f199307 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.Options.js.html @@ -0,0 +1,355 @@ +
  1 /*
+  2 Script: Deluge.Details.Options.js
+  3     The options tab displayed in the details panel.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 
+ 23     In addition, as a special exception, the copyright holders give
+ 24     permission to link the code of portions of this program with the OpenSSL
+ 25     library.
+ 26     You must obey the GNU General Public License in all respects for all of
+ 27     the code used other than OpenSSL. If you modify file(s) with this
+ 28     exception, you may extend this exception to your version of the file(s),
+ 29     but you are not obligated to do so. If you do not wish to do so, delete
+ 30     this exception statement from your version. If you delete this exception
+ 31     statement from all source files in the program, then also delete it here.
+ 32 */
+ 33 
+ 34 Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
+ 35 
+ 36 	constructor: function(config) {
+ 37 		config = Ext.apply({
+ 38 			autoScroll: true,
+ 39 			bodyStyle: 'padding: 5px;',
+ 40 			border: false,
+ 41 			cls: 'x-deluge-options',
+ 42 			defaults: {
+ 43 				autoHeight: true,
+ 44 				labelWidth: 1,
+ 45 				defaultType: 'checkbox'
+ 46 			},
+ 47 			deferredRender: false,
+ 48 			layout: 'column',
+ 49 			title: _('Options')
+ 50 		}, config);
+ 51 		Ext.deluge.details.OptionsTab.superclass.constructor.call(this, config);
+ 52 	},
+ 53 	
+ 54 	initComponent: function() {
+ 55 		Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
+ 56 		
+ 57 		this.fieldsets = {}, this.fields = {};
+ 58 		
+ 59 		/*
+ 60 		 * Bandwidth Options
+ 61 		 */
+ 62 		this.fieldsets.bandwidth = this.add({
+ 63 			xtype: 'fieldset',
+ 64 			defaultType: 'uxspinner',
+ 65 			bodyStyle: 'padding: 5px',
+ 66 			
+ 67 			layout: 'table',
+ 68 			layoutConfig: {columns: 3},
+ 69 			labelWidth: 150,
+ 70 			
+ 71 			style: 'margin-left: 10px; margin-right: 5px; padding: 5px',
+ 72 			title: _('Bandwidth'),
+ 73 			width: 300
+ 74 		});
+ 75 		
+ 76 		/*
+ 77 		 * Max Download Speed
+ 78 		 */
+ 79 		this.fieldsets.bandwidth.add({
+ 80 			xtype: 'label',
+ 81 			text: _('Max Download Speed'),
+ 82 			forId: 'max_download_speed',
+ 83 			cls: 'x-deluge-options-label'
+ 84 		});
+ 85 		this.fields.max_download_speed = this.fieldsets.bandwidth.add({
+ 86 			id: 'max_download_speed',
+ 87 			name: 'max_download_speed',
+ 88 			width: 100,
+ 89 			value: -1,
+ 90 			stragegy: new Ext.ux.form.Spinner.NumberStrategy({
+ 91 				minValue: -1,
+ 92 				maxValue: 99999,
+ 93 				incrementValue: 1
+ 94 			})
+ 95 		});
+ 96 		this.fieldsets.bandwidth.add({
+ 97 			xtype: 'label',
+ 98 			text: _('KiB/s'),
+ 99 			style: 'margin-left: 10px'
+100 		});
+101 		
+102 		/*
+103 		 * Max Upload Speed
+104 		 */
+105 		this.fieldsets.bandwidth.add({
+106 			xtype: 'label',
+107 			text: _('Max Upload Speed'),
+108 			forId: 'max_upload_speed',
+109 			cls: 'x-deluge-options-label'
+110 		});
+111 		this.fields.max_upload_speed = this.fieldsets.bandwidth.add({
+112 			id: 'max_upload_speed',
+113 			name: 'max_upload_speed',
+114 			width: 100,
+115 			value: -1,
+116 			stragegy: new Ext.ux.form.Spinner.NumberStrategy({
+117 				minValue: -1,
+118 				maxValue: 99999,
+119 				incrementValue: 1
+120 			})
+121 		});
+122 		this.fieldsets.bandwidth.add({
+123 			xtype: 'label',
+124 			text: _('KiB/s'),
+125 			style: 'margin-left: 10px'
+126 		});
+127 		
+128 		/*
+129 		 * Max Connections
+130 		 */
+131 		this.fieldsets.bandwidth.add({
+132 			xtype: 'label',
+133 			text: _('Max Connections'),
+134 			forId: 'max_connections',
+135 			cls: 'x-deluge-options-label'
+136 		});
+137 		this.fields.max_connections = this.fieldsets.bandwidth.add({
+138 			id: 'max_connections',
+139 			name: 'max_connections',
+140 			width: 100,
+141 			value: -1,
+142 			stragegy: new Ext.ux.form.Spinner.NumberStrategy({
+143 				minValue: -1,
+144 				maxValue: 99999,
+145 				incrementValue: 1
+146 			})
+147 		});
+148 		this.fieldsets.bandwidth.add({xtype: 'label'});
+149 		
+150 		/*
+151 		 * Max Upload Slots
+152 		 */
+153 		this.fieldsets.bandwidth.add({
+154 			xtype: 'label',
+155 			text: _('Max Upload Slots'),
+156 			forId: 'max_upload_slots',
+157 			cls: 'x-deluge-options-label'
+158 		});
+159 		this.fields.max_upload_slots = this.fieldsets.bandwidth.add({
+160 			id: 'max_upload_slots',
+161 			name: 'max_upload_slots',
+162 			width: 100,
+163 			value: -1,
+164 			stragegy: new Ext.ux.form.Spinner.NumberStrategy({
+165 				minValue: -1,
+166 				maxValue: 99999,
+167 				incrementValue: 1
+168 			})
+169 		});
+170 
+171 		/*
+172 		 * Queue Options
+173 		 */
+174 		this.fieldsets.queue = this.add({
+175 			xtype: 'fieldset',
+176 			title: _('Queue'),
+177 			style: 'margin-left: 5px; margin-right: 5px; padding: 5px',
+178 			width: 200,
+179 			defaults: {
+180 				fieldLabel: '',
+181 				labelSeparator: ''
+182 			}
+183 		});
+184 		
+185 		this.fields.is_auto_managed = this.fieldsets.queue.add({
+186 			fieldLabel: '',
+187 			labelSeparator: '',
+188 			id: 'is_auto_managed',
+189 			boxLabel: _('Auto Managed')
+190 		});
+191 		
+192 		this.fields.stop_at_ratio = this.fieldsets.queue.add({
+193 			fieldLabel: '',
+194 			labelSeparator: '',
+195 			id: 'stop_at_ratio',
+196 			boxLabel: _('Stop seed at ratio')
+197 		});
+198 		
+199 		this.fields.remove_at_ratio = this.fieldsets.queue.add({
+200 			fieldLabel: '',
+201 			labelSeparator: '',
+202 			id: 'remove_at_ratio',
+203 			style: 'margin-left: 10px',
+204 			boxLabel: _('Remove at ratio')
+205 		});
+206 		
+207 		this.fields.move_completed = this.fieldsets.queue.add({
+208 			fieldLabel: '',
+209 			labelSeparator: '',
+210 			id: 'move_completed',
+211 			boxLabel: _('Move Completed')
+212 		});
+213 		
+214 		
+215 		/*
+216 		 * General Options
+217 		 */
+218 		this.rightColumn =  this.add({
+219 			border: false,
+220 			autoHeight: true,
+221 			style: 'margin-left: 5px',
+222 			width: 200
+223 		});
+224 		
+225 		this.fieldsets.general = this.rightColumn.add({
+226 			xtype: 'fieldset',
+227 			autoHeight: true,
+228 			defaultType: 'checkbox',
+229 			title: _('General'),
+230 			layout: 'form'
+231 		});
+232 		
+233 		this.fields['private'] = this.fieldsets.general.add({
+234 			fieldLabel: '',
+235 			labelSeparator: '',
+236 			boxLabel: _('Private'),
+237 			id: 'private'
+238 		});
+239 		
+240 		this.fields.prioritize_first_last = this.fieldsets.general.add({
+241 			fieldLabel: '',
+242 			labelSeparator: '',
+243 			boxLabel: _('Prioritize First/Last'),
+244 			id: 'prioritize_first_last'
+245 		});
+246 		
+247 		/*
+248 		 * Buttons
+249 		 */
+250 		this.buttonPanel = this.rightColumn.add({
+251 			layout: 'column',
+252 			xtype: 'panel',
+253 			border: false
+254 		});
+255 		
+256 		// The buttons below are required to be added to a panel
+257 		// first as simply adding them to the column layout throws an
+258 		// error c.getSize() does not exist. This could be intentional
+259 		// or it may possible be a bug in ext-js. Take care when upgrading
+260 		// to ext-js 3.0.
+261 		
+262 		/*
+263 		 * Edit Trackers button
+264 		 */
+265 		this.buttonPanel.add({
+266 			xtype: 'panel',
+267 			border: false
+268 		}).add({
+269 			id: 'edit_trackers',
+270 			xtype: 'button',
+271 			text: _('Edit Trackers'),
+272 			cls: 'x-btn-text-icon',
+273 			iconCls: 'x-deluge-edit-trackers',
+274 			border: false,
+275 			width: 100,
+276 			handler: this.onEditTrackers,
+277 			scope: this
+278 		});
+279 		
+280 		/*
+281 		 * Apply button
+282 		 */
+283 		this.buttonPanel.add({
+284 			xtype: 'panel',
+285 			border: false
+286 		}).add({
+287 			id: 'apply',
+288 			xtype: 'button',
+289 			text: _('Apply'),
+290 			style: 'margin-left: 10px;',
+291 			border: false,
+292 			width: 100,
+293 		});
+294 		
+295 		this.disable();
+296 	},
+297 	
+298 	onRender: function(ct, position) {
+299 		Ext.deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
+300 		
+301 		// This is another hack I think, so keep an eye out here when upgrading.
+302 		this.layout = new Ext.layout.ColumnLayout();
+303 		this.layout.setContainer(this);
+304 		this.doLayout();
+305 	},
+306 	
+307 	clear: function() {
+308 		this.fields.max_download_speed.setValue(0);
+309 		this.fields.max_upload_speed.setValue(0);
+310 		this.fields.max_connections.setValue(0);
+311 		this.fields.max_upload_slots.setValue(0);
+312 		this.fields.is_auto_managed.setValue(false);
+313 		this.fields.stop_at_ratio.setValue(false);
+314 		this.fields.remove_at_ratio.setValue(false);
+315 		this.fields['private'].setValue(false);
+316 		this.fields.prioritize_first_last.setValue(false);
+317 	},
+318 	
+319 	reset: function() {
+320 		if (this.torrentId) {
+321 			delete this.changed[this.torrentId];
+322 		}
+323 	},
+324 	
+325 	update: function(torrentId) {
+326 		this.torrentId = torrentId;
+327 		Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
+328 			success: this.onRequestComplete,
+329 			scope: this
+330 		});
+331 	},
+332 	
+333 	onEditTrackers: function() {
+334 		Deluge.EditTrackers.show();
+335 	},
+336 	
+337 	onRequestComplete: function(torrent, options) {
+338 		for (var key in torrent) {
+339 			if (this.fields[key]) {
+340 				this.fields[key].setValue(torrent[key])
+341 			} else {
+342 				//alert(key);
+343 			}
+344 		}
+345 	}
+346 });
+347 Deluge.Details.add(new Ext.deluge.details.OptionsTab());
+348 
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.Peers.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.Peers.js.html new file mode 100644 index 000000000..345555ad8 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.Peers.js.html @@ -0,0 +1,153 @@ +
  1 /*
+  2 Script: Deluge.Details.Peers.js
+  3     The peers tab displayed in the details panel.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function() {
+ 36 	function flagRenderer(value) {
+ 37 		return String.format('<img src="/flag/{0}" />', value);
+ 38 	}
+ 39 	function peerAddressRenderer(value, p, record) {
+ 40 		var seed = (record.data['seed'] == 1024) ? 'x-deluge-seed' : 'x-deluge-peer'
+ 41 		return String.format('<div class="{0}">{1}</div>', seed, value);
+ 42 	}
+ 43 	function peerProgressRenderer(value) {
+ 44 		var progress = (value * 100).toFixed(0);
+ 45 		var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]).toFixed(0) - 8;
+ 46 		return Deluge.progressBar(progress, width, progress + '%');
+ 47 	}
+ 48 	function sort_address(value) {
+ 49 		var m = value.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);
+ 50 		var address = 0;
+ 51 		var parts = [m[1], m[2], m[3], m[4]];
+ 52 		Ext.each(parts, function(part, index) {
+ 53 			part = parseInt(part);
+ 54 			address = address | part << ((3 - index) * 8);
+ 55 			//alert("Total: " + address + "\nPart: " + part + "\nIndex: " + index + "\nCalc: " + (part << ((3 - index) * 8)));
+ 56 		});
+ 57 		return address;
+ 58 	}
+ 59 
+ 60 	Ext.deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
+ 61 		
+ 62 		constructor: function(config) {
+ 63 			config = Ext.apply({
+ 64 				title: _('Peers'),
+ 65 				cls: 'x-deluge-peers',
+ 66 				store: new Ext.data.SimpleStore({
+ 67 					fields: [
+ 68 						{name: 'country'},
+ 69 						{name: 'address', sortType: sort_address},
+ 70 						{name: 'client'},
+ 71 						{name: 'progress', type: 'float'},
+ 72 						{name: 'downspeed', type: 'int'},
+ 73 						{name: 'upspeed', type: 'int'},
+ 74 						{name: 'seed', type: 'int'}
+ 75 					],
+ 76 					id: 0
+ 77 				}),
+ 78 				columns: [{
+ 79 					header: ' ',
+ 80 					width: 30,
+ 81 					sortable: true,
+ 82 					renderer: flagRenderer,
+ 83 					dataIndex: 'country'
+ 84 				}, {
+ 85 					header: 'Address',
+ 86 					width: 125,
+ 87 					sortable: true,
+ 88 					renderer: peerAddressRenderer,
+ 89 					dataIndex: 'address'
+ 90 				}, {
+ 91 					header: 'Client',
+ 92 					width: 125,
+ 93 					sortable: true,
+ 94 					renderer: fplain,
+ 95 					dataIndex: 'client'
+ 96 				}, {
+ 97 					header: 'Progress',
+ 98 					width: 150,
+ 99 					sortable: true,
+100 					renderer: peerProgressRenderer,
+101 					dataIndex: 'progress'
+102 				}, {
+103 					header: 'Down Speed',
+104 					width: 100,
+105 					sortable: true,
+106 					renderer: fspeed,
+107 					dataIndex: 'downspeed'
+108 				}, {
+109 					header: 'Up Speed',
+110 					width: 100,
+111 					sortable: true,
+112 					renderer: fspeed,
+113 					dataIndex: 'upspeed'
+114 				}],	
+115 				stripeRows: true,
+116 				deferredRender:false,
+117 				autoScroll:true
+118 			}, config);
+119 			Ext.deluge.details.PeersTab.superclass.constructor.call(this, config);
+120 		},
+121 		
+122 		onRender: function(ct, position) {
+123 			Ext.deluge.details.PeersTab.superclass.onRender.call(this, ct, position);
+124 		},
+125 		
+126 		clear: function() {
+127 			this.getStore().loadData([]);
+128 		},
+129 		
+130 		update: function(torrentId) {
+131 			Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Peers, {
+132 				success: this.onRequestComplete,
+133 				scope: this
+134 			});
+135 		},
+136 		
+137 		onRequestComplete: function(torrent, options) {
+138 			var peers = new Array();
+139 			Ext.each(torrent.peers, function(peer) {
+140 				peers.push([peer.country, peer.ip, peer.client, peer.progress, peer.down_speed, peer.up_speed, peer.seed]);
+141 			}, this);
+142 			this.getStore().loadData(peers);
+143 		}
+144 	});
+145 	Deluge.Details.add(new Ext.deluge.details.PeersTab());
+146 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.Status.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.Status.js.html new file mode 100644 index 000000000..93d2d0185 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.Status.js.html @@ -0,0 +1,125 @@ +
  1 /*
+  2 Script: Deluge.Details.Status.js
+  3     The status tab displayed in the details panel.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {
+ 36 	title: _('Status'),
+ 37 	
+ 38 	onRender: function(ct, position) {
+ 39 		Ext.deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
+ 40 		
+ 41 		this.progressBar = this.add({
+ 42 			xtype: 'fullprogressbar',
+ 43 			cls: 'x-deluge-status-progressbar'
+ 44 		});
+ 45 		
+ 46 		this.status = this.add({
+ 47 			cls: 'x-deluge-status',
+ 48 			border: false,
+ 49 			listeners: {
+ 50 				'render': {
+ 51 					fn: function(panel) {
+ 52 						panel.load({
+ 53 							url: '/render/tab_status.html',
+ 54 							text: _('Loading') + '...'
+ 55 						});
+ 56 						panel.getUpdater().on('update', this.onPanelUpdate, this);
+ 57 					},
+ 58 					scope: this
+ 59 				}
+ 60 			}
+ 61 		});
+ 62 	},
+ 63 	
+ 64 	clear: function() {
+ 65 		if (!this.fields) return;
+ 66 		this.progressBar.updateProgress(0, ' ');
+ 67 		for (var k in this.fields) {
+ 68 			this.fields[k].innerHTML = '';
+ 69 		}
+ 70 	},
+ 71 	
+ 72 	update: function(torrentId) {
+ 73 		if (!this.fields) this.getFields();
+ 74 		Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, {
+ 75 			success: this.onRequestComplete,
+ 76 			scope: this
+ 77 		});
+ 78 	},
+ 79 	
+ 80 	onPanelUpdate: function(el, response) {
+ 81 		this.fields = {};
+ 82 		Ext.each(Ext.query('dd', this.status.body.dom), function(field) {
+ 83 			this.fields[field.className] = field;
+ 84 		}, this);
+ 85 	},
+ 86 	
+ 87 	onRequestComplete: function(status) {
+ 88 		seeders = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds
+ 89 		peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers
+ 90 		var data = {
+ 91 			downloaded: fsize(status.total_done) + ' (' + fsize(status.total_payload_download) + ')',
+ 92 			uploaded: fsize(status.total_uploaded) + ' (' + fsize(status.total_payload_upload) + ')',
+ 93 			share: status.ratio.toFixed(3),
+ 94 			announce: ftime(status.next_announce),
+ 95 			tracker_status: status.tracker_status,
+ 96 			downspeed: fspeed(status.download_payload_rate),
+ 97 			upspeed: fspeed(status.upload_payload_rate),
+ 98 			eta: ftime(status.eta),
+ 99 			pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')',
+100 			seeders: seeders,
+101 			peers: peers,
+102 			avail: status.distributed_copies.toFixed(3),
+103 			active_time: ftime(status.active_time),
+104 			seeding_time: ftime(status.seeding_time),
+105 			seed_rank: status.seed_rank,
+106 			auto_managed: 'False',
+107 			time_added: fdate(status.time_added)
+108 		}
+109 		if (status.is_auto_managed) {data.auto_managed = 'True'}
+110 		
+111 		for (var field in this.fields) {
+112 			this.fields[field].innerHTML = data[field];
+113 		}
+114 		var text = status.state + ' ' + status.progress.toFixed(2) + '%';
+115 		this.progressBar.updateProgress(status.progress, text);
+116 	}
+117 });
+118 Deluge.Details.add(new Ext.deluge.details.StatusTab());
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Details.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Details.js.html new file mode 100644 index 000000000..d7257ca19 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Details.js.html @@ -0,0 +1,98 @@ +
  1 /*
+  2 Script: deluge-details.js
+  3     Contains all objects and functions related to the lower details panel and
+  4 	it's containing tabs.
+  5 
+  6 Copyright:
+  7 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  8 	This program is free software; you can redistribute it and/or modify
+  9 	it under the terms of the GNU General Public License as published by
+ 10 	the Free Software Foundation; either version 3, or (at your option)
+ 11 	any later version.
+ 12 
+ 13 	This program is distributed in the hope that it will be useful,
+ 14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 16 	GNU General Public License for more details.
+ 17 
+ 18 	You should have received a copy of the GNU General Public License
+ 19 	along with this program.  If not, write to:
+ 20 		The Free Software Foundation, Inc.,
+ 21 		51 Franklin Street, Fifth Floor
+ 22 		Boston, MA  02110-1301, USA.
+ 23 #
+ 24 #    In addition, as a special exception, the copyright holders give
+ 25 #    permission to link the code of portions of this program with the OpenSSL
+ 26 #    library.
+ 27 #    You must obey the GNU General Public License in all respects for all of
+ 28 #    the code used other than OpenSSL. If you modify file(s) with this
+ 29 #    exception, you may extend this exception to your version of the file(s),
+ 30 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 31 #    this exception statement from your version. If you delete this exception
+ 32 #    statement from all source files in the program, then also delete it here.
+ 33 #
+ 34 */
+ 35 
+ 36 (function() {
+ 37 	Ext.namespace('Ext.deluge.details');
+ 38 	Ext.deluge.details.TabPanel = Ext.extend(Ext.TabPanel, {
+ 39 		
+ 40 		constructor: function(config) {
+ 41 			config = Ext.apply({
+ 42 				region: 'south',
+ 43 				split: true,
+ 44 				height: 220,
+ 45 				minSize: 100,
+ 46 				collapsible: true,
+ 47 				margins: '0 5 5 5',
+ 48 				activeTab: 0
+ 49 			}, config);
+ 50 			Ext.deluge.details.TabPanel.superclass.constructor.call(this, config);
+ 51 		},
+ 52 		
+ 53 		clear: function() {
+ 54 			this.items.each(function(panel) {
+ 55 				if (panel.clear) panel.clear();
+ 56 			});
+ 57 		},
+ 58 		
+ 59 		update: function(tab) {
+ 60 			var torrent = Deluge.Torrents.getSelected();
+ 61 			if (!torrent) return;
+ 62 			
+ 63 			tab = tab || this.getActiveTab();
+ 64 			if (tab.update) tab.update(torrent.id);
+ 65 		},
+ 66 		
+ 67 		/* Event Handlers */
+ 68 		
+ 69 		// We need to add the events in onRender since Deluge.Torrents hasn't
+ 70 		// been created yet.
+ 71 		onRender: function(ct, position) {
+ 72 			Ext.deluge.details.TabPanel.superclass.onRender.call(this, ct, position);
+ 73 			Deluge.Events.on('disconnect', this.clear, this);
+ 74 			Deluge.Torrents.on('rowclick', this.onTorrentsClick, this);
+ 75 			this.on('tabchange', this.onTabChange, this);
+ 76 			
+ 77 			Deluge.Torrents.getSelectionModel().on('selectionchange', function(selModel) {
+ 78 				if (!selModel.hasSelection()) this.clear();
+ 79 			}, this);
+ 80 		},
+ 81 		
+ 82 		onTabChange: function(panel, tab) {
+ 83 			this.update(tab);
+ 84 		},
+ 85 		
+ 86 		onTorrentsClick: function(grid, rowIndex, e) {
+ 87 			this.update();
+ 88 		}
+ 89 	});
+ 90 	Deluge.Details = new Ext.deluge.details.TabPanel();
+ 91 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.EditTrackers.js.html b/deluge/ui/web/docs/symbols/src/Deluge.EditTrackers.js.html new file mode 100644 index 000000000..4d5f86cba --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.EditTrackers.js.html @@ -0,0 +1,354 @@ +
  1 /*
+  2 Script: Deluge.EditTrackers.js
+  3     Contains the edit trackers window.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function() {
+ 36 	Ext.deluge.AddTracker = Ext.extend(Ext.Window, {
+ 37 		constructor: function(config) {
+ 38 			config = Ext.apply({
+ 39 				title: _('Add Tracker'),
+ 40 				width: 375,
+ 41 				height: 150,
+ 42 				bodyStyle: 'padding: 5px',
+ 43 				layout: 'fit',
+ 44 				buttonAlign: 'right',
+ 45 				closeAction: 'hide',
+ 46 				closable: true,
+ 47 				iconCls: 'x-deluge-edit-trackers',
+ 48 				plain: true,
+ 49 				resizable: false
+ 50 			}, config);
+ 51 			Ext.deluge.AddTracker.superclass.constructor.call(this, config);
+ 52 		},
+ 53 		
+ 54 		initComponent: function() {
+ 55 			Ext.deluge.AddTracker.superclass.initComponent.call(this);
+ 56 			
+ 57 			this.addButton(_('Cancel'), this.onCancel, this);
+ 58 			this.addButton(_('Add'), this.onAdd, this);
+ 59 			this.addEvents('add');
+ 60 			
+ 61 			this.form = this.add({
+ 62 				xtype: 'form',
+ 63 				defaultType: 'textarea',
+ 64 				baseCls: 'x-plain',
+ 65 				labelWidth: 55,
+ 66 				items: [{
+ 67 					fieldLabel: _('Trackers'),
+ 68 					name: 'trackers',
+ 69 					anchor: '100%'
+ 70 				}]
+ 71 			})
+ 72 		},
+ 73 		
+ 74 		onCancel: function() {
+ 75 			this.form.getForm().findField('trackers').setValue('');
+ 76 			this.hide();
+ 77 		},
+ 78 		
+ 79 		onAdd: function() {
+ 80 			var trackers = this.form.getForm().findField('trackers').getValue();
+ 81 			trackers = trackers.split('\n');
+ 82 			
+ 83 			var cleaned = [];
+ 84 			Ext.each(trackers, function(tracker) {
+ 85 				if (Ext.form.VTypes.url(tracker)) {
+ 86 					cleaned.push(tracker);
+ 87 				}
+ 88 			}, this);
+ 89 			this.fireEvent('add', cleaned);
+ 90 			this.hide();
+ 91 			this.form.getForm().findField('trackers').setValue('');
+ 92 		}
+ 93 	});
+ 94 	
+ 95 	Ext.deluge.EditTracker = Ext.extend(Ext.Window, {
+ 96 		constructor: function(config) {
+ 97 			config = Ext.apply({
+ 98 				title: _('Edit Tracker'),
+ 99 				width: 375,
+100 				height: 110,
+101 				bodyStyle: 'padding: 5px',
+102 				layout: 'fit',
+103 				buttonAlign: 'right',
+104 				closeAction: 'hide',
+105 				closable: true,
+106 				iconCls: 'x-deluge-edit-trackers',
+107 				plain: true,
+108 				resizable: false
+109 			}, config);
+110 			Ext.deluge.EditTracker.superclass.constructor.call(this, config);
+111 		},
+112 		
+113 		initComponent: function() {
+114 			Ext.deluge.EditTracker.superclass.initComponent.call(this);
+115 			
+116 			this.addButton(_('Cancel'), this.onCancel, this);
+117 			this.addButton(_('Save'), this.onSave, this);
+118 			this.on('hide', this.onHide, this);
+119 			
+120 			this.form = this.add({
+121 				xtype: 'form',
+122 				defaultType: 'textfield',
+123 				baseCls: 'x-plain',
+124 				labelWidth: 55,
+125 				items: [{
+126 					fieldLabel: _('Tracker'),
+127 					name: 'tracker',
+128 					anchor: '100%'
+129 				}]
+130 			});
+131 		},
+132 		
+133 		show: function(record) {
+134 			Ext.deluge.EditTracker.superclass.show.call(this);
+135 			
+136 			this.record = record;
+137 			this.form.getForm().findField('tracker').setValue(record.data['url']);
+138 		},
+139 		
+140 		onCancel: function() {
+141 			this.hide();
+142 		},
+143 		
+144 		onHide: function() {
+145 			this.form.getForm().findField('tracker').setValue('');
+146 		},
+147 		
+148 		onSave: function() {
+149 			var url = this.form.getForm().findField('tracker').getValue();
+150 			this.record.set('url', url);
+151 			this.record.commit();
+152 			this.hide();
+153 		}
+154 	});
+155 	
+156 	Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
+157 	
+158 		constructor: function(config) {
+159 			config = Ext.apply({
+160 				title: _('Edit Trackers'),
+161 				width: 350,
+162 				height: 220,
+163 				bodyStyle: 'padding: 5px',
+164 				layout: 'fit',
+165 				buttonAlign: 'right',
+166 				closeAction: 'hide',
+167 				closable: true,
+168 				iconCls: 'x-deluge-edit-trackers',
+169 				plain: true,
+170 				resizable: true
+171 			}, config);
+172 			Ext.deluge.EditTrackers.superclass.constructor.call(this, config);
+173 		},
+174 		
+175 		initComponent: function() {
+176 			Ext.deluge.EditTrackers.superclass.initComponent.call(this);
+177 			
+178 			this.addButton(_('Cancel'), this.onCancel, this);
+179 			this.addButton(_('Ok'), this.onOk, this);
+180 			this.addEvents('save');
+181 			
+182 			this.on('show', this.onShow, this);
+183 			this.on('save', this.onSave, this);
+184 			
+185 			this.addWindow = new Ext.deluge.AddTracker();
+186 			this.addWindow.on('add', this.onAddTrackers, this);
+187 			this.editWindow = new Ext.deluge.EditTracker();
+188 			
+189 			this.grid = this.add({
+190 				xtype: 'grid',
+191 				store: new Ext.data.SimpleStore({
+192 					fields: [
+193 						{name: 'tier', mapping: 0},
+194 						{name: 'url', mapping: 1}
+195 					]
+196 				}),
+197 				columns: [{
+198 					header: _('Tier'),
+199 					width: 50,
+200 					sortable: true,
+201 					renderer: fplain,
+202 					dataIndex: 'tier'
+203 				}, {
+204 					id:'tracker',
+205 					header: _('Tracker'),
+206 					sortable: true,
+207 					renderer: fplain,
+208 					dataIndex: 'url'
+209 				}],
+210 				stripeRows: true,
+211 				selModel: new Ext.grid.RowSelectionModel({
+212 					singleSelect: true,
+213 					listeners: {
+214 						'selectionchange': {fn: this.onSelect, scope: this}
+215 					}
+216 				}),
+217 				autoExpandColumn: 'tracker',
+218 				deferredRender:false,
+219 				autoScroll:true,
+220 				margins: '0 0 0 0',
+221 				bbar: new Ext.Toolbar({
+222 					items: [
+223 						{
+224 							cls: 'x-btn-text-icon',
+225 							text: _('Up'),
+226 							icon: '/icons/up.png',
+227 							handler: this.onUp,
+228 							scope: this
+229 						}, {
+230 							cls: 'x-btn-text-icon',
+231 							text: _('Down'),
+232 							icon: '/icons/down.png',
+233 							handler: this.onDown,
+234 							scope: this
+235 						}, '->', {
+236 							cls: 'x-btn-text-icon',
+237 							text: _('Add'),
+238 							icon: '/icons/add.png',
+239 							handler: this.onAdd,
+240 							scope: this
+241 						}, {
+242 							cls: 'x-btn-text-icon',
+243 							text: _('Edit'),
+244 							icon: '/icons/edit_trackers.png',
+245 							handler: this.onEdit,
+246 							scope: this
+247 						}, {
+248 							cls: 'x-btn-text-icon',
+249 							text: _('Remove'),
+250 							icon: '/icons/remove.png',
+251 							handler: this.onRemove,
+252 							scope: this
+253 						}
+254 					]
+255 				})
+256 			});
+257 		},
+258 		
+259 		onAdd: function() {
+260 			this.addWindow.show();
+261 		},
+262 		
+263 		onAddTrackers: function(trackers) {
+264 			var store = this.grid.getStore();
+265 			Ext.each(trackers, function(tracker) {
+266 				var duplicate = false, heightestTier = -1;
+267 				store.each(function(record) {
+268 					if (record.get('tier') > heightestTier) {
+269 						heightestTier = record.get('tier');
+270 					}
+271 					if (tracker == record.get('tracker')) {
+272 						duplicate = true;
+273 						return false;
+274 					}
+275 				}, this);
+276 				if (!duplicate) {
+277 					store.loadData([[heightestTier + 1, tracker]], true);
+278 				}
+279 			}, this);
+280 		},
+281 		
+282 		onCancel: function() {
+283 			this.hide();
+284 		},
+285 		
+286 		onEdit: function() {
+287 			var r = this.grid.getSelectionModel().getSelected();
+288 			this.editWindow.show(r);
+289 		},
+290 		
+291 		onHide: function() {
+292 			this.grid.getStore().removeAll();
+293 		},
+294 		
+295 		onOk: function() {
+296 			var trackers = [];
+297 			this.grid.getStore().each(function(record) {
+298 				trackers.push({
+299 					'tier': record.get('tier'),
+300 					'url': record.get('url')
+301 				})
+302 			}, this);
+303 			
+304 			Deluge.Client.core.set_torrent_trackers(this.torrentId, trackers, {
+305 				failure: this.onSaveFail,
+306 				scope: this
+307 			});
+308 
+309 			this.hide();
+310 		},
+311 		
+312 		onRemove: function() {
+313 			// Remove from the grid
+314 			var r = this.grid.getSelectionModel().getSelected();
+315 			this.grid.getStore().remove(r);
+316 		},
+317 		
+318 		onRequestComplete: function(status) {
+319 			var trackers = [];
+320 			Ext.each(status['trackers'], function(tracker) {
+321 				trackers.push([tracker['tier'], tracker['url']]);
+322 			});
+323 			this.grid.getStore().loadData(trackers);
+324 		},
+325 		
+326 		onSaveFail: function() {
+327 			
+328 		},
+329 		
+330 		onSelect: function(sm) {
+331 			if (sm.hasSelection()) {
+332 				this.grid.getBottomToolbar().items.get(4).enable();
+333 			}
+334 		},
+335 		
+336 		onShow: function() {
+337 			this.grid.getBottomToolbar().items.get(4).disable();
+338 			var r = Deluge.Torrents.getSelected();
+339 			this.torrentId = r.id;
+340 			Deluge.Client.core.get_torrent_status(r.id, ['trackers'], {
+341 				success: this.onRequestComplete,
+342 				scope: this
+343 			});
+344 		}
+345 	});
+346 	Deluge.EditTrackers = new Ext.deluge.EditTrackers();
+347 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Events.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Events.js.html new file mode 100644 index 000000000..db91213aa --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Events.js.html @@ -0,0 +1,64 @@ +
  1 /*
+  2 Script: Deluge.Events.js
+  3 	Class for holding global events that occur within the UI.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 
+ 23     In addition, as a special exception, the copyright holders give
+ 24     permission to link the code of portions of this program with the OpenSSL
+ 25     library.
+ 26     You must obey the GNU General Public License in all respects for all of
+ 27     the code used other than OpenSSL. If you modify file(s) with this
+ 28     exception, you may extend this exception to your version of the file(s),
+ 29     but you are not obligated to do so. If you do not wish to do so, delete
+ 30     this exception statement from your version. If you delete this exception
+ 31     statement from all source files in the program, then also delete it here.
+ 32 */
+ 33 
+ 34 /**
+ 35  * @namespace Deluge.Events
+ 36  * @class Deluge.Events
+ 37  * @name Deluge.Events
+ 38  * @description Class for holding global events that occur within the UI.
+ 39  */
+ 40 
+ 41 (function() {
+ 42 
+ 43     Events = Ext.extend(Ext.util.Observable, {
+ 44         constructor: function() {
+ 45             Events.superclass.constructor.call(this);
+ 46         },
+ 47         
+ 48         addListener: function(eventName, fn, scope, o) {
+ 49             this.addEvents(eventName);
+ 50             Events.superclass.addListener.call(this, eventName, fn, scope, o);
+ 51         }
+ 52     });
+ 53     Events.prototype.on = Events.prototype.addListener
+ 54     Events.prototype.fire = Events.prototype.fireEvent
+ 55     Deluge.Events = new Events();
+ 56 })();
+ 57 
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Formatters.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Formatters.js.html new file mode 100644 index 000000000..685c4285a --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Formatters.js.html @@ -0,0 +1,151 @@ +
  1 /*
+  2 Script:
+  3 	Deluge.Formatters.ks
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 
+ 23     In addition, as a special exception, the copyright holders give
+ 24     permission to link the code of portions of this program with the OpenSSL
+ 25     library.
+ 26     You must obey the GNU General Public License in all respects for all of
+ 27     the code used other than OpenSSL. If you modify file(s) with this
+ 28     exception, you may extend this exception to your version of the file(s),
+ 29     but you are not obligated to do so. If you do not wish to do so, delete
+ 30     this exception statement from your version. If you delete this exception
+ 31     statement from all source files in the program, then also delete it here.
+ 32 */
+ 33 
+ 34 /**
+ 35  * @description A collection of functions for string formatting values.
+ 36  * @namespace Deluge.Formatters
+ 37  */
+ 38 Deluge.Formatters = {
+ 39 	/**
+ 40 	 * Formats a date string in the locale's date representation based on the
+ 41 	 * systems timezone.
+ 42 	 *
+ 43 	 * @param {number} timestamp time in seconds since the Epoch
+ 44 	 * @returns {string} a string in the locale's date representation or ""
+ 45 	 * if seconds < 0
+ 46 	 */
+ 47 	date: function(timestamp) {
+ 48 		function zeroPad(num, count) {
+ 49 			var numZeropad = num + '';
+ 50 			while (numZeropad.length < count) {
+ 51 				numZeropad = '0' + numZeropad;
+ 52 			}
+ 53 			return numZeropad;
+ 54 		}
+ 55 		timestamp = timestamp * 1000;
+ 56 		var date = new Date(timestamp);
+ 57 		return String.format('{0}/{1}/{2}', zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear());
+ 58 	},
+ 59 	
+ 60 	/**
+ 61 	 * Formats the bytes value into a string with KiB, MiB or GiB units.
+ 62 	 *
+ 63 	 * @param {number} bytes the filesize in bytes
+ 64 	 * @returns {string} formatted string with KiB, MiB or GiB units.
+ 65 	 */
+ 66 	size: function(bytes) {
+ 67 		bytes = bytes / 1024.0;
+ 68 	
+ 69 		if (bytes < 1024) { return bytes.toFixed(1)  + ' KiB'; }
+ 70 		else { bytes = bytes / 1024; }
+ 71 	
+ 72 		if (bytes < 1024) { return bytes.toFixed(1)  + ' MiB'; }
+ 73 		else { bytes = bytes / 1024; }
+ 74 	
+ 75 		return bytes.toFixed(1) + ' GiB'
+ 76 	},
+ 77 	
+ 78 	/**
+ 79 	 * Formats a string to display a transfer speed utilizing {@link Deluge.Formatters.size}
+ 80 	 *
+ 81 	 * @param {number} bytes the filesize in bytes
+ 82 	 * @returns {string} formatted string with KiB, MiB or GiB units.
+ 83 	 */
+ 84 	speed: function(bits) {
+ 85 		return fsize(bits) + '/s'
+ 86 	},
+ 87 	
+ 88 	/**
+ 89 	 * Formats a string to show time in a human readable form.
+ 90 	 *
+ 91 	 * @param {number} time the number of seconds
+ 92 	 * @returns {string} a formatted time string. will return '' if seconds == 0
+ 93 	 */
+ 94 	timeRemaining: function(time) {
+ 95 		if (time == 0) { return '∞' }
+ 96 		if (time < 60) { return time + 's'; }
+ 97 		else { time = time / 60; }
+ 98 	
+ 99 		if (time < 60) {
+100 			var minutes = Math.floor(time)
+101 			var seconds = Math.round(60 * (time - minutes))
+102 			if (seconds > 0) {
+103 				return minutes + 'm ' + seconds + 's';
+104 			} else {
+105 				return minutes + 'm'; }
+106 			}
+107 		else { time = time / 60; }
+108 	
+109 		if (time < 24) { 
+110 			var hours = Math.floor(time)
+111 			var minutes = Math.round(60 * (time - hours))
+112 			if (minutes > 0) {
+113 				return hours + 'h ' + minutes + 'm';
+114 			} else {
+115 				return hours + 'h';
+116 			}			
+117 		}
+118 		else { time = time / 24; }
+119 	
+120 		var days = Math.floor(time)
+121 		var hours = Math.round(24 * (time - days))
+122 		if (hours > 0) {
+123 			return days + 'd ' + hours + 'h';
+124 		} else {
+125 			return days + 'd';
+126 		}
+127 	},
+128 	
+129 	/**
+130 	 * Simply returns the value untouched, for when no formatting is required.
+131 	 *
+132 	 * @param value, the value to be displayed
+133 	 * @returns the untouched value.
+134 	 */
+135 	plain: function(value) {
+136 		return value;
+137 	}
+138 }
+139 var fsize = Deluge.Formatters.size;
+140 var fspeed = Deluge.Formatters.speed;
+141 var ftime = Deluge.Formatters.timeRemaining;
+142 var fdate = Deluge.Formatters.date;
+143 var fplain = Deluge.Formatters.plain;
+144 
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Keys.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Keys.js.html new file mode 100644 index 000000000..34a06f5f8 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Keys.js.html @@ -0,0 +1,115 @@ +
  1 /*
+  2 Script: Deluge.Keys.js
+  3     The torrent status keys that are commonly used around the UI.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 
+ 23     In addition, as a special exception, the copyright holders give
+ 24     permission to link the code of portions of this program with the OpenSSL
+ 25     library.
+ 26     You must obey the GNU General Public License in all respects for all of
+ 27     the code used other than OpenSSL. If you modify file(s) with this
+ 28     exception, you may extend this exception to your version of the file(s),
+ 29     but you are not obligated to do so. If you do not wish to do so, delete
+ 30     this exception statement from your version. If you delete this exception
+ 31     statement from all source files in the program, then also delete it here.
+ 32 */
+ 33 
+ 34 /**
+ 35  * @description The torrent status keys that are commonly used around the UI.
+ 36  * @namespace Deluge.Keys
+ 37  */
+ 38 Deluge.Keys = {
+ 39 	/**
+ 40 	 * @static
+ 41 	 */
+ 42     Grid: [
+ 43         'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
+ 44         'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
+ 45         'upload_payload_rate', 'eta', 'ratio', 'distributed_copies',
+ 46         'is_auto_managed', 'time_added', 'tracker_host'
+ 47     ],
+ 48     
+ 49     /**
+ 50      * @description Keys used in the status tab of the statistics panel.
+ 51      * These get extended
+ 52      * by {@link Deluge.Keys.Grid}.
+ 53 	 * @static
+ 54 	 */
+ 55     Status: [
+ 56         'total_done', 'total_payload_download', 'total_uploaded',
+ 57         'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces',
+ 58         'piece_length', 'is_auto_managed', 'active_time', 'seeding_time',
+ 59         'seed_rank'
+ 60     ],
+ 61     
+ 62     /**
+ 63 	 * @static
+ 64      * @description Keys used in the files tab of the statistics panel.
+ 65      * <pre>['files', 'file_progress', 'file_priorities']</pre>
+ 66 	 */
+ 67     Files: [
+ 68         'files', 'file_progress', 'file_priorities'
+ 69     ],
+ 70     
+ 71     /**
+ 72      * @description Keys used in the peers tab of the statistics panel.
+ 73      * <pre>['peers', 'seed']</pre>
+ 74 	 * @static
+ 75 	 */
+ 76     Peers: [
+ 77         'peers', 'seeds'
+ 78     ],
+ 79     
+ 80     /**
+ 81      * @description Keys used in the details tab of the statistics panel.
+ 82 	 * @static
+ 83 	 */
+ 84     Details: [
+ 85         'name', 'save_path', 'total_size', 'num_files', 'tracker_status',
+ 86         'tracker', 'comment'
+ 87     ],
+ 88     
+ 89     /**
+ 90 	 * @static
+ 91 	 * @description Keys used in the options tab of the statistics panel.
+ 92 	 * <pre>['max_download_speed', 'max_upload_speed', 'max_connections', 'max_upload_slots',
+ 93 	 *  'is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'remove_at_ratio', 'private',
+ 94 	 *  'prioritize_first_last']</pre>
+ 95 	 */
+ 96     Options: [
+ 97         'max_download_speed', 'max_upload_speed', 'max_connections',
+ 98         'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio',
+ 99         'remove_at_ratio', 'private', 'prioritize_first_last'
+100     ]
+101 };
+102 
+103 // Merge the grid and status keys together as the status keys contain all the
+104 // grid ones.
+105 Ext.each(Deluge.Keys.Grid, function(key) {
+106     Deluge.Keys.Status.push(key);
+107 });
+108 
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Login.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Login.js.html new file mode 100644 index 000000000..ba08e8982 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Login.js.html @@ -0,0 +1,174 @@ +
  1 /*
+  2 Script: deluge-login.js
+  3     Contains all objects and functions related to the login system.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function(){
+ 36 	Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
+ 37 		
+ 38 		firstShow: true,
+ 39 		
+ 40 		constructor: function(config) {
+ 41 			config = Ext.apply({
+ 42 				layout: 'fit',
+ 43 				width: 300,
+ 44 				height: 120,
+ 45 				bodyStyle: 'padding: 10px 5px;',
+ 46 				buttonAlign: 'center',
+ 47 				closeAction: 'hide',
+ 48 				closable: false,
+ 49 				modal: true,
+ 50 				plain: true,
+ 51 				resizable: false,
+ 52 				title: _('Login'),
+ 53 				iconCls: 'x-deluge-login-window-icon'
+ 54 			}, config);
+ 55 			Ext.deluge.LoginWindow.superclass.constructor.call(this, config);
+ 56 		},
+ 57 		
+ 58 		initComponent: function() {
+ 59 			Ext.deluge.LoginWindow.superclass.initComponent.call(this);
+ 60 			Deluge.Events.on('logout', this.onLogout, this);
+ 61 			this.on('show', this.onShow, this);
+ 62 			this.on('beforeshow', this.onBeforeShow, this);
+ 63 			
+ 64 			this.addButton({
+ 65 				text: _('Login'),
+ 66 				handler: this.onLogin,
+ 67 				scope: this
+ 68 			});
+ 69 			
+ 70 			this.loginForm = this.add({
+ 71 				xtype: 'form',
+ 72 				defaultType: 'textfield',
+ 73 				id: 'loginForm',
+ 74 				baseCls: 'x-plain',
+ 75 				labelWidth: 55,
+ 76 				items: [{
+ 77 					fieldLabel: _('Password'),
+ 78 					id: 'password',
+ 79 					name: 'password',
+ 80 					inputType: 'password',
+ 81 					anchor: '100%',
+ 82 					listeners: {
+ 83 						'specialkey': {
+ 84 							fn: this.onKey,
+ 85 							scope: this
+ 86 						}
+ 87 					}
+ 88 				}]
+ 89 			})
+ 90 		},
+ 91 		
+ 92 		onKey: function(field, e) {
+ 93 			if (e.getKey() == 13) this.onLogin();
+ 94 		},
+ 95 		
+ 96 		onLogin: function() {
+ 97 			var passwordField = this.loginForm.items.get('password');
+ 98 			Deluge.Client.auth.login(passwordField.getValue(), {
+ 99 				success: function(result) {
+100 					if (result) {
+101 						Deluge.Events.fire('login');
+102 						this.hide();
+103 						passwordField.setRawValue('');
+104 						Deluge.UI.cookies.set("session", result);
+105 					} else {
+106 						Ext.MessageBox.show({
+107 							title: _('Login Failed'),
+108 							msg: _('You entered an incorrect password'),
+109 							buttons: Ext.MessageBox.OK,
+110 							modal: false,
+111 							fn: function() {
+112 								passwordField.focus();
+113 							},
+114 							icon: Ext.MessageBox.WARNING,
+115 							iconCls: 'x-deluge-icon-warning'
+116 						});
+117 					}
+118 				},
+119 				scope: this
+120 			});
+121 		},
+122 		
+123 		onLogout: function() {
+124 			var session = Deluge.UI.cookies.get("session", false);
+125 			if (session) {
+126 				Deluge.Client.auth.delete_session(session, {
+127 					success: function(result) {
+128 						Deluge.UI.cookies.clear("session");
+129 						this.show();
+130 					},
+131 					scope: this
+132 				});
+133 			}
+134 		},
+135 		
+136 		onBeforeShow: function() {
+137 			var session = Deluge.UI.cookies.get("session", false);
+138 			if (session) {
+139 				Deluge.Client.auth.check_session(session, {
+140 					success: function(result) {
+141 						if (result) {
+142 							Deluge.Events.fire('login');
+143 							this.loginForm.items.get('password').setRawValue('');
+144 							this.hide();
+145 						} else {
+146 							Deluge.UI.cookies.clear("session");
+147 							this.show();
+148 						}
+149 					},
+150 					failure: function(result) {
+151 						Deluge.UI.cookies.clear("session");
+152 						this.show();
+153 					},
+154 					scope: this
+155 				});
+156 				return false;
+157 			}
+158 		},
+159 		
+160 		onShow: function() {
+161 			var passwordField = this.loginForm.items.get('password');
+162 			passwordField.focus(false, 150);
+163 		}
+164 	});
+165 	
+166 	Deluge.Login = new Ext.deluge.LoginWindow();
+167 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Menus.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Menus.js.html new file mode 100644 index 000000000..1d3812c38 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Menus.js.html @@ -0,0 +1,439 @@ +
  1 /*
+  2 Script: deluge-menus.js
+  3     Contains all the menus contained within the UI for easy access and editing.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Deluge.Menus = {
+ 36 	onTorrentAction: function(item, e) {
+ 37 		var selection = Deluge.Torrents.getSelections();
+ 38 		var ids = [];
+ 39 		Ext.each(selection, function(record) {
+ 40 			ids.push(record.id);
+ 41 		});
+ 42 		
+ 43 		switch (item.id) {
+ 44 			case 'pause':
+ 45 			case 'resume':
+ 46 				Deluge.Client.core[item.id + '_torrent'](ids, {
+ 47 					success: function() {
+ 48 						Deluge.UI.update();
+ 49 					}
+ 50 				});
+ 51 				break;
+ 52 			case 'top':
+ 53 			case 'up':
+ 54 			case 'down':
+ 55 			case 'bottom':
+ 56 				Deluge.Client.core['queue_' + item.id](ids, {
+ 57 					success: function() {
+ 58 						Deluge.UI.update();
+ 59 					}
+ 60 				});
+ 61 				break;
+ 62 			case 'edit_trackers':
+ 63 				Deluge.EditTrackers.show();
+ 64 				break;
+ 65 			case 'update':
+ 66 				Deluge.Client.core.force_reannounce(ids, {
+ 67 					success: function() {
+ 68 						Deluge.UI.update();
+ 69 					}
+ 70 				});
+ 71 				break;
+ 72 			case 'remove':
+ 73 				Deluge.Events.fire('torrentRemoved', ids);
+ 74 				Deluge.Client.core.remove_torrent(ids, null, {
+ 75 					success: function() {
+ 76 						Deluge.UI.update();
+ 77 					}
+ 78 				});
+ 79 				break;
+ 80 			case 'recheck':
+ 81 				Deluge.Client.core.force_recheck(ids, {
+ 82 					success: function() {	
+ 83 						Deluge.UI.update();
+ 84 					}
+ 85 				});
+ 86 				break;
+ 87 		}
+ 88 	}
+ 89 }
+ 90 
+ 91 Deluge.Menus.Torrent = new Ext.menu.Menu({
+ 92 	id: 'torrentMenu',
+ 93 	items: [{
+ 94 		id: 'pause',
+ 95 		text: _('Pause'),
+ 96 		icon: '/icons/pause.png',
+ 97 		handler: Deluge.Menus.onTorrentAction,
+ 98 		scope: Deluge.Menus
+ 99 	}, {
+100 		id: 'resume',
+101 		text: _('Resume'),
+102 		icon: '/icons/start.png',
+103 		handler: Deluge.Menus.onTorrentAction,
+104 		scope: Deluge.Menus
+105 	}, '-', {
+106 		id: 'options',
+107 		text: _('Options'),
+108 		icon: '/icons/preferences.png',
+109 		menu: new Ext.menu.Menu({
+110 			items: [{
+111 				text: _('D/L Speed Limit'),
+112 				iconCls: 'x-deluge-downloading',
+113 				menu: new Ext.menu.Menu({
+114 					items: [{
+115 						text: _('5 KiB/s')
+116 					}, {
+117 						text: _('10 KiB/s')
+118 					}, {
+119 						text: _('30 KiB/s')
+120 					}, {
+121 						text: _('80 KiB/s')
+122 					}, {
+123 						text: _('300 KiB/s')
+124 					},{
+125 						text: _('Unlimited')
+126 					}]
+127 				})
+128 			}, {
+129 				text: _('U/L Speed Limit'),
+130 				iconCls: 'x-deluge-seeding',
+131 				menu: new Ext.menu.Menu({
+132 					items: [{
+133 						text: _('5 KiB/s')
+134 					}, {
+135 						text: _('10 KiB/s')
+136 					}, {
+137 						text: _('30 KiB/s')
+138 					}, {
+139 						text: _('80 KiB/s')
+140 					}, {
+141 						text: _('300 KiB/s')
+142 					},{
+143 						text: _('Unlimited')
+144 					}]
+145 				})
+146 			}, {
+147 				text: _('Connection Limit'),
+148 				iconCls: 'x-deluge-connections',
+149 				menu: new Ext.menu.Menu({
+150 					items: [{
+151 						text: _('50')
+152 					}, {
+153 						text: _('100')
+154 					}, {
+155 						text: _('200')
+156 					}, {
+157 						text: _('300')
+158 					}, {
+159 						text: _('500')
+160 					},{
+161 						text: _('Unlimited')
+162 					}]
+163 				})
+164 			}, {
+165 				text: _('Upload Slot Limit'),
+166 				icon: '/icons/upload_slots.png',
+167 				menu: new Ext.menu.Menu({
+168 					items: [{
+169 						text: _('0')
+170 					}, {
+171 						text: _('1')
+172 					}, {
+173 						text: _('2')
+174 					}, {
+175 						text: _('3')
+176 					}, {
+177 						text: _('5')
+178 					},{
+179 						text: _('Unlimited')
+180 					}]
+181 				})
+182 			}, {
+183 				id: 'auto_managed',
+184 				text: _('Auto Managed'),
+185 				checked: false
+186 			}]
+187 		})
+188 	}, '-', {
+189 		text: _('Queue'),
+190 		icon: '/icons/queue.png',
+191 		menu: new Ext.menu.Menu({
+192 			items: [{
+193 				id: 'top',
+194 				text: _('Top'),
+195 				icon: '/icons/top.png',
+196 				handler: Deluge.Menus.onTorrentAction,
+197 				scope: Deluge.Menus
+198 			},{
+199 				id: 'up',
+200 				text: _('Up'),
+201 				icon: '/icons/up.png',
+202 				handler: Deluge.Menus.onTorrentAction,
+203 				scope: Deluge.Menus
+204 			},{
+205 				id: 'down',
+206 				text: _('Down'),
+207 				icon: '/icons/down.png',
+208 				handler: Deluge.Menus.onTorrentAction,
+209 				scope: Deluge.Menus
+210 			},{
+211 				id: 'bottom',
+212 				text: _('Bottom'),
+213 				icon: '/icons/bottom.png',
+214 				handler: Deluge.Menus.onTorrentAction,
+215 				scope: Deluge.Menus
+216 			}]
+217 		})
+218 	}, '-', {
+219 		id: 'update',
+220 		text: _('Update Tracker'),
+221 		icon: '/icons/update.png',
+222 		handler: Deluge.Menus.onTorrentAction,
+223 		scope: Deluge.Menus
+224 	}, {
+225 		id: 'edit_trackers',
+226 		text: _('Edit Trackers'),
+227 		icon: '/icons/edit_trackers.png',
+228 		handler: Deluge.Menus.onTorrentAction,
+229 		scope: Deluge.Menus
+230 	}, '-', {
+231 		id: 'remove',
+232 		text: _('Remove Torrent'),
+233 		icon: '/icons/remove.png',
+234 		handler: Deluge.Menus.onTorrentAction,
+235 		scope: Deluge.Menus
+236 	}, '-', {
+237 		id: 'recheck',
+238 		text: _('Force Recheck'),
+239 		icon: '/icons/recheck.png',
+240 		handler: Deluge.Menus.onTorrentAction,
+241 		scope: Deluge.Menus
+242 	}, {
+243 		id: 'move',
+244 		text: _('Move Storage'),
+245 		icon: '/icons/move.png',
+246 		handler: Deluge.Menus.onTorrentAction,
+247 		scope: Deluge.Menus
+248 	}]
+249 });
+250 
+251 Deluge.Menus.Connections = new Ext.menu.Menu({
+252 	id: 'connectionsMenu',
+253 	items: [{
+254 		id: '50',
+255 		text: '50',
+256 		group: 'max_connections_global',
+257 		checked: false,
+258 		checkHandler: onLimitChanged
+259 	},{
+260 		id: '100',
+261 		text: '100',
+262 		group: 'max_connections_global',
+263 		checked: false,
+264 		checkHandler: onLimitChanged
+265 	},{
+266 		id: '200',
+267 		text: '200',
+268 		group: 'max_connections_global',
+269 		checked: false,
+270 		checkHandler: onLimitChanged
+271 	},{
+272 		id: '300',
+273 		text: '300',
+274 		group: 'max_connections_global',
+275 		checked: false,
+276 		checkHandler: onLimitChanged
+277 	},{
+278 		id: '500',
+279 		text: '500',
+280 		group: 'max_connections_global',
+281 		checked: false,
+282 		checkHandler: onLimitChanged
+283 	},{
+284 		id: '-1',
+285 		text: _('Unlimited'),
+286 		group: 'max_connections_global',
+287 		checked: false,
+288 		checkHandler: onLimitChanged
+289 	},'-',{
+290 		id: 'other',
+291 		text: _('Other'),
+292 		group: 'max_connections_global',
+293 		checked: false,
+294 		checkHandler: onLimitChanged
+295 	}]
+296 });
+297 
+298 Deluge.Menus.Download = new Ext.menu.Menu({
+299 	id: 'downspeedMenu',
+300 	items: [{
+301 		id: '5',
+302 		text: '5 KiB/s',
+303 		group: 'max_download_speed',
+304 		checked: false,
+305 		checkHandler: onLimitChanged
+306 	},{
+307 		id: '10',
+308 		text: '10 KiB/s',
+309 		group: 'max_download_speed',
+310 		checked: false,
+311 		checkHandler: onLimitChanged
+312 	},{
+313 		id: '30',
+314 		text: '30 KiB/s',
+315 		group: 'max_download_speed',
+316 		checked: false,
+317 		checkHandler: onLimitChanged
+318 	},{
+319 		id: '80',
+320 		text: '80 KiB/s',
+321 		group: 'max_download_speed',
+322 		checked: false,
+323 		checkHandler: onLimitChanged
+324 	},{
+325 		id: '300',
+326 		text: '300 KiB/s',
+327 		group: 'max_download_speed',
+328 		checked: false,
+329 		checkHandler: onLimitChanged
+330 	},{
+331 		id: '-1',
+332 		text: _('Unlimited'),
+333 		group: 'max_download_speed',
+334 		checked: false,
+335 		checkHandler: onLimitChanged
+336 	},'-',{
+337 		id: 'other',
+338 		text: _('Other'),
+339 		group: 'max_download_speed',
+340 		checked: false,
+341 		checkHandler: onLimitChanged
+342 	}]
+343 });
+344 
+345 Deluge.Menus.Upload = new Ext.menu.Menu({
+346 	id: 'upspeedMenu',
+347 	items: [{
+348 		id: '5',
+349 		text: '5 KiB/s',
+350 		group: 'max_upload_speed',
+351 		checked: false,
+352 		checkHandler: onLimitChanged
+353 	},{
+354 		id: '10',
+355 		text: '10 KiB/s',
+356 		group: 'max_upload_speed',
+357 		checked: false,
+358 		checkHandler: onLimitChanged
+359 	},{
+360 		id: '30',
+361 		text: '30 KiB/s',
+362 		group: 'max_upload_speed',
+363 		checked: false,
+364 		checkHandler: onLimitChanged
+365 	},{
+366 		id: '80',
+367 		text: '80 KiB/s',
+368 		group: 'max_upload_speed',
+369 		checked: false,
+370 		checkHandler: onLimitChanged
+371 	},{
+372 		id: '300',
+373 		text: '300 KiB/s',
+374 		group: 'max_upload_speed',
+375 		checked: false,
+376 		checkHandler: onLimitChanged
+377 	},{
+378 		id: '-1',
+379 		text: _('Unlimited'),
+380 		group: 'max_upload_speed',
+381 		checked: false,
+382 		checkHandler: onLimitChanged
+383 	},'-',{
+384 		id: 'other',
+385 		text: _('Other'),
+386 		group: 'max_upload_speed',
+387 		checked: false,
+388 		checkHandler: onLimitChanged
+389 	}]
+390 });
+391 
+392 Deluge.Menus.FilePriorities = new Ext.menu.Menu({
+393 	id: 'filePrioritiesMenu',
+394 	items: [{
+395 		id: 'expandAll',
+396 		text: _('Expand All'),
+397 		icon: '/icons/expand_all.png'
+398 	}, '-', {
+399 		id: 'no_download',
+400 		text: _('Do Not Download'),
+401 		icon: '/icons/no_download.png',
+402 		filePriority: 0
+403 	}, {
+404 		id: 'normal',
+405 		text: _('Normal Priority'),
+406 		icon: '/icons/normal.png',
+407 		filePriority: 1
+408 	}, {
+409 		id: 'high',
+410 		text: _('High Priority'),
+411 		icon: '/icons/high.png',
+412 		filePriority: 2
+413 	}, {
+414 		id: 'highest',
+415 		text: _('Highest Priority'),
+416 		icon: '/icons/highest.png',
+417 		filePriority: 5
+418 	}]
+419 });
+420 
+421 function onLimitChanged(item, checked) {
+422 	if (item.id == "other") {
+423 	} else {
+424 		config = {}
+425 		config[item.group] = item.id
+426 		Deluge.Client.core.set_config(config, {
+427 			success: function() {
+428 				Deluge.UI.update();
+429 			}
+430 		});
+431 	}
+432 }
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Bandwidth.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Bandwidth.js.html new file mode 100644 index 000000000..83db293c0 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Bandwidth.js.html @@ -0,0 +1,103 @@ +
  1 Deluge.Preferences.addPage({
+  2 	border: false,
+  3 	title: _('Bandwidth'),
+  4 	xtype: 'form',
+  5 	layout: 'form',
+  6 	labelWidth: 10,
+  7 	items: [{
+  8 		xtype: 'fieldset',
+  9 		border: false,
+ 10 		title: _('Global Bandwidth Usage'),
+ 11 		autoHeight: true,
+ 12 		labelWidth: 200,
+ 13 		style: 'margin-bottom: 0px; padding-bottom: 0px;',
+ 14 		defaultType: 'uxspinner',
+ 15 		items: [{
+ 16 			name: 'max_connections',
+ 17 			fieldLabel: _('Maximum Connections'),
+ 18 			width: 60,
+ 19 			value: -1
+ 20 		}, {
+ 21 			name: 'max_upload_slots',
+ 22 			fieldLabel: _('Maximum Upload Slots'),
+ 23 			width: 60,
+ 24 			value: -1
+ 25 		}, {
+ 26 			name: 'max_download_speed',
+ 27 			fieldLabel: _('Maximum Download Speed (KiB/s)'),
+ 28 			width: 60,
+ 29 			value: -1
+ 30 		}, {
+ 31 			name: 'max_upload_speed',
+ 32 			fieldLabel: _('Maximum Upload Speed (KiB/s)'),
+ 33 			width: 60,
+ 34 			value: -1
+ 35 		}, {
+ 36 			name: 'max_half_open_connections',
+ 37 			fieldLabel: _('Maximum Half-Open Connections'),
+ 38 			width: 60,
+ 39 			value: -1
+ 40 		}, {
+ 41 			name: 'max_connections_per_second',
+ 42 			fieldLabel: _('Maximum Connection Attempts per Second'),
+ 43 			width: 60,
+ 44 			value: -1
+ 45 		}]
+ 46 	}, {
+ 47 		xtype: 'fieldset',
+ 48 		border: false,
+ 49 		title: '',
+ 50 		autoHeight: true,
+ 51 		style: 'padding-top: 0px; margin-top: 0px; margin-bottom: 0px;',
+ 52 		items: [{
+ 53 			xtype: 'checkbox',
+ 54 			name: 'ignore_local',
+ 55 			fieldLabel: '',
+ 56 			labelSeparator: '',
+ 57 			boxLabel: _('Ignore limits on local network'),
+ 58 			value: -1
+ 59 		}, {
+ 60 			xtype: 'checkbox',
+ 61 			name: 'limit_ip_overhead',
+ 62 			fieldLabel: '',
+ 63 			labelSeparator: '',
+ 64 			boxLabel: _('Rate limit IP overhead'),
+ 65 			value: -1
+ 66 		}]
+ 67 	}, {
+ 68 		xtype: 'fieldset',
+ 69 		border: false,
+ 70 		title: _('Per Torrent Bandwidth Usage'),
+ 71 		autoHeight: true,
+ 72 		labelWidth: 200,
+ 73 		defaultType: 'uxspinner',
+ 74 		items: [{
+ 75 			name: 'max_connections_per_torrent',
+ 76 			fieldLabel: _('Maximum Connections'),
+ 77 			width: 60,
+ 78 			value: -1
+ 79 		}, {
+ 80 			name: 'max_upload_slots_per_torrent',
+ 81 			fieldLabel: _('Maximum Upload Slots'),
+ 82 			width: 60,
+ 83 			value: -1
+ 84 		}, {
+ 85 			name: 'max_download_speed_per_torrent',
+ 86 			fieldLabel: _('Maximum Download Speed (KiB/s)'),
+ 87 			width: 60,
+ 88 			value: -1
+ 89 		}, {
+ 90 			name: 'max_upload_speed_per_torrent',
+ 91 			fieldLabel: _('Maximum Upload Speed (KiB/s)'),
+ 92 			width: 60,
+ 93 			value: -1
+ 94 		}]
+ 95 	}]
+ 96 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Daemon.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Daemon.js.html new file mode 100644 index 000000000..282cd2a65 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Daemon.js.html @@ -0,0 +1,51 @@ +
  1 Deluge.Preferences.addPage({
+  2 	border: false,
+  3 	title: _('Daemon'),
+  4 	xtype: 'form',
+  5 	layout: 'form',
+  6 	items: [{
+  7 		xtype: 'fieldset',
+  8 		border: false,
+  9 		title: _('Port'),
+ 10 		autoHeight: true,
+ 11 		defaultType: 'uxspinner',
+ 12 		items: [{
+ 13 			fieldLabel: _('Daemon port'),
+ 14 			id: 'daemon_port'
+ 15 		}]
+ 16 	}, {
+ 17 		xtype: 'fieldset',
+ 18 		border: false,
+ 19 		title: _('Connections'),
+ 20 		autoHeight: true,
+ 21 		labelWidth: 1,
+ 22 		defaultType: 'checkbox',
+ 23 		items: [{
+ 24 			fieldLabel: '',
+ 25 			labelSeparator: '',
+ 26 			boxLabel: _('Allow Remote Connections'),
+ 27 			id: 'allow_remote'
+ 28 		}]
+ 29 	}, {
+ 30 		xtype: 'fieldset',
+ 31 		border: false,
+ 32 		title: _('Other'),
+ 33 		autoHeight: true,
+ 34 		labelWidth: 1,
+ 35 		defaultType: 'checkbox',
+ 36 		items: [{
+ 37 			fieldLabel: '',
+ 38 			labelSeparator: '',
+ 39 			height: 40,
+ 40 			boxLabel: _('Periodically check the website for new releases'),
+ 41 			id: 'new_releases'
+ 42 		}]
+ 43 	}]
+ 44 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Downloads.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Downloads.js.html new file mode 100644 index 000000000..06ee584b6 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Downloads.js.html @@ -0,0 +1,66 @@ +
  1 Deluge.Preferences.addPage({
+  2 	border: false,
+  3 	title: _('Downloads'),
+  4 	xtype: 'form',
+  5 	layout: 'form',
+  6 	items: [{
+  7 		xtype: 'fieldset',
+  8 		border: false,
+  9 		title: _('Folders'),
+ 10 		labelWidth: 140,
+ 11 		defaultType: 'textfield',
+ 12 		autoHeight: true,
+ 13 		items: [{
+ 14 			name: 'download_location',
+ 15 			fieldLabel: _('Download to'),
+ 16 			width: 125
+ 17 		}, {
+ 18 			name: 'move_completed',
+ 19 			fieldLabel: _('Move completed to'),
+ 20 			width: 125
+ 21 		}, {
+ 22 			name: 'copy_torrent_files',
+ 23 			fieldLabel: _('Copy of .torrent files to'),
+ 24 			width: 125
+ 25 		}]
+ 26 	}, {
+ 27 		xtype: 'fieldset',
+ 28 		border: false,
+ 29 		title: _('Allocation'),
+ 30 		autoHeight: true,
+ 31 		labelWidth: 1,
+ 32 		defaultType: 'radio',
+ 33 		items: [{
+ 34 			name: 'compact_allocation',
+ 35 			labelSeparator: '',
+ 36 			boxLabel: _('Compact')
+ 37 		}, {
+ 38 			name: 'compact_allocation',
+ 39 			labelSeparator: '',
+ 40 			boxLabel: _('Full')
+ 41 		}]
+ 42 	}, {
+ 43 		xtype: 'fieldset',
+ 44 		border: false,
+ 45 		title: _('Options'),
+ 46 		autoHeight: true,
+ 47 		labelWidth: 1,
+ 48 		defaultType: 'checkbox',
+ 49 		items: [{
+ 50 			name: 'prioritize_first_last',
+ 51 			labelSeparator: '',
+ 52 			boxLabel: _('Prioritize first and last pieces of torrent')
+ 53 		}, {
+ 54 			name: 'add_paused',
+ 55 			labelSeparator: '',
+ 56 			boxLabel: _('Add torrents in Paused state')
+ 57 		}]
+ 58 	}]
+ 59 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Interface.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Interface.js.html new file mode 100644 index 000000000..605ebcf41 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Interface.js.html @@ -0,0 +1,55 @@ +
  1 Deluge.Preferences.addPage({
+  2 	border: false,
+  3 	title: _('Interface'),
+  4 	xtype: 'form',
+  5 	layout: 'form',
+  6 	items: [{
+  7 		xtype: 'fieldset',
+  8 		border: false,
+  9 		title: _('Window'),
+ 10 		autoHeight: true,
+ 11 		labelWidth: 1,
+ 12 		items: [{
+ 13 			xtype: 'checkbox',
+ 14 			fieldLabel: '',
+ 15 			labelSeparator: '',
+ 16 			boxLabel: _('Show session speed in titlebar'),
+ 17 			id: 'show_session_speed'
+ 18 		}]
+ 19 	}, {
+ 20 		xtype: 'fieldset',
+ 21 		border: false,
+ 22 		title: _('Sidebar'),
+ 23 		autoHeight: true,
+ 24 		labelWidth: 1,
+ 25 		items: [{
+ 26 			xtype: 'checkbox',
+ 27 			fieldLabel: '',
+ 28 			labelSeparator: '',
+ 29 			boxLabel: _('Hide filters with zero torrents'),
+ 30 			id: 'hide_sidebar_zero'
+ 31 		}]
+ 32 	}, {
+ 33 		xtype: 'fieldset',
+ 34 		border: false,
+ 35 		title: _('Password'),
+ 36 		autoHeight: true,
+ 37 		defaultType: 'textfield',
+ 38 		items: [{
+ 39 			fieldLabel: 'New Password',
+ 40 			inputType: 'password',
+ 41 			id: 'new_password'
+ 42 		}, {
+ 43 			inputType: 'password',
+ 44 			fieldLabel: 'Confirm Password',
+ 45 			id: 'confirm_password'
+ 46 		}]
+ 47 	}]
+ 48 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Network.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Network.js.html new file mode 100644 index 000000000..cc8ef75a1 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Network.js.html @@ -0,0 +1,14 @@ +
  1 /*Deluge.Preferences.addPage(_('Network'), {
+  2 	border: false,
+  3 	xtype: 'form',
+  4 	layout: 'form',
+  5 	items: []
+  6 });
+  7 */
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Notification.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Notification.js.html new file mode 100644 index 000000000..df36a2201 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Notification.js.html @@ -0,0 +1,14 @@ +
  1 /*Deluge.Preferences.addPage(_('Notification'), {
+  2 	border: false,
+  3 	xtype: 'form',
+  4 	layout: 'form',
+  5 	items: []
+  6 });
+  7 */
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Other.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Other.js.html new file mode 100644 index 000000000..cdad634ef --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Other.js.html @@ -0,0 +1,14 @@ +
  1 /*Deluge.Preferences.addPage(_('Other'), {
+  2 	border: false,
+  3 	xtype: 'form',
+  4 	layout: 'form',
+  5 	items: []
+  6 });
+  7 */
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Plugins.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Plugins.js.html new file mode 100644 index 000000000..e6d6e1f30 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Plugins.js.html @@ -0,0 +1,14 @@ +
  1 /*Deluge.Preferences.addPage(_('Plugins'), {
+  2 	border: false,
+  3 	xtype: 'form',
+  4 	layout: 'form',
+  5 	items: []
+  6 });
+  7 */
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Proxy.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Proxy.js.html new file mode 100644 index 000000000..0a52cb248 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Proxy.js.html @@ -0,0 +1,15 @@ +
  1 /*
+  2 Deluge.Preferences.addPage(_('Proxy'), {
+  3 	border: false,
+  4 	xtype: 'form',
+  5 	layout: 'form',
+  6 	items: []
+  7 });
+  8 */
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Queue.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Queue.js.html new file mode 100644 index 000000000..4a0aae4d0 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.Queue.js.html @@ -0,0 +1,15 @@ +
  1 /*
+  2 Deluge.Preferences.addPage(_('Queue'), {
+  3 	border: false,
+  4 	xtype: 'form',
+  5 	layout: 'form',
+  6 	items: []
+  7 });
+  8 */
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Preferences.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.js.html new file mode 100644 index 000000000..e53f91be8 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Preferences.js.html @@ -0,0 +1,140 @@ +
  1 /*
+  2 Script: Deluge.Preferences.js
+  3     Contains the preferences window.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function() {	
+ 36 	Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
+ 37 		constructor: function(config) {
+ 38 			config = Ext.apply({
+ 39 				layout: 'border',
+ 40 				width: 485,
+ 41 				height: 500,
+ 42 				buttonAlign: 'right',
+ 43 				closeAction: 'hide',
+ 44 				closable: true,
+ 45 				iconCls: 'x-deluge-preferences',
+ 46 				plain: true,
+ 47 				resizable: true,
+ 48 				title: _('Preferences'),
+ 49 				
+ 50 				buttons: [{
+ 51 					text: _('Close'),
+ 52 					handler: this.onCloseButtonClick,
+ 53 					scope: this
+ 54 				},{
+ 55 					text: _('Apply')
+ 56 				},{
+ 57 					text: _('Ok')
+ 58 				}],
+ 59 				
+ 60 				currentPage: false,
+ 61 				items: [{
+ 62 					xtype: 'grid',
+ 63 					region: 'west',
+ 64 					title: _('Categories'),
+ 65 					store: new Ext.data.SimpleStore({
+ 66 						fields: [{name: 'name', mapping: 0}]
+ 67 					}),
+ 68 					columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}],
+ 69 					sm: new Ext.grid.RowSelectionModel({
+ 70 						singleSelect: true,
+ 71 						listeners: {'rowselect': {fn: this.onPageSelect, scope: this}}
+ 72 					}),
+ 73 					hideHeaders: true,
+ 74 					autoExpandColumn: 'name',
+ 75 					deferredRender: false,
+ 76 					autoScroll: true,
+ 77 					margins: '5 0 5 5',
+ 78 					cmargins: '5 0 5 5',
+ 79 					width: 120,
+ 80 					collapsible: true
+ 81 				}, {
+ 82 					region: 'center',
+ 83 					header: false,
+ 84 					layout: 'fit',
+ 85 					height: 400,
+ 86 					margins: '5 5 5 5',
+ 87 					cmargins: '5 5 5 5'
+ 88 				}]
+ 89 			}, config);
+ 90 			Ext.deluge.PreferencesWindow.superclass.constructor.call(this, config);
+ 91 		},
+ 92 		
+ 93 		initComponent: function() {
+ 94 			Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);
+ 95 			this.categoriesGrid = this.items.get(0);
+ 96 			this.configPanel = this.items.get(1);
+ 97 			this.pages = {};
+ 98 			this.on('show', this.onShow, this);
+ 99 		},
+100 		
+101 		onCloseButtonClick: function() {
+102 			this.hide();
+103 		},
+104 		
+105 		addPage: function(page) {
+106 			var store = this.categoriesGrid.getStore();
+107 			var name = page.title;
+108 			store.loadData([[name]], true);
+109 			page['bodyStyle'] = 'margin: 5px';
+110 			this.pages[name] = this.configPanel.add(page);
+111 			this.pages[name].hide();
+112 		},
+113 		
+114 		onPageSelect: function(selModel, rowIndex, r) {
+115 			if (this.currentPage) {
+116 				this.currentPage.hide();
+117 			}
+118 			var name = r.get('name');
+119 			
+120 			this.pages[name].show();
+121 			this.currentPage = this.pages[name];
+122 			this.configPanel.doLayout();
+123 		},
+124 		
+125 		onShow: function() {
+126 			if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
+127 				this.categoriesGrid.getSelectionModel().selectFirstRow();
+128 			}
+129 		}
+130 	});
+131 
+132 	Deluge.Preferences = new Ext.deluge.PreferencesWindow();
+133 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Sidebar.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Sidebar.js.html new file mode 100644 index 000000000..64090fd68 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Sidebar.js.html @@ -0,0 +1,220 @@ +
  1 /*
+  2 Script: deluge-bars.js
+  3     Contains all objects and functions related to the statusbar, toolbar and
+  4 	sidebar.
+  5 
+  6 Copyright:
+  7 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  8 	This program is free software; you can redistribute it and/or modify
+  9 	it under the terms of the GNU General Public License as published by
+ 10 	the Free Software Foundation; either version 3, or (at your option)
+ 11 	any later version.
+ 12 
+ 13 	This program is distributed in the hope that it will be useful,
+ 14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 16 	GNU General Public License for more details.
+ 17 
+ 18 	You should have received a copy of the GNU General Public License
+ 19 	along with this program.  If not, write to:
+ 20 		The Free Software Foundation, Inc.,
+ 21 		51 Franklin Street, Fifth Floor
+ 22 		Boston, MA  02110-1301, USA.
+ 23 #
+ 24 #    In addition, as a special exception, the copyright holders give
+ 25 #    permission to link the code of portions of this program with the OpenSSL
+ 26 #    library.
+ 27 #    You must obey the GNU General Public License in all respects for all of
+ 28 #    the code used other than OpenSSL. If you modify file(s) with this
+ 29 #    exception, you may extend this exception to your version of the file(s),
+ 30 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 31 #    this exception statement from your version. If you delete this exception
+ 32 #    statement from all source files in the program, then also delete it here.
+ 33 #
+ 34 */
+ 35 
+ 36 // These are just so gen_gettext.js will pick up the strings
+ 37 // _('State')
+ 38 // _('Tracker Host')
+ 39 
+ 40 (function() {
+ 41 	// Renderer for the items in the filter grids.
+ 42 	function filterRenderer(value, p, r) {
+ 43 		var lname = value.toLowerCase().replace('.', '_');
+ 44 		
+ 45 		var image = '';	
+ 46 		if (r.store.id == 'tracker_host') {
+ 47 			if (value != 'Error') {
+ 48 				image = String.format('url(/tracker/{0})', value);
+ 49 			} else {
+ 50 				lname = null;
+ 51 			}
+ 52 		}
+ 53 		if (image) {
+ 54 			return String.format('<div class="x-deluge-filter" style="background-image: {2};">{0} ({1})</div>', value, r.data['count'], image);
+ 55 		} else if (lname) {
+ 56 			return String.format('<div class="x-deluge-filter x-deluge-{2}">{0} ({1})</div>', value, r.data['count'], lname);
+ 57 		} else {
+ 58 			return String.format('<div class="x-deluge-filter">{0} ({1})</div>', value, r.data['count']);
+ 59 		}
+ 60 	}
+ 61 	
+ 62 	Ext.deluge.Sidebar = Ext.extend(Ext.Panel, {
+ 63 		
+ 64 		// private
+ 65 		panels: {},
+ 66 		
+ 67 		// private
+ 68 		selected: null,
+ 69 		
+ 70 		constructor: function(config) {
+ 71 			config = Ext.apply({
+ 72 				id: 'sidebar',
+ 73 				region: 'west',
+ 74 				cls: 'deluge-sidebar',
+ 75 				title: _('Filters'),
+ 76 				layout: 'accordion',
+ 77 				split: true,
+ 78 				width: 200,
+ 79 				minSize: 175,
+ 80 				collapsible: true,
+ 81 				margins: '5 0 0 5',
+ 82 				cmargins: '5 0 0 5'
+ 83 			}, config);
+ 84 			Ext.deluge.Sidebar.superclass.constructor.call(this, config);
+ 85 		},
+ 86 		
+ 87 		// private
+ 88 		initComponent: function() {
+ 89 			Ext.deluge.Sidebar.superclass.initComponent.call(this);
+ 90 			Deluge.Events.on("disconnect", this.onDisconnect, this);
+ 91 		},
+ 92 		
+ 93 		createFilter: function(filter, states) {
+ 94 			var store = new Ext.data.SimpleStore({
+ 95 				id: filter,
+ 96 				fields: [
+ 97 					{name: 'filter'},
+ 98 					{name: 'count'}
+ 99 				]
+100 			});
+101 			
+102 			var title = filter.replace('_', ' ');
+103 			var parts = title.split(' ');
+104 			title = '';
+105 			Ext.each(parts, function(part) {
+106 				firstLetter = part.substring(0, 1);
+107 				firstLetter = firstLetter.toUpperCase();
+108 				part = firstLetter + part.substring(1);
+109 				title += part + ' ';
+110 			});
+111 			
+112 			var panel = new Ext.grid.GridPanel({
+113 				id: filter + '-panel',
+114 				store: store,
+115 				title: _(title),
+116 				columns: [
+117 					{id: 'filter', sortable: false, renderer: filterRenderer, dataIndex: 'filter'}
+118 				],	
+119 				stripeRows: false,
+120 				selModel: new Ext.grid.RowSelectionModel({
+121 					singleSelect: true,
+122 					listeners: {
+123 						'rowselect': {fn: this.onFilterSelect, scope: this}
+124 					}
+125 				}),
+126 				hideHeaders: true,
+127 				autoExpandColumn: 'filter',
+128 				deferredRender: false,
+129 				autoScroll: true
+130 			});
+131 			store.loadData(states);
+132 			this.add(panel);
+133 			
+134 			this.doLayout();
+135 			this.panels[filter] = panel;
+136 			
+137 			if (!this.selected) {
+138 				panel.getSelectionModel().selectFirstRow();
+139 				this.selected = {
+140 					row: 0,
+141 					filter: states[0][0],
+142 					panel: panel
+143 				}
+144 			}
+145 		},
+146 		
+147 		getFilters: function() {
+148 			var filters = {}
+149 			if (!this.selected) {
+150 				return filters;
+151 			}
+152 			if (!this.selected.filter || !this.selected.panel) {
+153 				return filters;
+154 			}
+155 			var filterType = this.selected.panel.store.id;
+156 			if (filterType == "state" && this.selected.filter == "All") {
+157 				return filters;
+158 			}
+159 			
+160 			filters[filterType] = this.selected.filter;
+161 			return filters;
+162 		},
+163 		
+164 		// private
+165 		onDisconnect: function() {
+166 			Ext.each(Ext.getKeys(this.panels), function(filter) {
+167 				this.remove(filter + '-panel');
+168 			}, this);
+169 			this.panels = {};
+170 			this.selected = null;
+171 		},
+172 		
+173 		onFilterSelect: function(selModel, rowIndex, record) {
+174 			if (!this.selected) needsUpdate = true;
+175 			else if (this.selected.row != rowIndex) needsUpdate = true;
+176 			else needsUpdate = false;
+177 			this.selected = {
+178 				row: rowIndex,
+179 				filter: record.get('filter'),
+180 				panel: this.panels[record.store.id]
+181 			}
+182 			
+183 			if (needsUpdate) Deluge.UI.update();
+184 		},
+185 		
+186 		update: function(filters) {
+187 			for (var filter in filters) {
+188 				var states = filters[filter];
+189 				if (Ext.getKeys(this.panels).indexOf(filter) > -1) {
+190 					this.updateFilter(filter, states);
+191 				} else {
+192 					this.createFilter(filter, states);
+193 				}
+194 			}
+195 			
+196 			// Perform a cleanup of fitlers that aren't enabled any more
+197 			Ext.each(Ext.keys(this.panels), function(filter) {
+198 				if (Ext.keys(filters).indexOf(filter) == -1) {
+199 					// We need to remove the panel
+200 				}
+201 			});
+202 		},
+203 		
+204 		updateFilter: function(filter, states) {
+205 			this.panels[filter].store.loadData(states);
+206 			if (this.selected && this.selected.panel == this.panels[filter]) {
+207 				this.panels[filter].getSelectionModel().selectRow(this.selected.row);
+208 			}
+209 		}
+210 		
+211 	});
+212 	Deluge.Sidebar = new Ext.deluge.Sidebar();
+213 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Statusbar.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Statusbar.js.html new file mode 100644 index 000000000..4069ea759 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Statusbar.js.html @@ -0,0 +1,154 @@ +
  1 (function() {	
+  2 	Ext.deluge.Statusbar = Ext.extend(Ext.StatusBar, {
+  3 		constructor: function(config) {
+  4 			config = Ext.apply({
+  5 				id: 'deluge-statusbar',
+  6 				defaultIconCls: 'x-not-connected',
+  7 				defaultText: _('Not Connected')
+  8 			}, config);
+  9 			Ext.deluge.Statusbar.superclass.constructor.call(this, config);
+ 10 		},
+ 11 		
+ 12 		initComponent: function() {
+ 13 			Ext.deluge.Statusbar.superclass.initComponent.call(this);
+ 14 			
+ 15 			Deluge.Events.on('connect', this.onConnect, this);
+ 16 			Deluge.Events.on('disconnect', this.onDisconnect, this);
+ 17 		},
+ 18 		
+ 19 		createButtons: function() {
+ 20 			this.add({
+ 21 				id: 'statusbar-connections',
+ 22 				text: ' ',
+ 23 				cls: 'x-btn-text-icon',
+ 24 				iconCls: 'x-deluge-connections',
+ 25 				menu: Deluge.Menus.Connections
+ 26 			}, '-', {
+ 27 				id: 'statusbar-downspeed',
+ 28 				text: ' ',
+ 29 				cls: 'x-btn-text-icon',
+ 30 				iconCls: 'x-deluge-downloading',
+ 31 				menu: Deluge.Menus.Download
+ 32 			}, '-', {
+ 33 				id: 'statusbar-upspeed',
+ 34 				text: ' ',
+ 35 				cls: 'x-btn-text-icon',
+ 36 				iconCls: 'x-deluge-seeding',
+ 37 				menu: Deluge.Menus.Upload
+ 38 			}, '-', {
+ 39 				id: 'statusbar-traffic',
+ 40 				text: ' ',
+ 41 				cls: 'x-btn-text-icon',
+ 42 				iconCls: 'x-deluge-traffic'
+ 43 			}, '-', {
+ 44 				id: 'statusbar-dht',
+ 45 				text: ' ',
+ 46 				cls: 'x-btn-text-icon',
+ 47 				iconCls: 'x-deluge-dht'
+ 48 			});
+ 49 			this.created = true;
+ 50 		},
+ 51 		
+ 52 		onConnect: function() {
+ 53 			this.setStatus({
+ 54 				iconCls: 'x-connected',
+ 55 				text: ''
+ 56 			});
+ 57 			if (!this.created) this.createButtons();
+ 58 			else {
+ 59 				this.items.each(function(item) {
+ 60 					item.show();
+ 61 					item.enable();
+ 62 				});
+ 63 			}
+ 64 		},
+ 65 	
+ 66 		onDisconnect: function() {
+ 67 			this.clearStatus({useDefaults:true});
+ 68 			this.items.each(function(item) {
+ 69 				item.hide();
+ 70 				item.disable();
+ 71 			});
+ 72 		},
+ 73 		
+ 74 		update: function(stats) {
+ 75 			function addSpeed(val) {return val + ' KiB/s'}
+ 76 			
+ 77 			var updateStat = function(name, config) {
+ 78 				var item = this.items.get('statusbar-' + name);
+ 79 				if (config.limit.value == -1) {
+ 80 					var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
+ 81 				} else {
+ 82 					var value = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
+ 83 					var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value) : config.limit.value;
+ 84 					var str = String.format(config.format, value, limit);
+ 85 				}
+ 86 				item.setText(str);
+ 87 			}.bind(this);
+ 88 			
+ 89 			updateStat('connections', {
+ 90 				value: {value: stats.num_connections},
+ 91 				limit: {value: stats.max_num_connections},
+ 92 				format: '{0} ({1})'
+ 93 			});
+ 94 	
+ 95 			updateStat('downspeed', {
+ 96 				value: {
+ 97 					value: stats.download_rate,
+ 98 					formatter: Deluge.Formatters.speed
+ 99 				},
+100 				limit: {
+101 					value: stats.max_download,
+102 					formatter: addSpeed
+103 				},
+104 				format: '{0} ({1})'
+105 			});
+106 	
+107 			updateStat('upspeed', {
+108 				value: {
+109 					value: stats.upload_rate,
+110 					formatter: Deluge.Formatters.speed
+111 				},
+112 				limit: {
+113 					value: stats.max_upload,
+114 					formatter: addSpeed
+115 				},
+116 				format: '{0} ({1})'
+117 			});
+118 			
+119 			updateStat('traffic', {
+120 				value: {
+121 					value: stats.payload_download_rate,
+122 					formatter: Deluge.Formatters.speed
+123 				},
+124 				limit: {
+125 					value: stats.payload_upload_rate,
+126 					formatter: Deluge.Formatters.speed
+127 				},
+128 				format: '{0}/{1}'
+129 			});
+130 	
+131 			this.items.get('statusbar-dht').setText(stats.dht_nodes);
+132 	
+133 			function updateMenu(menu, stat) {
+134 				var item = menu.items.get(stat)
+135 				if (!item) {
+136 					item = menu.items.get('other')
+137 				}
+138 				item.setChecked(true);
+139 			}
+140 			
+141 			updateMenu(Deluge.Menus.Connections, stats.max_num_connections);
+142 			updateMenu(Deluge.Menus.Download, stats.max_download);
+143 			updateMenu(Deluge.Menus.Upload, stats.max_upload);
+144 		}
+145 	});
+146 	Deluge.Statusbar = new Ext.deluge.Statusbar();
+147 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Toolbar.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Toolbar.js.html new file mode 100644 index 000000000..c2db44cf0 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Toolbar.js.html @@ -0,0 +1,213 @@ +
  1 /*
+  2 Script: Deluge.Toolbar.js
+  3     Contains the Deluge toolbar.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function() {
+ 36 	Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
+ 37 		constructor: function(config) {
+ 38 			config = Ext.apply({
+ 39 				items: [
+ 40 					{
+ 41 						id: 'create',
+ 42 						cls: 'x-btn-text-icon',
+ 43 						disabled: true,
+ 44 						text: _('Create'),
+ 45 						icon: '/icons/create.png',
+ 46 						handler: this.onTorrentAction
+ 47 					},{
+ 48 						id: 'add',
+ 49 						cls: 'x-btn-text-icon',
+ 50 						disabled: true,
+ 51 						text: _('Add'),
+ 52 						icon: '/icons/add.png',
+ 53 						handler: this.onTorrentAdd
+ 54 					},{
+ 55 						id: 'remove',
+ 56 						cls: 'x-btn-text-icon',
+ 57 						disabled: true,
+ 58 						text: _('Remove'),
+ 59 						icon: '/icons/remove.png',
+ 60 						handler: this.onTorrentAction
+ 61 					},'|',{
+ 62 						id: 'pause',
+ 63 						cls: 'x-btn-text-icon',
+ 64 						disabled: true,
+ 65 						text: _('Pause'),
+ 66 						icon: '/icons/pause.png',
+ 67 						handler: this.onTorrentAction
+ 68 					},{
+ 69 						id: 'resume',
+ 70 						cls: 'x-btn-text-icon',
+ 71 						disabled: true,
+ 72 						text: _('Resume'),
+ 73 						icon: '/icons/start.png',
+ 74 						handler: this.onTorrentAction
+ 75 					},'|',{
+ 76 						id: 'up',
+ 77 						cls: 'x-btn-text-icon',
+ 78 						disabled: true,
+ 79 						text: _('Up'),
+ 80 						icon: '/icons/up.png',
+ 81 						handler: this.onTorrentAction
+ 82 					},{
+ 83 						id: 'down',
+ 84 						cls: 'x-btn-text-icon',
+ 85 						disabled: true,
+ 86 						text: _('Down'),
+ 87 						icon: '/icons/down.png',
+ 88 						handler: this.onTorrentAction
+ 89 					},'|',{
+ 90 						id: 'preferences',
+ 91 						cls: 'x-btn-text-icon',
+ 92 						text: _('Preferences'),
+ 93 						icon: '/icons/preferences.png',
+ 94 						handler: this.onPreferencesClick,
+ 95 						scope: this
+ 96 					},{
+ 97 						id: 'connectionman',
+ 98 						cls: 'x-btn-text-icon',
+ 99 						text: _('Connection Manager'),
+100 						iconCls: 'x-deluge-connections',
+101 						handler: this.onConnectionManagerClick,
+102 						scope: this
+103 					},'->',{
+104 						id: 'help',
+105 						cls: 'x-btn-text-icon',
+106 						disabled: true,
+107 						icon: '/icons/help.png',
+108 						text: _('Help'),
+109 						handler: this.onHelpClick,
+110 						scope: this
+111 					},{
+112 						id: 'logout',
+113 						cls: 'x-btn-text-icon',
+114 						icon: '/icons/logout.png',
+115 						disabled: true,
+116 						text: _('Logout'),
+117 						handler: this.onLogout,
+118 						scope: this
+119 					}
+120 				]
+121 			}, config);
+122 			Ext.deluge.Toolbar.superclass.constructor.call(this, config);
+123 		},
+124 
+125 		connectedButtons: [
+126 			'add', 'remove', 'pause', 'resume', 'up', 'down'
+127 		],
+128 		
+129 		initComponent: function() {
+130 			Ext.deluge.Toolbar.superclass.initComponent.call(this);
+131 			Deluge.Events.on('connect', this.onConnect, this);
+132 			Deluge.Events.on('login', this.onLogin, this);
+133 		},
+134 		
+135 		onConnect: function() {
+136 			Ext.each(this.connectedButtons, function(buttonId) {
+137 				this.items.get(buttonId).enable();
+138 			}, this);
+139 		},
+140 		
+141 		onDisconnect: function() {
+142 			Ext.each(this.connectedButtons, function(buttonId) {
+143 				this.items.get(buttonId).disable();
+144 			}, this);
+145 		},
+146 		
+147 		onLogin: function() {
+148 			this.items.get('logout').enable();
+149 		},
+150 		
+151 		onLogout: function() {
+152 			this.items.get('logout').disable();
+153 			Deluge.Events.fire('logout');
+154 			Deluge.Login.show();
+155 		},
+156 		
+157 		onConnectionManagerClick: function() {
+158 			Deluge.ConnectionManager.show();
+159 		},
+160 		
+161 		onPreferencesClick: function() {
+162 			Deluge.Preferences.show();
+163 		},
+164 		
+165 		onTorrentAction: function(item) {
+166 			var selection = Deluge.Torrents.getSelections();
+167 			var ids = [];
+168 			Ext.each(selection, function(record) {
+169 				ids.push(record.id);
+170 			});
+171 			
+172 			switch (item.id) {
+173 				case 'remove':
+174 					Deluge.Events.fire('torrentRemoved', ids);
+175 					Deluge.Client.core.remove_torrent(ids, null, {
+176 						success: function() {
+177 							Deluge.UI.update();
+178 						}
+179 					});
+180 					break;
+181 				case 'pause':
+182 				case 'resume':
+183 					Deluge.Client.core[item.id + '_torrent'](ids, {
+184 						success: function() {
+185 							Deluge.UI.update();
+186 						}
+187 					});
+188 					break;
+189 				case 'up':
+190 				case 'down':
+191 					Deluge.Client.core['queue_' + item.id](ids, {
+192 						success: function() {
+193 							Deluge.UI.update();
+194 						}
+195 					});
+196 					break;
+197 			}
+198 		},
+199 		
+200 		onTorrentAdd: function() {
+201 			Deluge.Add.show();
+202 		}
+203 	});
+204 	
+205 	Deluge.Toolbar = new Ext.deluge.Toolbar();
+206 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.Torrents.js.html b/deluge/ui/web/docs/symbols/src/Deluge.Torrents.js.html new file mode 100644 index 000000000..0e7db73c1 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.Torrents.js.html @@ -0,0 +1,313 @@ +
  1 /*
+  2 Script: deluge-torrents.js
+  3     Contains all objects and functions related to the torrent grid.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 (function() {
+ 36 	/* Renderers for the Torrent Grid */
+ 37 	function queueRenderer(value) {
+ 38 		return (value == -1) ? '' : value + 1;
+ 39 	}
+ 40 	function torrentNameRenderer(value, p, r) {
+ 41 		return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value);
+ 42 	}
+ 43 	function torrentSpeedRenderer(value) {
+ 44 		if (!value) return;
+ 45 		return fspeed(value);
+ 46 	}
+ 47 	function torrentProgressRenderer(value, p, r) {
+ 48 		value = new Number(value);
+ 49 		var progress = value;
+ 50 		var text = r.data['state'] + ' ' + value.toFixed(2) + '%'
+ 51 		var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]) - 8;
+ 52 		return Deluge.progressBar(value, width, text);
+ 53 	}
+ 54 	function seedsRenderer(value, p, r) {
+ 55 		if (r.data['total_seeds'] > -1) {
+ 56 			return String.format('{0} ({1})', value, r.data['total_seeds']);
+ 57 		} else {
+ 58 			return value;
+ 59 		}
+ 60 	}
+ 61 	function peersRenderer(value, p, r) {
+ 62 		if (r.data['total_peers'] > -1) {
+ 63 			return String.format('{0} ({1})', value, r.data['total_peers']);
+ 64 		} else {
+ 65 			return value;
+ 66 		}
+ 67 	}
+ 68 	function availRenderer(value, p, r)	{
+ 69 		return new Number(value).toFixed(3);
+ 70 	}
+ 71 	function trackerRenderer(value, p, r) {
+ 72 		return String.format('<div style="background: url(/tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
+ 73 	}
+ 74 	
+ 75 	/**
+ 76 	* Ext.deluge.TorrentGrid Class
+ 77 	*
+ 78 	* @author Damien Churchill <damoxc@gmail.com>
+ 79 	* @version 1.2
+ 80 	*
+ 81 	* @class Ext.deluge.TorrentGrid
+ 82 	* @extends Ext.grid.GridPanel
+ 83 	* @constructor
+ 84 	* @param {Object} config Configuration options
+ 85 	*/
+ 86 	Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
+ 87 		constructor: function(config) {
+ 88 			config = Ext.apply({
+ 89 				id: 'torrentGrid',
+ 90 				store: new Ext.data.SimpleStore({
+ 91 					fields: [
+ 92 						{name: 'queue'},
+ 93 						{name: 'name'},
+ 94 						{name: 'size', type: 'int'},
+ 95 						{name: 'state'},
+ 96 						{name: 'progress', type: 'float'},
+ 97 						{name: 'seeds', type: 'int'},
+ 98 						{name: 'total_seeds', type: 'int'},
+ 99 						{name: 'peers', type: 'int'},
+100 						{name: 'total_peers', type: 'int'},
+101 						{name: 'downspeed', type: 'int'},
+102 						{name: 'upspeed', type: 'int'},
+103 						{name: 'eta', type: 'int'},
+104 						{name: 'ratio', type: 'float'},
+105 						{name: 'avail', type: 'float'},
+106 						{name: 'added', type: 'int'},
+107 						{name: 'tracker'}
+108 					],
+109 					id: 16
+110 				}),
+111 				columns: [{
+112 					id:'queue',
+113 					header: _('#'), 
+114 					width: 30, 
+115 					sortable: true, 
+116 					renderer: queueRenderer,
+117 					dataIndex: 'queue'
+118 				}, {
+119 					id:'name',
+120 					header: _('Name'),
+121 					width: 150,
+122 					sortable: true,
+123 					renderer: torrentNameRenderer,
+124 					dataIndex: 'name'
+125 				}, {
+126 					header: _('Size'),
+127 					width: 75,
+128 					sortable: true,
+129 					renderer: fsize,
+130 					dataIndex: 'size'
+131 				}, {
+132 					header: _('Progress'),
+133 					width: 150, 
+134 					sortable: true, 
+135 					renderer: torrentProgressRenderer,
+136 					dataIndex: 'progress'
+137 				}, {
+138 					header: _('Seeders'),
+139 					width: 60,
+140 					sortable: true,
+141 					renderer: seedsRenderer,
+142 					dataIndex: 'seeds'
+143 				}, {
+144 					header: _('Peers'),
+145 					width: 60,
+146 					sortable: true,
+147 					renderer: peersRenderer,
+148 					dataIndex: 'peers'
+149 				}, {
+150 					header: _('Down Speed'),
+151 					width: 80,
+152 					sortable: true,
+153 					renderer: torrentSpeedRenderer,
+154 					dataIndex: 'downspeed'
+155 				}, {
+156 					header: _('Up Speed'),
+157 					width: 80,
+158 					sortable: true,
+159 					renderer: torrentSpeedRenderer,
+160 					dataIndex: 'upspeed'
+161 				}, {
+162 					header: _('ETA'),
+163 					width: 60,
+164 					sortable: true,
+165 					renderer: ftime,
+166 					dataIndex: 'eta'
+167 				}, {
+168 					header: _('Ratio'),
+169 					width: 60,
+170 					sortable: true,
+171 					renderer: availRenderer,
+172 					dataIndex: 'ratio'
+173 				}, {
+174 					header: _('Avail'),
+175 					width: 60,
+176 					sortable: true,
+177 					renderer: availRenderer,
+178 					dataIndex: 'avail'
+179 				}, {
+180 					header: _('Added'),
+181 					width: 80,
+182 					sortable: true,
+183 					renderer: fdate,
+184 					dataIndex: 'added'
+185 				}, {
+186 					header: _('Tracker'),
+187 					width: 120,
+188 					sortable: true,
+189 					renderer: trackerRenderer,
+190 					dataIndex: 'tracker'
+191 				}],
+192 				region: 'center',
+193 				cls: 'deluge-torrents',
+194 				stripeRows: true,
+195 				autoExpandColumn: 'name',
+196 				deferredRender:false,
+197 				autoScroll:true,
+198 				margins: '5 5 0 0'
+199 			}, config);
+200 			Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
+201 		},
+202 
+203 		initComponent: function() {
+204 			Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
+205 			Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
+206 			this.on('rowcontextmenu', function(grid, rowIndex, e) {
+207 				e.stopEvent();
+208 				var selection = grid.getSelectionModel();
+209 				if (!selection.hasSelection()) {
+210 					selection.selectRow(rowIndex);
+211 				}
+212 				Deluge.Menus.Torrent.showAt(e.getPoint());
+213 			});
+214 		},
+215 		
+216 		/**
+217 		 * Returns the record representing the torrent at the specified index.
+218 		 *
+219 		 * @param {int} The row index of the torrent you wish to retrieve.
+220 		 * @return {Ext.data.Record} The record representing the torrent.
+221 		 */
+222 		getTorrent: function(rowIndex) {
+223 			return this.getStore().getAt(rowIndex);
+224 		},
+225 		
+226 		getSelected: function() {
+227 		return this.getSelectionModel().getSelected();
+228 		},
+229 		
+230 		getSelections: function() {
+231 			return this.getSelectionModel().getSelections();
+232 		},
+233 		
+234 		update: function(torrents) {
+235 			//var torrents = [];
+236 			var store = this.getStore();
+237 			for (var torrentId in torrents) {
+238 				var record = store.getById(torrentId);
+239 				var torrent = torrents[torrentId];
+240 				if (!record) {
+241 					// We need to create a new record
+242 					var data = [
+243 						torrent.queue,
+244 						torrent.name,
+245 						torrent.total_size,
+246 						torrent.state,
+247 						torrent.progress,
+248 						torrent.num_seeds,
+249 						torrent.total_seeds,
+250 						torrent.num_peers,
+251 						torrent.total_peers,
+252 						torrent.download_payload_rate,
+253 						torrent.upload_payload_rate,
+254 						torrent.eta,
+255 						torrent.ratio,
+256 						torrent.distributed_copies,
+257 						torrent.time_added,
+258 						torrent.tracker_host,
+259 						torrentId
+260 					];
+261 					store.loadData([data], true);
+262 				} else {
+263 					// We just need to do an update
+264 					record.set('queue', torrent.queue);
+265 					record.set('name', torrent.name);
+266 					record.set('size', torrent.total_size);
+267 					record.set('state', torrent.state);
+268 					record.set('progress', torrent.progress);
+269 					record.set('seeds', torrent.num_seeds);
+270 					record.set('total_seeds', torrent.total_seeds);
+271 					record.set('peers', torrent.num_peers);
+272 					record.set('total_peers', torrent.total_peers);
+273 					record.set('downspeed', torrent.download_payload_rate);
+274 					record.set('upspeed', torrent.upload_payload_rate);
+275 					record.set('eta', torrent.eta);
+276 					record.set('ratio', torrent.ratio);
+277 					record.set('avail', torrent.distributed_copies);
+278 					record.set('added', torrent.time_added);
+279 					record.set('tracker', torrent.tracker_host);
+280 					record.commit();
+281 				}
+282 			}
+283 			
+284 			var torrentIds = Ext.keys(torrents);
+285 			store.each(function(record) {
+286 				if (torrentIds.indexOf(record.id) == -1) {
+287 					// Torrent is no longer in the grid so we must remove it.
+288 					store.remove(record);
+289 				}
+290 			}, this);
+291 		},
+292 		
+293 		// private
+294 		onTorrentRemoved: function(torrentIds) {
+295 			var selModel = this.getSelectionModel();
+296 			Ext.each(torrentIds, function(torrentId) {
+297 				var record = this.getStore().getById(torrentId);
+298 				if (selModel.isSelected(record)) {
+299 					selModel.deselectRow(this.getStore().indexOf(record));
+300 				}
+301 				this.getStore().remove(record);
+302 			}, this);
+303 		}
+304 	});
+305 	Deluge.Torrents = new Ext.deluge.TorrentGrid();
+306 })();
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.UI.js.html b/deluge/ui/web/docs/symbols/src/Deluge.UI.js.html new file mode 100644 index 000000000..05a7c6205 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.UI.js.html @@ -0,0 +1,158 @@ +
  1 /*
+  2 Script: deluge-ui.js
+  3     The core ui module that builds up the ui layout and controls the polling
+  4 	of the server.
+  5 
+  6 Copyright:
+  7 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  8 	This program is free software; you can redistribute it and/or modify
+  9 	it under the terms of the GNU General Public License as published by
+ 10 	the Free Software Foundation; either version 3, or (at your option)
+ 11 	any later version.
+ 12 
+ 13 	This program is distributed in the hope that it will be useful,
+ 14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 16 	GNU General Public License for more details.
+ 17 
+ 18 	You should have received a copy of the GNU General Public License
+ 19 	along with this program.  If not, write to:
+ 20 		The Free Software Foundation, Inc.,
+ 21 		51 Franklin Street, Fifth Floor
+ 22 		Boston, MA  02110-1301, USA.
+ 23 #
+ 24 #    In addition, as a special exception, the copyright holders give
+ 25 #    permission to link the code of portions of this program with the OpenSSL
+ 26 #    library.
+ 27 #    You must obey the GNU General Public License in all respects for all of
+ 28 #    the code used other than OpenSSL. If you modify file(s) with this
+ 29 #    exception, you may extend this exception to your version of the file(s),
+ 30 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 31 #    this exception statement from your version. If you delete this exception
+ 32 #    statement from all source files in the program, then also delete it here.
+ 33 #
+ 34 */
+ 35 
+ 36 Deluge.UI = {
+ 37 
+ 38 	cookies: new Ext.state.CookieProvider(),
+ 39 	
+ 40 	errorCount: 0,
+ 41 	
+ 42 	initialize: function() {
+ 43 		Ext.state.Manager.setProvider(this.cookies);		
+ 44 		this.MainPanel = new Ext.Panel({
+ 45 			id: 'mainPanel',
+ 46 			iconCls: 'x-deluge-main-panel',
+ 47 			title: 'Deluge',
+ 48 			layout: 'border',
+ 49 			tbar: Deluge.Toolbar,
+ 50 			items: [
+ 51 				Deluge.Sidebar,
+ 52 				Deluge.Details,
+ 53 				Deluge.Torrents
+ 54 			],
+ 55 			bbar: Deluge.Statusbar
+ 56 		});
+ 57 
+ 58 		this.Viewport = new Ext.Viewport({
+ 59 			layout: 'fit',
+ 60 			items: [this.MainPanel]
+ 61 		});
+ 62 		
+ 63 		Deluge.Events.on("connect", this.onConnect, this);
+ 64 		Deluge.Events.on("disconnect", this.onDisconnect, this);
+ 65 		Deluge.Client = new Ext.ux.util.RpcClient({
+ 66 			url: '/json'
+ 67 		});
+ 68 		Deluge.Client.on('connected', function(e) {
+ 69 			Deluge.Login.show();
+ 70 		});
+ 71 		this.update = this.update.bind(this);
+ 72 	},
+ 73 	
+ 74 	update: function() {
+ 75 		var filters = Deluge.Sidebar.getFilters();
+ 76 		Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, {
+ 77 			success: this.onUpdate,
+ 78 			failure: this.onUpdateError,
+ 79 			scope: this
+ 80 		});
+ 81 		Deluge.Details.update();
+ 82 		Deluge.Client.web.connected({
+ 83 			success: this.onConnectedCheck,
+ 84 			scope: this
+ 85 		});
+ 86 	},
+ 87 	
+ 88 	onConnectedCheck: function(connected) {
+ 89 		if (!connected) {
+ 90 			Deluge.Events.fire('disconnect');
+ 91 		}
+ 92 	},
+ 93 	
+ 94 	onUpdateError: function(error) {
+ 95 		if (this.errorCount == 2) {
+ 96 			Ext.MessageBox.show({
+ 97 				title: 'Lost Connection',
+ 98 				msg: 'The connection to the webserver has been lost!',
+ 99 				buttons: Ext.MessageBox.OK,
+100 				icon: Ext.MessageBox.ERROR
+101 			});
+102 		}
+103 		this.errorCount++;
+104 	},
+105 	
+106 	onUpdate: function(data) {
+107 		Deluge.Torrents.update(data['torrents']);
+108 		Deluge.Statusbar.update(data['stats']);
+109 		Deluge.Sidebar.update(data['filters']);
+110 		this.errorCount = 0;
+111 	},
+112 	
+113 	/*
+114     Property: run
+115         Start the Deluge UI polling the server to get the updated torrent
+116         information.
+117 
+118     Example:
+119         Deluge.UI.onConnect();
+120     */
+121 	onConnect: function() {
+122 		if (!this.running) {
+123 			this.running = setInterval(this.update, 2000);
+124 			this.update();
+125 		}
+126 	},
+127 	
+128 	onDisconnect: function() {
+129 		this.stop();
+130 	},
+131 	
+132 	/*
+133     Property: stop
+134         Stop the Deluge UI polling the server to get the updated torrent
+135         information.
+136 
+137     Example:
+138         Deluge.UI.stop();
+139     */
+140 	stop: function() {
+141 		if (this.running) {
+142             clearInterval(this.running);
+143             this.running = false;
+144 			Deluge.Torrents.getStore().loadData([]);
+145         }
+146 	}
+147 }
+148 
+149 Ext.onReady(function(e) {
+150 	Deluge.UI.initialize();
+151 });
\ No newline at end of file diff --git a/deluge/ui/web/docs/symbols/src/Deluge.js.html b/deluge/ui/web/docs/symbols/src/Deluge.js.html new file mode 100644 index 000000000..e62dae885 --- /dev/null +++ b/deluge/ui/web/docs/symbols/src/Deluge.js.html @@ -0,0 +1,116 @@ +
  1 /*
+  2 Script: Deluge.js
+  3     Contains the keys for get_torrent(s)_status.
+  4 
+  5 Copyright:
+  6 	(C) Damien Churchill 2009 <damoxc@gmail.com>
+  7 	This program is free software; you can redistribute it and/or modify
+  8 	it under the terms of the GNU General Public License as published by
+  9 	the Free Software Foundation; either version 3, or (at your option)
+ 10 	any later version.
+ 11 
+ 12 	This program is distributed in the hope that it will be useful,
+ 13 	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 14 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ 15 	GNU General Public License for more details.
+ 16 
+ 17 	You should have received a copy of the GNU General Public License
+ 18 	along with this program.  If not, write to:
+ 19 		The Free Software Foundation, Inc.,
+ 20 		51 Franklin Street, Fifth Floor
+ 21 		Boston, MA  02110-1301, USA.
+ 22 #
+ 23 #    In addition, as a special exception, the copyright holders give
+ 24 #    permission to link the code of portions of this program with the OpenSSL
+ 25 #    library.
+ 26 #    You must obey the GNU General Public License in all respects for all of
+ 27 #    the code used other than OpenSSL. If you modify file(s) with this
+ 28 #    exception, you may extend this exception to your version of the file(s),
+ 29 #    but you are not obligated to do so. If you do not wish to do so, delete
+ 30 #    this exception statement from your version. If you delete this exception
+ 31 #    statement from all source files in the program, then also delete it here.
+ 32 #
+ 33 */
+ 34 
+ 35 Ext.namespace('Ext.deluge');
+ 36 
+ 37 (function() {
+ 38 	/* Add some helper functions to Ext */
+ 39 	Ext.apply(Function.prototype, {
+ 40 		bind: function(scope) {
+ 41 			var self = this;
+ 42 			return function() {
+ 43 				return self.apply(scope, arguments);
+ 44 			}
+ 45 		}
+ 46 	});
+ 47 	
+ 48 	Ext.apply(Ext, {
+ 49 		keys: function(obj) {
+ 50 			var keys = [];
+ 51 			for (i in obj) if (obj.hasOwnProperty(i))
+ 52 			{
+ 53 				keys.push(i);
+ 54 			}
+ 55 			return keys;
+ 56 		},
+ 57 			
+ 58 		splat: function(obj) {
+ 59 			var type = Ext.type(obj);
+ 60 			return (type) ? ((type != 'array') ? [obj] : obj) : [];
+ 61 		}
+ 62 	});
+ 63 	Ext.getKeys = Ext.keys;
+ 64 })();
+ 65 
+ 66 (function() {
+ 67 	var tpl = '<div class="x-progress-wrap x-progress-renderered">' +
+ 68 		'<div class="x-progress-inner">' +
+ 69 			'<div style="width: {2}px" class="x-progress-bar">' +
+ 70 				'<div style="z-index: 99; width: {3}px" class="x-progress-text">' +
+ 71 					'<div style="width: {1}px;">{0}</div>' +
+ 72 				'</div>' +
+ 73 			'</div>' +
+ 74 			'<div class="x-progress-text x-progress-text-back">' +
+ 75 				'<div style="width: {1}px;">{0}</div>' +
+ 76 			'</div>' +
+ 77 		'</div>' +
+ 78 	'</div>';
+ 79 	
+ 80 	Deluge.progressBar =  function(progress, width, text) {
+ 81 		var progressWidth = ((width / 100.0) * progress).toFixed(0);
+ 82 		var barWidth = progressWidth - 1;
+ 83 		var textWidth = ((progressWidth - 10) > 0 ? progressWidth - 10 : 0);
+ 84 		return String.format(tpl, text, width, barWidth, textWidth);
+ 85 	}
+ 86 })();
+ 87 
+ 88 // Hinting for gettext_gen.py
+ 89 // _('Do Not Download')
+ 90 // _('Normal Priority')
+ 91 // _('High Priority')
+ 92 // _('Highest Priority')
+ 93 FILE_PRIORITY = {
+ 94     0: 'Do Not Download',
+ 95     1: 'Normal Priority',
+ 96     2: 'High Priority',
+ 97     5: 'Highest Priority',
+ 98     'Do Not Download': 0,
+ 99     'Normal Priority': 1,
+100     'High Priority': 2,
+101     'Highest Priority': 5
+102 }
+103 
+104 FILE_PRIORITY_CSS = {
+105 	0: 'x-no-download',
+106 	1: 'x-normal-download',
+107 	2: 'x-high-download',
+108 	5: 'x-highest-download'
+109 }
\ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Details.Options.js b/deluge/ui/web/js/Deluge.Details.Options.js index 8720592f3..be7d85db9 100644 --- a/deluge/ui/web/js/Deluge.Details.Options.js +++ b/deluge/ui/web/js/Deluge.Details.Options.js @@ -19,17 +19,16 @@ Copyright: 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. -# + + 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.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { @@ -201,6 +200,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { fieldLabel: '', labelSeparator: '', id: 'remove_at_ratio', + style: 'margin-left: 10px', boxLabel: _('Remove at ratio') }); @@ -255,7 +255,9 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { // The buttons below are required to be added to a panel // first as simply adding them to the column layout throws an - // error c.getSize() does not exist + // error c.getSize() does not exist. This could be intentional + // or it may possible be a bug in ext-js. Take care when upgrading + // to ext-js 3.0. /* * Edit Trackers button @@ -289,10 +291,14 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { border: false, width: 100, }); + + this.disable(); }, onRender: function(ct, position) { Ext.deluge.details.OptionsTab.superclass.onRender.call(this, ct, position); + + // This is another hack I think, so keep an eye out here when upgrading. this.layout = new Ext.layout.ColumnLayout(); this.layout.setContainer(this); this.doLayout(); @@ -317,10 +323,10 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { }, update: function(torrentId) { + this.torrentId = torrentId; Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, { success: this.onRequestComplete, - scope: this, - torrentId: torrentId + scope: this }); }, @@ -329,7 +335,13 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { }, onRequestComplete: function(torrent, options) { - + for (var key in torrent) { + if (this.fields[key]) { + this.fields[key].setValue(torrent[key]) + } else { + //alert(key); + } + } } }); Deluge.Details.add(new Ext.deluge.details.OptionsTab()); diff --git a/deluge/ui/web/js/Deluge.Events.js b/deluge/ui/web/js/Deluge.Events.js index bc6fa7d59..8eef3b2cb 100644 --- a/deluge/ui/web/js/Deluge.Events.js +++ b/deluge/ui/web/js/Deluge.Events.js @@ -1,41 +1,45 @@ +/* +Script: Deluge.Events.js + Class for holding global events that occur within the UI. + +Copyright: + (C) Damien Churchill 2009 + 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. +*/ + /** - * - * @script Deluge.Events.js - * - * (C) Damien Churchill 2009 - * 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. -# - * + * @namespace Deluge.Events * @class Deluge.Events - *

Class for holding global events that occur within the UI.

- * @singleton + * @name Deluge.Events + * @description Class for holding global events that occur within the UI. */ (function() { + Events = Ext.extend(Ext.util.Observable, { constructor: function() { Events.superclass.constructor.call(this); @@ -49,4 +53,4 @@ Events.prototype.on = Events.prototype.addListener Events.prototype.fire = Events.prototype.fireEvent Deluge.Events = new Events(); -})(); \ No newline at end of file +})(); diff --git a/deluge/ui/web/js/Deluge.Formatters.js b/deluge/ui/web/js/Deluge.Formatters.js index 533a65f83..0c5f7d2e6 100644 --- a/deluge/ui/web/js/Deluge.Formatters.js +++ b/deluge/ui/web/js/Deluge.Formatters.js @@ -1,6 +1,6 @@ /* -Script: Deluge.Formatters.js - A collection of functions for string formatting values. +Script: + Deluge.Formatters.ks Copyright: (C) Damien Churchill 2009 @@ -19,20 +19,31 @@ Copyright: 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. -# + + 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. */ +/** + * @description A collection of functions for string formatting values. + * @namespace Deluge.Formatters + */ Deluge.Formatters = { + /** + * Formats a date string in the locale's date representation based on the + * systems timezone. + * + * @param {number} timestamp time in seconds since the Epoch + * @returns {string} a string in the locale's date representation or "" + * if seconds < 0 + */ date: function(timestamp) { function zeroPad(num, count) { var numZeropad = num + ''; @@ -45,6 +56,13 @@ Deluge.Formatters = { var date = new Date(timestamp); return String.format('{0}/{1}/{2}', zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear()); }, + + /** + * Formats the bytes value into a string with KiB, MiB or GiB units. + * + * @param {number} bytes the filesize in bytes + * @returns {string} formatted string with KiB, MiB or GiB units. + */ size: function(bytes) { bytes = bytes / 1024.0; @@ -57,10 +75,22 @@ Deluge.Formatters = { return bytes.toFixed(1) + ' GiB' }, + /** + * Formats a string to display a transfer speed utilizing {@link Deluge.Formatters.size} + * + * @param {number} bytes the filesize in bytes + * @returns {string} formatted string with KiB, MiB or GiB units. + */ speed: function(bits) { return fsize(bits) + '/s' }, + /** + * Formats a string to show time in a human readable form. + * + * @param {number} time the number of seconds + * @returns {string} a formatted time string. will return '' if seconds == 0 + */ timeRemaining: function(time) { if (time == 0) { return '∞' } if (time < 60) { return time + 's'; } @@ -96,6 +126,12 @@ Deluge.Formatters = { } }, + /** + * Simply returns the value untouched, for when no formatting is required. + * + * @param value, the value to be displayed + * @returns the untouched value. + */ plain: function(value) { return value; } @@ -104,4 +140,4 @@ var fsize = Deluge.Formatters.size; var fspeed = Deluge.Formatters.speed; var ftime = Deluge.Formatters.timeRemaining; var fdate = Deluge.Formatters.date; -var fplain = Deluge.Formatters.plain; \ No newline at end of file +var fplain = Deluge.Formatters.plain; diff --git a/deluge/ui/web/js/Deluge.Keys.js b/deluge/ui/web/js/Deluge.Keys.js index 89de03444..c91ec48ca 100644 --- a/deluge/ui/web/js/Deluge.Keys.js +++ b/deluge/ui/web/js/Deluge.Keys.js @@ -1,26 +1,98 @@ +/* +Script: Deluge.Keys.js + The torrent status keys that are commonly used around the UI. + +Copyright: + (C) Damien Churchill 2009 + 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. +*/ + +/** + * @description The torrent status keys that are commonly used around the UI. + * @namespace Deluge.Keys + */ Deluge.Keys = { + /** + * @static + */ Grid: [ 'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds', 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate', 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', 'is_auto_managed', 'time_added', 'tracker_host' ], + + /** + * @description Keys used in the status tab of the statistics panel. + * These get extended + * by {@link Deluge.Keys.Grid}. + * @static + */ Status: [ 'total_done', 'total_payload_download', 'total_uploaded', 'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces', 'piece_length', 'is_auto_managed', 'active_time', 'seeding_time', 'seed_rank' ], + + /** + * @static + * @description Keys used in the files tab of the statistics panel. + *
['files', 'file_progress', 'file_priorities']
+ */ Files: [ 'files', 'file_progress', 'file_priorities' ], + + /** + * @description Keys used in the peers tab of the statistics panel. + *
['peers', 'seed']
+ * @static + */ Peers: [ 'peers', 'seeds' ], + + /** + * @description Keys used in the details tab of the statistics panel. + * @static + */ Details: [ 'name', 'save_path', 'total_size', 'num_files', 'tracker_status', 'tracker', 'comment' ], + + /** + * @static + * @description Keys used in the options tab of the statistics panel. + *
['max_download_speed', 'max_upload_speed', 'max_connections', 'max_upload_slots',
+	 *  'is_auto_managed', 'stop_at_ratio', 'stop_ratio', 'remove_at_ratio', 'private',
+	 *  'prioritize_first_last']
+ */ Options: [ 'max_download_speed', 'max_upload_speed', 'max_connections', 'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio', @@ -28,6 +100,8 @@ Deluge.Keys = { ] }; +// Merge the grid and status keys together as the status keys contain all the +// grid ones. Ext.each(Deluge.Keys.Grid, function(key) { Deluge.Keys.Status.push(key); -}); \ No newline at end of file +}); diff --git a/deluge/ui/web/js/deluge-yc.js b/deluge/ui/web/js/deluge-yc.js index 879ba1f2b..af5b284a3 100644 --- a/deluge/ui/web/js/deluge-yc.js +++ b/deluge/ui/web/js/deluge-yc.js @@ -1 +1 @@ -Ext.namespace("Ext.deluge");(function(){Ext.apply(Function.prototype,{bind:function(b){var a=this;return function(){return a.apply(b,arguments)}}});Ext.apply(Ext,{keys:function(b){var a=[];for(i in b){if(b.hasOwnProperty(i)){a.push(i)}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys})();(function(){var a='
{0}
{0}
';Deluge.progressBar=function(c,e,g){var b=((e/100)*c).toFixed(0);var d=b-1;var f=((b-10)>0?b-10:0);return String.format(a,g,e,d,f)}})();FILE_PRIORITY={0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority","Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};Deluge.Formatters={date:function(c){function b(d,e){var f=d+"";while(f.length0){return b+"m "+d+"s"}else{return b+"m"}}else{c=c/60}if(c<24){var a=Math.floor(c);var b=Math.round(60*(c-a));if(b>0){return a+"h "+b+"m"}else{return a+"h"}}else{c=c/24}var e=Math.floor(c);var a=Math.round(24*(c-e));if(a>0){return e+"d "+a+"h"}else{return e+"d"}},plain:function(a){return a}};var fsize=Deluge.Formatters.size;var fspeed=Deluge.Formatters.speed;var ftime=Deluge.Formatters.timeRemaining;var fdate=Deluge.Formatters.date;var fplain=Deluge.Formatters.plain;Deluge.Menus={onTorrentAction:function(c,d){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(e){a.push(e.id)});switch(c.id){case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"top":case"up":case"down":case"bottom":Deluge.Client.core["queue_"+c.id](a,{success:function(){Deluge.UI.update()}});break;case"edit_trackers":Deluge.EditTrackers.show();break;case"update":Deluge.Client.core.force_reannounce(a,{success:function(){Deluge.UI.update()}});break;case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{success:function(){Deluge.UI.update()}});break;case"recheck":Deluge.Client.core.force_recheck(a,{success:function(){Deluge.UI.update()}});break}}};Deluge.Menus.Torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{id:"pause",text:_("Pause"),icon:"/icons/pause.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"resume",text:_("Resume"),icon:"/icons/start.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"options",text:_("Options"),icon:"/icons/preferences.png",menu:new Ext.menu.Menu({items:[{text:_("D/L Speed Limit"),iconCls:"x-deluge-downloading",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("U/L Speed Limit"),iconCls:"x-deluge-seeding",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("Connection Limit"),iconCls:"x-deluge-connections",menu:new Ext.menu.Menu({items:[{text:_("50")},{text:_("100")},{text:_("200")},{text:_("300")},{text:_("500")},{text:_("Unlimited")}]})},{text:_("Upload Slot Limit"),icon:"/icons/upload_slots.png",menu:new Ext.menu.Menu({items:[{text:_("0")},{text:_("1")},{text:_("2")},{text:_("3")},{text:_("5")},{text:_("Unlimited")}]})},{id:"auto_managed",text:_("Auto Managed"),checked:false}]})},"-",{text:_("Queue"),icon:"/icons/queue.png",menu:new Ext.menu.Menu({items:[{id:"top",text:_("Top"),icon:"/icons/top.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"up",text:_("Up"),icon:"/icons/up.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"down",text:_("Down"),icon:"/icons/down.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"bottom",text:_("Bottom"),icon:"/icons/bottom.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]})},"-",{id:"update",text:_("Update Tracker"),icon:"/icons/update.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"edit_trackers",text:_("Edit Trackers"),icon:"/icons/edit_trackers.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"remove",text:_("Remove Torrent"),icon:"/icons/remove.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"recheck",text:_("Force Recheck"),icon:"/icons/recheck.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"move",text:_("Move Storage"),icon:"/icons/move.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]});Deluge.Menus.Connections=new Ext.menu.Menu({id:"connectionsMenu",items:[{id:"50",text:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"100",text:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"200",text:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"500",text:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Download=new Ext.menu.Menu({id:"downspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Upload=new Ext.menu.Menu({id:"upspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.FilePriorities=new Ext.menu.Menu({id:"filePrioritiesMenu",items:[{id:"expandAll",text:_("Expand All"),icon:"/icons/expand_all.png"},"-",{id:"no_download",text:_("Do Not Download"),icon:"/icons/no_download.png",filePriority:0},{id:"normal",text:_("Normal Priority"),icon:"/icons/normal.png",filePriority:1},{id:"high",text:_("High Priority"),icon:"/icons/high.png",filePriority:2},{id:"highest",text:_("Highest Priority"),icon:"/icons/highest.png",filePriority:5}]});function onLimitChanged(b,a){if(b.id=="other"){}else{config={};config[b.group]=b.id;Deluge.Client.core.set_config(config,{success:function(){Deluge.UI.update()}})}}(function(){Events=Ext.extend(Ext.util.Observable,{constructor:function(){Events.superclass.constructor.call(this)},addListener:function(a,c,b,d){this.addEvents(a);Events.superclass.addListener.call(this,a,c,b,d)}});Events.prototype.on=Events.prototype.addListener;Events.prototype.fire=Events.prototype.fireEvent;Deluge.Events=new Events()})();Ext.namespace("Ext.deluge.add");Ext.deluge.add.OptionsPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",margins:"5 5 5 5",activeTab:0,height:220},a);Ext.deluge.add.OptionsPanel.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);this.files=this.add(new Ext.tree.ColumnTree({layout:"fit",title:_("Files"),rootVisible:false,autoScroll:true,height:170,border:false,animate:false,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{header:_("Size"),width:80,dataIndex:"size"}],root:new Ext.tree.AsyncTreeNode({text:"Files"})}));new Ext.tree.TreeSorter(this.files,{folderSort:true});this.form=this.add({xtype:"form",labelWidth:1,frame:false,title:_("Options"),bodyStyle:"padding: 5px;",border:false,items:[{xtype:"fieldset",title:_("Download Location"),border:false,defaultType:"textfield",labelWidth:1,items:[{fieldLabel:"",labelSeperator:"",name:"download_location",width:330}]}]})},clear:function(){this.clearFiles()},clearFiles:function(){var a=this.files.getRootNode();if(!a.hasChildNodes()){return}a.cascade(function(b){if(!b.parentNode||!b.getOwnerTree()){return}b.remove()})},getDefaults:function(){var a=["add_paused","compact_allocation","download_location","max_connections_per_torrent","max_download_speed_per_torrent","max_upload_slots_per_torrent","max_upload_speed_per_torrent","prioritize_first_last_pieces"];Deluge.Client.core.get_config_values(a,{success:function(b){this.defaults=b;for(var c in b){var d=this.form.findField(c);if(!d){return}d.setValue(b[c])}var d=this.form.findField("compact_allocation");if(b.compact_allocation){d.items.get("compact_allocation_true").setValue(true);d.items.get("compact_allocation_false").setValue(false)}else{d.items.get("compact_allocation_false").setValue(true);d.items.get("compact_allocation_true").setValue(false)}},scope:this})}});Ext.deluge.add.Window=Ext.extend(Ext.Window,{initComponent:function(){Ext.deluge.add.Window.superclass.initComponent.call(this);this.addEvents("beforeadd","add")},createTorrentId:function(){return new Date().getTime()}});Ext.deluge.add.AddWindow=Ext.extend(Ext.deluge.add.Window,{torrents:{},constructor:function(a){a=Ext.apply({title:_("Add Torrents"),layout:"border",width:470,height:450,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-add-window-icon"},a);Ext.deluge.add.AddWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.AddWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Add"),this.onAdd,this);function a(c,d,b){if(b.data.info_hash){return String.format('
{0}
',c)}else{return String.format('
{0}
',c)}}this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"info_hash",mapping:1},{name:"text",mapping:2}],id:0}),columns:[{id:"torrent",width:150,sortable:true,renderer:a,dataIndex:"text"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"torrent",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{id:"file",cls:"x-btn-text-icon",iconCls:"x-deluge-add-file",text:_("File"),handler:this.onFile,scope:this},{id:"url",cls:"x-btn-text-icon",text:_("Url"),icon:"/icons/add_url.png",handler:this.onUrl,scope:this},{id:"infohash",cls:"x-btn-text-icon",text:_("Infohash"),icon:"/icons/add_magnet.png",disabled:true},"->",{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this}]})});this.options=this.add(new Ext.deluge.add.OptionsPanel());this.on("show",this.onShow,this)},clear:function(){this.torrents={};this.grid.getStore().removeAll();this.options.clear()},onAdd:function(){torrents=[];for(var b in this.torrents){var a=this.torrents[b];torrents.push({path:a.filename,options:{}})}Deluge.Client.web.add_torrents(torrents,{success:function(c){}});this.clear();this.hide()},onCancel:function(){this.clear();this.hide()},onFile:function(){this.file.show()},onRemove:function(){var a=this.grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();delete this.torrents[b.id];this.grid.getStore().remove(b);this.options.clear()},onSelect:function(e,f,c){var d=this.torrents[c.get("info_hash")];function b(k,h){for(var g in k){var j=k[g];if(Ext.type(j)=="object"){var l=new Ext.tree.TreeNode({text:g});b(j,l);h.appendChild(l)}else{h.appendChild(new Ext.tree.TreeNode({filename:g,text:g,size:fsize(j[0]),leaf:true,checked:j[1],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI}))}}}this.options.clearFiles();var a=this.options.files.getRootNode();b(d.files_tree,a);a.firstChild.expand()},onShow:function(){if(!this.url){this.url=new Ext.deluge.add.UrlWindow();this.url.on("beforeadd",this.onTorrentBeforeAdd,this);this.url.on("add",this.onTorrentAdd,this)}if(!this.file){this.file=new Ext.deluge.add.FileWindow();this.file.on("beforeadd",this.onTorrentBeforeAdd,this);this.file.on("add",this.onTorrentAdd,this)}},onTorrentBeforeAdd:function(b,c){var a=this.grid.getStore();a.loadData([[b,null,c]],true)},onTorrentAdd:function(a,c){if(!c){Ext.MessageBox.show({title:_("Error"),msg:_("Not a valid torrent"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var b=this.grid.getStore().getById(a);b.set("info_hash",c.info_hash);b.set("text",c.name);this.grid.getStore().commitChanges();this.torrents[c.info_hash]=c},onUrl:function(a,b){this.url.show()}});Deluge.Add=new Ext.deluge.add.AddWindow();Ext.deluge.add.FileWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from File"),iconCls:"x-deluge-add-file",buttons:[{text:_("Add"),handler:this.onAdd,scope:this}]},a);Ext.deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);this.form=this.add(new Ext.form.FormPanel({baseCls:"x-plain",labelWidth:55,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"torrentFile",emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]}))},onAdd:function(c,b){if(this.form.getForm().isValid()){this.torrentId=this.createTorrentId();this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),success:this.onUploadSuccess,scope:this});var a=this.form.getForm().findField("torrentFile").value;this.fireEvent("beforeadd",this.torrentId,a)}},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",this.torrentId,d)},onUploadSuccess:function(c,b){this.hide();var a=b.result.toString();this.form.getForm().findField("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a})}});Ext.deluge.add.UrlWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon",buttons:[{text:_("Add"),handler:this.onAdd,scope:this}]},a);Ext.deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);this.form=this.add(new Ext.form.FormPanel({defaultType:"textfield",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Url"),id:"url",name:"url",inputType:"url",anchor:"100%",listeners:{specialkey:{fn:this.onAdd,scope:this}}}]}))},onAdd:function(d,c){if(d.id=="url"&&c.getKey()!=c.ENTER){return}var d=this.form.items.get("url");var b=d.getValue();var a=this.createTorrentId();Deluge.Client.web.download_torrent_from_url(b,{success:this.onDownload,scope:this,torrentId:a});this.hide();this.fireEvent("beforeadd",a,b)},onDownload:function(a,c,d,b){this.form.items.get("url").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a,torrentId:b.options.torrentId})},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",b.options.torrentId,d)}});Ext.namespace("Ext.ux.util");(function(){Ext.ux.util.RpcClient=Ext.extend(Ext.util.Observable,{_components:[],_methods:[],_requests:{},_url:null,_optionKeys:["scope","success","failure"],constructor:function(a){Ext.ux.util.RpcClient.superclass.constructor.call(this,a);this._url=a.url||null;this._id=0;this.addEvents("connected");this.reloadMethods()},reloadMethods:function(){Ext.each(this._components,function(a){delete this[a]},this);this._execute("system.listMethods",{success:this._setMethods,scope:this})},_execute:function(c,a){a=a||{};a.params=a.params||[];a.id=this._id;var b=Ext.encode({method:c,params:a.params,id:a.id});this._id++;return Ext.Ajax.request({url:this._url,method:"POST",success:this._onSuccess,failure:this._onFailure,scope:this,jsonData:b,options:a})},_onFailure:function(b,a){var c=a.options;errorObj={id:c.id,result:null,error:"HTTP"+b.status};if(Ext.type(c.failure)!="function"){return}if(c.scope){c.failure.call(c.scope,responseObj.error,responseObj,b)}else{c.failure(responseObj.error,responseObj,b)}},_onSuccess:function(c,a){var b=Ext.decode(c.responseText);var d=a.options;if(b.error){if(Ext.type(d.failure)!="function"){return}if(d.scope){d.failure.call(d.scope,b.error,b,c,a)}else{d.failure(b.error,b,c,a)}}else{if(Ext.type(d.success)!="function"){return}if(d.scope){d.success.call(d.scope,b.result,b,c,a)}else{d.success(b.result,b,c,a)}}},_parseArgs:function(c){var e=[];Ext.each(c,function(f){e.push(f)});var b=e[e.length-1];if(Ext.type(b)=="object"){var d=Ext.keys(b),a=false;Ext.each(this._optionKeys,function(f){if(d.indexOf(f)>-1){a=true}});if(a){e.remove(b)}else{b={}}}else{b={}}b.params=e;return b},_setMethods:function(b){var d={},a=this;Ext.each(b,function(h){var g=h.split(".");var e=d[g[0]]||{};var f=function(){var j=a._parseArgs(arguments);return a._execute(h,j)};e[g[1]]=f;d[g[0]]=e});for(var c in d){a[c]=d[c]}this._components=Ext.keys(d);this.fireEvent("connected",this)}})})();(function(){var a=function(c,d,b){return c+":"+b.data.port};Ext.deluge.ConnectionManager=Ext.extend(Ext.Window,{layout:"fit",width:300,height:220,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Connection Manager"),iconCls:"x-deluge-connect-window-icon",initComponent:function(){Ext.deluge.ConnectionManager.superclass.initComponent.call(this);this.on({hide:this.onHide,show:this.onShow});Deluge.Events.on("login",this.onLogin,this);Deluge.Events.on("logout",this.onLogout,this);this.addButton(_("Close"),this.onClose,this);this.addButton(_("Connect"),this.onConnect,this);this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"status",mapping:3},{name:"host",mapping:1},{name:"port",mapping:2},{name:"version",mapping:4}],id:0}),columns:[{header:_("Status"),width:65,sortable:true,renderer:fplain,dataIndex:"status"},{id:"host",header:_("Host"),width:150,sortable:true,renderer:a,dataIndex:"host"},{header:_("Version"),width:75,sortable:true,renderer:fplain,dataIndex:"version"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this}}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{id:"add",cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAdd,scope:this},{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this},"->",{id:"stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),icon:"/icons/error.png",handler:this.onStop,scope:this}]})})},disconnect:function(){Deluge.Events.fire("disconnect")},runCheck:function(c,b){c=c||this.onGetHosts;b=b||this;Deluge.Client.web.get_hosts({success:c,scope:b})},onAdd:function(b,c){},onAddHost:function(){var e=Deluge.Connections.Add.items.first();var d=e.items.get("host").getValue();var b=e.items.get("port").getValue();var f=e.items.get("username").getValue();var c=e.items.get("_password").getValue();Deluge.Client.web.add_host(d,b,f,c,{onSuccess:function(g){if(!g[0]){Ext.MessageBox.show({title:_("Error"),msg:"Unable to add host: "+g[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.runCheck()}Deluge.Connections.Add.hide()}})},onAddWindowHide:function(){var b=Deluge.Connections.Add.items.first();b.items.get("host").reset();b.items.get("port").reset();b.items.get("username").reset();b.items.get("_password").reset()},onClose:function(b){if(this.running){window.clearInterval(this.running)}this.hide()},onConnect:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")==_("Connected")){Deluge.Client.web.disconnect({success:function(e){this.runCheck();Deluge.Events.fire("disconnect")},scope:this})}else{var d=b.id;Deluge.Client.web.connect(d,{success:function(e){Deluge.Client.reloadMethods();Deluge.Client.on("connected",function(f){Deluge.Events.fire("connect")},this,{single:true})}});if(this.running){window.clearInterval(this.running)}this.hide()}},onGetHosts:function(b){this.grid.getStore().loadData(b);var c=this.grid.getSelectionModel();c.selectRow(this.selectedRow)},onLogin:function(){Deluge.Client.web.connected({success:function(b){if(b){Deluge.Events.fire("connect")}else{this.show()}},scope:this})},onLogout:function(){this.disconnect();if(!this.hidden&&this.rendered){this.hide()}},onRemove:function(c){var b=Deluge.Connections.Grid.getSelectionModel().getSelected();Deluge.Client.web.remove_host(b.id,{onSuccess:function(d){if(!d){Ext.MessageBox.show({title:_("Error"),msg:d[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{Deluge.Connections.Grid.store.remove(b)}}})},onSelect:function(c,e,b){this.selectedRow=e;var d=this.buttons[1];if(b.get("status")==_("Connected")){d.setText(_("Disconnect"))}else{d.setText(_("Connect"))}},onShow:function(){this.runCheck();this.running=window.setInterval(this.runCheck,2000)},onStop:function(c,d){var b=this.grid.getSelectionModel().getSelected();Deluge.Client.web.stop_daemon(b.id,{success:function(e){if(!e[0]){Ext.MessageBox.show({title:_("Error"),msg:e[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}}})}});Deluge.ConnectionManager=new Ext.deluge.ConnectionManager()})();(function(){Ext.namespace("Ext.deluge.details");Ext.deluge.details.TabPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0},a);Ext.deluge.details.TabPanel.superclass.constructor.call(this,a)},clear:function(){this.items.each(function(a){if(a.clear){a.clear()}})},update:function(a){var b=Deluge.Torrents.getSelected();if(!b){return}a=a||this.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(b,a){Ext.deluge.details.TabPanel.superclass.onRender.call(this,b,a);Deluge.Events.on("disconnect",this.clear,this);Deluge.Torrents.on("rowclick",this.onTorrentsClick,this);this.on("tabchange",this.onTabChange,this);Deluge.Torrents.getSelectionModel().on("selectionchange",function(c){if(!c.hasSelection()){this.clear()}},this)},onTabChange:function(a,b){this.update(b)},onTorrentsClick:function(a,c,b){this.update()}});Deluge.Details=new Ext.deluge.details.TabPanel()})();Ext.deluge.details.StatusTab=Ext.extend(Ext.Panel,{title:_("Status"),onRender:function(b,a){Ext.deluge.details.StatusTab.superclass.onRender.call(this,b,a);this.progressBar=this.add({xtype:"fullprogressbar",cls:"x-deluge-status-progressbar"});this.status=this.add({cls:"x-deluge-status",border:false,listeners:{render:{fn:function(c){c.load({url:"/render/tab_status.html",text:_("Loading")+"..."});c.getUpdater().on("update",this.onPanelUpdate,this)},scope:this}}})},clear:function(){if(!this.fields){return}this.progressBar.updateProgress(0," ");for(var a in this.fields){this.fields[a].innerHTML=""}},update:function(a){if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Status,{success:this.onRequestComplete,scope:this})},onPanelUpdate:function(b,a){this.fields={};Ext.each(Ext.query("dd",this.status.body.dom),function(c){this.fields[c.className]=c},this)},onRequestComplete:function(a){seeders=a.total_seeds>-1?a.num_seeds+" ("+a.total_seeds+")":a.num_seeds;peers=a.total_peers>-1?a.num_peers+" ("+a.total_peers+")":a.num_peers;var b={downloaded:fsize(a.total_done)+" ("+fsize(a.total_payload_download)+")",uploaded:fsize(a.total_uploaded)+" ("+fsize(a.total_payload_upload)+")",share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:fspeed(a.download_payload_rate),upspeed:fspeed(a.upload_payload_rate),eta:ftime(a.eta),pieces:a.num_pieces+" ("+fsize(a.piece_length)+")",seeders:seeders,peers:peers,avail:a.distributed_copies.toFixed(3),active_time:ftime(a.active_time),seeding_time:ftime(a.seeding_time),seed_rank:a.seed_rank,auto_managed:"False",time_added:fdate(a.time_added)};if(a.is_auto_managed){b.auto_managed="True"}for(var c in this.fields){this.fields[c].innerHTML=b[c]}var d=a.state+" "+a.progress.toFixed(2)+"%";this.progressBar.updateProgress(a.progress,d)}});Deluge.Details.add(new Ext.deluge.details.StatusTab());Ext.deluge.details.DetailsTab=Ext.extend(Ext.Panel,{title:_("Details"),cls:"x-deluge-status",onRender:function(b,a){Ext.deluge.details.DetailsTab.superclass.onRender.call(this,b,a);this.load({url:"/render/tab_details.html",text:_("Loading")+"..."});this.getUpdater().on("update",this.onPanelUpdate,this)},clear:function(){if(!this.fields){return}for(var a in this.fields){this.fields[a].innerHTML=""}},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Details,{success:this.onRequestComplete,scope:this,torrentId:a})},onPanelUpdate:function(b,a){this.fields={};Ext.each(Ext.query("dd",this.body.dom),function(c){this.fields[c.className]=c},this)},onRequestComplete:function(c,a){var b={torrent_name:c.name,hash:a.torrentId,path:c.save_path,size:fsize(c.total_size),files:c.num_files,status:c.tracker_status,tracker:c.tracker,comment:c.comment};for(var d in this.fields){this.fields[d].innerHTML=b[d]}}});Deluge.Details.add(new Ext.deluge.details.DetailsTab());(function(){function b(d){var c=d*100;return Deluge.progressBar(c,this.width-50,c.toFixed(2)+"%")}function a(c){return String.format('
{1}
',FILE_PRIORITY_CSS[c],_(FILE_PRIORITY[c]))}Ext.deluge.details.FilesTab=Ext.extend(Ext.tree.ColumnTree,{constructor:function(c){c=Ext.apply({title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{header:_("Progress"),width:150,dataIndex:"progress",renderer:b},{header:_("Priority"),width:150,dataIndex:"priority",renderer:a}],root:new Ext.tree.TreeNode({text:"Files"})},c);Ext.deluge.details.FilesTab.superclass.constructor.call(this,c)},onRender:function(d,c){Ext.deluge.details.FilesTab.superclass.onRender.call(this,d,c);Deluge.Menus.FilePriorities.on("itemclick",this.onItemClick,this);this.on("contextmenu",this.onContextMenu,this);this.sorter=new Ext.tree.TreeSorter(this,{folderSort:true})},clear:function(){var c=this.getRootNode();if(!c.hasChildNodes()){return}c.cascade(function(e){var d=e.parentNode;if(!d){return}if(!d.ownerTree){return}d.removeChild(e)})},update:function(c){if(this.torrentId!=c){this.clear();this.torrentId=c}Deluge.Client.web.get_torrent_files(c,{success:this.onRequestComplete,scope:this,torrentId:c})},onContextMenu:function(d,f){f.stopEvent();var c=this.getSelectionModel();if(c.getSelectedNodes().length<2){c.clearSelections();d.select()}Deluge.Menus.FilePriorities.showAt(f.getPoint())},onItemClick:function(j,h){switch(j.id){case"expandAll":this.expandAll();break;default:var g={};function c(e){if(!e.attributes.fileIndex){return}g[e.attributes.fileIndex]=e.attributes.priority}this.getRootNode().cascade(c);var d=this.getSelectionModel().getSelectedNodes();Ext.each(d,function(e){if(!e.attributes.fileIndex){return}g[e.attributes.fileIndex]=j.filePriority});alert(Ext.keys(g));priorities=new Array(Ext.keys(g).length);for(var f in g){priorities[f]=g[f]}alert(this.torrentId);alert(priorities);Deluge.Client.core.set_torrent_file_priorities(this.torrentId,priorities,{success:function(){Ext.each(d,function(e){e.setColumnValue(3,j.filePriority)})},scope:this});break}},onRequestComplete:function(f,e){function d(k,h){for(var g in k){var j=k[g];var l=h.findChild("id",g);if(Ext.type(j)=="object"){if(!l){l=new Ext.tree.TreeNode({id:g,text:g});h.appendChild(l)}d(j,l)}else{if(!l){l=new Ext.tree.ColumnTreeNode({id:g,filename:g,text:g,fileIndex:j[0],size:j[1],progress:j[2],priority:j[3],leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});h.appendChild(l)}l.setColumnValue(1,j[1]);l.setColumnValue(2,j[2]);l.setColumnValue(3,j[3])}}}var c=this.getRootNode();d(f,c);c.firstChild.expand()}});Deluge.Details.add(new Ext.deluge.details.FilesTab())})();(function(){function a(e){return String.format('',e)}function c(g,h,f){var e=(f.data.seed==1024)?"x-deluge-seed":"x-deluge-peer";return String.format('
{1}
',e,g)}function d(g){var e=(g*100).toFixed(0);var f=new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]).toFixed(0)-8;return Deluge.progressBar(e,f,e+"%")}function b(g){var e=g.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);var f=0;var h=[e[1],e[2],e[3],e[4]];Ext.each(h,function(k,j){k=parseInt(k);f=f|k<<((3-j)*8)});return f}Ext.deluge.details.PeersTab=Ext.extend(Ext.grid.GridPanel,{constructor:function(e){e=Ext.apply({title:_("Peers"),cls:"x-deluge-peers",store:new Ext.data.SimpleStore({fields:[{name:"country"},{name:"address",sortType:b},{name:"client"},{name:"progress",type:"float"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"seed",type:"int"}],id:0}),columns:[{header:" ",width:30,sortable:true,renderer:a,dataIndex:"country"},{header:"Address",width:125,sortable:true,renderer:c,dataIndex:"address"},{header:"Client",width:125,sortable:true,renderer:fplain,dataIndex:"client"},{header:"Progress",width:150,sortable:true,renderer:d,dataIndex:"progress"},{header:"Down Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"downspeed"},{header:"Up Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"upspeed"}],stripeRows:true,deferredRender:false,autoScroll:true},e);Ext.deluge.details.PeersTab.superclass.constructor.call(this,e)},onRender:function(f,e){Ext.deluge.details.PeersTab.superclass.onRender.call(this,f,e)},clear:function(){this.getStore().loadData([])},update:function(e){Deluge.Client.core.get_torrent_status(e,Deluge.Keys.Peers,{success:this.onRequestComplete,scope:this})},onRequestComplete:function(g,f){var e=new Array();Ext.each(g.peers,function(h){e.push([h.country,h.ip,h.client,h.progress,h.down_speed,h.up_speed,h.seed])},this);this.getStore().loadData(e)}});Deluge.Details.add(new Ext.deluge.details.PeersTab())})();Ext.deluge.details.OptionsTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({autoScroll:true,bodyStyle:"padding: 5px;",border:false,cls:"x-deluge-options",defaults:{autoHeight:true,labelWidth:1,defaultType:"checkbox"},deferredRender:false,layout:"column",title:_("Options")},a);Ext.deluge.details.OptionsTab.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);this.fieldsets={},this.fields={};this.fieldsets.bandwidth=this.add({xtype:"fieldset",defaultType:"uxspinner",bodyStyle:"padding: 5px",layout:"table",layoutConfig:{columns:3},labelWidth:150,style:"margin-left: 10px; margin-right: 5px; padding: 5px",title:_("Bandwidth"),width:300});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Download Speed"),forId:"max_download_speed",cls:"x-deluge-options-label"});this.fields.max_download_speed=this.fieldsets.bandwidth.add({id:"max_download_speed",name:"max_download_speed",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Speed"),forId:"max_upload_speed",cls:"x-deluge-options-label"});this.fields.max_upload_speed=this.fieldsets.bandwidth.add({id:"max_upload_speed",name:"max_upload_speed",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Connections"),forId:"max_connections",cls:"x-deluge-options-label"});this.fields.max_connections=this.fieldsets.bandwidth.add({id:"max_connections",name:"max_connections",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.bandwidth.add({xtype:"label"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Slots"),forId:"max_upload_slots",cls:"x-deluge-options-label"});this.fields.max_upload_slots=this.fieldsets.bandwidth.add({id:"max_upload_slots",name:"max_upload_slots",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.queue=this.add({xtype:"fieldset",title:_("Queue"),style:"margin-left: 5px; margin-right: 5px; padding: 5px",width:200,defaults:{fieldLabel:"",labelSeparator:""}});this.fields.is_auto_managed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"is_auto_managed",boxLabel:_("Auto Managed")});this.fields.stop_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"stop_at_ratio",boxLabel:_("Stop seed at ratio")});this.fields.remove_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"remove_at_ratio",boxLabel:_("Remove at ratio")});this.fields.move_completed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"move_completed",boxLabel:_("Move Completed")});this.rightColumn=this.add({border:false,autoHeight:true,style:"margin-left: 5px",width:200});this.fieldsets.general=this.rightColumn.add({xtype:"fieldset",autoHeight:true,defaultType:"checkbox",title:_("General"),layout:"form"});this.fields["private"]=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Private"),id:"private"});this.fields.prioritize_first_last=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"});this.buttonPanel=this.rightColumn.add({layout:"column",xtype:"panel",border:false});this.buttonPanel.add({xtype:"panel",border:false}).add({id:"edit_trackers",xtype:"button",text:_("Edit Trackers"),cls:"x-btn-text-icon",iconCls:"x-deluge-edit-trackers",border:false,width:100,handler:this.onEditTrackers,scope:this});this.buttonPanel.add({xtype:"panel",border:false}).add({id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px;",border:false,width:100,})},onRender:function(b,a){Ext.deluge.details.OptionsTab.superclass.onRender.call(this,b,a);this.layout=new Ext.layout.ColumnLayout();this.layout.setContainer(this);this.doLayout()},clear:function(){this.fields.max_download_speed.setValue(0);this.fields.max_upload_speed.setValue(0);this.fields.max_connections.setValue(0);this.fields.max_upload_slots.setValue(0);this.fields.is_auto_managed.setValue(false);this.fields.stop_at_ratio.setValue(false);this.fields.remove_at_ratio.setValue(false);this.fields["private"].setValue(false);this.fields.prioritize_first_last.setValue(false)},reset:function(){if(this.torrentId){delete this.changed[this.torrentId]}},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Options,{success:this.onRequestComplete,scope:this,torrentId:a})},onEditTrackers:function(){Deluge.EditTrackers.show()},onRequestComplete:function(b,a){}});Deluge.Details.add(new Ext.deluge.details.OptionsTab());(function(){Ext.deluge.AddTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Add Tracker"),width:375,height:150,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Ext.deluge.AddTracker.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.AddTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Add"),this.onAdd,this);this.addEvents("add");this.form=this.add({xtype:"form",defaultType:"textarea",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Trackers"),name:"trackers",anchor:"100%"}]})},onCancel:function(){this.form.getForm().findField("trackers").setValue("");this.hide()},onAdd:function(){var b=this.form.getForm().findField("trackers").getValue();b=b.split("\n");var a=[];Ext.each(b,function(c){if(Ext.form.VTypes.url(c)){a.push(c)}},this);this.fireEvent("add",a);this.hide();this.form.getForm().findField("trackers").setValue("")}});Ext.deluge.EditTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Tracker"),width:375,height:110,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Ext.deluge.EditTracker.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.EditTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Save"),this.onSave,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Tracker"),name:"tracker",anchor:"100%"}]})},show:function(a){Ext.deluge.EditTracker.superclass.show.call(this);this.record=a;this.form.getForm().findField("tracker").setValue(a.data.url)},onCancel:function(){this.hide()},onHide:function(){this.form.getForm().findField("tracker").setValue("")},onSave:function(){var a=this.form.getForm().findField("tracker").getValue();this.record.set("url",a);this.record.commit();this.hide()}});Ext.deluge.EditTrackers=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Trackers"),width:350,height:220,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:true},a);Ext.deluge.EditTrackers.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.EditTrackers.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Ok"),this.onOk,this);this.addEvents("save");this.on("show",this.onShow,this);this.on("save",this.onSave,this);this.addWindow=new Ext.deluge.AddTracker();this.addWindow.on("add",this.onAddTrackers,this);this.editWindow=new Ext.deluge.EditTracker();this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"tier",mapping:0},{name:"url",mapping:1}]}),columns:[{header:_("Tier"),width:50,sortable:true,renderer:fplain,dataIndex:"tier"},{id:"tracker",header:_("Tracker"),sortable:true,renderer:fplain,dataIndex:"url"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:{fn:this.onSelect,scope:this}}}),autoExpandColumn:"tracker",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",text:_("Up"),icon:"/icons/up.png",handler:this.onUp,scope:this},{cls:"x-btn-text-icon",text:_("Down"),icon:"/icons/down.png",handler:this.onDown,scope:this},"->",{cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAdd,scope:this},{cls:"x-btn-text-icon",text:_("Edit"),icon:"/icons/edit_trackers.png",handler:this.onEdit,scope:this},{cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this}]})})},onAdd:function(){this.addWindow.show()},onAddTrackers:function(b){var a=this.grid.getStore();Ext.each(b,function(d){var e=false,c=-1;a.each(function(f){if(f.get("tier")>c){c=f.get("tier")}if(d==f.get("tracker")){e=true;return false}},this);if(!e){a.loadData([[c+1,d]],true)}},this)},onCancel:function(){this.hide()},onEdit:function(){var a=this.grid.getSelectionModel().getSelected();this.editWindow.show(a)},onHide:function(){this.grid.getStore().removeAll()},onOk:function(){var a=[];this.grid.getStore().each(function(b){a.push({tier:b.get("tier"),url:b.get("url")})},this);Deluge.Client.core.set_torrent_trackers(this.torrentId,a,{failure:this.onSaveFail,scope:this});this.hide()},onRemove:function(){var a=this.grid.getSelectionModel().getSelected();this.grid.getStore().remove(a)},onRequestComplete:function(a){var b=[];Ext.each(a.trackers,function(c){b.push([c.tier,c.url])});this.grid.getStore().loadData(b)},onSaveFail:function(){},onSelect:function(a){if(a.hasSelection()){this.grid.getBottomToolbar().items.get(4).enable()}},onShow:function(){this.grid.getBottomToolbar().items.get(4).disable();var a=Deluge.Torrents.getSelected();this.torrentId=a.id;Deluge.Client.core.get_torrent_status(a.id,["trackers"],{success:this.onRequestComplete,scope:this})}});Deluge.EditTrackers=new Ext.deluge.EditTrackers()})();Deluge.Keys={Grid:["queue","name","total_size","state","progress","num_seeds","total_seeds","num_peers","total_peers","download_payload_rate","upload_payload_rate","eta","ratio","distributed_copies","is_auto_managed","time_added","tracker_host"],Status:["total_done","total_payload_download","total_uploaded","total_payload_upload","next_announce","tracker_status","num_pieces","piece_length","is_auto_managed","active_time","seeding_time","seed_rank"],Files:["files","file_progress","file_priorities"],Peers:["peers","seeds"],Details:["name","save_path","total_size","num_files","tracker_status","tracker","comment"],Options:["max_download_speed","max_upload_speed","max_connections","max_upload_slots","is_auto_managed","stop_at_ratio","stop_ratio","remove_at_ratio","private","prioritize_first_last"]};Ext.each(Deluge.Keys.Grid,function(a){Deluge.Keys.Status.push(a)});(function(){Ext.deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,constructor:function(a){a=Ext.apply({layout:"fit",width:300,height:120,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",closable:false,modal:true,plain:true,resizable:false,title:_("Login"),iconCls:"x-deluge-login-window-icon"},a);Ext.deluge.LoginWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.LoginWindow.superclass.initComponent.call(this);Deluge.Events.on("logout",this.onLogout,this);this.on("show",this.onShow,this);this.on("beforeshow",this.onBeforeShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.loginForm=this.add({xtype:"form",defaultType:"textfield",id:"loginForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Password"),id:"password",name:"password",inputType:"password",anchor:"100%",listeners:{specialkey:{fn:this.onKey,scope:this}}}]})},onKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.loginForm.items.get("password");Deluge.Client.auth.login(a.getValue(),{success:function(b){if(b){Deluge.Events.fire("login");this.hide();a.setRawValue("");Deluge.UI.cookies.set("session",b)}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){a.focus()},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}},scope:this})},onLogout:function(){var a=Deluge.UI.cookies.get("session",false);if(a){Deluge.Client.auth.delete_session(a,{success:function(b){Deluge.UI.cookies.clear("session");this.show()},scope:this})}},onBeforeShow:function(){var a=Deluge.UI.cookies.get("session",false);if(a){Deluge.Client.auth.check_session(a,{success:function(b){if(b){Deluge.Events.fire("login");this.loginForm.items.get("password").setRawValue("");this.hide()}else{Deluge.UI.cookies.clear("session");this.show()}},failure:function(b){Deluge.UI.cookies.clear("session");this.show()},scope:this});return false}},onShow:function(){var a=this.loginForm.items.get("password");a.focus(false,150)}});Deluge.Login=new Ext.deluge.LoginWindow()})();(function(){Ext.deluge.PreferencesWindow=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({layout:"border",width:485,height:500,buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-preferences",plain:true,resizable:true,title:_("Preferences"),buttons:[{text:_("Close"),handler:this.onCloseButtonClick,scope:this},{text:_("Apply")},{text:_("Ok")}],currentPage:false,items:[{xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.SimpleStore({fields:[{name:"name",mapping:0}]}),columns:[{id:"name",renderer:fplain,dataIndex:"name"}],sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPageSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 0 5 5",cmargins:"5 0 5 5",width:120,collapsible:true},{region:"center",header:false,layout:"fit",height:400,margins:"5 5 5 5",cmargins:"5 5 5 5"}]},a);Ext.deluge.PreferencesWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.items.get(0);this.configPanel=this.items.get(1);this.pages={};this.on("show",this.onShow,this)},onCloseButtonClick:function(){this.hide()},addPage:function(c){var a=this.categoriesGrid.getStore();var b=c.title;a.loadData([[b]],true);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);this.pages[b].hide()},onPageSelect:function(a,d,c){if(this.currentPage){this.currentPage.hide()}var b=c.get("name");this.pages[b].show();this.currentPage=this.pages[b];this.configPanel.doLayout()},onShow:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}}});Deluge.Preferences=new Ext.deluge.PreferencesWindow()})();Deluge.Preferences.addPage({border:false,title:_("Downloads"),xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Folders"),labelWidth:140,defaultType:"textfield",autoHeight:true,items:[{name:"download_location",fieldLabel:_("Download to"),width:125},{name:"move_completed",fieldLabel:_("Move completed to"),width:125},{name:"copy_torrent_files",fieldLabel:_("Copy of .torrent files to"),width:125}]},{xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radio",items:[{name:"compact_allocation",labelSeparator:"",boxLabel:_("Compact")},{name:"compact_allocation",labelSeparator:"",boxLabel:_("Full")}]},{xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{name:"prioritize_first_last",labelSeparator:"",boxLabel:_("Prioritize first and last pieces of torrent")},{name:"add_paused",labelSeparator:"",boxLabel:_("Add torrents in Paused state")}]}]});Deluge.Preferences.addPage({border:false,title:_("Bandwidth"),xtype:"form",layout:"form",labelWidth:10,items:[{xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),autoHeight:true,labelWidth:200,style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"uxspinner",items:[{name:"max_connections",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1},{name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:60,value:-1},{name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:60,value:-1}]},{xtype:"fieldset",border:false,title:"",autoHeight:true,style:"padding-top: 0px; margin-top: 0px; margin-bottom: 0px;",items:[{xtype:"checkbox",name:"ignore_local",fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),value:-1},{xtype:"checkbox",name:"limit_ip_overhead",fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),value:-1}]},{xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),autoHeight:true,labelWidth:200,defaultType:"uxspinner",items:[{name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1}]}]});Deluge.Preferences.addPage({border:false,title:_("Interface"),xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Window"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar"),id:"show_session_speed"}]},{xtype:"fieldset",border:false,title:_("Sidebar"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Hide filters with zero torrents"),id:"hide_sidebar_zero"}]},{xtype:"fieldset",border:false,title:_("Password"),autoHeight:true,defaultType:"textfield",items:[{fieldLabel:"New Password",inputType:"password",id:"new_password"},{inputType:"password",fieldLabel:"Confirm Password",id:"confirm_password"}]}]});Deluge.Preferences.addPage({border:false,title:_("Daemon"),xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"uxspinner",items:[{fieldLabel:_("Daemon port"),id:"daemon_port"}]},{xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Allow Remote Connections"),id:"allow_remote"}]},{xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_releases"}]}]});(function(){function a(d,f,c){var b=d.toLowerCase().replace(".","_");var e="";if(c.store.id=="tracker_host"){if(d!="Error"){e=String.format("url(/tracker/{0})",d)}else{b=null}}if(e){return String.format('
{0} ({1})
',d,c.data.count,e)}else{if(b){return String.format('
{0} ({1})
',d,c.data.count,b)}else{return String.format('
{0} ({1})
',d,c.data.count)}}}Ext.deluge.Sidebar=Ext.extend(Ext.Panel,{panels:{},selected:null,constructor:function(b){b=Ext.apply({id:"sidebar",region:"west",cls:"deluge-sidebar",title:_("Filters"),layout:"accordion",split:true,width:200,minSize:175,collapsible:true,margins:"5 0 0 5",cmargins:"5 0 0 5"},b);Ext.deluge.Sidebar.superclass.constructor.call(this,b)},initComponent:function(){Ext.deluge.Sidebar.superclass.initComponent.call(this);Deluge.Events.on("disconnect",this.onDisconnect,this)},createFilter:function(e,d){var c=new Ext.data.SimpleStore({id:e,fields:[{name:"filter"},{name:"count"}]});var g=e.replace("_"," ");var f=g.split(" ");g="";Ext.each(f,function(h){firstLetter=h.substring(0,1);firstLetter=firstLetter.toUpperCase();h=firstLetter+h.substring(1);g+=h+" "});var b=new Ext.grid.GridPanel({id:e+"-panel",store:c,title:_(g),columns:[{id:"filter",sortable:false,renderer:a,dataIndex:"filter"}],stripeRows:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onFilterSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"filter",deferredRender:false,autoScroll:true});c.loadData(d);this.add(b);this.doLayout();this.panels[e]=b;if(!this.selected){b.getSelectionModel().selectFirstRow();this.selected={row:0,filter:d[0][0],panel:b}}},getFilters:function(){var c={};if(!this.selected){return c}if(!this.selected.filter||!this.selected.panel){return c}var b=this.selected.panel.store.id;if(b=="state"&&this.selected.filter=="All"){return c}c[b]=this.selected.filter;return c},onDisconnect:function(){Ext.each(Ext.getKeys(this.panels),function(b){this.remove(b+"-panel")},this);this.panels={};this.selected=null},onFilterSelect:function(c,d,b){if(!this.selected){needsUpdate=true}else{if(this.selected.row!=d){needsUpdate=true}else{needsUpdate=false}}this.selected={row:d,filter:b.get("filter"),panel:this.panels[b.store.id]};if(needsUpdate){Deluge.UI.update()}},update:function(d){for(var c in d){var b=d[c];if(Ext.getKeys(this.panels).indexOf(c)>-1){this.updateFilter(c,b)}else{this.createFilter(c,b)}}Ext.each(Ext.keys(this.panels),function(e){if(Ext.keys(d).indexOf(e)==-1){}})},updateFilter:function(c,b){this.panels[c].store.loadData(b);if(this.selected&&this.selected.panel==this.panels[c]){this.panels[c].getSelectionModel().selectRow(this.selected.row)}}});Deluge.Sidebar=new Ext.deluge.Sidebar()})();(function(){Ext.deluge.Statusbar=Ext.extend(Ext.StatusBar,{constructor:function(a){a=Ext.apply({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected")},a);Ext.deluge.Statusbar.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.Statusbar.superclass.initComponent.call(this);Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("disconnect",this.onDisconnect,this)},createButtons:function(){this.add({id:"statusbar-connections",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",menu:Deluge.Menus.Connections},"-",{id:"statusbar-downspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",menu:Deluge.Menus.Download},"-",{id:"statusbar-upspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",menu:Deluge.Menus.Upload},"-",{id:"statusbar-traffic",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic"},"-",{id:"statusbar-dht",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-dht"});this.created=true},onConnect:function(){this.setStatus({iconCls:"x-connected",text:""});if(!this.created){this.createButtons()}else{this.items.each(function(a){a.show();a.enable()})}},onDisconnect:function(){this.clearStatus({useDefaults:true});this.items.each(function(a){a.hide();a.disable()})},update:function(b){function d(e){return e+" KiB/s"}var a=function(g,f){var h=this.items.get("statusbar-"+g);if(f.limit.value==-1){var k=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value}else{var j=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value;var e=(f.limit.formatter)?f.limit.formatter(f.limit.value):f.limit.value;var k=String.format(f.format,j,e)}h.setText(k)}.bind(this);a("connections",{value:{value:b.num_connections},limit:{value:b.max_num_connections},format:"{0} ({1})"});a("downspeed",{value:{value:b.download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_download,formatter:d},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:d},format:"{0} ({1})"});a("traffic",{value:{value:b.payload_download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.payload_upload_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.items.get("statusbar-dht").setText(b.dht_nodes);function c(g,e){var f=g.items.get(e);if(!f){f=g.items.get("other")}f.setChecked(true)}c(Deluge.Menus.Connections,b.max_num_connections);c(Deluge.Menus.Download,b.max_download);c(Deluge.Menus.Upload,b.max_upload)}});Deluge.Statusbar=new Ext.deluge.Statusbar()})();(function(){Ext.deluge.Toolbar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=Ext.apply({items:[{id:"create",cls:"x-btn-text-icon",disabled:true,text:_("Create"),icon:"/icons/create.png",handler:this.onTorrentAction},{id:"add",cls:"x-btn-text-icon",disabled:true,text:_("Add"),icon:"/icons/add.png",handler:this.onTorrentAdd},{id:"remove",cls:"x-btn-text-icon",disabled:true,text:_("Remove"),icon:"/icons/remove.png",handler:this.onTorrentAction},"|",{id:"pause",cls:"x-btn-text-icon",disabled:true,text:_("Pause"),icon:"/icons/pause.png",handler:this.onTorrentAction},{id:"resume",cls:"x-btn-text-icon",disabled:true,text:_("Resume"),icon:"/icons/start.png",handler:this.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),icon:"/icons/up.png",handler:this.onTorrentAction},{id:"down",cls:"x-btn-text-icon",disabled:true,text:_("Down"),icon:"/icons/down.png",handler:this.onTorrentAction},"|",{id:"preferences",cls:"x-btn-text-icon",text:_("Preferences"),icon:"/icons/preferences.png",handler:this.onPreferencesClick,scope:this},{id:"connectionman",cls:"x-btn-text-icon",text:_("Connection Manager"),iconCls:"x-deluge-connections",handler:this.onConnectionManagerClick,scope:this},"->",{id:"help",cls:"x-btn-text-icon",disabled:true,icon:"/icons/help.png",text:_("Help"),handler:this.onHelpClick,scope:this},{id:"logout",cls:"x-btn-text-icon",icon:"/icons/logout.png",disabled:true,text:_("Logout"),handler:this.onLogout,scope:this}]},a);Ext.deluge.Toolbar.superclass.constructor.call(this,a)},connectedButtons:["add","remove","pause","resume","up","down"],initComponent:function(){Ext.deluge.Toolbar.superclass.initComponent.call(this);Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("login",this.onLogin,this)},onConnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).enable()},this)},onDisconnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).disable()},this)},onLogin:function(){this.items.get("logout").enable()},onLogout:function(){this.items.get("logout").disable();Deluge.Events.fire("logout");Deluge.Login.show()},onConnectionManagerClick:function(){Deluge.ConnectionManager.show()},onPreferencesClick:function(){Deluge.Preferences.show()},onTorrentAction:function(c){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(d){a.push(d.id)});switch(c.id){case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{success:function(){Deluge.UI.update()}});break;case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"up":case"down":Deluge.Client.core["queue_"+c.id](a,{success:function(){Deluge.UI.update()}});break}},onTorrentAdd:function(){Deluge.Add.show()}});Deluge.Toolbar=new Ext.deluge.Toolbar()})();(function(){function f(j){return(j==-1)?"":j+1}function b(k,l,j){return String.format('
{1}
',j.data.state.toLowerCase(),k)}function h(j){if(!j){return}return fspeed(j)}function c(m,n,l){m=new Number(m);var j=m;var o=l.data.state+" "+m.toFixed(2)+"%";var k=new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1])-8;return Deluge.progressBar(m,k,o)}function e(k,l,j){if(j.data.total_seeds>-1){return String.format("{0} ({1})",k,j.data.total_seeds)}else{return k}}function g(k,l,j){if(j.data.total_peers>-1){return String.format("{0} ({1})",k,j.data.total_peers)}else{return k}}function d(k,l,j){return new Number(k).toFixed(3)}function a(k,l,j){return String.format('
{0}
',k)}Ext.deluge.TorrentGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(j){j=Ext.apply({id:"torrentGrid",store:new Ext.data.SimpleStore({fields:[{name:"queue"},{name:"name"},{name:"size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"peers",type:"int"},{name:"total_peers",type:"int"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"avail",type:"float"},{name:"added",type:"int"},{name:"tracker"}],id:16}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:f,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:b,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"size"},{header:_("Progress"),width:150,sortable:true,renderer:c,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:e,dataIndex:"seeds"},{header:_("Peers"),width:60,sortable:true,renderer:g,dataIndex:"peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:h,dataIndex:"downspeed"},{header:_("Up Speed"),width:80,sortable:true,renderer:h,dataIndex:"upspeed"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:d,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:d,dataIndex:"avail"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"added"},{header:_("Tracker"),width:120,sortable:true,renderer:a,dataIndex:"tracker"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0"},j);Ext.deluge.TorrentGrid.superclass.constructor.call(this,j)},initComponent:function(){Ext.deluge.TorrentGrid.superclass.initComponent.call(this);Deluge.Events.on("torrentRemoved",this.onTorrentRemoved,this);this.on("rowcontextmenu",function(j,m,l){l.stopEvent();var k=j.getSelectionModel();if(!k.hasSelection()){k.selectRow(m)}Deluge.Menus.Torrent.showAt(l.getPoint())})},getTorrent:function(j){return this.getStore().getAt(j)},getSelected:function(){return this.getSelectionModel().getSelected()},getSelections:function(){return this.getSelectionModel().getSelections()},update:function(n){var l=this.getStore();for(var k in n){var j=l.getById(k);var p=n[k];if(!j){var o=[p.queue,p.name,p.total_size,p.state,p.progress,p.num_seeds,p.total_seeds,p.num_peers,p.total_peers,p.download_payload_rate,p.upload_payload_rate,p.eta,p.ratio,p.distributed_copies,p.time_added,p.tracker_host,k];l.loadData([o],true)}else{j.set("queue",p.queue);j.set("name",p.name);j.set("size",p.total_size);j.set("state",p.state);j.set("progress",p.progress);j.set("seeds",p.num_seeds);j.set("total_seeds",p.total_seeds);j.set("peers",p.num_peers);j.set("total_peers",p.total_peers);j.set("downspeed",p.download_payload_rate);j.set("upspeed",p.upload_payload_rate);j.set("eta",p.eta);j.set("ratio",p.ratio);j.set("avail",p.distributed_copies);j.set("added",p.time_added);j.set("tracker",p.tracker_host);j.commit()}}var m=Ext.keys(n);l.each(function(q){if(m.indexOf(q.id)==-1){l.remove(q)}},this)},onTorrentRemoved:function(k){var j=this.getSelectionModel();Ext.each(k,function(m){var l=this.getStore().getById(m);if(j.isSelected(l)){j.deselectRow(this.getStore().indexOf(l))}this.getStore().remove(l)},this)}});Deluge.Torrents=new Ext.deluge.TorrentGrid()})();Deluge.UI={cookies:new Ext.state.CookieProvider(),errorCount:0,initialize:function(){Ext.state.Manager.setProvider(this.cookies);this.MainPanel=new Ext.Panel({id:"mainPanel",iconCls:"x-deluge-main-panel",title:"Deluge",layout:"border",tbar:Deluge.Toolbar,items:[Deluge.Sidebar,Deluge.Details,Deluge.Torrents],bbar:Deluge.Statusbar});this.Viewport=new Ext.Viewport({layout:"fit",items:[this.MainPanel]});Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("disconnect",this.onDisconnect,this);Deluge.Client=new Ext.ux.util.RpcClient({url:"/json"});Deluge.Client.on("connected",function(a){Deluge.Login.show()});this.update=this.update.bind(this)},update:function(){var a=Deluge.Sidebar.getFilters();Deluge.Client.web.update_ui(Deluge.Keys.Grid,a,{success:this.onUpdate,failure:this.onUpdateError,scope:this});Deluge.Details.update();Deluge.Client.web.connected({success:this.onConnectedCheck,scope:this})},onConnectedCheck:function(a){if(!a){Deluge.Events.fire("disconnect")}},onUpdateError:function(a){if(this.errorCount==2){Ext.MessageBox.show({title:"Lost Connection",msg:"The connection to the webserver has been lost!",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}this.errorCount++},onUpdate:function(a){Deluge.Torrents.update(a.torrents);Deluge.Statusbar.update(a.stats);Deluge.Sidebar.update(a.filters);this.errorCount=0},onConnect:function(){if(!this.running){this.running=setInterval(this.update,2000);this.update()}},onDisconnect:function(){this.stop()},stop:function(){if(this.running){clearInterval(this.running);this.running=false;Deluge.Torrents.getStore().loadData([])}}};Ext.onReady(function(a){Deluge.UI.initialize()}); \ No newline at end of file +Ext.namespace("Ext.deluge");(function(){Ext.apply(Function.prototype,{bind:function(b){var a=this;return function(){return a.apply(b,arguments)}}});Ext.apply(Ext,{keys:function(b){var a=[];for(i in b){if(b.hasOwnProperty(i)){a.push(i)}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys})();(function(){var a='
{0}
{0}
';Deluge.progressBar=function(c,e,g){var b=((e/100)*c).toFixed(0);var d=b-1;var f=((b-10)>0?b-10:0);return String.format(a,g,e,d,f)}})();FILE_PRIORITY={0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority","Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};Deluge.Formatters={date:function(c){function b(d,e){var f=d+"";while(f.length0){return b+"m "+d+"s"}else{return b+"m"}}else{c=c/60}if(c<24){var a=Math.floor(c);var b=Math.round(60*(c-a));if(b>0){return a+"h "+b+"m"}else{return a+"h"}}else{c=c/24}var e=Math.floor(c);var a=Math.round(24*(c-e));if(a>0){return e+"d "+a+"h"}else{return e+"d"}},plain:function(a){return a}};var fsize=Deluge.Formatters.size;var fspeed=Deluge.Formatters.speed;var ftime=Deluge.Formatters.timeRemaining;var fdate=Deluge.Formatters.date;var fplain=Deluge.Formatters.plain;Deluge.Menus={onTorrentAction:function(c,d){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(e){a.push(e.id)});switch(c.id){case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"top":case"up":case"down":case"bottom":Deluge.Client.core["queue_"+c.id](a,{success:function(){Deluge.UI.update()}});break;case"edit_trackers":Deluge.EditTrackers.show();break;case"update":Deluge.Client.core.force_reannounce(a,{success:function(){Deluge.UI.update()}});break;case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{success:function(){Deluge.UI.update()}});break;case"recheck":Deluge.Client.core.force_recheck(a,{success:function(){Deluge.UI.update()}});break}}};Deluge.Menus.Torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{id:"pause",text:_("Pause"),icon:"/icons/pause.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"resume",text:_("Resume"),icon:"/icons/start.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"options",text:_("Options"),icon:"/icons/preferences.png",menu:new Ext.menu.Menu({items:[{text:_("D/L Speed Limit"),iconCls:"x-deluge-downloading",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("U/L Speed Limit"),iconCls:"x-deluge-seeding",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("Connection Limit"),iconCls:"x-deluge-connections",menu:new Ext.menu.Menu({items:[{text:_("50")},{text:_("100")},{text:_("200")},{text:_("300")},{text:_("500")},{text:_("Unlimited")}]})},{text:_("Upload Slot Limit"),icon:"/icons/upload_slots.png",menu:new Ext.menu.Menu({items:[{text:_("0")},{text:_("1")},{text:_("2")},{text:_("3")},{text:_("5")},{text:_("Unlimited")}]})},{id:"auto_managed",text:_("Auto Managed"),checked:false}]})},"-",{text:_("Queue"),icon:"/icons/queue.png",menu:new Ext.menu.Menu({items:[{id:"top",text:_("Top"),icon:"/icons/top.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"up",text:_("Up"),icon:"/icons/up.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"down",text:_("Down"),icon:"/icons/down.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"bottom",text:_("Bottom"),icon:"/icons/bottom.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]})},"-",{id:"update",text:_("Update Tracker"),icon:"/icons/update.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"edit_trackers",text:_("Edit Trackers"),icon:"/icons/edit_trackers.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"remove",text:_("Remove Torrent"),icon:"/icons/remove.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"recheck",text:_("Force Recheck"),icon:"/icons/recheck.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"move",text:_("Move Storage"),icon:"/icons/move.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]});Deluge.Menus.Connections=new Ext.menu.Menu({id:"connectionsMenu",items:[{id:"50",text:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"100",text:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"200",text:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"500",text:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Download=new Ext.menu.Menu({id:"downspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Upload=new Ext.menu.Menu({id:"upspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.FilePriorities=new Ext.menu.Menu({id:"filePrioritiesMenu",items:[{id:"expandAll",text:_("Expand All"),icon:"/icons/expand_all.png"},"-",{id:"no_download",text:_("Do Not Download"),icon:"/icons/no_download.png",filePriority:0},{id:"normal",text:_("Normal Priority"),icon:"/icons/normal.png",filePriority:1},{id:"high",text:_("High Priority"),icon:"/icons/high.png",filePriority:2},{id:"highest",text:_("Highest Priority"),icon:"/icons/highest.png",filePriority:5}]});function onLimitChanged(b,a){if(b.id=="other"){}else{config={};config[b.group]=b.id;Deluge.Client.core.set_config(config,{success:function(){Deluge.UI.update()}})}}(function(){Events=Ext.extend(Ext.util.Observable,{constructor:function(){Events.superclass.constructor.call(this)},addListener:function(a,c,b,d){this.addEvents(a);Events.superclass.addListener.call(this,a,c,b,d)}});Events.prototype.on=Events.prototype.addListener;Events.prototype.fire=Events.prototype.fireEvent;Deluge.Events=new Events()})();Ext.namespace("Ext.deluge.add");Ext.deluge.add.OptionsPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",margins:"5 5 5 5",activeTab:0,height:220},a);Ext.deluge.add.OptionsPanel.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);this.files=this.add(new Ext.tree.ColumnTree({layout:"fit",title:_("Files"),rootVisible:false,autoScroll:true,height:170,border:false,animate:false,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{header:_("Size"),width:80,dataIndex:"size"}],root:new Ext.tree.AsyncTreeNode({text:"Files"})}));new Ext.tree.TreeSorter(this.files,{folderSort:true});this.form=this.add({xtype:"form",labelWidth:1,frame:false,title:_("Options"),bodyStyle:"padding: 5px;",border:false,items:[{xtype:"fieldset",title:_("Download Location"),border:false,defaultType:"textfield",labelWidth:1,items:[{fieldLabel:"",labelSeperator:"",name:"download_location",width:330}]}]})},clear:function(){this.clearFiles()},clearFiles:function(){var a=this.files.getRootNode();if(!a.hasChildNodes()){return}a.cascade(function(b){if(!b.parentNode||!b.getOwnerTree()){return}b.remove()})},getDefaults:function(){var a=["add_paused","compact_allocation","download_location","max_connections_per_torrent","max_download_speed_per_torrent","max_upload_slots_per_torrent","max_upload_speed_per_torrent","prioritize_first_last_pieces"];Deluge.Client.core.get_config_values(a,{success:function(b){this.defaults=b;for(var c in b){var d=this.form.findField(c);if(!d){return}d.setValue(b[c])}var d=this.form.findField("compact_allocation");if(b.compact_allocation){d.items.get("compact_allocation_true").setValue(true);d.items.get("compact_allocation_false").setValue(false)}else{d.items.get("compact_allocation_false").setValue(true);d.items.get("compact_allocation_true").setValue(false)}},scope:this})}});Ext.deluge.add.Window=Ext.extend(Ext.Window,{initComponent:function(){Ext.deluge.add.Window.superclass.initComponent.call(this);this.addEvents("beforeadd","add")},createTorrentId:function(){return new Date().getTime()}});Ext.deluge.add.AddWindow=Ext.extend(Ext.deluge.add.Window,{torrents:{},constructor:function(a){a=Ext.apply({title:_("Add Torrents"),layout:"border",width:470,height:450,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-add-window-icon"},a);Ext.deluge.add.AddWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.AddWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Add"),this.onAdd,this);function a(c,d,b){if(b.data.info_hash){return String.format('
{0}
',c)}else{return String.format('
{0}
',c)}}this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"info_hash",mapping:1},{name:"text",mapping:2}],id:0}),columns:[{id:"torrent",width:150,sortable:true,renderer:a,dataIndex:"text"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"torrent",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{id:"file",cls:"x-btn-text-icon",iconCls:"x-deluge-add-file",text:_("File"),handler:this.onFile,scope:this},{id:"url",cls:"x-btn-text-icon",text:_("Url"),icon:"/icons/add_url.png",handler:this.onUrl,scope:this},{id:"infohash",cls:"x-btn-text-icon",text:_("Infohash"),icon:"/icons/add_magnet.png",disabled:true},"->",{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this}]})});this.options=this.add(new Ext.deluge.add.OptionsPanel());this.on("show",this.onShow,this)},clear:function(){this.torrents={};this.grid.getStore().removeAll();this.options.clear()},onAdd:function(){torrents=[];for(var b in this.torrents){var a=this.torrents[b];torrents.push({path:a.filename,options:{}})}Deluge.Client.web.add_torrents(torrents,{success:function(c){}});this.clear();this.hide()},onCancel:function(){this.clear();this.hide()},onFile:function(){this.file.show()},onRemove:function(){var a=this.grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();delete this.torrents[b.id];this.grid.getStore().remove(b);this.options.clear()},onSelect:function(e,f,c){var d=this.torrents[c.get("info_hash")];function b(k,h){for(var g in k){var j=k[g];if(Ext.type(j)=="object"){var l=new Ext.tree.TreeNode({text:g});b(j,l);h.appendChild(l)}else{h.appendChild(new Ext.tree.TreeNode({filename:g,text:g,size:fsize(j[0]),leaf:true,checked:j[1],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI}))}}}this.options.clearFiles();var a=this.options.files.getRootNode();b(d.files_tree,a);a.firstChild.expand()},onShow:function(){if(!this.url){this.url=new Ext.deluge.add.UrlWindow();this.url.on("beforeadd",this.onTorrentBeforeAdd,this);this.url.on("add",this.onTorrentAdd,this)}if(!this.file){this.file=new Ext.deluge.add.FileWindow();this.file.on("beforeadd",this.onTorrentBeforeAdd,this);this.file.on("add",this.onTorrentAdd,this)}},onTorrentBeforeAdd:function(b,c){var a=this.grid.getStore();a.loadData([[b,null,c]],true)},onTorrentAdd:function(a,c){if(!c){Ext.MessageBox.show({title:_("Error"),msg:_("Not a valid torrent"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var b=this.grid.getStore().getById(a);b.set("info_hash",c.info_hash);b.set("text",c.name);this.grid.getStore().commitChanges();this.torrents[c.info_hash]=c},onUrl:function(a,b){this.url.show()}});Deluge.Add=new Ext.deluge.add.AddWindow();Ext.deluge.add.FileWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from File"),iconCls:"x-deluge-add-file",buttons:[{text:_("Add"),handler:this.onAdd,scope:this}]},a);Ext.deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);this.form=this.add(new Ext.form.FormPanel({baseCls:"x-plain",labelWidth:55,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"torrentFile",emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]}))},onAdd:function(c,b){if(this.form.getForm().isValid()){this.torrentId=this.createTorrentId();this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),success:this.onUploadSuccess,scope:this});var a=this.form.getForm().findField("torrentFile").value;this.fireEvent("beforeadd",this.torrentId,a)}},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",this.torrentId,d)},onUploadSuccess:function(c,b){this.hide();var a=b.result.toString();this.form.getForm().findField("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a})}});Ext.deluge.add.UrlWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon",buttons:[{text:_("Add"),handler:this.onAdd,scope:this}]},a);Ext.deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);this.form=this.add(new Ext.form.FormPanel({defaultType:"textfield",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Url"),id:"url",name:"url",inputType:"url",anchor:"100%",listeners:{specialkey:{fn:this.onAdd,scope:this}}}]}))},onAdd:function(d,c){if(d.id=="url"&&c.getKey()!=c.ENTER){return}var d=this.form.items.get("url");var b=d.getValue();var a=this.createTorrentId();Deluge.Client.web.download_torrent_from_url(b,{success:this.onDownload,scope:this,torrentId:a});this.hide();this.fireEvent("beforeadd",a,b)},onDownload:function(a,c,d,b){this.form.items.get("url").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a,torrentId:b.options.torrentId})},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",b.options.torrentId,d)}});Ext.namespace("Ext.ux.util");(function(){Ext.ux.util.RpcClient=Ext.extend(Ext.util.Observable,{_components:[],_methods:[],_requests:{},_url:null,_optionKeys:["scope","success","failure"],constructor:function(a){Ext.ux.util.RpcClient.superclass.constructor.call(this,a);this._url=a.url||null;this._id=0;this.addEvents("connected");this.reloadMethods()},reloadMethods:function(){Ext.each(this._components,function(a){delete this[a]},this);this._execute("system.listMethods",{success:this._setMethods,scope:this})},_execute:function(c,a){a=a||{};a.params=a.params||[];a.id=this._id;var b=Ext.encode({method:c,params:a.params,id:a.id});this._id++;return Ext.Ajax.request({url:this._url,method:"POST",success:this._onSuccess,failure:this._onFailure,scope:this,jsonData:b,options:a})},_onFailure:function(b,a){var c=a.options;errorObj={id:c.id,result:null,error:"HTTP"+b.status};if(Ext.type(c.failure)!="function"){return}if(c.scope){c.failure.call(c.scope,responseObj.error,responseObj,b)}else{c.failure(responseObj.error,responseObj,b)}},_onSuccess:function(c,a){var b=Ext.decode(c.responseText);var d=a.options;if(b.error){if(Ext.type(d.failure)!="function"){return}if(d.scope){d.failure.call(d.scope,b.error,b,c,a)}else{d.failure(b.error,b,c,a)}}else{if(Ext.type(d.success)!="function"){return}if(d.scope){d.success.call(d.scope,b.result,b,c,a)}else{d.success(b.result,b,c,a)}}},_parseArgs:function(c){var e=[];Ext.each(c,function(f){e.push(f)});var b=e[e.length-1];if(Ext.type(b)=="object"){var d=Ext.keys(b),a=false;Ext.each(this._optionKeys,function(f){if(d.indexOf(f)>-1){a=true}});if(a){e.remove(b)}else{b={}}}else{b={}}b.params=e;return b},_setMethods:function(b){var d={},a=this;Ext.each(b,function(h){var g=h.split(".");var e=d[g[0]]||{};var f=function(){var j=a._parseArgs(arguments);return a._execute(h,j)};e[g[1]]=f;d[g[0]]=e});for(var c in d){a[c]=d[c]}this._components=Ext.keys(d);this.fireEvent("connected",this)}})})();(function(){var a=function(c,d,b){return c+":"+b.data.port};Ext.deluge.ConnectionManager=Ext.extend(Ext.Window,{layout:"fit",width:300,height:220,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Connection Manager"),iconCls:"x-deluge-connect-window-icon",initComponent:function(){Ext.deluge.ConnectionManager.superclass.initComponent.call(this);this.on({hide:this.onHide,show:this.onShow});Deluge.Events.on("login",this.onLogin,this);Deluge.Events.on("logout",this.onLogout,this);this.addButton(_("Close"),this.onClose,this);this.addButton(_("Connect"),this.onConnect,this);this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"status",mapping:3},{name:"host",mapping:1},{name:"port",mapping:2},{name:"version",mapping:4}],id:0}),columns:[{header:_("Status"),width:65,sortable:true,renderer:fplain,dataIndex:"status"},{id:"host",header:_("Host"),width:150,sortable:true,renderer:a,dataIndex:"host"},{header:_("Version"),width:75,sortable:true,renderer:fplain,dataIndex:"version"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this}}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{id:"add",cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAdd,scope:this},{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this},"->",{id:"stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),icon:"/icons/error.png",handler:this.onStop,scope:this}]})})},disconnect:function(){Deluge.Events.fire("disconnect")},runCheck:function(c,b){c=c||this.onGetHosts;b=b||this;Deluge.Client.web.get_hosts({success:c,scope:b})},onAdd:function(b,c){},onAddHost:function(){var e=Deluge.Connections.Add.items.first();var d=e.items.get("host").getValue();var b=e.items.get("port").getValue();var f=e.items.get("username").getValue();var c=e.items.get("_password").getValue();Deluge.Client.web.add_host(d,b,f,c,{onSuccess:function(g){if(!g[0]){Ext.MessageBox.show({title:_("Error"),msg:"Unable to add host: "+g[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.runCheck()}Deluge.Connections.Add.hide()}})},onAddWindowHide:function(){var b=Deluge.Connections.Add.items.first();b.items.get("host").reset();b.items.get("port").reset();b.items.get("username").reset();b.items.get("_password").reset()},onClose:function(b){if(this.running){window.clearInterval(this.running)}this.hide()},onConnect:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")==_("Connected")){Deluge.Client.web.disconnect({success:function(e){this.runCheck();Deluge.Events.fire("disconnect")},scope:this})}else{var d=b.id;Deluge.Client.web.connect(d,{success:function(e){Deluge.Client.reloadMethods();Deluge.Client.on("connected",function(f){Deluge.Events.fire("connect")},this,{single:true})}});if(this.running){window.clearInterval(this.running)}this.hide()}},onGetHosts:function(b){this.grid.getStore().loadData(b);var c=this.grid.getSelectionModel();c.selectRow(this.selectedRow)},onLogin:function(){Deluge.Client.web.connected({success:function(b){if(b){Deluge.Events.fire("connect")}else{this.show()}},scope:this})},onLogout:function(){this.disconnect();if(!this.hidden&&this.rendered){this.hide()}},onRemove:function(c){var b=Deluge.Connections.Grid.getSelectionModel().getSelected();Deluge.Client.web.remove_host(b.id,{onSuccess:function(d){if(!d){Ext.MessageBox.show({title:_("Error"),msg:d[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{Deluge.Connections.Grid.store.remove(b)}}})},onSelect:function(c,e,b){this.selectedRow=e;var d=this.buttons[1];if(b.get("status")==_("Connected")){d.setText(_("Disconnect"))}else{d.setText(_("Connect"))}},onShow:function(){this.runCheck();this.running=window.setInterval(this.runCheck,2000)},onStop:function(c,d){var b=this.grid.getSelectionModel().getSelected();Deluge.Client.web.stop_daemon(b.id,{success:function(e){if(!e[0]){Ext.MessageBox.show({title:_("Error"),msg:e[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}}})}});Deluge.ConnectionManager=new Ext.deluge.ConnectionManager()})();(function(){Ext.namespace("Ext.deluge.details");Ext.deluge.details.TabPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0},a);Ext.deluge.details.TabPanel.superclass.constructor.call(this,a)},clear:function(){this.items.each(function(a){if(a.clear){a.clear()}})},update:function(a){var b=Deluge.Torrents.getSelected();if(!b){return}a=a||this.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(b,a){Ext.deluge.details.TabPanel.superclass.onRender.call(this,b,a);Deluge.Events.on("disconnect",this.clear,this);Deluge.Torrents.on("rowclick",this.onTorrentsClick,this);this.on("tabchange",this.onTabChange,this);Deluge.Torrents.getSelectionModel().on("selectionchange",function(c){if(!c.hasSelection()){this.clear()}},this)},onTabChange:function(a,b){this.update(b)},onTorrentsClick:function(a,c,b){this.update()}});Deluge.Details=new Ext.deluge.details.TabPanel()})();Ext.deluge.details.StatusTab=Ext.extend(Ext.Panel,{title:_("Status"),onRender:function(b,a){Ext.deluge.details.StatusTab.superclass.onRender.call(this,b,a);this.progressBar=this.add({xtype:"fullprogressbar",cls:"x-deluge-status-progressbar"});this.status=this.add({cls:"x-deluge-status",border:false,listeners:{render:{fn:function(c){c.load({url:"/render/tab_status.html",text:_("Loading")+"..."});c.getUpdater().on("update",this.onPanelUpdate,this)},scope:this}}})},clear:function(){if(!this.fields){return}this.progressBar.updateProgress(0," ");for(var a in this.fields){this.fields[a].innerHTML=""}},update:function(a){if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Status,{success:this.onRequestComplete,scope:this})},onPanelUpdate:function(b,a){this.fields={};Ext.each(Ext.query("dd",this.status.body.dom),function(c){this.fields[c.className]=c},this)},onRequestComplete:function(a){seeders=a.total_seeds>-1?a.num_seeds+" ("+a.total_seeds+")":a.num_seeds;peers=a.total_peers>-1?a.num_peers+" ("+a.total_peers+")":a.num_peers;var b={downloaded:fsize(a.total_done)+" ("+fsize(a.total_payload_download)+")",uploaded:fsize(a.total_uploaded)+" ("+fsize(a.total_payload_upload)+")",share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:fspeed(a.download_payload_rate),upspeed:fspeed(a.upload_payload_rate),eta:ftime(a.eta),pieces:a.num_pieces+" ("+fsize(a.piece_length)+")",seeders:seeders,peers:peers,avail:a.distributed_copies.toFixed(3),active_time:ftime(a.active_time),seeding_time:ftime(a.seeding_time),seed_rank:a.seed_rank,auto_managed:"False",time_added:fdate(a.time_added)};if(a.is_auto_managed){b.auto_managed="True"}for(var c in this.fields){this.fields[c].innerHTML=b[c]}var d=a.state+" "+a.progress.toFixed(2)+"%";this.progressBar.updateProgress(a.progress,d)}});Deluge.Details.add(new Ext.deluge.details.StatusTab());Ext.deluge.details.DetailsTab=Ext.extend(Ext.Panel,{title:_("Details"),cls:"x-deluge-status",onRender:function(b,a){Ext.deluge.details.DetailsTab.superclass.onRender.call(this,b,a);this.load({url:"/render/tab_details.html",text:_("Loading")+"..."});this.getUpdater().on("update",this.onPanelUpdate,this)},clear:function(){if(!this.fields){return}for(var a in this.fields){this.fields[a].innerHTML=""}},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Details,{success:this.onRequestComplete,scope:this,torrentId:a})},onPanelUpdate:function(b,a){this.fields={};Ext.each(Ext.query("dd",this.body.dom),function(c){this.fields[c.className]=c},this)},onRequestComplete:function(c,a){var b={torrent_name:c.name,hash:a.torrentId,path:c.save_path,size:fsize(c.total_size),files:c.num_files,status:c.tracker_status,tracker:c.tracker,comment:c.comment};for(var d in this.fields){this.fields[d].innerHTML=b[d]}}});Deluge.Details.add(new Ext.deluge.details.DetailsTab());(function(){function b(d){var c=d*100;return Deluge.progressBar(c,this.width-50,c.toFixed(2)+"%")}function a(c){return String.format('
{1}
',FILE_PRIORITY_CSS[c],_(FILE_PRIORITY[c]))}Ext.deluge.details.FilesTab=Ext.extend(Ext.tree.ColumnTree,{constructor:function(c){c=Ext.apply({title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{header:_("Progress"),width:150,dataIndex:"progress",renderer:b},{header:_("Priority"),width:150,dataIndex:"priority",renderer:a}],root:new Ext.tree.TreeNode({text:"Files"})},c);Ext.deluge.details.FilesTab.superclass.constructor.call(this,c)},onRender:function(d,c){Ext.deluge.details.FilesTab.superclass.onRender.call(this,d,c);Deluge.Menus.FilePriorities.on("itemclick",this.onItemClick,this);this.on("contextmenu",this.onContextMenu,this);this.sorter=new Ext.tree.TreeSorter(this,{folderSort:true})},clear:function(){var c=this.getRootNode();if(!c.hasChildNodes()){return}c.cascade(function(e){var d=e.parentNode;if(!d){return}if(!d.ownerTree){return}d.removeChild(e)})},update:function(c){if(this.torrentId!=c){this.clear();this.torrentId=c}Deluge.Client.web.get_torrent_files(c,{success:this.onRequestComplete,scope:this,torrentId:c})},onContextMenu:function(d,f){f.stopEvent();var c=this.getSelectionModel();if(c.getSelectedNodes().length<2){c.clearSelections();d.select()}Deluge.Menus.FilePriorities.showAt(f.getPoint())},onItemClick:function(j,h){switch(j.id){case"expandAll":this.expandAll();break;default:var g={};function c(e){if(!e.attributes.fileIndex){return}g[e.attributes.fileIndex]=e.attributes.priority}this.getRootNode().cascade(c);var d=this.getSelectionModel().getSelectedNodes();Ext.each(d,function(e){if(!e.attributes.fileIndex){return}g[e.attributes.fileIndex]=j.filePriority});alert(Ext.keys(g));priorities=new Array(Ext.keys(g).length);for(var f in g){priorities[f]=g[f]}alert(this.torrentId);alert(priorities);Deluge.Client.core.set_torrent_file_priorities(this.torrentId,priorities,{success:function(){Ext.each(d,function(e){e.setColumnValue(3,j.filePriority)})},scope:this});break}},onRequestComplete:function(f,e){function d(k,h){for(var g in k){var j=k[g];var l=h.findChild("id",g);if(Ext.type(j)=="object"){if(!l){l=new Ext.tree.TreeNode({id:g,text:g});h.appendChild(l)}d(j,l)}else{if(!l){l=new Ext.tree.ColumnTreeNode({id:g,filename:g,text:g,fileIndex:j[0],size:j[1],progress:j[2],priority:j[3],leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});h.appendChild(l)}l.setColumnValue(1,j[1]);l.setColumnValue(2,j[2]);l.setColumnValue(3,j[3])}}}var c=this.getRootNode();d(f,c);c.firstChild.expand()}});Deluge.Details.add(new Ext.deluge.details.FilesTab())})();(function(){function a(e){return String.format('',e)}function c(g,h,f){var e=(f.data.seed==1024)?"x-deluge-seed":"x-deluge-peer";return String.format('
{1}
',e,g)}function d(g){var e=(g*100).toFixed(0);var f=new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]).toFixed(0)-8;return Deluge.progressBar(e,f,e+"%")}function b(g){var e=g.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);var f=0;var h=[e[1],e[2],e[3],e[4]];Ext.each(h,function(k,j){k=parseInt(k);f=f|k<<((3-j)*8)});return f}Ext.deluge.details.PeersTab=Ext.extend(Ext.grid.GridPanel,{constructor:function(e){e=Ext.apply({title:_("Peers"),cls:"x-deluge-peers",store:new Ext.data.SimpleStore({fields:[{name:"country"},{name:"address",sortType:b},{name:"client"},{name:"progress",type:"float"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"seed",type:"int"}],id:0}),columns:[{header:" ",width:30,sortable:true,renderer:a,dataIndex:"country"},{header:"Address",width:125,sortable:true,renderer:c,dataIndex:"address"},{header:"Client",width:125,sortable:true,renderer:fplain,dataIndex:"client"},{header:"Progress",width:150,sortable:true,renderer:d,dataIndex:"progress"},{header:"Down Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"downspeed"},{header:"Up Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"upspeed"}],stripeRows:true,deferredRender:false,autoScroll:true},e);Ext.deluge.details.PeersTab.superclass.constructor.call(this,e)},onRender:function(f,e){Ext.deluge.details.PeersTab.superclass.onRender.call(this,f,e)},clear:function(){this.getStore().loadData([])},update:function(e){Deluge.Client.core.get_torrent_status(e,Deluge.Keys.Peers,{success:this.onRequestComplete,scope:this})},onRequestComplete:function(g,f){var e=new Array();Ext.each(g.peers,function(h){e.push([h.country,h.ip,h.client,h.progress,h.down_speed,h.up_speed,h.seed])},this);this.getStore().loadData(e)}});Deluge.Details.add(new Ext.deluge.details.PeersTab())})();Ext.deluge.details.OptionsTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({autoScroll:true,bodyStyle:"padding: 5px;",border:false,cls:"x-deluge-options",defaults:{autoHeight:true,labelWidth:1,defaultType:"checkbox"},deferredRender:false,layout:"column",title:_("Options")},a);Ext.deluge.details.OptionsTab.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);this.fieldsets={},this.fields={};this.fieldsets.bandwidth=this.add({xtype:"fieldset",defaultType:"uxspinner",bodyStyle:"padding: 5px",layout:"table",layoutConfig:{columns:3},labelWidth:150,style:"margin-left: 10px; margin-right: 5px; padding: 5px",title:_("Bandwidth"),width:300});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Download Speed"),forId:"max_download_speed",cls:"x-deluge-options-label"});this.fields.max_download_speed=this.fieldsets.bandwidth.add({id:"max_download_speed",name:"max_download_speed",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Speed"),forId:"max_upload_speed",cls:"x-deluge-options-label"});this.fields.max_upload_speed=this.fieldsets.bandwidth.add({id:"max_upload_speed",name:"max_upload_speed",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Connections"),forId:"max_connections",cls:"x-deluge-options-label"});this.fields.max_connections=this.fieldsets.bandwidth.add({id:"max_connections",name:"max_connections",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.bandwidth.add({xtype:"label"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Slots"),forId:"max_upload_slots",cls:"x-deluge-options-label"});this.fields.max_upload_slots=this.fieldsets.bandwidth.add({id:"max_upload_slots",name:"max_upload_slots",width:100,value:-1,stragegy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})});this.fieldsets.queue=this.add({xtype:"fieldset",title:_("Queue"),style:"margin-left: 5px; margin-right: 5px; padding: 5px",width:200,defaults:{fieldLabel:"",labelSeparator:""}});this.fields.is_auto_managed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"is_auto_managed",boxLabel:_("Auto Managed")});this.fields.stop_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"stop_at_ratio",boxLabel:_("Stop seed at ratio")});this.fields.remove_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"remove_at_ratio",style:"margin-left: 10px",boxLabel:_("Remove at ratio")});this.fields.move_completed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"move_completed",boxLabel:_("Move Completed")});this.rightColumn=this.add({border:false,autoHeight:true,style:"margin-left: 5px",width:200});this.fieldsets.general=this.rightColumn.add({xtype:"fieldset",autoHeight:true,defaultType:"checkbox",title:_("General"),layout:"form"});this.fields["private"]=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Private"),id:"private"});this.fields.prioritize_first_last=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"});this.buttonPanel=this.rightColumn.add({layout:"column",xtype:"panel",border:false});this.buttonPanel.add({xtype:"panel",border:false}).add({id:"edit_trackers",xtype:"button",text:_("Edit Trackers"),cls:"x-btn-text-icon",iconCls:"x-deluge-edit-trackers",border:false,width:100,handler:this.onEditTrackers,scope:this});this.buttonPanel.add({xtype:"panel",border:false}).add({id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px;",border:false,width:100,});this.disable()},onRender:function(b,a){Ext.deluge.details.OptionsTab.superclass.onRender.call(this,b,a);this.layout=new Ext.layout.ColumnLayout();this.layout.setContainer(this);this.doLayout()},clear:function(){this.fields.max_download_speed.setValue(0);this.fields.max_upload_speed.setValue(0);this.fields.max_connections.setValue(0);this.fields.max_upload_slots.setValue(0);this.fields.is_auto_managed.setValue(false);this.fields.stop_at_ratio.setValue(false);this.fields.remove_at_ratio.setValue(false);this.fields["private"].setValue(false);this.fields.prioritize_first_last.setValue(false)},reset:function(){if(this.torrentId){delete this.changed[this.torrentId]}},update:function(a){this.torrentId=a;Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Options,{success:this.onRequestComplete,scope:this})},onEditTrackers:function(){Deluge.EditTrackers.show()},onRequestComplete:function(c,a){for(var b in c){if(this.fields[b]){this.fields[b].setValue(c[b])}else{}}}});Deluge.Details.add(new Ext.deluge.details.OptionsTab());(function(){Ext.deluge.AddTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Add Tracker"),width:375,height:150,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Ext.deluge.AddTracker.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.AddTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Add"),this.onAdd,this);this.addEvents("add");this.form=this.add({xtype:"form",defaultType:"textarea",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Trackers"),name:"trackers",anchor:"100%"}]})},onCancel:function(){this.form.getForm().findField("trackers").setValue("");this.hide()},onAdd:function(){var b=this.form.getForm().findField("trackers").getValue();b=b.split("\n");var a=[];Ext.each(b,function(c){if(Ext.form.VTypes.url(c)){a.push(c)}},this);this.fireEvent("add",a);this.hide();this.form.getForm().findField("trackers").setValue("")}});Ext.deluge.EditTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Tracker"),width:375,height:110,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Ext.deluge.EditTracker.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.EditTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Save"),this.onSave,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Tracker"),name:"tracker",anchor:"100%"}]})},show:function(a){Ext.deluge.EditTracker.superclass.show.call(this);this.record=a;this.form.getForm().findField("tracker").setValue(a.data.url)},onCancel:function(){this.hide()},onHide:function(){this.form.getForm().findField("tracker").setValue("")},onSave:function(){var a=this.form.getForm().findField("tracker").getValue();this.record.set("url",a);this.record.commit();this.hide()}});Ext.deluge.EditTrackers=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Trackers"),width:350,height:220,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:true},a);Ext.deluge.EditTrackers.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.EditTrackers.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Ok"),this.onOk,this);this.addEvents("save");this.on("show",this.onShow,this);this.on("save",this.onSave,this);this.addWindow=new Ext.deluge.AddTracker();this.addWindow.on("add",this.onAddTrackers,this);this.editWindow=new Ext.deluge.EditTracker();this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"tier",mapping:0},{name:"url",mapping:1}]}),columns:[{header:_("Tier"),width:50,sortable:true,renderer:fplain,dataIndex:"tier"},{id:"tracker",header:_("Tracker"),sortable:true,renderer:fplain,dataIndex:"url"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:{fn:this.onSelect,scope:this}}}),autoExpandColumn:"tracker",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",text:_("Up"),icon:"/icons/up.png",handler:this.onUp,scope:this},{cls:"x-btn-text-icon",text:_("Down"),icon:"/icons/down.png",handler:this.onDown,scope:this},"->",{cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAdd,scope:this},{cls:"x-btn-text-icon",text:_("Edit"),icon:"/icons/edit_trackers.png",handler:this.onEdit,scope:this},{cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this}]})})},onAdd:function(){this.addWindow.show()},onAddTrackers:function(b){var a=this.grid.getStore();Ext.each(b,function(d){var e=false,c=-1;a.each(function(f){if(f.get("tier")>c){c=f.get("tier")}if(d==f.get("tracker")){e=true;return false}},this);if(!e){a.loadData([[c+1,d]],true)}},this)},onCancel:function(){this.hide()},onEdit:function(){var a=this.grid.getSelectionModel().getSelected();this.editWindow.show(a)},onHide:function(){this.grid.getStore().removeAll()},onOk:function(){var a=[];this.grid.getStore().each(function(b){a.push({tier:b.get("tier"),url:b.get("url")})},this);Deluge.Client.core.set_torrent_trackers(this.torrentId,a,{failure:this.onSaveFail,scope:this});this.hide()},onRemove:function(){var a=this.grid.getSelectionModel().getSelected();this.grid.getStore().remove(a)},onRequestComplete:function(a){var b=[];Ext.each(a.trackers,function(c){b.push([c.tier,c.url])});this.grid.getStore().loadData(b)},onSaveFail:function(){},onSelect:function(a){if(a.hasSelection()){this.grid.getBottomToolbar().items.get(4).enable()}},onShow:function(){this.grid.getBottomToolbar().items.get(4).disable();var a=Deluge.Torrents.getSelected();this.torrentId=a.id;Deluge.Client.core.get_torrent_status(a.id,["trackers"],{success:this.onRequestComplete,scope:this})}});Deluge.EditTrackers=new Ext.deluge.EditTrackers()})();Deluge.Keys={Grid:["queue","name","total_size","state","progress","num_seeds","total_seeds","num_peers","total_peers","download_payload_rate","upload_payload_rate","eta","ratio","distributed_copies","is_auto_managed","time_added","tracker_host"],Status:["total_done","total_payload_download","total_uploaded","total_payload_upload","next_announce","tracker_status","num_pieces","piece_length","is_auto_managed","active_time","seeding_time","seed_rank"],Files:["files","file_progress","file_priorities"],Peers:["peers","seeds"],Details:["name","save_path","total_size","num_files","tracker_status","tracker","comment"],Options:["max_download_speed","max_upload_speed","max_connections","max_upload_slots","is_auto_managed","stop_at_ratio","stop_ratio","remove_at_ratio","private","prioritize_first_last"]};Ext.each(Deluge.Keys.Grid,function(a){Deluge.Keys.Status.push(a)});(function(){Ext.deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,constructor:function(a){a=Ext.apply({layout:"fit",width:300,height:120,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",closable:false,modal:true,plain:true,resizable:false,title:_("Login"),iconCls:"x-deluge-login-window-icon"},a);Ext.deluge.LoginWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.LoginWindow.superclass.initComponent.call(this);Deluge.Events.on("logout",this.onLogout,this);this.on("show",this.onShow,this);this.on("beforeshow",this.onBeforeShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.loginForm=this.add({xtype:"form",defaultType:"textfield",id:"loginForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Password"),id:"password",name:"password",inputType:"password",anchor:"100%",listeners:{specialkey:{fn:this.onKey,scope:this}}}]})},onKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.loginForm.items.get("password");Deluge.Client.auth.login(a.getValue(),{success:function(b){if(b){Deluge.Events.fire("login");this.hide();a.setRawValue("");Deluge.UI.cookies.set("session",b)}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){a.focus()},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}},scope:this})},onLogout:function(){var a=Deluge.UI.cookies.get("session",false);if(a){Deluge.Client.auth.delete_session(a,{success:function(b){Deluge.UI.cookies.clear("session");this.show()},scope:this})}},onBeforeShow:function(){var a=Deluge.UI.cookies.get("session",false);if(a){Deluge.Client.auth.check_session(a,{success:function(b){if(b){Deluge.Events.fire("login");this.loginForm.items.get("password").setRawValue("");this.hide()}else{Deluge.UI.cookies.clear("session");this.show()}},failure:function(b){Deluge.UI.cookies.clear("session");this.show()},scope:this});return false}},onShow:function(){var a=this.loginForm.items.get("password");a.focus(false,150)}});Deluge.Login=new Ext.deluge.LoginWindow()})();(function(){Ext.deluge.PreferencesWindow=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({layout:"border",width:485,height:500,buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-preferences",plain:true,resizable:true,title:_("Preferences"),buttons:[{text:_("Close"),handler:this.onCloseButtonClick,scope:this},{text:_("Apply")},{text:_("Ok")}],currentPage:false,items:[{xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.SimpleStore({fields:[{name:"name",mapping:0}]}),columns:[{id:"name",renderer:fplain,dataIndex:"name"}],sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPageSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 0 5 5",cmargins:"5 0 5 5",width:120,collapsible:true},{region:"center",header:false,layout:"fit",height:400,margins:"5 5 5 5",cmargins:"5 5 5 5"}]},a);Ext.deluge.PreferencesWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.items.get(0);this.configPanel=this.items.get(1);this.pages={};this.on("show",this.onShow,this)},onCloseButtonClick:function(){this.hide()},addPage:function(c){var a=this.categoriesGrid.getStore();var b=c.title;a.loadData([[b]],true);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);this.pages[b].hide()},onPageSelect:function(a,d,c){if(this.currentPage){this.currentPage.hide()}var b=c.get("name");this.pages[b].show();this.currentPage=this.pages[b];this.configPanel.doLayout()},onShow:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}}});Deluge.Preferences=new Ext.deluge.PreferencesWindow()})();Deluge.Preferences.addPage({border:false,title:_("Downloads"),xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Folders"),labelWidth:140,defaultType:"textfield",autoHeight:true,items:[{name:"download_location",fieldLabel:_("Download to"),width:125},{name:"move_completed",fieldLabel:_("Move completed to"),width:125},{name:"copy_torrent_files",fieldLabel:_("Copy of .torrent files to"),width:125}]},{xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radio",items:[{name:"compact_allocation",labelSeparator:"",boxLabel:_("Compact")},{name:"compact_allocation",labelSeparator:"",boxLabel:_("Full")}]},{xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{name:"prioritize_first_last",labelSeparator:"",boxLabel:_("Prioritize first and last pieces of torrent")},{name:"add_paused",labelSeparator:"",boxLabel:_("Add torrents in Paused state")}]}]});Deluge.Preferences.addPage({border:false,title:_("Bandwidth"),xtype:"form",layout:"form",labelWidth:10,items:[{xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),autoHeight:true,labelWidth:200,style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"uxspinner",items:[{name:"max_connections",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1},{name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:60,value:-1},{name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:60,value:-1}]},{xtype:"fieldset",border:false,title:"",autoHeight:true,style:"padding-top: 0px; margin-top: 0px; margin-bottom: 0px;",items:[{xtype:"checkbox",name:"ignore_local",fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),value:-1},{xtype:"checkbox",name:"limit_ip_overhead",fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),value:-1}]},{xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),autoHeight:true,labelWidth:200,defaultType:"uxspinner",items:[{name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1}]}]});Deluge.Preferences.addPage({border:false,title:_("Interface"),xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Window"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar"),id:"show_session_speed"}]},{xtype:"fieldset",border:false,title:_("Sidebar"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Hide filters with zero torrents"),id:"hide_sidebar_zero"}]},{xtype:"fieldset",border:false,title:_("Password"),autoHeight:true,defaultType:"textfield",items:[{fieldLabel:"New Password",inputType:"password",id:"new_password"},{inputType:"password",fieldLabel:"Confirm Password",id:"confirm_password"}]}]});Deluge.Preferences.addPage({border:false,title:_("Daemon"),xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"uxspinner",items:[{fieldLabel:_("Daemon port"),id:"daemon_port"}]},{xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Allow Remote Connections"),id:"allow_remote"}]},{xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_releases"}]}]});(function(){function a(d,f,c){var b=d.toLowerCase().replace(".","_");var e="";if(c.store.id=="tracker_host"){if(d!="Error"){e=String.format("url(/tracker/{0})",d)}else{b=null}}if(e){return String.format('
{0} ({1})
',d,c.data.count,e)}else{if(b){return String.format('
{0} ({1})
',d,c.data.count,b)}else{return String.format('
{0} ({1})
',d,c.data.count)}}}Ext.deluge.Sidebar=Ext.extend(Ext.Panel,{panels:{},selected:null,constructor:function(b){b=Ext.apply({id:"sidebar",region:"west",cls:"deluge-sidebar",title:_("Filters"),layout:"accordion",split:true,width:200,minSize:175,collapsible:true,margins:"5 0 0 5",cmargins:"5 0 0 5"},b);Ext.deluge.Sidebar.superclass.constructor.call(this,b)},initComponent:function(){Ext.deluge.Sidebar.superclass.initComponent.call(this);Deluge.Events.on("disconnect",this.onDisconnect,this)},createFilter:function(e,d){var c=new Ext.data.SimpleStore({id:e,fields:[{name:"filter"},{name:"count"}]});var g=e.replace("_"," ");var f=g.split(" ");g="";Ext.each(f,function(h){firstLetter=h.substring(0,1);firstLetter=firstLetter.toUpperCase();h=firstLetter+h.substring(1);g+=h+" "});var b=new Ext.grid.GridPanel({id:e+"-panel",store:c,title:_(g),columns:[{id:"filter",sortable:false,renderer:a,dataIndex:"filter"}],stripeRows:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onFilterSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"filter",deferredRender:false,autoScroll:true});c.loadData(d);this.add(b);this.doLayout();this.panels[e]=b;if(!this.selected){b.getSelectionModel().selectFirstRow();this.selected={row:0,filter:d[0][0],panel:b}}},getFilters:function(){var c={};if(!this.selected){return c}if(!this.selected.filter||!this.selected.panel){return c}var b=this.selected.panel.store.id;if(b=="state"&&this.selected.filter=="All"){return c}c[b]=this.selected.filter;return c},onDisconnect:function(){Ext.each(Ext.getKeys(this.panels),function(b){this.remove(b+"-panel")},this);this.panels={};this.selected=null},onFilterSelect:function(c,d,b){if(!this.selected){needsUpdate=true}else{if(this.selected.row!=d){needsUpdate=true}else{needsUpdate=false}}this.selected={row:d,filter:b.get("filter"),panel:this.panels[b.store.id]};if(needsUpdate){Deluge.UI.update()}},update:function(d){for(var c in d){var b=d[c];if(Ext.getKeys(this.panels).indexOf(c)>-1){this.updateFilter(c,b)}else{this.createFilter(c,b)}}Ext.each(Ext.keys(this.panels),function(e){if(Ext.keys(d).indexOf(e)==-1){}})},updateFilter:function(c,b){this.panels[c].store.loadData(b);if(this.selected&&this.selected.panel==this.panels[c]){this.panels[c].getSelectionModel().selectRow(this.selected.row)}}});Deluge.Sidebar=new Ext.deluge.Sidebar()})();(function(){Ext.deluge.Statusbar=Ext.extend(Ext.StatusBar,{constructor:function(a){a=Ext.apply({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected")},a);Ext.deluge.Statusbar.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.Statusbar.superclass.initComponent.call(this);Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("disconnect",this.onDisconnect,this)},createButtons:function(){this.add({id:"statusbar-connections",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",menu:Deluge.Menus.Connections},"-",{id:"statusbar-downspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",menu:Deluge.Menus.Download},"-",{id:"statusbar-upspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",menu:Deluge.Menus.Upload},"-",{id:"statusbar-traffic",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic"},"-",{id:"statusbar-dht",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-dht"});this.created=true},onConnect:function(){this.setStatus({iconCls:"x-connected",text:""});if(!this.created){this.createButtons()}else{this.items.each(function(a){a.show();a.enable()})}},onDisconnect:function(){this.clearStatus({useDefaults:true});this.items.each(function(a){a.hide();a.disable()})},update:function(b){function d(e){return e+" KiB/s"}var a=function(g,f){var h=this.items.get("statusbar-"+g);if(f.limit.value==-1){var k=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value}else{var j=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value;var e=(f.limit.formatter)?f.limit.formatter(f.limit.value):f.limit.value;var k=String.format(f.format,j,e)}h.setText(k)}.bind(this);a("connections",{value:{value:b.num_connections},limit:{value:b.max_num_connections},format:"{0} ({1})"});a("downspeed",{value:{value:b.download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_download,formatter:d},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:d},format:"{0} ({1})"});a("traffic",{value:{value:b.payload_download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.payload_upload_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.items.get("statusbar-dht").setText(b.dht_nodes);function c(g,e){var f=g.items.get(e);if(!f){f=g.items.get("other")}f.setChecked(true)}c(Deluge.Menus.Connections,b.max_num_connections);c(Deluge.Menus.Download,b.max_download);c(Deluge.Menus.Upload,b.max_upload)}});Deluge.Statusbar=new Ext.deluge.Statusbar()})();(function(){Ext.deluge.Toolbar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=Ext.apply({items:[{id:"create",cls:"x-btn-text-icon",disabled:true,text:_("Create"),icon:"/icons/create.png",handler:this.onTorrentAction},{id:"add",cls:"x-btn-text-icon",disabled:true,text:_("Add"),icon:"/icons/add.png",handler:this.onTorrentAdd},{id:"remove",cls:"x-btn-text-icon",disabled:true,text:_("Remove"),icon:"/icons/remove.png",handler:this.onTorrentAction},"|",{id:"pause",cls:"x-btn-text-icon",disabled:true,text:_("Pause"),icon:"/icons/pause.png",handler:this.onTorrentAction},{id:"resume",cls:"x-btn-text-icon",disabled:true,text:_("Resume"),icon:"/icons/start.png",handler:this.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),icon:"/icons/up.png",handler:this.onTorrentAction},{id:"down",cls:"x-btn-text-icon",disabled:true,text:_("Down"),icon:"/icons/down.png",handler:this.onTorrentAction},"|",{id:"preferences",cls:"x-btn-text-icon",text:_("Preferences"),icon:"/icons/preferences.png",handler:this.onPreferencesClick,scope:this},{id:"connectionman",cls:"x-btn-text-icon",text:_("Connection Manager"),iconCls:"x-deluge-connections",handler:this.onConnectionManagerClick,scope:this},"->",{id:"help",cls:"x-btn-text-icon",disabled:true,icon:"/icons/help.png",text:_("Help"),handler:this.onHelpClick,scope:this},{id:"logout",cls:"x-btn-text-icon",icon:"/icons/logout.png",disabled:true,text:_("Logout"),handler:this.onLogout,scope:this}]},a);Ext.deluge.Toolbar.superclass.constructor.call(this,a)},connectedButtons:["add","remove","pause","resume","up","down"],initComponent:function(){Ext.deluge.Toolbar.superclass.initComponent.call(this);Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("login",this.onLogin,this)},onConnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).enable()},this)},onDisconnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).disable()},this)},onLogin:function(){this.items.get("logout").enable()},onLogout:function(){this.items.get("logout").disable();Deluge.Events.fire("logout");Deluge.Login.show()},onConnectionManagerClick:function(){Deluge.ConnectionManager.show()},onPreferencesClick:function(){Deluge.Preferences.show()},onTorrentAction:function(c){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(d){a.push(d.id)});switch(c.id){case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{success:function(){Deluge.UI.update()}});break;case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"up":case"down":Deluge.Client.core["queue_"+c.id](a,{success:function(){Deluge.UI.update()}});break}},onTorrentAdd:function(){Deluge.Add.show()}});Deluge.Toolbar=new Ext.deluge.Toolbar()})();(function(){function f(j){return(j==-1)?"":j+1}function b(k,l,j){return String.format('
{1}
',j.data.state.toLowerCase(),k)}function h(j){if(!j){return}return fspeed(j)}function c(m,n,l){m=new Number(m);var j=m;var o=l.data.state+" "+m.toFixed(2)+"%";var k=new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1])-8;return Deluge.progressBar(m,k,o)}function e(k,l,j){if(j.data.total_seeds>-1){return String.format("{0} ({1})",k,j.data.total_seeds)}else{return k}}function g(k,l,j){if(j.data.total_peers>-1){return String.format("{0} ({1})",k,j.data.total_peers)}else{return k}}function d(k,l,j){return new Number(k).toFixed(3)}function a(k,l,j){return String.format('
{0}
',k)}Ext.deluge.TorrentGrid=Ext.extend(Ext.grid.GridPanel,{constructor:function(j){j=Ext.apply({id:"torrentGrid",store:new Ext.data.SimpleStore({fields:[{name:"queue"},{name:"name"},{name:"size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"peers",type:"int"},{name:"total_peers",type:"int"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"avail",type:"float"},{name:"added",type:"int"},{name:"tracker"}],id:16}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:f,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:b,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"size"},{header:_("Progress"),width:150,sortable:true,renderer:c,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:e,dataIndex:"seeds"},{header:_("Peers"),width:60,sortable:true,renderer:g,dataIndex:"peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:h,dataIndex:"downspeed"},{header:_("Up Speed"),width:80,sortable:true,renderer:h,dataIndex:"upspeed"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:d,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:d,dataIndex:"avail"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"added"},{header:_("Tracker"),width:120,sortable:true,renderer:a,dataIndex:"tracker"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0"},j);Ext.deluge.TorrentGrid.superclass.constructor.call(this,j)},initComponent:function(){Ext.deluge.TorrentGrid.superclass.initComponent.call(this);Deluge.Events.on("torrentRemoved",this.onTorrentRemoved,this);this.on("rowcontextmenu",function(j,m,l){l.stopEvent();var k=j.getSelectionModel();if(!k.hasSelection()){k.selectRow(m)}Deluge.Menus.Torrent.showAt(l.getPoint())})},getTorrent:function(j){return this.getStore().getAt(j)},getSelected:function(){return this.getSelectionModel().getSelected()},getSelections:function(){return this.getSelectionModel().getSelections()},update:function(n){var l=this.getStore();for(var k in n){var j=l.getById(k);var p=n[k];if(!j){var o=[p.queue,p.name,p.total_size,p.state,p.progress,p.num_seeds,p.total_seeds,p.num_peers,p.total_peers,p.download_payload_rate,p.upload_payload_rate,p.eta,p.ratio,p.distributed_copies,p.time_added,p.tracker_host,k];l.loadData([o],true)}else{j.set("queue",p.queue);j.set("name",p.name);j.set("size",p.total_size);j.set("state",p.state);j.set("progress",p.progress);j.set("seeds",p.num_seeds);j.set("total_seeds",p.total_seeds);j.set("peers",p.num_peers);j.set("total_peers",p.total_peers);j.set("downspeed",p.download_payload_rate);j.set("upspeed",p.upload_payload_rate);j.set("eta",p.eta);j.set("ratio",p.ratio);j.set("avail",p.distributed_copies);j.set("added",p.time_added);j.set("tracker",p.tracker_host);j.commit()}}var m=Ext.keys(n);l.each(function(q){if(m.indexOf(q.id)==-1){l.remove(q)}},this)},onTorrentRemoved:function(k){var j=this.getSelectionModel();Ext.each(k,function(m){var l=this.getStore().getById(m);if(j.isSelected(l)){j.deselectRow(this.getStore().indexOf(l))}this.getStore().remove(l)},this)}});Deluge.Torrents=new Ext.deluge.TorrentGrid()})();Deluge.UI={cookies:new Ext.state.CookieProvider(),errorCount:0,initialize:function(){Ext.state.Manager.setProvider(this.cookies);this.MainPanel=new Ext.Panel({id:"mainPanel",iconCls:"x-deluge-main-panel",title:"Deluge",layout:"border",tbar:Deluge.Toolbar,items:[Deluge.Sidebar,Deluge.Details,Deluge.Torrents],bbar:Deluge.Statusbar});this.Viewport=new Ext.Viewport({layout:"fit",items:[this.MainPanel]});Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("disconnect",this.onDisconnect,this);Deluge.Client=new Ext.ux.util.RpcClient({url:"/json"});Deluge.Client.on("connected",function(a){Deluge.Login.show()});this.update=this.update.bind(this)},update:function(){var a=Deluge.Sidebar.getFilters();Deluge.Client.web.update_ui(Deluge.Keys.Grid,a,{success:this.onUpdate,failure:this.onUpdateError,scope:this});Deluge.Details.update();Deluge.Client.web.connected({success:this.onConnectedCheck,scope:this})},onConnectedCheck:function(a){if(!a){Deluge.Events.fire("disconnect")}},onUpdateError:function(a){if(this.errorCount==2){Ext.MessageBox.show({title:"Lost Connection",msg:"The connection to the webserver has been lost!",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}this.errorCount++},onUpdate:function(a){Deluge.Torrents.update(a.torrents);Deluge.Statusbar.update(a.stats);Deluge.Sidebar.update(a.filters);this.errorCount=0},onConnect:function(){if(!this.running){this.running=setInterval(this.update,2000);this.update()}},onDisconnect:function(){this.stop()},stop:function(){if(this.running){clearInterval(this.running);this.running=false;Deluge.Torrents.getStore().loadData([])}}};Ext.onReady(function(a){Deluge.UI.initialize()}); \ No newline at end of file