diff --git a/deluge/ui/web/js/deluge-all-debug.js b/deluge/ui/web/js/deluge-all-debug.js
index 8529899af..c242a1974 100644
--- a/deluge/ui/web/js/deluge-all-debug.js
+++ b/deluge/ui/web/js/deluge-all-debug.js
@@ -31,13 +31,14 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-// Create the namespace Ext.deluge
-Ext.namespace('Ext.deluge');
// Setup the state manager
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
+// Add some additional functions to ext and setup some of the
+// configurable parameters
(function() {
+
Ext.apply(Ext, {
escapeHTML: function(text) {
text = String(text).replace('<', '<').replace('>', '>');
@@ -85,34 +86,48 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
}
});
Ext.getKeys = Ext.keys;
- Ext.BLANK_IMAGE_URL = '/images/s.gif';
+ Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif';
Ext.USE_NATIVE_JSON = true;
})();
-(function() {
- var tpl = '
';
+// Create the Deluge namespace
+Deluge = {
- Deluge.progressBar = function(progress, width, text, modifier) {
+ // private
+ progressTpl: '',
+
+
+ /**
+ * A method to create a progress bar that can be used by renderers
+ * to display a bar within a grid or tree.
+ * @param {Number} progress The bars progress
+ * @param {Number} width The width of the bar
+ * @param {String} text The text to display on the bar
+ * @param {Number} modified Amount to subtract from the width allowing for fixes
+ */
+ progressBar: function(progress, width, text, modifier) {
modifier = Ext.value(modifier, 10);
var progressWidth = ((width / 100.0) * progress).toFixed(0);
var barWidth = progressWidth - 1;
var textWidth = ((progressWidth - modifier) > 0 ? progressWidth - modifier : 0);
- return String.format(tpl, text, width, barWidth, textWidth);
+ return String.format(Deluge.progressTpl, text, width, barWidth, textWidth);
}
- Deluge.Plugins = {};
-})();
+}
+
+// Setup a space for plugins to insert themselves
+deluge.plugins = {};
// Hinting for gettext_gen.py
// _('Do Not Download')
@@ -205,10 +220,11 @@ Deluge.Formatters = {
* Formats the bytes value into a string with KiB, MiB or GiB units.
*
* @param {Number} bytes the filesize in bytes
+ * @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with KiB, MiB or GiB units.
*/
- size: function(bytes) {
- if (!bytes) return '';
+ size: function(bytes, showZero) {
+ if (!bytes && !showZero) return '';
bytes = bytes / 1024.0;
if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; }
@@ -224,10 +240,11 @@ Deluge.Formatters = {
* Formats a string to display a transfer speed utilizing {@link #size}
*
* @param {Number} bits the number of bits per second
+ * @param {Boolean} showZero pass in true to displays 0 values
* @return {String} formatted string with KiB, MiB or GiB units.
*/
- speed: function(bits) {
- return (!bits) ? '' : fsize(bits) + '/s';
+ speed: function(bits, showZero) {
+ return (!bits && !showZero) ? '' : fsize(bits, showZero) + '/s';
},
/**
@@ -399,7 +416,7 @@ Ext.each(Deluge.Keys.Grid, function(key) {
Deluge.Keys.Status.push(key);
});
/*
-Script: deluge-menus.js
+Script: deluge.menus.js
Contains all the menus contained within the UI for easy access and editing.
Copyright:
@@ -432,9 +449,9 @@ Copyright:
*/
-Deluge.Menus = {
+deluge.menus = {
onTorrentAction: function(item, e) {
- var selection = Deluge.Torrents.getSelections();
+ var selection = deluge.torrents.getSelections();
var ids = [];
Ext.each(selection, function(record) {
ids.push(record.id);
@@ -444,9 +461,9 @@ Deluge.Menus = {
switch (action) {
case 'pause':
case 'resume':
- Deluge.Client.core[action + '_torrent'](ids, {
+ deluge.client.core[action + '_torrent'](ids, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
break;
@@ -454,53 +471,53 @@ Deluge.Menus = {
case 'up':
case 'down':
case 'bottom':
- Deluge.Client.core['queue_' + action](ids, {
+ deluge.client.core['queue_' + action](ids, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
break;
case 'edit_trackers':
- Deluge.EditTrackers.show();
+ deluge.editTrackers.show();
break;
case 'update':
- Deluge.Client.core.force_reannounce(ids, {
+ deluge.client.core.force_reannounce(ids, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
break;
case 'remove':
- Deluge.RemoveWindow.show(ids);
+ deluge.removeWindow.show(ids);
break;
case 'recheck':
- Deluge.Client.core.force_recheck(ids, {
+ deluge.client.core.force_recheck(ids, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
break;
case 'move':
- Deluge.MoveStorage.show(ids);
+ deluge.moveStorage.show(ids);
break;
}
}
}
-Deluge.Menus.Torrent = new Ext.menu.Menu({
+deluge.menus.torrent = new Ext.menu.Menu({
id: 'torrentMenu',
items: [{
torrentAction: 'pause',
text: _('Pause'),
iconCls: 'icon-pause',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}, {
torrentAction: 'resume',
text: _('Resume'),
iconCls: 'icon-resume',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}, '-', {
text: _('Options'),
iconCls: 'icon-options',
@@ -561,7 +578,7 @@ Deluge.Menus.Torrent = new Ext.menu.Menu({
})
}, {
text: _('Upload Slot Limit'),
- icon: '/icons/upload_slots.png',
+ iconCls: 'icon-upload-slots',
menu: new Ext.menu.Menu({
items: [{
text: _('0')
@@ -591,160 +608,178 @@ Deluge.Menus.Torrent = new Ext.menu.Menu({
torrentAction: 'top',
text: _('Top'),
iconCls: 'icon-top',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
},{
torrentAction: 'up',
text: _('Up'),
iconCls: 'icon-up',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
},{
torrentAction: 'down',
text: _('Down'),
iconCls: 'icon-down',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
},{
torrentAction: 'bottom',
text: _('Bottom'),
iconCls: 'icon-bottom',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}]
})
}, '-', {
torrentAction: 'update',
text: _('Update Tracker'),
iconCls: 'icon-update-tracker',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}, {
torrentAction: 'edit_trackers',
text: _('Edit Trackers'),
iconCls: 'icon-edit-trackers',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}, '-', {
torrentAction: 'remove',
text: _('Remove Torrent'),
iconCls: 'icon-remove',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}, '-', {
torrentAction: 'recheck',
text: _('Force Recheck'),
iconCls: 'icon-recheck',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}, {
torrentAction: 'move',
text: _('Move Storage'),
iconCls: 'icon-move',
- handler: Deluge.Menus.onTorrentAction,
- scope: Deluge.Menus
+ handler: deluge.menus.onTorrentAction,
+ scope: deluge.menus
}]
});
-Ext.deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
+Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
setValue: function(value) {
+ var beenSet = false;
+ // set the new value
value = (value == 0) ? -1 : value;
- var item = this.items.get(value);
- if (!item) item = this.items.get('other')
+
+ // uncheck all items
+ this.items.each(function(item) {
+ if (item.setChecked) {
+ item.suspendEvents();
+ if (item.value == value) {
+ item.setChecked(true);
+ beenSet = true;
+ } else {
+ item.setChecked(false);
+ }
+ item.resumeEvents();
+ }
+ });
+
+ if (beenSet) return;
+
+ var item = this.items.get('other');
item.suspendEvents();
item.setChecked(true);
item.resumeEvents();
}
});
-Deluge.Menus.Connections = new Ext.deluge.StatusbarMenu({
+deluge.menus.connections = new Deluge.StatusbarMenu({
id: 'connectionsMenu',
items: [{
- id: '50',
text: '50',
+ value: '50',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
},{
- id: '100',
text: '100',
+ value: '100',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
},{
- id: '200',
text: '200',
+ value: '200',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
},{
- id: '300',
text: '300',
+ value: '300',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
},{
- id: '500',
text: '500',
+ value: '500',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
},{
- id: '-1',
text: _('Unlimited'),
+ value: '-1',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
},'-',{
- id: 'other',
text: _('Other'),
+ value: 'other',
group: 'max_connections_global',
checked: false,
checkHandler: onLimitChanged
}]
});
-Deluge.Menus.Download = new Ext.deluge.StatusbarMenu({
+deluge.menus.download = new Deluge.StatusbarMenu({
id: 'downspeedMenu',
items: [{
- id: '5',
+ value: '5',
text: '5 KiB/s',
group: 'max_download_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '10',
+ value: '10',
text: '10 KiB/s',
group: 'max_download_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '30',
+ value: '30',
text: '30 KiB/s',
group: 'max_download_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '80',
+ value: '80',
text: '80 KiB/s',
group: 'max_download_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '300',
+ value: '300',
text: '300 KiB/s',
group: 'max_download_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '-1',
+ value: '-1',
text: _('Unlimited'),
group: 'max_download_speed',
checked: false,
checkHandler: onLimitChanged
},'-',{
- id: 'other',
+ value: 'other',
text: _('Other'),
group: 'max_download_speed',
checked: false,
@@ -752,46 +787,46 @@ Deluge.Menus.Download = new Ext.deluge.StatusbarMenu({
}]
});
-Deluge.Menus.Upload = new Ext.deluge.StatusbarMenu({
+deluge.menus.upload = new Deluge.StatusbarMenu({
id: 'upspeedMenu',
items: [{
- id: '5',
+ value: '5',
text: '5 KiB/s',
group: 'max_upload_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '10',
+ value: '10',
text: '10 KiB/s',
group: 'max_upload_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '30',
+ value: '30',
text: '30 KiB/s',
group: 'max_upload_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '80',
+ value: '80',
text: '80 KiB/s',
group: 'max_upload_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '300',
+ value: '300',
text: '300 KiB/s',
group: 'max_upload_speed',
checked: false,
checkHandler: onLimitChanged
},{
- id: '-1',
+ value: '-1',
text: _('Unlimited'),
group: 'max_upload_speed',
checked: false,
checkHandler: onLimitChanged
},'-',{
- id: 'other',
+ value: 'other',
text: _('Other'),
group: 'max_upload_speed',
checked: false,
@@ -799,49 +834,49 @@ Deluge.Menus.Upload = new Ext.deluge.StatusbarMenu({
}]
});
-Deluge.Menus.FilePriorities = new Ext.menu.Menu({
+deluge.menus.filePriorities = new Ext.menu.Menu({
id: 'filePrioritiesMenu',
items: [{
id: 'expandAll',
text: _('Expand All'),
- icon: '/icons/expand_all.png'
+ iconCls: 'icon-expand-all'
}, '-', {
id: 'no_download',
text: _('Do Not Download'),
- icon: '/icons/no_download.png',
+ iconCls: 'icon-do-not-download',
filePriority: 0
}, {
id: 'normal',
text: _('Normal Priority'),
- icon: '/icons/normal.png',
+ iconCls: 'icon-normal',
filePriority: 1
}, {
id: 'high',
text: _('High Priority'),
- icon: '/icons/high.png',
+ iconCls: 'icon-high',
filePriority: 2
}, {
id: 'highest',
text: _('Highest Priority'),
- icon: '/icons/highest.png',
+ iconCls: 'icon-highest',
filePriority: 5
}]
});
function onLimitChanged(item, checked) {
- if (item.id == "other") {
+ if (item.value == "other") {
} else {
config = {}
- config[item.group] = item.id
- Deluge.Client.core.set_config(config, {
+ config[item.group] = item.value
+ deluge.client.core.set_config(config, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
}
}
/*
-Script: Deluge.Events.js
+Script: Deluge.EventsManager.js
Class for holding global events that occur within the UI.
Copyright:
@@ -873,100 +908,98 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-(function() {
+/**
+ * @class Deluge.EventsManager
+ * @extends Ext.util.Observable
+ * Deluge.EventsManager is instantated as deluge.events and can be used by components of the UI to fire global events
+ * Class for holding global events that occur within the UI.
+ */
+Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
+ constructor: function() {
+ this.toRegister = [];
+ this.on('login', this.onLogin, this);
+ Deluge.EventsManager.superclass.constructor.call(this);
+ },
+
/**
- * @class Deluge.Events
- * Deluge.Events is a singleton that components of the UI can use to fire global events
- * @singleton
- * Class for holding global events that occur within the UI.
+ * Append an event handler to this object.
*/
- Events = Ext.extend(Ext.util.Observable, {
- constructor: function() {
- this.toRegister = [];
- this.on('login', this.onLogin, this);
- Events.superclass.constructor.call(this);
- },
-
- /**
- * Append an event handler to this object.
- */
- addListener: function(eventName, fn, scope, o) {
- this.addEvents(eventName);
- if (/[A-Z]/.test(eventName.substring(0, 1))) {
- if (!Deluge.Client) {
- this.toRegister.push(eventName);
- } else {
- Deluge.Client.web.register_event_listener(eventName);
- }
+ addListener: function(eventName, fn, scope, o) {
+ this.addEvents(eventName);
+ if (/[A-Z]/.test(eventName.substring(0, 1))) {
+ if (!deluge.client) {
+ this.toRegister.push(eventName);
+ } else {
+ deluge.client.web.register_event_listener(eventName);
}
- Events.superclass.addListener.call(this, eventName, fn, scope, o);
- },
-
- getEvents: function() {
- Deluge.Client.web.get_events({
- success: this.onGetEventsSuccess,
- failure: this.onGetEventsFailure,
- scope: this
- });
- },
-
- /**
- * Starts the EventsManager checking for events.
- */
- start: function() {
- Ext.each(this.toRegister, function(eventName) {
- Deluge.Client.web.register_event_listener(eventName);
- });
- this.running = true;
- this.getEvents();
- },
-
- /**
- * Stops the EventsManager checking for events.
- */
- stop: function() {
- this.running = false;
- },
-
- // private
- onLogin: function() {
- this.start();
- this.on('PluginEnabledEvent', this.onPluginEnabled, this);
- this.on('PluginDisabledEvent', this.onPluginDisabled, this);
- },
-
- onGetEventsSuccess: function(events) {
- if (!events) return;
- Ext.each(events, function(event) {
- var name = event[0], args = event[1];
- args.splice(0, 0, name);
- this.fireEvent.apply(this, args);
- }, this);
- if (this.running) this.getEvents();
- },
-
- // private
- onGetEventsFailure: function(events) {
- // the request timed out so we just want to open up another
- // one.
- if (this.running) this.getEvents();
}
- });
+ Deluge.EventsManager.superclass.addListener.call(this, eventName, fn, scope, o);
+ },
+
+ getEvents: function() {
+ deluge.client.web.get_events({
+ success: this.onGetEventsSuccess,
+ failure: this.onGetEventsFailure,
+ scope: this
+ });
+ },
/**
- * Appends an event handler to this object (shorthand for {@link #addListener})
- * @method
+ * Starts the EventsManagerManager checking for events.
*/
- Events.prototype.on = Events.prototype.addListener
+ start: function() {
+ Ext.each(this.toRegister, function(eventName) {
+ deluge.client.web.register_event_listener(eventName);
+ });
+ this.running = true;
+ this.getEvents();
+ },
/**
- * Fires the specified event with the passed parameters (minus the
- * event name).
- * @method
+ * Stops the EventsManagerManager checking for events.
*/
- Events.prototype.fire = Events.prototype.fireEvent
- Deluge.Events = new Events();
-})();
+ stop: function() {
+ this.running = false;
+ },
+
+ // private
+ onLogin: function() {
+ this.start();
+ this.on('PluginEnabledEvent', this.onPluginEnabled, this);
+ this.on('PluginDisabledEvent', this.onPluginDisabled, this);
+ },
+
+ onGetEventsSuccess: function(events) {
+ if (!events) return;
+ Ext.each(events, function(event) {
+ var name = event[0], args = event[1];
+ args.splice(0, 0, name);
+ this.fireEvent.apply(this, args);
+ }, this);
+ if (this.running) this.getEvents();
+ },
+
+ // private
+ onGetEventsFailure: function(events) {
+ // the request timed out so we just want to open up another
+ // one.
+ if (this.running) this.getEvents();
+ }
+});
+
+/**
+ * Appends an event handler to this object (shorthand for {@link #addListener})
+ * @method
+ */
+Deluge.EventsManager.prototype.on = Deluge.EventsManager.prototype.addListener
+
+/**
+ * Fires the specified event with the passed parameters (minus the
+ * event name).
+ * @method
+ */
+Deluge.EventsManager.prototype.fire = Deluge.EventsManager.prototype.fireEvent
+deluge.events = new Deluge.EventsManager();
/*
Script:
Deluge.OptionsManager.js
@@ -1534,8 +1567,8 @@ Copyright:
*/
-Ext.namespace('Ext.deluge.add');
-Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
+Ext.namespace('Deluge.add');
+Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
torrents: {},
@@ -1546,11 +1579,11 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
activeTab: 0,
height: 220
}, config);
- Ext.deluge.add.OptionsPanel.superclass.constructor.call(this, config);
+ Deluge.add.OptionsPanel.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);
+ Deluge.add.OptionsPanel.superclass.initComponent.call(this);
this.files = this.add(new Ext.ux.tree.TreeGrid({
layout: 'fit',
title: _('Files'),
@@ -1739,7 +1772,7 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
'max_upload_slots_per_torrent','max_upload_speed_per_torrent',
'prioritize_first_last_pieces'];
- Deluge.Client.core.get_config_values(keys, {
+ deluge.client.core.get_config_values(keys, {
success: function(config) {
var options = {
'file_priorities': [],
@@ -1845,9 +1878,9 @@ Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
}
});
-Ext.deluge.add.Window = Ext.extend(Ext.Window, {
+Deluge.add.Window = Ext.extend(Ext.Window, {
initComponent: function() {
- Ext.deluge.add.Window.superclass.initComponent.call(this);
+ Deluge.add.Window.superclass.initComponent.call(this);
this.addEvents(
'beforeadd',
'add'
@@ -1859,7 +1892,7 @@ Ext.deluge.add.Window = Ext.extend(Ext.Window, {
}
});
-Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
+Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
constructor: function(config) {
config = Ext.apply({
@@ -1874,11 +1907,11 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
plain: true,
iconCls: 'x-deluge-add-window-icon'
}, config);
- Ext.deluge.add.AddWindow.superclass.constructor.call(this, config);
+ Deluge.add.AddWindow.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.add.AddWindow.superclass.initComponent.call(this);
+ Deluge.add.AddWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Add'), this.onAddClick, this);
@@ -1925,37 +1958,29 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
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',
+ iconCls: 'icon-add-url',
handler: this.onUrl,
scope: this
}, {
- id: 'infohash',
- cls: 'x-btn-text-icon',
text: _('Infohash'),
- icon: '/icons/add_magnet.png',
+ iconCls: 'icon-add-magnet',
disabled: true
}, '->', {
- id: 'remove',
- cls: 'x-btn-text-icon',
text: _('Remove'),
- icon: '/icons/remove.png',
+ iconCls: 'icon-remove',
handler: this.onRemove,
scope: this
}]
})
});
- this.optionsPanel = this.add(new Ext.deluge.add.OptionsPanel());
+ this.optionsPanel = this.add(new Deluge.add.OptionsPanel());
this.on('hide', this.onHide, this);
this.on('show', this.onShow, this);
},
@@ -1976,7 +2001,7 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
});
}, this);
- Deluge.Client.web.add_torrents(torrents, {
+ deluge.client.web.add_torrents(torrents, {
success: function(result) {
}
})
@@ -2017,13 +2042,13 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
onShow: function() {
if (!this.url) {
- this.url = new Ext.deluge.add.UrlWindow();
+ this.url = new 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 = new Deluge.add.FileWindow();
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
this.file.on('add', this.onTorrentAdd, this);
}
@@ -2037,6 +2062,7 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
},
onTorrentAdd: function(torrentId, info) {
+ var r = this.grid.getStore().getById(torrentId);
if (!info) {
Ext.MessageBox.show({
title: _('Error'),
@@ -2046,21 +2072,20 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
icon: Ext.MessageBox.ERROR,
iconCls: 'x-deluge-icon-error'
});
- return;
+ this.grid.getStore().remove(r);
+ } else {
+ r.set('info_hash', info['info_hash']);
+ r.set('text', info['name']);
+ this.grid.getStore().commitChanges();
+ this.optionsPanel.addTorrent(info);
}
-
- var r = this.grid.getStore().getById(torrentId);
- r.set('info_hash', info['info_hash']);
- r.set('text', info['name']);
- this.grid.getStore().commitChanges();
- this.optionsPanel.addTorrent(info);
},
onUrl: function(button, event) {
this.url.show();
}
});
-Deluge.Add = new Ext.deluge.add.AddWindow();
+deluge.add = new Deluge.add.AddWindow();
/*
Script: Deluge.Add.File.js
Contains the Add Torrent by file window.
@@ -2096,7 +2121,7 @@ Copyright:
*/
Ext.namespace('Ext.deluge.add');
-Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
+Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
constructor: function(config) {
config = Ext.apply({
layout: 'fit',
@@ -2110,11 +2135,11 @@ Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
title: _('Add from File'),
iconCls: 'x-deluge-add-file'
}, config);
- Ext.deluge.add.FileWindow.superclass.constructor.call(this, config);
+ Deluge.add.FileWindow.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.add.FileWindow.superclass.initComponent.call(this);
+ Deluge.add.FileWindow.superclass.initComponent.call(this);
this.addButton(_('Add'), this.onAddClick, this);
this.form = this.add({
@@ -2143,10 +2168,12 @@ Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
this.form.getForm().submit({
url: '/upload',
waitMsg: _('Uploading your torrent...'),
+ failure: this.onUploadFailure,
success: this.onUploadSuccess,
scope: this
});
var name = this.form.getForm().findField('torrentFile').value;
+ name = name.split('\\').slice(-1)[0];
this.fireEvent('beforeadd', this.torrentId, name);
}
},
@@ -2155,6 +2182,10 @@ Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
info['filename'] = request.options.filename;
this.fireEvent('add', this.torrentId, info);
},
+
+ onUploadFailure: function(form, action) {
+ this.hide();
+ },
onUploadSuccess: function(fp, upload) {
this.hide();
@@ -2203,8 +2234,8 @@ Copyright:
*/
-Ext.namespace('Ext.deluge.add');
-Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
+Ext.namespace('Deluge.add');
+Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
constructor: function(config) {
config = Ext.apply({
layout: 'fit',
@@ -2218,11 +2249,11 @@ Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
title: _('Add from Url'),
iconCls: 'x-deluge-add-url-window-icon'
}, config);
- Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
+ Deluge.add.UrlWindow.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
+ Deluge.add.UrlWindow.superclass.initComponent.call(this);
this.addButton(_('Add'), this.onAddClick, this);
var form = this.add({
@@ -2257,7 +2288,7 @@ Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
var cookies = this.cookieField.getValue();
var torrentId = this.createTorrentId();
- Deluge.Client.web.download_torrent_from_url(url, cookies, {
+ deluge.client.web.download_torrent_from_url(url, cookies, {
success: this.onDownload,
scope: this,
torrentId: torrentId
@@ -2268,7 +2299,7 @@ Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
onDownload: function(filename, obj, resp, req) {
this.urlField.setValue('');
- Deluge.Client.web.get_torrent_info(filename, {
+ deluge.client.web.get_torrent_info(filename, {
success: this.onGotInfo,
scope: this,
filename: filename,
@@ -2478,7 +2509,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
}
});
/*
-Script: deluge-connections.js
+Script: Deluge.ConnectionManager.js
Contains all objects and functions related to the connection manager.
Copyright:
@@ -2516,7 +2547,7 @@ Copyright:
return value + ':' + r.data['port']
}
- Ext.deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
+ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
@@ -2531,11 +2562,11 @@ Copyright:
title: _('Add Connection'),
iconCls: 'x-deluge-add-window-icon'
}, config);
- Ext.deluge.AddConnectionWindow.superclass.constructor.call(this, config);
+ Deluge.AddConnectionWindow.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this);
+ Deluge.AddConnectionWindow.superclass.initComponent.call(this);
this.addEvents('hostadded');
@@ -2563,8 +2594,7 @@ Copyright:
this.portField = this.form.add({
fieldLabel: _('Port'),
id: 'port',
- xtype: 'uxspinner',
- ctCls: 'x-form-uxspinner',
+ xtype: 'spinnerfield',
name: 'port',
strategy: {
xtype: 'number',
@@ -2600,7 +2630,7 @@ Copyright:
var username = this.usernameField.getValue();
var password = this.passwordField.getValue();
- Deluge.Client.web.add_host(host, port, username, password, {
+ deluge.client.web.add_host(host, port, username, password, {
success: function(result) {
if (!result[0]) {
Ext.MessageBox.show({
@@ -2625,7 +2655,7 @@ Copyright:
}
});
- Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, {
+ Deluge.ConnectionManager = Ext.extend(Ext.Window, {
layout: 'fit',
width: 300,
@@ -2639,11 +2669,13 @@ Copyright:
iconCls: 'x-deluge-connect-window-icon',
initComponent: function() {
- Ext.deluge.ConnectionManager.superclass.initComponent.call(this);
+ Deluge.ConnectionManager.superclass.initComponent.call(this);
this.on('hide', this.onHide, this);
this.on('show', this.onShow, this);
- Deluge.Events.on('login', this.onLogin, this);
- Deluge.Events.on('logout', this.onLogout, this);
+
+ deluge.events.on('disconnect', this.onDisconnect, this);
+ 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);
@@ -2697,14 +2729,14 @@ Copyright:
id: 'cm-add',
cls: 'x-btn-text-icon',
text: _('Add'),
- icon: '/icons/add.png',
+ iconCls: 'icon-add',
handler: this.onAddClick,
scope: this
}, {
id: 'cm-remove',
cls: 'x-btn-text-icon',
text: _('Remove'),
- icon: '/icons/remove.png',
+ iconCls: 'icon-remove',
handler: this.onRemove,
disabled: true,
scope: this
@@ -2712,7 +2744,7 @@ Copyright:
id: 'cm-stop',
cls: 'x-btn-text-icon',
text: _('Stop Daemon'),
- icon: '/icons/error.png',
+ iconCls: 'icon-error',
handler: this.onStop,
disabled: true,
scope: this
@@ -2724,12 +2756,29 @@ Copyright:
this.update = this.update.createDelegate(this);
},
+ /**
+ * Check to see if the the web interface is currently connected
+ * to a Deluge Daemon and show the Connection Manager if not.
+ */
+ checkConnected: function() {
+ deluge.client.web.connected({
+ success: function(connected) {
+ if (connected) {
+ deluge.events.fire('connect');
+ } else {
+ this.show();
+ }
+ },
+ scope: this
+ });
+ },
+
disconnect: function() {
- Deluge.Events.fire('disconnect');
+ deluge.events.fire('disconnect');
},
loadHosts: function() {
- Deluge.Client.web.get_hosts({
+ deluge.client.web.get_hosts({
success: this.onGetHosts,
scope: this
});
@@ -2737,7 +2786,7 @@ Copyright:
update: function() {
this.grid.getStore().each(function(r) {
- Deluge.Client.web.get_host_status(r.id, {
+ deluge.client.web.get_host_status(r.id, {
success: this.onGetHostStatus,
scope: this
});
@@ -2779,7 +2828,7 @@ Copyright:
onAddClick: function(button, e) {
if (!this.addWindow) {
- this.addWindow = new Ext.deluge.AddConnectionWindow();
+ this.addWindow = new Deluge.AddConnectionWindow();
this.addWindow.on('hostadded', this.onHostAdded, this);
}
this.addWindow.show();
@@ -2789,17 +2838,19 @@ Copyright:
this.loadHosts();
},
+ // private
onClose: function(e) {
if (this.running) window.clearInterval(this.running);
this.hide();
},
+ // private
onConnect: function(e) {
var selected = this.grid.getSelectionModel().getSelected();
if (!selected) return;
if (selected.get('status') == _('Connected')) {
- Deluge.Client.web.disconnect({
+ deluge.client.web.disconnect({
success: function(result) {
this.update(this);
Deluge.Events.fire('disconnect');
@@ -2808,11 +2859,11 @@ Copyright:
});
} else {
var id = selected.id;
- Deluge.Client.web.connect(id, {
+ deluge.client.web.connect(id, {
success: function(methods) {
- Deluge.Client.reloadMethods();
- Deluge.Client.on('connected', function(e) {
- Deluge.Events.fire('connect');
+ deluge.client.reloadMethods();
+ deluge.client.on('connected', function(e) {
+ deluge.events.fire('connect');
}, this, {single: true});
}
});
@@ -2820,16 +2871,23 @@ Copyright:
}
},
+ onDisconnect: function() {
+ if (this.isVisible()) return;
+ this.show();
+ },
+
+ // private
onGetHosts: function(hosts) {
this.grid.getStore().loadData(hosts);
Ext.each(hosts, function(host) {
- Deluge.Client.web.get_host_status(host[0], {
+ deluge.client.web.get_host_status(host[0], {
success: this.onGetHostStatus,
scope: this
});
}, this);
},
+ // private
onGetHostStatus: function(host) {
var record = this.grid.getStore().getById(host[0]);
record.set('status', host[3])
@@ -2838,23 +2896,31 @@ Copyright:
if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record);
},
+ // private
onHide: function() {
if (this.running) window.clearInterval(this.running);
},
+ // private
onLogin: function() {
- Deluge.Client.web.connected({
- success: function(connected) {
- if (connected) {
- Deluge.Events.fire('connect');
- } else {
- this.show();
- }
- },
- scope: this
- });
+ if (deluge.config.first_login) {
+ Ext.MessageBox.confirm('Change password',
+ 'As this is your first login, we recommend that you ' +
+ 'change your password. Would you like to ' +
+ 'do this now?', function(res) {
+ this.checkConnected();
+ if (res == 'yes') {
+ deluge.preferences.show();
+ deluge.preferences.selectPage('Interface');
+ }
+ deluge.client.web.set_config({first_login: false});
+ }, this);
+ } else {
+ this.checkConnected();
+ }
},
+ // private
onLogout: function() {
this.disconnect();
if (!this.hidden && this.rendered) {
@@ -2862,11 +2928,12 @@ Copyright:
}
},
+ // private
onRemove: function(button) {
var connection = this.grid.getSelectionModel().getSelected();
if (!connection) return;
- Deluge.Client.web.remove_host(connection.id, {
+ deluge.client.web.remove_host(connection.id, {
success: function(result) {
if (!result) {
Ext.MessageBox.show({
@@ -2885,10 +2952,12 @@ Copyright:
});
},
+ // private
onSelect: function(selModel, rowIndex, record) {
this.selectedRow = rowIndex;
},
+ // private
onSelectionChanged: function(selModel) {
var record = selModel.getSelected();
if (selModel.hasSelection()) {
@@ -2902,6 +2971,7 @@ Copyright:
this.updateButtons(record);
},
+ // private
onShow: function() {
if (!this.addHostButton) {
var bbar = this.grid.getBottomToolbar();
@@ -2912,17 +2982,18 @@ Copyright:
this.loadHosts();
this.running = window.setInterval(this.update, 2000, this);
},
-
+
+ // private
onStop: function(button, e) {
var connection = this.grid.getSelectionModel().getSelected();
if (!connection) return;
if (connection.get('status') == 'Offline') {
// This means we need to start the daemon
- Deluge.Client.web.start_daemon(connection.get('port'));
+ deluge.client.web.start_daemon(connection.get('port'));
} else {
// This means we need to stop the daemon
- Deluge.Client.web.stop_daemon(connection.id, {
+ deluge.client.web.stop_daemon(connection.id, {
success: function(result) {
if (!result[0]) {
Ext.MessageBox.show({
@@ -2939,7 +3010,7 @@ Copyright:
}
}
});
- Deluge.ConnectionManager = new Ext.deluge.ConnectionManager();
+ deluge.connectionManager = new Deluge.ConnectionManager();
})();
/*
Script: Deluge.Details.js
@@ -2976,8 +3047,8 @@ Copyright:
*/
(function() {
- Ext.namespace('Ext.deluge.details');
- Ext.deluge.details.TabPanel = Ext.extend(Ext.TabPanel, {
+ Ext.namespace('Deluge.details');
+ Deluge.details.TabPanel = Ext.extend(Ext.TabPanel, {
constructor: function(config) {
config = Ext.apply({
@@ -2990,7 +3061,7 @@ Copyright:
margins: '0 5 5 5',
activeTab: 0
}, config);
- Ext.deluge.details.TabPanel.superclass.constructor.call(this, config);
+ Deluge.details.TabPanel.superclass.constructor.call(this, config);
},
clear: function() {
@@ -3004,7 +3075,7 @@ Copyright:
update: function(tab) {
- var torrent = Deluge.Torrents.getSelected();
+ var torrent = deluge.torrents.getSelected();
if (!torrent) {
this.clear();
return;
@@ -3023,12 +3094,12 @@ Copyright:
// We need to add the events in onRender since Deluge.Torrents hasn't
// been created yet.
onRender: function(ct, position) {
- Ext.deluge.details.TabPanel.superclass.onRender.call(this, ct, position);
- Deluge.Events.on('disconnect', this.clear, this);
- Deluge.Torrents.on('rowclick', this.onTorrentsClick, this);
+ Deluge.details.TabPanel.superclass.onRender.call(this, ct, position);
+ 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(selModel) {
+ deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) {
if (!selModel.hasSelection()) this.clear();
}, this);
},
@@ -3041,7 +3112,7 @@ Copyright:
this.update();
}
});
- Deluge.Details = new Ext.deluge.details.TabPanel();
+ deluge.details = new Deluge.details.TabPanel();
})();
/*
Script: Deluge.Details.Status.js
@@ -3076,12 +3147,12 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {
+Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
title: _('Status'),
autoScroll: true,
onRender: function(ct, position) {
- Ext.deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
+ Deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
this.progressBar = this.add({
xtype: 'progress',
@@ -3098,7 +3169,7 @@ Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {
'render': {
fn: function(panel) {
panel.load({
- url: '/render/tab_status.html',
+ url: deluge.config.base + 'render/tab_status.html',
text: _('Loading') + '...'
});
panel.getUpdater().on('update', this.onPanelUpdate, this);
@@ -3118,7 +3189,7 @@ Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {
update: function(torrentId) {
if (!this.fields) this.getFields();
- Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, {
+ deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Status, {
success: this.onRequestComplete,
scope: this
});
@@ -3161,10 +3232,10 @@ Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {
this.fields[field].innerHTML = data[field];
}
var text = status.state + ' ' + status.progress.toFixed(2) + '%';
- this.progressBar.updateProgress(status.progress, text);
+ this.progressBar.updateProgress(status.progress / 100.0, text);
}
});
-Deluge.Details.add(new Ext.deluge.details.StatusTab());
+deluge.details.add(new Deluge.details.StatusTab());
/*
Script: Deluge.Details.Details.js
The details tab displayed in the details panel.
@@ -3199,7 +3270,7 @@ Copyright:
*/
-Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
+Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
title: _('Details'),
fields: {},
@@ -3209,7 +3280,7 @@ Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
oldData: {},
initComponent: function() {
- Ext.deluge.details.DetailsTab.superclass.initComponent.call(this);
+ Deluge.details.DetailsTab.superclass.initComponent.call(this);
this.addItem('torrent_name', _('Name'));
this.addItem('hash', _('Hash'));
this.addItem('path', _('Path'));
@@ -3221,7 +3292,7 @@ Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
},
onRender: function(ct, position) {
- Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
+ Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
this.body.setStyle('padding', '10px');
this.dl = Ext.DomHelper.append(this.body, {tag: 'dl'}, true);
@@ -3252,7 +3323,7 @@ Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
},
update: function(torrentId) {
- Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
+ deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
success: this.onRequestComplete,
scope: this,
torrentId: torrentId
@@ -3279,7 +3350,7 @@ Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
this.oldData = data;
}
});
-Deluge.Details.add(new Ext.deluge.details.DetailsTab());
+deluge.details.add(new Deluge.details.DetailsTab());
/*
Script: Deluge.Details.Files.js
The files tab displayed in the details panel.
@@ -3323,7 +3394,7 @@ Copyright:
return String.format('{1}
', FILE_PRIORITY_CSS[value], _(FILE_PRIORITY[value]));
}
- Ext.deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
+ Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
constructor: function(config) {
config = Ext.apply({
@@ -3361,17 +3432,17 @@ Copyright:
})
}, config);
- Ext.deluge.details.FilesTab.superclass.constructor.call(this, config);
+ Deluge.details.FilesTab.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.details.FilesTab.superclass.initComponent.call(this);
+ Deluge.details.FilesTab.superclass.initComponent.call(this);
},
onRender: function(ct, position) {
- Ext.deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
- Deluge.Menus.FilePriorities.on('itemclick', this.onItemClick, this);
+ Deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
+ deluge.menus.filePriorities.on('itemclick', this.onItemClick, this);
this.on('contextmenu', this.onContextMenu, this);
this.sorter = new Ext.tree.TreeSorter(this, {
folderSort: true
@@ -3395,7 +3466,7 @@ Copyright:
this.torrentId = torrentId;
}
- Deluge.Client.web.get_torrent_files(torrentId, {
+ deluge.client.web.get_torrent_files(torrentId, {
success: this.onRequestComplete,
scope: this,
torrentId: torrentId
@@ -3409,7 +3480,7 @@ Copyright:
selModel.clearSelections();
node.select();
}
- Deluge.Menus.FilePriorities.showAt(e.getPoint());
+ deluge.menus.filePriorities.showAt(e.getPoint());
},
onItemClick: function(baseItem, e) {
@@ -3444,7 +3515,7 @@ Copyright:
priorities[index] = indexes[index];
}
- Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {
+ deluge.client.core.set_torrent_file_priorities(this.torrentId, priorities, {
success: function() {
Ext.each(nodes, function(node) {
node.setColumnValue(3, baseItem.filePriority);
@@ -3498,7 +3569,7 @@ Copyright:
root.firstChild.expand();
}
});
- Deluge.Details.add(new Ext.deluge.details.FilesTab());
+ deluge.details.add(new Deluge.details.FilesTab());
})();
/*
Script: Deluge.Details.Peers.js
@@ -3551,7 +3622,7 @@ Copyright:
return ((((((+d[1])*256)+(+d[2]))*256)+(+d[3]))*256)+(+d[4]);
}
- Ext.deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
+ Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
constructor: function(config) {
config = Ext.apply({
@@ -3610,11 +3681,11 @@ Copyright:
deferredRender:false,
autoScroll:true
}, config);
- Ext.deluge.details.PeersTab.superclass.constructor.call(this, config);
+ Deluge.details.PeersTab.superclass.constructor.call(this, config);
},
onRender: function(ct, position) {
- Ext.deluge.details.PeersTab.superclass.onRender.call(this, ct, position);
+ Deluge.details.PeersTab.superclass.onRender.call(this, ct, position);
},
clear: function() {
@@ -3622,7 +3693,7 @@ Copyright:
},
update: function(torrentId) {
- Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Peers, {
+ deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Peers, {
success: this.onRequestComplete,
scope: this
});
@@ -3637,7 +3708,7 @@ Copyright:
this.getStore().loadData(peers);
}
});
- Deluge.Details.add(new Ext.deluge.details.PeersTab());
+ deluge.details.add(new Deluge.details.PeersTab());
})();
/*
Script: Deluge.Details.Options.js
@@ -3673,7 +3744,7 @@ Copyright:
*/
-Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
+Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
@@ -3690,11 +3761,11 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
layout: 'column',
title: _('Options')
}, config);
- Ext.deluge.details.OptionsTab.superclass.constructor.call(this, config);
+ Deluge.details.OptionsTab.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
+ Deluge.details.OptionsTab.superclass.initComponent.call(this);
this.fieldsets = {}, this.fields = {};
this.optionsManager = new Deluge.MultiOptionsManager({
@@ -3983,7 +4054,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
},
onRender: function(ct, position) {
- Ext.deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
+ 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();
@@ -4010,7 +4081,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
this.torrentId = torrentId;
this.optionsManager.changeId(torrentId);
}
- Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
+ deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
success: this.onRequestComplete,
scope: this
});
@@ -4020,14 +4091,14 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
var changed = this.optionsManager.getDirty();
if (!Ext.isEmpty(changed['prioritize_first_last'])) {
var value = changed['prioritize_first_last'];
- Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
+ deluge.client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
success: function() {
this.optionsManager.set('prioritize_first_last', value);
},
scope: this
});
}
- Deluge.Client.core.set_torrent_options([this.torrentId], changed, {
+ deluge.client.core.set_torrent_options([this.torrentId], changed, {
success: function() {
this.optionsManager.commit();
},
@@ -4036,7 +4107,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
},
onEditTrackers: function() {
- Deluge.EditTrackers.show();
+ deluge.editTrackers.show();
},
onStopRatioChecked: function(checkbox, checked) {
@@ -4055,7 +4126,7 @@ Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
this.fields.stop_ratio.setDisabled(!stop_at_ratio);
}
});
-Deluge.Details.add(new Ext.deluge.details.OptionsTab());
+deluge.details.add(new Deluge.details.OptionsTab());
/*
Script: Deluge.EditTrackers.js
Contains the edit trackers window.
@@ -4091,7 +4162,7 @@ Copyright:
*/
(function() {
- Ext.deluge.AddTracker = Ext.extend(Ext.Window, {
+ Deluge.AddTracker = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
title: _('Add Tracker'),
@@ -4106,11 +4177,11 @@ Copyright:
plain: true,
resizable: false
}, config);
- Ext.deluge.AddTracker.superclass.constructor.call(this, config);
+ Deluge.AddTracker.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.AddTracker.superclass.initComponent.call(this);
+ Deluge.AddTracker.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Add'), this.onAddClick, this);
@@ -4150,7 +4221,7 @@ Copyright:
}
});
- Ext.deluge.EditTracker = Ext.extend(Ext.Window, {
+ Deluge.EditTracker = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
title: _('Edit Tracker'),
@@ -4165,11 +4236,11 @@ Copyright:
plain: true,
resizable: false
}, config);
- Ext.deluge.EditTracker.superclass.constructor.call(this, config);
+ Deluge.EditTracker.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.EditTracker.superclass.initComponent.call(this);
+ Deluge.EditTracker.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Save'), this.onSaveClick, this);
@@ -4189,7 +4260,7 @@ Copyright:
},
show: function(record) {
- Ext.deluge.EditTracker.superclass.show.call(this);
+ Deluge.EditTracker.superclass.show.call(this);
this.record = record;
this.form.getForm().findField('tracker').setValue(record.data['url']);
@@ -4211,7 +4282,7 @@ Copyright:
}
});
- Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
+ Deluge.EditTrackers = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
@@ -4227,11 +4298,11 @@ Copyright:
plain: true,
resizable: true
}, config);
- Ext.deluge.EditTrackers.superclass.constructor.call(this, config);
+ Deluge.EditTrackers.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.EditTrackers.superclass.initComponent.call(this);
+ Deluge.EditTrackers.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Ok'), this.onOkClick, this);
@@ -4240,9 +4311,9 @@ Copyright:
this.on('show', this.onShow, this);
this.on('save', this.onSave, this);
- this.addWindow = new Ext.deluge.AddTracker();
+ this.addWindow = new Deluge.AddTracker();
this.addWindow.on('add', this.onAddTrackers, this);
- this.editWindow = new Ext.deluge.EditTracker();
+ this.editWindow = new Deluge.EditTracker();
this.grid = this.add({
xtype: 'grid',
@@ -4279,33 +4350,28 @@ Copyright:
bbar: new Ext.Toolbar({
items: [
{
- cls: 'x-btn-text-icon',
text: _('Up'),
- icon: '/icons/up.png',
+ iconCls: 'icon-up',
handler: this.onUpClick,
scope: this
}, {
- cls: 'x-btn-text-icon',
text: _('Down'),
- icon: '/icons/down.png',
+ iconCls: 'icon-down',
handler: this.onDownClick,
scope: this
}, '->', {
- cls: 'x-btn-text-icon',
text: _('Add'),
- icon: '/icons/add.png',
+ iconCls: 'icon-add',
handler: this.onAddClick,
scope: this
}, {
- cls: 'x-btn-text-icon',
text: _('Edit'),
- icon: '/icons/edit_trackers.png',
+ iconCls: 'icon-edit-trackers',
handler: this.onEditClick,
scope: this
}, {
- cls: 'x-btn-text-icon',
text: _('Remove'),
- icon: '/icons/remove.png',
+ iconCls: 'icon-remove',
handler: this.onRemoveClick,
scope: this
}
@@ -4359,7 +4425,7 @@ Copyright:
})
}, this);
- Deluge.Client.core.set_torrent_trackers(this.torrentId, trackers, {
+ deluge.client.core.set_torrent_trackers(this.torrentId, trackers, {
failure: this.onSaveFail,
scope: this
});
@@ -4393,23 +4459,43 @@ Copyright:
onShow: function() {
this.grid.getBottomToolbar().items.get(4).disable();
- var r = Deluge.Torrents.getSelected();
+ var r = deluge.torrents.getSelected();
this.torrentId = r.id;
- Deluge.Client.core.get_torrent_status(r.id, ['trackers'], {
+ deluge.client.core.get_torrent_status(r.id, ['trackers'], {
success: this.onRequestComplete,
scope: this
});
}
});
- Deluge.EditTrackers = new Ext.deluge.EditTrackers();
+ deluge.editTrackers = new Deluge.EditTrackers();
})();
Ext.namespace('Deluge');
Deluge.FileBrowser = Ext.extend(Ext.Window, {
- title: 'Filebrowser',
-
+ title: _('File Browser'),
+
+ width: 500,
+ height: 400,
+
initComponent: function() {
Deluge.FileBrowser.superclass.initComponent.call(this);
+
+ this.add({
+ xtype: 'toolbar',
+ items: [{
+ text: _('Back'),
+ iconCls: 'icon-back'
+ }, {
+ text: _('Forward'),
+ iconCls: 'icon-forward'
+ }, {
+ text: _('Up'),
+ iconCls: 'icon-up'
+ }, {
+ text: _('Home'),
+ iconCls: 'icon-home'
+ }]
+ });
}
});
@@ -4447,7 +4533,7 @@ Copyright:
*/
-Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
+Deluge.LoginWindow = Ext.extend(Ext.Window, {
firstShow: true,
bodyStyle: 'padding: 10px 5px;',
@@ -4464,7 +4550,7 @@ Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
height: 120,
initComponent: function() {
- Ext.deluge.LoginWindow.superclass.initComponent.call(this);
+ Deluge.LoginWindow.superclass.initComponent.call(this);
this.on('show', this.onShow, this);
this.addButton({
@@ -4493,8 +4579,8 @@ Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
},
logout: function() {
- Deluge.Events.fire('logout');
- Deluge.Client.auth.delete_session({
+ deluge.events.fire('logout');
+ deluge.client.auth.delete_session({
success: function(result) {
this.show(true);
},
@@ -4504,18 +4590,18 @@ Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
show: function(skipCheck) {
if (this.firstShow) {
- Deluge.Client.on('error', this.onClientError, this);
+ deluge.client.on('error', this.onClientError, this);
this.firstShow = false;
}
if (skipCheck) {
- return Ext.deluge.LoginWindow.superclass.show.call(this);
+ return Deluge.LoginWindow.superclass.show.call(this);
}
- Deluge.Client.auth.check_session({
+ deluge.client.auth.check_session({
success: function(result) {
if (result) {
- Deluge.Events.fire('login');
+ deluge.events.fire('login');
} else {
this.show(true);
}
@@ -4533,10 +4619,10 @@ Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
onLogin: function() {
var passwordField = this.passwordField;
- Deluge.Client.auth.login(passwordField.getValue(), {
+ deluge.client.auth.login(passwordField.getValue(), {
success: function(result) {
if (result) {
- Deluge.Events.fire('login');
+ deluge.events.fire('login');
this.hide();
passwordField.setRawValue('');
} else {
@@ -4559,7 +4645,7 @@ Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
onClientError: function(errorObj, response, requestOptions) {
if (errorObj.error.code == 1) {
- Deluge.Events.fire('logout');
+ deluge.events.fire('logout');
this.show(true);
}
},
@@ -4570,7 +4656,7 @@ Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
}
});
-Deluge.Login = new Ext.deluge.LoginWindow();
+deluge.login = new Deluge.LoginWindow();
/*
Script: Deluge.MoveStorage.js
Contains the move storage window.
@@ -4604,8 +4690,8 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge');
-Ext.deluge.MoveStorage = Ext.extend(Ext.Window, {
+Ext.namespace('Deluge');
+Deluge.MoveStorage = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
@@ -4620,11 +4706,11 @@ Ext.deluge.MoveStorage = Ext.extend(Ext.Window, {
plain: true,
resizable: false
}, config);
- Ext.deluge.MoveStorage.superclass.constructor.call(this, config);
+ Deluge.MoveStorage.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.MoveStorage.superclass.initComponent.call(this);
+ Deluge.MoveStorage.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancel, this);
this.addButton(_('Move'), this.onMove, this);
@@ -4642,15 +4728,26 @@ Ext.deluge.MoveStorage = Ext.extend(Ext.Window, {
name: 'location',
width: 240
});
+ this.form.add({
+ xtype: 'button',
+ text: _('Browse'),
+ handler: function() {
+ if (!this.fileBrowser) {
+ this.fileBrowser = new Deluge.FileBrowser();
+ }
+ this.fileBrowser.show();
+ },
+ scope: this
+ });
},
hide: function() {
- Ext.deluge.MoveStorage.superclass.hide.call(this);
+ Deluge.MoveStorage.superclass.hide.call(this);
this.torrentIds = null;
},
show: function(torrentIds) {
- Ext.deluge.MoveStorage.superclass.show.call(this);
+ Deluge.MoveStorage.superclass.show.call(this);
this.torrentIds = torrentIds;
},
@@ -4660,11 +4757,11 @@ Ext.deluge.MoveStorage = Ext.extend(Ext.Window, {
onMove: function() {
var dest = this.moveLocation.getValue();
- Deluge.Client.core.move_storage(this.torrentIds, dest);
+ deluge.client.core.move_storage(this.torrentIds, dest);
this.hide();
}
});
-Deluge.MoveStorage = new Ext.deluge.MoveStorage();
+deluge.moveStorage = new Deluge.MoveStorage();
/*
Script: Deluge.Plugin.js
Contains a base class for plugins to extend.
@@ -4784,57 +4881,70 @@ Copyright:
*/
-Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
+Ext.namespace('Deluge.preferences');
+PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]);
+/**
+ * @class Deluge.preferences.PreferencesWindow
+ * @extends Ext.Window
+ */
+Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
+
+ /**
+ * @property {String} currentPage The currently selected page.
+ */
currentPage: null,
- constructor: function(config) {
- config = Ext.apply({
- layout: 'border',
- width: 485,
- height: 500,
- buttonAlign: 'right',
- closeAction: 'hide',
- closable: true,
- iconCls: 'x-deluge-preferences',
- plain: true,
- resizable: false,
- title: _('Preferences'),
+ title: _('Preferences'),
+ layout: 'border',
+ width: 485,
+ height: 500,
+
+ buttonAlign: 'right',
+ closeAction: 'hide',
+ closable: true,
+ iconCls: 'x-deluge-preferences',
+ plain: true,
+ resizable: 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
- }, ]
- }, config);
- Ext.deluge.PreferencesWindow.superclass.constructor.call(this, config);
- },
-
initComponent: function() {
- Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);
- this.categoriesGrid = this.items.get(0);
- this.configPanel = this.add({
- region: 'center',
- header: false,
- layout: 'fit',
- height: 400,
+ Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this);
+
+ this.categoriesGrid = this.add({
+ xtype: 'grid',
+ region: 'west',
+ title: _('Categories'),
+ store: new Ext.data.Store(),
+ 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
+ });
+
+ this.configPanel = this.add({
+ type: 'container',
+ autoDestroy: false,
+ region: 'center',
+ layout: 'card',
+ //height: 400,
+ //autoScroll: true,
margins: '5 5 5 5',
cmargins: '5 5 5 5'
});
@@ -4845,13 +4955,14 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
this.pages = {};
this.optionsManager = new Deluge.OptionsManager();
+ this.on('afterrender', this.onAfterRender, this);
this.on('show', this.onShow, this);
},
onApply: function(e) {
var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) {
- Deluge.Client.core.set_config(changed, {
+ deluge.client.core.set_config(changed, {
success: this.onSetConfig,
scope: this
});
@@ -4862,23 +4973,23 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
}
},
- onClose: function() {
- this.hide();
- },
-
- onOk: function() {
- Deluge.Client.core.set_config(this.optionsManager.getDirty());
- this.hide();
+
+ /**
+ * Return the options manager for the preferences window.
+ * @returns {Deluge.OptionsManager} the options manager
+ */
+ getOptionsManager: function() {
+ return this.optionsManager;
},
/**
* Adds a page to the preferences window.
- * @param {mixed} page
+ * @param {Mixed} page
*/
addPage: function(page) {
var store = this.categoriesGrid.getStore();
var name = page.title;
- store.loadData([[name]], true);
+ store.add([new PreferencesRecord({name: name})]);
page['bodyStyle'] = 'margin: 5px';
this.pages[name] = this.configPanel.add(page);
return this.pages[name];
@@ -4895,52 +5006,61 @@ Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
this.configPanel.remove(page);
delete this.pages[page.title];
},
-
- /**
- * Return the options manager for the preferences window.
- * @returns {Deluge.OptionsManager} the options manager
+
+ /**
+ * Select which preferences page is displayed.
+ * @param {String} page The page name to change to
*/
- getOptionsManager: function() {
- return this.optionsManager;
+ selectPage: function(page) {
+ var index = this.configPanel.items.indexOf(this.pages[page]);
+ this.configPanel.getLayout().setActiveItem(index);
+ this.currentPage = page;
},
+ // private
onGotConfig: function(config) {
this.getOptionsManager().set(config);
},
+ // private
onPageSelect: function(selModel, rowIndex, r) {
- if (this.currentPage == null) {
- for (var page in this.pages) {
- this.pages[page].hide();
- }
- } else {
- this.currentPage.hide();
- }
-
- var name = r.get('name');
-
- this.pages[name].show();
- this.currentPage = this.pages[name];
- this.configPanel.doLayout();
+ this.selectPage(r.get('name'));
},
+ // private
onSetConfig: function() {
this.getOptionsManager().commit();
},
-
- onShow: function() {
+
+ // private
+ onAfterRender: function() {
if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
this.categoriesGrid.getSelectionModel().selectFirstRow();
}
-
- Deluge.Client.core.get_config({
+ this.configPanel.getLayout().setActiveItem(0);
+ },
+
+ // private
+ onShow: function() {
+ if (!deluge.client.core) return;
+ deluge.client.core.get_config({
success: this.onGotConfig,
scope: this
})
+ },
+
+ // private
+ onClose: function() {
+ this.hide();
+ },
+
+ // private
+ onOk: function() {
+ deluge.client.core.set_config(this.optionsManager.getDirty());
+ this.hide();
}
});
-
-Deluge.Preferences = new Ext.deluge.PreferencesWindow();
+deluge.preferences = new Deluge.preferences.PreferencesWindow();
/*
Script: Deluge.Preferences.Downloads.js
The downloads preferences page.
@@ -4974,8 +5094,13 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Downloads
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
@@ -4984,13 +5109,13 @@ Ext.deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
autoHeight: true,
width: 320
}, config);
- Ext.deluge.preferences.Downloads.superclass.constructor.call(this, config);
+ Deluge.preferences.Downloads.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Downloads.superclass.initComponent.call(this);
+ Deluge.preferences.Downloads.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
border: false,
@@ -5090,12 +5215,12 @@ Ext.deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
},
onShow: function() {
- Ext.deluge.preferences.Downloads.superclass.onShow.call(this);
+ Deluge.preferences.Downloads.superclass.onShow.call(this);
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Downloads());
+deluge.preferences.addPage(new Deluge.preferences.Downloads());
/*
-Script: Deluge.Preferences.Network.js
+Script: deluge.preferences.Network.js
The network preferences page.
Copyright:
@@ -5127,21 +5252,25 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
+Ext.namespace('Deluge.preferences');
-Ext.deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
+/**
+ * @class Deluge.preferences.Network
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Network'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Network.superclass.constructor.call(this, config);
+ Deluge.preferences.Network.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Network.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ Deluge.preferences.Network.superclass.initComponent.call(this);
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
@@ -5328,9 +5457,9 @@ Ext.deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
}));
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Network());
+deluge.preferences.addPage(new Deluge.preferences.Network());
/*
-Script: Deluge.Preferences.Encryption.js
+Script: deluge.preferences.Encryption.js
The encryption preferences page.
Copyright:
@@ -5362,21 +5491,26 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Encryption
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Encryption'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Encryption.superclass.constructor.call(this, config);
+ Deluge.preferences.Encryption.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Encryption.superclass.initComponent.call(this);
+ Deluge.preferences.Encryption.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
@@ -5442,8 +5576,9 @@ Ext.deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
}));
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Encryption());/*
-Script: Deluge.Preferences.Bandwidth.js
+deluge.preferences.addPage(new Deluge.preferences.Encryption());
+/*
+Script: deluge.preferences.Bandwidth.js
The bandwidth preferences page.
Copyright:
@@ -5475,8 +5610,13 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Bandwidth
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
@@ -5484,13 +5624,13 @@ Ext.deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
layout: 'form',
labelWidth: 10
}, config);
- Ext.deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
+ Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Bandwidth.superclass.initComponent.call(this);
+ Deluge.preferences.Bandwidth.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
border: false,
@@ -5655,7 +5795,7 @@ Ext.deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
}));
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Bandwidth());
+deluge.preferences.addPage(new Deluge.preferences.Bandwidth());
/*
Script: Deluge.Preferences.Interface.js
The interface preferences page.
@@ -5689,19 +5829,24 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Interface
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Interface'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Interface.superclass.constructor.call(this, config);
+ Deluge.preferences.Interface.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Interface.superclass.initComponent.call(this);
+ Deluge.preferences.Interface.superclass.initComponent.call(this);
var optMan = this.optionsManager = new Deluge.OptionsManager();
this.on('show', this.onShow, this);
@@ -5842,7 +5987,7 @@ Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
onApply: function() {
var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) {
- Deluge.Client.web.set_config(changed, {
+ deluge.client.web.set_config(changed, {
success: this.onSetConfig,
scope: this
});
@@ -5868,7 +6013,7 @@ Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
}
var oldPassword = this.oldPassword.getValue();
- Deluge.Client.auth.change_password(oldPassword, newPassword, {
+ deluge.client.auth.change_password(oldPassword, newPassword, {
success: function(result) {
if (!result) {
Ext.MessageBox.show({
@@ -5903,8 +6048,8 @@ Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
},
onShow: function() {
- Ext.deluge.preferences.Interface.superclass.onShow.call(this);
- Deluge.Client.web.get_config({
+ Deluge.preferences.Interface.superclass.onShow.call(this);
+ deluge.client.web.get_config({
success: this.onGotConfig,
scope: this
})
@@ -5915,7 +6060,7 @@ Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
this.certField.setDisabled(!checked);
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Interface());
+deluge.preferences.addPage(new Deluge.preferences.Interface());
/*
Script: Deluge.Preferences.Other.js
The other preferences page.
@@ -5949,21 +6094,26 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Other
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Other'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Other.superclass.constructor.call(this, config);
+ Deluge.preferences.Other.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Other.superclass.initComponent.call(this);
+ Deluge.preferences.Other.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
@@ -6021,7 +6171,7 @@ Ext.deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
}));
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Other());
+deluge.preferences.addPage(new Deluge.preferences.Other());
/*
Script: Deluge.Preferences.Daemon.js
The daemon preferences page.
@@ -6055,21 +6205,26 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Daemon
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Daemon'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Daemon.superclass.constructor.call(this, config);
+ Deluge.preferences.Daemon.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Daemon.superclass.initComponent.call(this);
+ Deluge.preferences.Daemon.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
@@ -6123,7 +6278,7 @@ Ext.deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
}));
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Daemon());
+deluge.preferences.addPage(new Deluge.preferences.Daemon());
/*
Script: Deluge.Preferences.Queue.js
The queue preferences page.
@@ -6157,21 +6312,26 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Queue
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Queue'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Queue.superclass.constructor.call(this, config);
+ Deluge.preferences.Queue.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Queue.superclass.initComponent.call(this);
+ Deluge.preferences.Queue.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
@@ -6344,7 +6504,7 @@ Ext.deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
this.removeAtRatio.setDisabled(!checked);
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Queue());
+deluge.preferences.addPage(new Deluge.preferences.Queue());
/*
Script: Deluge.Preferences.Proxy.js
The proxy preferences page.
@@ -6378,8 +6538,13 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.ProxyField
+ * @extends Ext.form.FormSet
+ */
+Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
constructor: function(config) {
config = Ext.apply({
@@ -6387,11 +6552,11 @@ Ext.deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
autoHeight: true,
labelWidth: 70
}, config);
- Ext.deluge.preferences.ProxyField.superclass.constructor.call(this, config);
+ Deluge.preferences.ProxyField.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.ProxyField.superclass.initComponent.call(this);
+ Deluge.preferences.ProxyField.superclass.initComponent.call(this);
this.type = this.add({
xtype: 'combo',
fieldLabel: _('Type'),
@@ -6512,44 +6677,47 @@ Ext.deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
}
});
-
-Ext.deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
+/**
+ * @class Deluge.preferences.Proxy
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Proxy'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Proxy.superclass.constructor.call(this, config);
+ Deluge.preferences.Proxy.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Proxy.superclass.initComponent.call(this);
- this.peer = this.add(new Ext.deluge.preferences.ProxyField({
+ Deluge.preferences.Proxy.superclass.initComponent.call(this);
+ this.peer = this.add(new Deluge.preferences.ProxyField({
title: _('Peer'),
name: 'peer'
}));
this.peer.on('change', this.onProxyChange, this);
- this.web_seed = this.add(new Ext.deluge.preferences.ProxyField({
+ this.web_seed = this.add(new Deluge.preferences.ProxyField({
title: _('Web Seed'),
name: 'web_seed'
}));
this.web_seed.on('change', this.onProxyChange, this);
- this.tracker = this.add(new Ext.deluge.preferences.ProxyField({
+ this.tracker = this.add(new Deluge.preferences.ProxyField({
title: _('Tracker'),
name: 'tracker'
}));
this.tracker.on('change', this.onProxyChange, this);
- this.dht = this.add(new Ext.deluge.preferences.ProxyField({
+ this.dht = this.add(new Deluge.preferences.ProxyField({
title: _('DHT'),
name: 'dht'
}));
this.dht.on('change', this.onProxyChange, this);
- Deluge.Preferences.getOptionsManager().bind('proxies', this);
+ deluge.preferences.getOptionsManager().bind('proxies', this);
},
getValue: function() {
@@ -6575,9 +6743,9 @@ Ext.deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
this.fireEvent('change', this, newValues, oldValues);
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Proxy());
+deluge.preferences.addPage(new Deluge.preferences.Proxy());
/*
-Script: Deluge.Preferences.Cache.js
+Script: deluge.preferences.Cache.js
The cache preferences page.
Copyright:
@@ -6609,21 +6777,26 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
-Ext.deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
+Ext.namespace('Deluge.preferences');
+
+/**
+ * @class Deluge.preferences.Cache
+ * @extends Ext.form.FormPanel
+ */
+Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
constructor: function(config) {
config = Ext.apply({
border: false,
title: _('Cache'),
layout: 'form'
}, config);
- Ext.deluge.preferences.Cache.superclass.constructor.call(this, config);
+ Deluge.preferences.Cache.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.preferences.Cache.superclass.initComponent.call(this);
+ Deluge.preferences.Cache.superclass.initComponent.call(this);
- var optMan = Deluge.Preferences.getOptionsManager();
+ var optMan = deluge.preferences.getOptionsManager();
var fieldset = this.add({
xtype: 'fieldset',
@@ -6659,7 +6832,7 @@ Ext.deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
}));
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Cache());
+deluge.preferences.addPage(new Deluge.preferences.Cache());
/*
Script: Deluge.Preferences.Plugins.js
The plugins preferences page.
@@ -6693,9 +6866,13 @@ Copyright:
statement from all source files in the program, then also delete it here.
*/
-Ext.namespace('Ext.deluge.preferences');
+Ext.namespace('Deluge.preferences');
-Ext.deluge.preferences.InstallPlugin = Ext.extend(Ext.Window, {
+/**
+ * @class Deluge.preferences.InstallPluginWindow
+ * @extends Ext.Window
+ */
+Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
height: 115,
width: 350,
@@ -6717,7 +6894,7 @@ Ext.deluge.preferences.InstallPlugin = Ext.extend(Ext.Window, {
title: _('Install Plugin'),
initComponent: function() {
- Ext.deluge.add.FileWindow.superclass.initComponent.call(this);
+ Deluge.add.FileWindow.superclass.initComponent.call(this);
this.addButton(_('Install'), this.onInstall, this);
this.form = this.add({
@@ -6758,7 +6935,7 @@ Ext.deluge.preferences.InstallPlugin = Ext.extend(Ext.Window, {
var filename = this.form.getForm().findField('pluginEgg').value;
var path = upload.result.files[0]
this.form.getForm().findField('pluginEgg').setValue('');
- Deluge.Client.web.upload_plugin(filename, path, {
+ deluge.client.web.upload_plugin(filename, path, {
success: this.onUploadPlugin,
scope: this,
filename: filename
@@ -6766,9 +6943,12 @@ Ext.deluge.preferences.InstallPlugin = Ext.extend(Ext.Window, {
}
}
});
-
-Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
+/**
+ * @class Deluge.preferences.Plugins
+ * @extends Ext.Panel
+ */
+Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
constructor: function(config) {
config = Ext.apply({
border: false,
@@ -6777,7 +6957,7 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
height: 400,
cls: 'x-deluge-plugins'
}, config);
- Ext.deluge.preferences.Plugins.superclass.constructor.call(this, config);
+ Deluge.preferences.Plugins.superclass.constructor.call(this, config);
},
pluginTemplate: new Ext.Template(
@@ -6791,7 +6971,7 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
),
initComponent: function() {
- Ext.deluge.preferences.Plugins.superclass.initComponent.call(this);
+ Deluge.preferences.Plugins.superclass.initComponent.call(this);
this.defaultValues = {
'version': '',
'email': '',
@@ -6846,7 +7026,7 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-install-plugin',
text: _('Install'),
- handler: this.onInstallPlugin,
+ handler: this.onInstallPluginWindow,
scope: this
}, '->', {
cls: 'x-btn-text-icon',
@@ -6877,17 +7057,17 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
this.on('show', this.onShow, this);
this.pluginInfo.on('render', this.onPluginInfoRender, this);
this.grid.on('cellclick', this.onCellClick, this);
- Deluge.Preferences.on('show', this.onPreferencesShow, this);
- Deluge.Events.on('PluginDisabledEvent', this.onPluginDisabled, this);
- Deluge.Events.on('PluginEnabledEvent', this.onPluginEnabled, this);
+ deluge.preferences.on('show', this.onPreferencesShow, this);
+ deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
+ deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
},
disablePlugin: function(plugin) {
- Deluge.Client.core.disable_plugin(plugin);
+ deluge.client.core.disable_plugin(plugin);
},
enablePlugin: function(plugin) {
- Deluge.Client.core.enable_plugin(plugin);
+ deluge.client.core.enable_plugin(plugin);
},
setInfo: function(plugin) {
@@ -6897,7 +7077,7 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
},
updatePlugins: function() {
- Deluge.Client.web.get_plugins({
+ deluge.client.web.get_plugins({
success: this.onGotPlugins,
scope: this
});
@@ -6950,9 +7130,9 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
delete info;
},
- onInstallPlugin: function() {
+ onInstallPluginWindow: function() {
if (!this.installWindow) {
- this.installWindow = new Ext.deluge.preferences.InstallPlugin();
+ this.installWindow = new Deluge.preferences.InstallPluginWindow();
this.installWindow.on('pluginadded', this.onPluginInstall, this);
}
this.installWindow.show();
@@ -6977,7 +7157,7 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
},
onPluginSelect: function(selmodel, rowIndex, r) {
- Deluge.Client.web.get_plugin_info(r.get('plugin'), {
+ deluge.client.web.get_plugin_info(r.get('plugin'), {
success: this.onGotPluginInfo,
scope: this
});
@@ -6991,7 +7171,7 @@ Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
this.setInfo();
}
});
-Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());
+deluge.preferences.addPage(new Deluge.preferences.Plugins());
/*
Script:
Deluge.Remove.js
@@ -7026,9 +7206,9 @@ Copyright:
*/
/**
- * @class Ext.deluge.RemoveWindow
+ * @class Deluge.RemoveWindow
*/
-Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {
+Deluge.RemoveWindow = Ext.extend(Ext.Window, {
constructor: function(config) {
config = Ext.apply({
@@ -7042,11 +7222,11 @@ Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {
plain: true,
iconCls: 'x-deluge-remove-window-icon'
}, config);
- Ext.deluge.RemoveWindow.superclass.constructor.call(this, config);
+ Deluge.RemoveWindow.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.RemoveWindow.superclass.initComponent.call(this);
+ Deluge.RemoveWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancel, this);
this.addButton(_('Remove With Data'), this.onRemoveData, this);
this.addButton(_('Remove Torrent'), this.onRemove, this);
@@ -7060,7 +7240,7 @@ Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {
remove: function(removeData) {
Ext.each(this.torrentIds, function(torrentId) {
- Deluge.Client.core.remove_torrent(torrentId, removeData, {
+ deluge.client.core.remove_torrent(torrentId, removeData, {
success: function() {
this.onRemoved(torrentId);
},
@@ -7072,7 +7252,7 @@ Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {
},
show: function(ids) {
- Ext.deluge.RemoveWindow.superclass.show.call(this);
+ Deluge.RemoveWindow.superclass.show.call(this);
this.torrentIds = ids;
},
@@ -7090,15 +7270,15 @@ Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {
},
onRemoved: function(torrentId) {
- Deluge.Events.fire('torrentRemoved', torrentId);
+ deluge.events.fire('torrentRemoved', torrentId);
this.hide();
- Deluge.UI.update();
+ deluge.ui.update();
}
});
-Deluge.RemoveWindow = new Ext.deluge.RemoveWindow();
+deluge.removeWindow = new Deluge.RemoveWindow();
/*
-Script: deluge-bars.js
+Script: Deluge.Sidebar.js
Contains all objects and functions related to the statusbar, toolbar and
sidebar.
@@ -7144,7 +7324,7 @@ Copyright:
var image = '';
if (r.store.id == 'tracker_host') {
if (value != 'Error') {
- image = String.format('url(/tracker/{0})', value);
+ image = String.format('url(' + deluge.config.base + 'tracker/{0})', value);
} else {
lname = null;
}
@@ -7159,11 +7339,11 @@ Copyright:
}
/**
- * @class Ext.deluge.Sidebar
+ * @class Deluge.Sidebar
* @author Damien Churchill
* @version 1.3
*/
- Ext.deluge.Sidebar = Ext.extend(Ext.Panel, {
+ Deluge.Sidebar = Ext.extend(Ext.Panel, {
// private
panels: {},
@@ -7185,23 +7365,24 @@ Copyright:
margins: '5 0 0 5',
cmargins: '5 0 0 5'
}, config);
- Ext.deluge.Sidebar.superclass.constructor.call(this, config);
+ Deluge.Sidebar.superclass.constructor.call(this, config);
},
// private
initComponent: function() {
- Ext.deluge.Sidebar.superclass.initComponent.call(this);
- Deluge.Events.on("disconnect", this.onDisconnect, this);
+ Deluge.Sidebar.superclass.initComponent.call(this);
+ deluge.events.on("disconnect", this.onDisconnect, this);
},
createFilter: function(filter, states) {
- var store = new Ext.data.SimpleStore({
- id: filter,
+ var store = new Ext.data.ArrayStore({
+ idIndex: 0,
fields: [
{name: 'filter'},
{name: 'count'}
]
});
+ store.id = filter;
var title = filter.replace('_', ' ');
var parts = title.split(' ');
@@ -7234,7 +7415,7 @@ Copyright:
autoScroll: true
});
- if (Deluge.config['sidebar_show_zero'] == false) {
+ if (deluge.config['sidebar_show_zero'] == false) {
states = this.removeZero(states);
}
@@ -7244,30 +7425,26 @@ Copyright:
this.doLayout();
this.panels[filter] = panel;
- if (!this.selected) {
- panel.getSelectionModel().selectFirstRow();
- this.selected = {
- row: 0,
- filter: states[0][0],
- panel: panel
- }
- }
+ panel.getSelectionModel().selectFirstRow();
},
getFilters: function() {
var filters = {}
- if (!this.selected) {
- return filters;
- }
- if (!this.selected.filter || !this.selected.panel) {
- return filters;
- }
- var filterType = this.selected.panel.store.id;
- if (filterType == "state" && this.selected.filter == "All") {
- return filters;
- }
-
- filters[filterType] = this.selected.filter;
+
+ // Grab the filters from each of the filter panels
+ this.items.each(function(panel) {
+ var sm = panel.getSelectionModel();
+
+ if (!sm.hasSelection()) return;
+
+ var filter = sm.getSelected();
+ var filterType = panel.getStore().id;
+
+ if (filter.id == "All") return;
+
+ filters[filterType] = filter.id;
+ }, this);
+
return filters;
},
@@ -7281,16 +7458,7 @@ Copyright:
},
onFilterSelect: function(selModel, rowIndex, record) {
- if (!this.selected) needsUpdate = true;
- else if (this.selected.row != rowIndex) needsUpdate = true;
- else needsUpdate = false;
- this.selected = {
- row: rowIndex,
- filter: record.get('filter'),
- panel: this.panels[record.store.id]
- }
-
- if (needsUpdate) Deluge.UI.update();
+ deluge.ui.update();
},
/**
@@ -7326,57 +7494,79 @@ Copyright:
},
updateFilter: function(filter, states) {
- if (Deluge.config['sidebar_show_zero'] == false) {
+ if (deluge.config.sidebar_show_zero == false) {
states = this.removeZero(states);
}
-
- this.panels[filter].store.loadData(states);
- if (this.selected && this.selected.panel == this.panels[filter]) {
- this.panels[filter].getSelectionModel().selectRow(this.selected.row);
- }
+
+ var store = this.panels[filter].getStore();
+ var filters = [];
+ Ext.each(states, function(s, i) {
+ var record = store.getById(s[0]);
+ if (!record) {
+ record = new store.recordType({
+ filter: s[0],
+ count: s[1]
+ });
+ record.id = s[0];
+ store.insert(i, [record]);
+ }
+ record.beginEdit();
+ record.set('filter', s[0]);
+ record.set('count', s[1]);
+ record.endEdit();
+ filters[s[0]] = true;
+ }, this);
+
+ store.each(function(record) {
+ if (filters[record.id]) return;
+
+ store.remove(record);
+ }, this);
+
+ store.commitChanges();
}
});
- Deluge.Sidebar = new Ext.deluge.Sidebar();
+ deluge.sidebar = new Deluge.Sidebar();
})();
-Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
+Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
constructor: function(config) {
config = Ext.apply({
id: 'deluge-statusbar',
defaultIconCls: 'x-not-connected',
defaultText: _('Not Connected')
}, config);
- Ext.deluge.Statusbar.superclass.constructor.call(this, config);
+ Deluge.Statusbar.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.Statusbar.superclass.initComponent.call(this);
+ Deluge.Statusbar.superclass.initComponent.call(this);
- Deluge.Events.on('connect', this.onConnect, this);
- Deluge.Events.on('disconnect', this.onDisconnect, this);
+ deluge.events.on('connect', this.onConnect, this);
+ deluge.events.on('disconnect', this.onDisconnect, this);
},
createButtons: function() {
- this.add({
+ this.buttons = this.add({
id: 'statusbar-connections',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-connections',
tooltip: _('Connections'),
- menu: Deluge.Menus.Connections
+ menu: deluge.menus.connections
}, '-', {
id: 'statusbar-downspeed',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-downloading',
tooltip: _('Download Speed'),
- menu: Deluge.Menus.Download
+ menu: deluge.menus.download
}, '-', {
id: 'statusbar-upspeed',
text: ' ',
cls: 'x-btn-text-icon',
iconCls: 'x-deluge-seeding',
tooltip: _('Upload Speed'),
- menu: Deluge.Menus.Upload
+ menu: deluge.menus.upload
}, '-', {
id: 'statusbar-traffic',
text: ' ',
@@ -7400,25 +7590,28 @@ Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
},
onConnect: function() {
- //this.setStatus({
- // iconCls: 'x-connected',
- // text: ''
- //});
- if (!this.created) this.createButtons();
- else {
- this.items.each(function(item) {
+ this.setStatus({
+ iconCls: 'x-connected',
+ text: ''
+ });
+ if (!this.created) {
+ this.createButtons();
+ } else {
+ Ext.each(this.buttons, function(item) {
item.show();
item.enable();
});
}
+ this.doLayout();
},
onDisconnect: function() {
- //this.clearStatus({useDefaults:true});
- this.items.each(function(item) {
+ this.clearStatus({useDefaults:true});
+ Ext.each(this.buttons, function(item) {
item.hide();
item.disable();
});
+ this.doLayout();
},
update: function(stats) {
@@ -7429,11 +7622,11 @@ Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
var updateStat = function(name, config) {
var item = this.items.get('statusbar-' + name);
if (config.limit.value > 0) {
- var value = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
- var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value) : config.limit.value;
+ var value = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
+ var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value, true) : config.limit.value;
var str = String.format(config.format, value, limit);
} else {
- var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
+ var str = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
}
item.setText(str);
}.createDelegate(this);
@@ -7483,12 +7676,12 @@ Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
this.items.get('statusbar-dht').setText(stats.dht_nodes);
this.items.get('statusbar-freespace').setText(fsize(stats.free_space));
- Deluge.Menus.Connections.setValue(stats.max_num_connections);
- Deluge.Menus.Download.setValue(stats.max_download);
- Deluge.Menus.Upload.setValue(stats.max_upload);
+ deluge.menus.connections.setValue(stats.max_num_connections);
+ deluge.menus.download.setValue(stats.max_download);
+ deluge.menus.upload.setValue(stats.max_upload);
}
});
-Deluge.Statusbar = new Ext.deluge.Statusbar();
+deluge.statusbar = new Deluge.Statusbar();
/*
Script: Deluge.Toolbar.js
Contains the Deluge toolbar.
@@ -7525,87 +7718,77 @@ Copyright:
/**
* An extension of the Ext.Toolbar class that provides an extensible toolbar for Deluge.
- * @class Ext.deluge.Toolbar
+ * @class Deluge.Toolbar
* @extends Ext.Toolbar
*/
-Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
+Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
constructor: function(config) {
config = Ext.apply({
items: [
{
id: 'create',
- cls: 'x-btn-text-icon',
disabled: true,
text: _('Create'),
- icon: '/icons/create.png',
+ iconCls: 'icon-create',
handler: this.onTorrentAction
},{
id: 'add',
- cls: 'x-btn-text-icon',
disabled: true,
text: _('Add'),
- icon: '/icons/add.png',
+ iconCls: 'icon-add',
handler: this.onTorrentAdd
},{
id: 'remove',
- cls: 'x-btn-text-icon',
disabled: true,
text: _('Remove'),
- icon: '/icons/remove.png',
+ iconCls: 'icon-remove',
handler: this.onTorrentAction
},'|',{
id: 'pause',
- cls: 'x-btn-text-icon',
disabled: true,
text: _('Pause'),
- icon: '/icons/pause.png',
+ iconCls: 'icon-pause',
handler: this.onTorrentAction
},{
id: 'resume',
- cls: 'x-btn-text-icon',
disabled: true,
text: _('Resume'),
- icon: '/icons/start.png',
+ iconCls: 'icon-resume',
handler: this.onTorrentAction
},'|',{
id: 'up',
cls: 'x-btn-text-icon',
disabled: true,
text: _('Up'),
- icon: '/icons/up.png',
+ iconCls: 'icon-up',
handler: this.onTorrentAction
},{
id: 'down',
- cls: 'x-btn-text-icon',
disabled: true,
text: _('Down'),
- icon: '/icons/down.png',
+ iconCls: 'icon-down',
handler: this.onTorrentAction
},'|',{
id: 'preferences',
- cls: 'x-btn-text-icon',
text: _('Preferences'),
iconCls: 'x-deluge-preferences',
handler: this.onPreferencesClick,
scope: this
},{
id: 'connectionman',
- cls: 'x-btn-text-icon',
text: _('Connection Manager'),
iconCls: 'x-deluge-connection-manager',
handler: this.onConnectionManagerClick,
scope: this
},'->',{
id: 'help',
- cls: 'x-btn-text-icon',
- icon: '/icons/help.png',
+ iconCls: 'icon-help',
text: _('Help'),
handler: this.onHelpClick,
scope: this
},{
id: 'logout',
- cls: 'x-btn-text-icon',
- icon: '/icons/logout.png',
+ iconCls: 'icon-logout',
disabled: true,
text: _('Logout'),
handler: this.onLogout,
@@ -7613,7 +7796,7 @@ Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
}
]
}, config);
- Ext.deluge.Toolbar.superclass.constructor.call(this, config);
+ Deluge.Toolbar.superclass.constructor.call(this, config);
},
connectedButtons: [
@@ -7621,9 +7804,9 @@ Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
],
initComponent: function() {
- Ext.deluge.Toolbar.superclass.initComponent.call(this);
- Deluge.Events.on('connect', this.onConnect, this);
- Deluge.Events.on('login', this.onLogin, this);
+ Deluge.Toolbar.superclass.initComponent.call(this);
+ deluge.events.on('connect', this.onConnect, this);
+ deluge.events.on('login', this.onLogin, this);
},
onConnect: function() {
@@ -7644,11 +7827,11 @@ Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
onLogout: function() {
this.items.get('logout').disable();
- Deluge.Login.logout();
+ deluge.login.logout();
},
onConnectionManagerClick: function() {
- Deluge.ConnectionManager.show();
+ deluge.connectionManager.show();
},
onHelpClick: function() {
@@ -7656,11 +7839,11 @@ Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
},
onPreferencesClick: function() {
- Deluge.Preferences.show();
+ deluge.preferences.show();
},
onTorrentAction: function(item) {
- var selection = Deluge.Torrents.getSelections();
+ var selection = deluge.torrents.getSelections();
var ids = [];
Ext.each(selection, function(record) {
ids.push(record.id);
@@ -7668,21 +7851,21 @@ Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
switch (item.id) {
case 'remove':
- Deluge.RemoveWindow.show(ids);
+ deluge.removeWindow.show(ids);
break;
case 'pause':
case 'resume':
- Deluge.Client.core[item.id + '_torrent'](ids, {
+ deluge.client.core[item.id + '_torrent'](ids, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
break;
case 'up':
case 'down':
- Deluge.Client.core['queue_' + item.id](ids, {
+ deluge.client.core['queue_' + item.id](ids, {
success: function() {
- Deluge.UI.update();
+ deluge.ui.update();
}
});
break;
@@ -7690,11 +7873,11 @@ Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
},
onTorrentAdd: function() {
- Deluge.Add.show();
+ deluge.add.show();
}
});
-Deluge.Toolbar = new Ext.deluge.Toolbar();
+deluge.toolbar = new Deluge.Toolbar();
/*
Script: Deluge.Torrent.js
Contains the Deluge.Torrent record.
@@ -7861,7 +8044,7 @@ Copyright:
return (value < 0) ? '∞' : new Number(value).toFixed(3);
}
function trackerRenderer(value, p, r) {
- return String.format('{0}
', value);
+ return String.format('{0}
', value);
}
function etaSorter(eta) {
@@ -7869,17 +8052,17 @@ Copyright:
}
/**
- * Ext.deluge.TorrentGrid Class
+ * Deluge.TorrentGrid Class
*
* @author Damien Churchill
* @version 1.3
*
- * @class Ext.deluge.TorrentGrid
+ * @class Deluge.TorrentGrid
* @extends Ext.grid.GridPanel
* @constructor
* @param {Object} config Configuration options
*/
- Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
+ Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
// object to store contained torrent ids
torrents: {},
@@ -8003,13 +8186,13 @@ Copyright:
scrollDelay: false
})
}, config);
- Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
+ Deluge.TorrentGrid.superclass.constructor.call(this, config);
},
initComponent: function() {
- Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
- Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
- Deluge.Events.on('logout', this.onDisconnect, this);
+ Deluge.TorrentGrid.superclass.initComponent.call(this);
+ deluge.events.on('torrentRemoved', this.onTorrentRemoved, this);
+ deluge.events.on('logout', this.onDisconnect, this);
this.on('rowcontextmenu', function(grid, rowIndex, e) {
e.stopEvent();
@@ -8017,7 +8200,7 @@ Copyright:
if (!selection.hasSelection()) {
selection.selectRow(rowIndex);
}
- Deluge.Menus.Torrent.showAt(e.getPoint());
+ deluge.menus.torrent.showAt(e.getPoint());
});
},
@@ -8039,6 +8222,9 @@ Copyright:
return this.getSelectionModel().getSelected();
},
+ /**
+ * Returns the currently selected records.
+ */
getSelections: function() {
return this.getSelectionModel().getSelections();
},
@@ -8073,14 +8259,20 @@ Copyright:
store.each(function(record) {
if (!torrents[record.id]) {
store.remove(record);
+ delete this.torrents[record.id];
}
- });
+ }, this);
store.commitChanges();
+
+ var sortState = store.getSortState()
+ if (!sortState) return;
+ store.sort(sortState.field, sortState.direction);
},
// private
onDisconnect: function() {
this.getStore().removeAll();
+ this.torrents = {};
},
// private
@@ -8095,7 +8287,7 @@ Copyright:
}, this);
}
});
-Deluge.Torrents = new Ext.deluge.TorrentGrid();
+deluge.torrents = new Deluge.TorrentGrid();
})();
/*
Script: Deluge.UI.js
@@ -8137,7 +8329,7 @@ Copyright:
* The controller for the whole interface, that ties all the components
* together and handles the 2 second poll.
*/
-Deluge.UI = {
+deluge.ui = {
errorCount: 0,
@@ -8153,13 +8345,13 @@ Deluge.UI = {
iconCls: 'x-deluge-main-panel',
title: 'Deluge',
layout: 'border',
- tbar: Deluge.Toolbar,
+ tbar: deluge.toolbar,
items: [
- Deluge.Sidebar,
- Deluge.Details,
- Deluge.Torrents
+ deluge.sidebar,
+ deluge.details,
+ deluge.torrents
],
- bbar: Deluge.Statusbar
+ bbar: deluge.statusbar
});
this.Viewport = new Ext.Viewport({
@@ -8167,35 +8359,37 @@ Deluge.UI = {
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.events.on("connect", this.onConnect, this);
+ deluge.events.on("disconnect", this.onDisconnect, this);
+ deluge.client = new Ext.ux.util.RpcClient({
+ url: deluge.config.base + 'json'
});
- for (var plugin in Deluge.Plugins) {
- plugin = Deluge.Plugins[plugin];
+ for (var plugin in deluge.dlugins) {
+ plugin = deluge.plugins[plugin];
plugin.enable();
}
// Initialize quicktips so all the tooltip configs start working.
Ext.QuickTips.init();
- Deluge.Client.on('connected', function(e) {
- Deluge.Login.show();
+ deluge.client.on('connected', function(e) {
+ deluge.login.show();
}, this, {single: true});
this.update = this.update.createDelegate(this);
+
+ this.originalTitle = document.title;
},
update: function() {
- var filters = Deluge.Sidebar.getFilters();
- Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, {
+ var filters = deluge.sidebar.getFilters();
+ deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
success: this.onUpdate,
failure: this.onUpdateError,
scope: this
});
- Deluge.Details.update();
+ deluge.details.update();
},
onUpdateError: function(error) {
@@ -8216,10 +8410,16 @@ Deluge.UI = {
* Updates the various components in the interface.
*/
onUpdate: function(data) {
- if (!data['connected']) Deluge.Events.fire('disconnect');
- Deluge.Torrents.update(data['torrents']);
- Deluge.Statusbar.update(data['stats']);
- Deluge.Sidebar.update(data['filters']);
+ if (!data['connected']) deluge.events.fire('disconnect');
+
+ if (deluge.config.show_session_speed) {
+ document.title = this.originalTitle +
+ ' (Down: ' + fspeed(data['stats'].download_rate, true) +
+ ' Up: ' + fspeed(data['stats'].upload_rate, true) + ')';
+ }
+ deluge.torrents.update(data['torrents']);
+ deluge.statusbar.update(data['stats']);
+ deluge.sidebar.update(data['filters']);
this.errorCount = 0;
},
@@ -8244,14 +8444,14 @@ Deluge.UI = {
},
onPluginEnabled: function(pluginName) {
- Deluge.Client.web.get_plugin_resources(pluginName, {
+ deluge.client.web.get_plugin_resources(pluginName, {
success: this.onGotPluginResources,
scope: this
})
},
onGotPluginResources: function(resources) {
- var scripts = (Deluge.debug) ? resources.debug_scripts : resources.scripts;
+ var scripts = (deluge.debug) ? resources.debug_scripts : resources.scripts;
Ext.each(scripts, function(script) {
Ext.ux.JSLoader({
url: script,
@@ -8262,15 +8462,15 @@ Deluge.UI = {
},
onPluginDisabled: function(pluginName) {
- Deluge.Plugins[pluginName].disable();
+ deluge.plugins[pluginName].disable();
},
onPluginLoaded: function(options) {
// This could happen if the plugin has multiple scripts
- if (!Deluge.Plugins[options.pluginName]) return;
+ if (!deluge.plugins[options.pluginName]) return;
// Enable the plugin
- Deluge.Plugins[options.pluginName].enable();
+ deluge.plugins[options.pluginName].enable();
},
/**
@@ -8281,11 +8481,11 @@ Deluge.UI = {
if (this.running) {
clearInterval(this.running);
this.running = false;
- Deluge.Torrents.getStore().removeAll();
+ deluge.torrents.getStore().removeAll();
}
}
}
Ext.onReady(function(e) {
- Deluge.UI.initialize();
+ deluge.ui.initialize();
});
diff --git a/deluge/ui/web/js/deluge-all.js b/deluge/ui/web/js/deluge-all.js
index 46189cbaa..05991d1b0 100644
--- a/deluge/ui/web/js/deluge-all.js
+++ b/deluge/ui/web/js/deluge-all.js
@@ -1 +1 @@
-Ext.namespace("Ext.deluge");Ext.state.Manager.setProvider(new Ext.state.CookieProvider());(function(){Ext.apply(Ext,{escapeHTML:function(a){a=String(a).replace("<","<").replace(">",">");return a.replace("&","&")},isObjectEmpty:function(b){for(var a in b){return false}return true},isObjectsEqual:function(d,c){var b=true;if(!d||!c){return false}for(var a in d){if(d[a]!=c[a]){b=false}}return b},keys:function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b},values:function(c){var a=[];for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys;Ext.BLANK_IMAGE_URL="/images/s.gif";Ext.USE_NATIVE_JSON=true})();(function(){var a='';Deluge.progressBar=function(d,f,h,b){b=Ext.value(b,10);var c=((f/100)*d).toFixed(0);var e=c-1;var g=((c-b)>0?c-b:0);return String.format(a,h,f,e,g)};Deluge.Plugins={}})();FILE_PRIORITY={9:"Mixed",0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority",Mixed:9,"Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={9:"x-mixed-download",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.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"],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)});Deluge.Menus={onTorrentAction:function(c,f){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(e){a.push(e.id)});var d=c.initialConfig.torrentAction;switch(d){case"pause":case"resume":Deluge.Client.core[d+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"top":case"up":case"down":case"bottom":Deluge.Client.core["queue_"+d](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.RemoveWindow.show(a);break;case"recheck":Deluge.Client.core.force_recheck(a,{success:function(){Deluge.UI.update()}});break;case"move":Deluge.MoveStorage.show(a);break}}};Deluge.Menus.Torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{torrentAction:"pause",text:_("Pause"),iconCls:"icon-pause",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"resume",text:_("Resume"),iconCls:"icon-resume",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{text:_("Options"),iconCls:"icon-options",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"),iconCls:"icon-queue",menu:new Ext.menu.Menu({items:[{torrentAction:"top",text:_("Top"),iconCls:"icon-top",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"up",text:_("Up"),iconCls:"icon-up",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"down",text:_("Down"),iconCls:"icon-down",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"bottom",text:_("Bottom"),iconCls:"icon-bottom",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]})},"-",{torrentAction:"update",text:_("Update Tracker"),iconCls:"icon-update-tracker",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"edit_trackers",text:_("Edit Trackers"),iconCls:"icon-edit-trackers",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{torrentAction:"remove",text:_("Remove Torrent"),iconCls:"icon-remove",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{torrentAction:"recheck",text:_("Force Recheck"),iconCls:"icon-recheck",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"move",text:_("Move Storage"),iconCls:"icon-move",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]});Ext.deluge.StatusbarMenu=Ext.extend(Ext.menu.Menu,{setValue:function(b){b=(b==0)?-1:b;var a=this.items.get(b);if(!a){a=this.items.get("other")}a.suspendEvents();a.setChecked(true);a.resumeEvents()}});Deluge.Menus.Connections=new Ext.deluge.StatusbarMenu({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.deluge.StatusbarMenu({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.deluge.StatusbarMenu({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(){this.toRegister=[];this.on("login",this.onLogin,this);Events.superclass.constructor.call(this)},addListener:function(a,c,b,d){this.addEvents(a);if(/[A-Z]/.test(a.substring(0,1))){if(!Deluge.Client){this.toRegister.push(a)}else{Deluge.Client.web.register_event_listener(a)}}Events.superclass.addListener.call(this,a,c,b,d)},getEvents:function(){Deluge.Client.web.get_events({success:this.onGetEventsSuccess,failure:this.onGetEventsFailure,scope:this})},start:function(){Ext.each(this.toRegister,function(a){Deluge.Client.web.register_event_listener(a)});this.running=true;this.getEvents()},stop:function(){this.running=false},onLogin:function(){this.start();this.on("PluginEnabledEvent",this.onPluginEnabled,this);this.on("PluginDisabledEvent",this.onPluginDisabled,this)},onGetEventsSuccess:function(a){if(!a){return}Ext.each(a,function(d){var c=d[0],b=d[1];b.splice(0,0,c);this.fireEvent.apply(this,b)},this);if(this.running){this.getEvents()}},onGetEventsFailure:function(a){if(this.running){this.getEvents()}}});Events.prototype.on=Events.prototype.addListener;Events.prototype.fire=Events.prototype.fireEvent;Deluge.Events=new Events()})();Ext.namespace("Deluge");Deluge.OptionsManager=Ext.extend(Ext.util.Observable,{constructor:function(a){a=a||{};this.binds={};this.changed={};this.options=(a&&a.options)||{};this.focused=null;this.addEvents({add:true,changed:true,reset:true});this.on("changed",this.onChange,this);Deluge.OptionsManager.superclass.constructor.call(this)},addOptions:function(a){this.options=Ext.applyIf(this.options,a)},bind:function(a,b){this.binds[a]=this.binds[a]||[];this.binds[a].push(b);b._doption=a;b.on("focus",this.onFieldFocus,this);b.on("blur",this.onFieldBlur,this);b.on("change",this.onFieldChange,this);b.on("check",this.onFieldChange,this);return b},commit:function(){this.options=Ext.apply(this.options,this.changed);this.reset()},convertValueType:function(a,b){if(Ext.type(a)!=Ext.type(b)){switch(Ext.type(a)){case"string":b=String(b);break;case"number":b=Number(b);break;case"boolean":if(Ext.type(b)=="string"){b=b.toLowerCase();b=(b=="true"||b=="1"||b=="on")?true:false}else{b=Boolean(b)}break}}return b},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[b]:this.options[b]}else{var a={};Ext.each(arguments,function(c){if(!this.has(c)){return}a[c]=(this.isDirty(c))?this.changed[c]:this.options[c]},this);return a}},getDefault:function(a){return this.options[a]},getDirty:function(){return this.changed},isDirty:function(a){return !Ext.isEmpty(this.changed[a])},has:function(a){return(this.options[a])},reset:function(){this.changed={}},set:function(b,c){if(b===undefined){return}else{if(typeof b=="object"){var a=b;this.options=Ext.apply(this.options,a);for(var b in a){this.onChange(b,a[b])}}else{this.options[b]=c;this.onChange(b,c)}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[d]}this.fireEvent("changed",d,e,b);return}this.changed[d]=e;this.fireEvent("changed",d,e,b)}}},onFieldBlur:function(b,a){if(this.focused==b){this.focused=null}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onFieldFocus:function(b,a){this.focused=b},onChange:function(b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(d){if(d==this.focused){return}d.setValue(c)},this)}});Deluge.MultiOptionsManager=Ext.extend(Deluge.OptionsManager,{constructor:function(a){this.currentId=null;this.stored={};Deluge.MultiOptionsManager.superclass.constructor.call(this,a)},changeId:function(d,b){var c=this.currentId;this.currentId=d;if(!b){for(var a in this.options){if(!this.binds[a]){continue}Ext.each(this.binds[a],function(e){e.setValue(this.get(a))},this)}}return c},commit:function(){this.stored[this.currentId]=Ext.apply(this.stored[this.currentId],this.changed[this.currentId]);this.reset()},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}else{if(arguments.length==0){var a={};for(var b in this.options){a[b]=(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}return a}else{var a={};Ext.each(arguments,function(c){a[c]=(this.isDirty(c))?this.changed[this.currentId][c]:this.getDefault(c)},this);return a}}},getDefault:function(a){return(this.has(a))?this.stored[this.currentId][a]:this.options[a]},getDirty:function(){return(this.changed[this.currentId])?this.changed[this.currentId]:{}},isDirty:function(a){return(this.changed[this.currentId]&&!Ext.isEmpty(this.changed[this.currentId][a]))},has:function(a){return(this.stored[this.currentId]&&!Ext.isEmpty(this.stored[this.currentId][a]))},reset:function(){if(this.changed[this.currentId]){delete this.changed[this.currentId]}if(this.stored[this.currentId]){delete this.stored[this.currentId]}},resetAll:function(){this.changed={};this.stored={};this.changeId(null)},setDefault:function(c,d){if(c===undefined){return}else{if(d===undefined){for(var b in c){this.setDefault(b,c[b])}}else{var a=this.getDefault(c);d=this.convertValueType(a,d);if(a==d){return}if(!this.stored[this.currentId]){this.stored[this.currentId]={}}this.stored[this.currentId][c]=d;if(!this.isDirty(c)){this.fireEvent("changed",this.currentId,c,d,a)}}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{if(!this.changed[this.currentId]){this.changed[this.currentId]={}}var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[this.currentId][d]}this.fireEvent("changed",this.currentId,d,e,b);return}else{this.changed[this.currentId][d]=e;this.fireEvent("changed",this.currentId,d,e,b)}}}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onChange:function(d,b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(e){if(e==this.focused){return}e.setValue(c)},this)}});Ext.namespace("Ext.deluge.add");Ext.deluge.add.OptionsPanel=Ext.extend(Ext.TabPanel,{torrents:{},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.ux.tree.TreeGrid({layout:"fit",title:_("Files"),rootVisible:false,autoScroll:true,height:170,border:false,animate:false,disabled:true,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:80,dataIndex:"size",renderer:fsize}]}));new Ext.tree.TreeSorter(this.files,{folderSort:true});this.optionsManager=new Deluge.MultiOptionsManager();this.form=this.add({xtype:"form",labelWidth:1,title:_("Options"),bodyStyle:"padding: 5px;",border:false,height:170,disabled:true});var a=this.form.add({xtype:"fieldset",title:_("Download Location"),border:false,autoHeight:true,defaultType:"textfield",labelWidth:1,fieldLabel:""});this.optionsManager.bind("download_location",a.add({fieldLabel:"",name:"download_location",width:400,labelSeparator:""}));var b=this.form.add({border:false,layout:"column",defaultType:"fieldset"});a=b.add({title:_("Allocation"),border:false,autoHeight:true,defaultType:"radio",width:100});this.optionsManager.bind("compact_allocation",a.add({xtype:"radiogroup",columns:1,vertical:true,labelSeparator:"",items:[{name:"compact_allocation",value:false,inputValue:false,boxLabel:_("Full"),fieldLabel:"",labelSeparator:""},{name:"compact_allocation",value:true,inputValue:true,boxLabel:_("Compact"),fieldLabel:"",labelSeparator:"",}]}));a=b.add({title:_("Bandwidth"),border:false,autoHeight:true,labelWidth:100,width:200,defaultType:"spinnerfield"});this.optionsManager.bind("max_download_speed",a.add({fieldLabel:_("Max Down Speed"),name:"max_download_speed",width:60}));this.optionsManager.bind("max_upload_speed",a.add({fieldLabel:_("Max Up Speed"),name:"max_upload_speed",width:60}));this.optionsManager.bind("max_connections",a.add({fieldLabel:_("Max Connections"),name:"max_connections",width:60}));this.optionsManager.bind("max_upload_slots",a.add({fieldLabel:_("Max Upload Slots"),name:"max_upload_slots",width:60}));a=b.add({title:_("General"),border:false,autoHeight:true,defaultType:"checkbox"});this.optionsManager.bind("add_paused",a.add({name:"add_paused",boxLabel:_("Add In Paused State"),fieldLabel:"",labelSeparator:"",}));this.optionsManager.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",boxLabel:_("Prioritize First/Last Pieces"),fieldLabel:"",labelSeparator:"",}));this.form.on("render",this.onFormRender,this)},onFormRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout()},addTorrent:function(c){this.torrents[c.info_hash]=c;var b={};this.walkFileTree(c.files_tree,function(e,g,h,f){if(g!="file"){return}b[h[0]]=h[2]},this);var a=[];Ext.each(Ext.keys(b),function(e){a[e]=b[e]});var d=this.optionsManager.changeId(c.info_hash,true);this.optionsManager.setDefault("file_priorities",a);this.optionsManager.changeId(d,true)},clear:function(){this.clearFiles();this.optionsManager.resetAll()},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(c){var b={file_priorities:[],add_paused:c.add_paused,compact_allocation:c.compact_allocation,download_location:c.download_location,max_connections:c.max_connections_per_torrent,max_download_speed:c.max_download_speed_per_torrent,max_upload_slots:c.max_upload_slots_per_torrent,max_upload_speed:c.max_upload_speed_per_torrent,prioritize_first_last_pieces:c.prioritize_first_last_pieces};this.optionsManager.options=b;this.optionsManager.resetAll()},scope:this})},getFilename:function(a){return this.torrents[a]["filename"]},getOptions:function(a){var c=this.optionsManager.changeId(a,true);var b=this.optionsManager.get();this.optionsManager.changeId(c,true);Ext.each(b.file_priorities,function(e,d){b.file_priorities[d]=(e)?1:0});return b},setTorrent:function(b){if(!b){return}this.torrentId=b;this.optionsManager.changeId(b);this.clearFiles();var a=this.files.getRootNode();var c=this.optionsManager.get("file_priorities");this.walkFileTree(this.torrents[b]["files_tree"],function(d,f,i,e){if(f=="dir"){var h=new Ext.tree.TreeNode({text:d,checked:true});h.on("checkchange",this.onFolderCheck,this);e.appendChild(h);return h}else{var g=new Ext.tree.TreeNode({filename:d,fileindex:i[0],text:d,size:fsize(i[1]),leaf:true,checked:c[i[0]],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});g.on("checkchange",this.onNodeCheck,this);e.appendChild(g)}},this,a);a.firstChild.expand()},walkFileTree:function(g,h,e,d){for(var a in g){var f=g[a];var c=(Ext.type(f)=="object")?"dir":"file";if(e){var b=h.apply(e,[a,c,f,d])}else{var b=h(a,c,f,d)}if(c=="dir"){this.walkFileTree(f,h,e,b)}}},onFolderCheck:function(c,b){var a=this.optionsManager.get("file_priorities");c.cascade(function(d){if(!d.ui.checkbox){d.attributes.checked=b}else{d.ui.checkbox.checked=b}a[d.attributes.fileindex]=b},this);this.optionsManager.setDefault("file_priorities",a)},onNodeCheck:function(c,b){var a=this.optionsManager.get("file_priorities");a[c.attributes.fileindex]=b;this.optionsManager.update("file_priorities",a)}});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,{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.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,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.optionsPanel=this.add(new Ext.deluge.add.OptionsPanel());this.on("hide",this.onHide,this);this.on("show",this.onShow,this)},clear:function(){this.grid.getStore().removeAll();this.optionsPanel.clear()},onAddClick:function(){var a=[];if(!this.grid){return}this.grid.getStore().each(function(b){var c=b.get("info_hash");a.push({path:this.optionsPanel.getFilename(c),options:this.optionsPanel.getOptions(c)})},this);Deluge.Client.web.add_torrents(a,{success:function(b){}});this.clear();this.hide()},onCancelClick:function(){this.clear();this.hide()},onFile:function(){this.file.show()},onHide:function(){this.optionsPanel.setActiveTab(0);this.optionsPanel.files.setDisabled(true);this.optionsPanel.form.setDisabled(true)},onRemove:function(){var a=this.grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();this.grid.getStore().remove(b);this.optionsPanel.clear();if(this.torrents&&this.torrents[b.id]){delete this.torrents[b.id]}},onSelect:function(b,c,a){this.optionsPanel.setTorrent(a.get("info_hash"));this.optionsPanel.files.setDisabled(false);this.optionsPanel.form.setDisabled(false)},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)}this.optionsPanel.getDefaults()},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.optionsPanel.addTorrent(c)},onUrl:function(a,b){this.url.show()}});Deluge.Add=new Ext.deluge.add.AddWindow();Ext.namespace("Ext.deluge.add");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"},a);Ext.deluge.add.FileWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:35,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"torrentFile",width:280,emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onAddClick: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();if(b.result.success){var a=b.result.files[0];this.form.getForm().findField("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a})}}});Ext.namespace("Ext.deluge.add");Ext.deluge.add.UrlWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:155,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon"},a);Ext.deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);var a=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55});this.urlField=a.add({fieldLabel:_("Url"),id:"url",name:"url",anchor:"100%"});this.urlField.on("specialkey",this.onAdd,this);this.cookieField=a.add({fieldLabel:_("Cookies"),id:"cookies",name:"cookies",anchor:"100%"});this.cookieField.on("specialkey",this.onAdd,this)},onAddClick:function(f,d){if((f.id=="url"||f.id=="cookies")&&d.getKey()!=d.ENTER){return}var f=this.urlField;var b=f.getValue();var c=this.cookieField.getValue();var a=this.createTorrentId();Deluge.Client.web.download_torrent_from_url(b,c,{success:this.onDownload,scope:this,torrentId:a});this.hide();this.fireEvent("beforeadd",a,b)},onDownload:function(a,c,d,b){this.urlField.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");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","error");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:{msg:"HTTP: "+b.status+" "+b.statusText,code:255}};this.fireEvent("error",errorObj,b,a);if(Ext.type(c.failure)!="function"){return}if(c.scope){c.failure.call(c.scope,errorObj,b,a)}else{c.failure(errorObj,b,a)}},_onSuccess:function(c,a){var b=Ext.decode(c.responseText);var d=a.options;if(b.error){this.fireEvent("error",b,c,a);if(Ext.type(d.failure)!="function"){return}if(d.scope){d.failure.call(d.scope,b,c,a)}else{d.failure(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 i=a._parseArgs(arguments);return a._execute(h,i)};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.AddConnectionWindow=Ext.extend(Ext.Window,{constructor:function(b){b=Ext.apply({layout:"fit",width:300,height:195,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Add Connection"),iconCls:"x-deluge-add-window-icon"},b);Ext.deluge.AddConnectionWindow.superclass.constructor.call(this,b)},initComponent:function(){Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this);this.addEvents("hostadded");this.addButton(_("Close"),this.hide,this);this.addButton(_("Add"),this.onAddClick,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",id:"connectionAddForm",baseCls:"x-plain",labelWidth:55});this.hostField=this.form.add({fieldLabel:_("Host"),id:"host",name:"host",anchor:"100%",value:""});this.portField=this.form.add({fieldLabel:_("Port"),id:"port",xtype:"uxspinner",ctCls:"x-form-uxspinner",name:"port",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:65535},value:"58846",anchor:"50%"});this.usernameField=this.form.add({fieldLabel:_("Username"),id:"username",name:"username",anchor:"100%",value:""});this.passwordField=this.form.add({fieldLabel:_("Password"),anchor:"100%",id:"_password",name:"_password",inputType:"password",value:""})},onAddClick:function(){var d=this.hostField.getValue();var b=this.portField.getValue();var e=this.usernameField.getValue();var c=this.passwordField.getValue();Deluge.Client.web.add_host(d,b,e,c,{success:function(f){if(!f[0]){Ext.MessageBox.show({title:_("Error"),msg:"Unable to add host: "+f[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.fireEvent("hostadded")}this.hide()},scope:this})},onHide:function(){this.form.getForm().reset()}});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,this);this.on("show",this.onShow,this);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},selectionchange:{fn:this.onSelectionChanged,scope:this}}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({buttons:[{id:"cm-add",cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAddClick,scope:this},{id:"cm-remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,disabled:true,scope:this},"->",{id:"cm-stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),icon:"/icons/error.png",handler:this.onStop,disabled:true,scope:this}]})});this.update=this.update.createDelegate(this)},disconnect:function(){Deluge.Events.fire("disconnect")},loadHosts:function(){Deluge.Client.web.get_hosts({success:this.onGetHosts,scope:this})},update:function(){this.grid.getStore().each(function(b){Deluge.Client.web.get_host_status(b.id,{success:this.onGetHostStatus,scope:this})},this)},updateButtons:function(c){var d=this.buttons[1],b=c.get("status");if(b==_("Connected")){d.enable();d.setText(_("Disconnect"))}else{if(b==_("Offline")){d.disable()}else{d.enable();d.setText(_("Connect"))}}if(b==_("Offline")){if(c.get("host")=="127.0.0.1"||c.get("host")=="localhost"){this.stopHostButton.enable();this.stopHostButton.setText(_("Start Daemon"))}else{this.stopHostButton.disable()}}else{this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}},onAddClick:function(b,c){if(!this.addWindow){this.addWindow=new Ext.deluge.AddConnectionWindow();this.addWindow.on("hostadded",this.onHostAdded,this)}this.addWindow.show()},onHostAdded:function(){this.loadHosts()},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.update(this);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})}});this.hide()}},onGetHosts:function(b){this.grid.getStore().loadData(b);Ext.each(b,function(c){Deluge.Client.web.get_host_status(c[0],{success:this.onGetHostStatus,scope:this})},this)},onGetHostStatus:function(c){var b=this.grid.getStore().getById(c[0]);b.set("status",c[3]);b.set("version",c[4]);b.commit();if(this.grid.getSelectionModel().getSelected()==b){this.updateButtons(b)}},onHide:function(){if(this.running){window.clearInterval(this.running)}},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=this.grid.getSelectionModel().getSelected();if(!b){return}Deluge.Client.web.remove_host(b.id,{success: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{this.grid.getStore().remove(b)}},scope:this})},onSelect:function(c,d,b){this.selectedRow=d},onSelectionChanged:function(c){var b=c.getSelected();if(c.hasSelection()){this.removeHostButton.enable();this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}else{this.removeHostButton.disable();this.stopHostButton.disable()}this.updateButtons(b)},onShow:function(){if(!this.addHostButton){var b=this.grid.getBottomToolbar();this.addHostButton=b.items.get("cm-add");this.removeHostButton=b.items.get("cm-remove");this.stopHostButton=b.items.get("cm-stop")}this.loadHosts();this.running=window.setInterval(this.update,2000,this)},onStop:function(c,d){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")=="Offline"){Deluge.Client.web.start_daemon(b.get("port"))}else{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",id:"torrentDetails",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.defer(100,a);a.disable()}})},update:function(a){var b=Deluge.Torrents.getSelected();if(!b){this.clear();return}this.items.each(function(c){if(c.disabled){c.enable()}});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"),autoScroll:true,onRender:function(b,a){Ext.deluge.details.StatusTab.superclass.onRender.call(this,b,a);this.progressBar=this.add({xtype:"progress",cls:"x-deluge-status-progressbar"});this.status=this.add({cls:"x-deluge-status",id:"deluge-details-status",border:false,width:1000,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(){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),uploaded:fsize(a.total_uploaded),share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:(a.download_payload_rate)?fspeed(a.download_payload_rate):"0.0 KiB/s",upspeed:(a.upload_payload_rate)?fspeed(a.upload_payload_rate):"0.0 KiB/s",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,time_added:fdate(a.time_added)};b.auto_managed=_((a.is_auto_managed)?"True":"False");b.downloaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";b.uploaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";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"),fields:{},queuedItems:{},oldData:{},initComponent:function(){Ext.deluge.details.DetailsTab.superclass.initComponent.call(this);this.addItem("torrent_name",_("Name"));this.addItem("hash",_("Hash"));this.addItem("path",_("Path"));this.addItem("size",_("Total Size"));this.addItem("files",_("# of files"));this.addItem("comment",_("Comment"));this.addItem("status",_("Status"));this.addItem("tracker",_("Tracker"))},onRender:function(b,a){Ext.deluge.details.DetailsTab.superclass.onRender.call(this,b,a);this.body.setStyle("padding","10px");this.dl=Ext.DomHelper.append(this.body,{tag:"dl"},true);for(var c in this.queuedItems){this.doAddItem(c,this.queuedItems[c])}},addItem:function(b,a){if(!this.rendered){this.queuedItems[b]=a}else{this.doAddItem(b,a)}},doAddItem:function(b,a){Ext.DomHelper.append(this.dl,{tag:"dt",cls:b,html:a+":"});this.fields[b]=Ext.DomHelper.append(this.dl,{tag:"dd",cls:b,html:""},true)},clear:function(){if(!this.fields){return}for(var a in this.fields){this.fields[a].dom.innerHTML=""}},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Details,{success:this.onRequestComplete,scope:this,torrentId:a})},onRequestComplete:function(e,c,a,b){var d={torrent_name:e.name,hash:b.options.torrentId,path:e.save_path,size:fsize(e.total_size),files:e.num_files,status:e.tracker_status,tracker:e.tracker,comment:e.comment};for(var f in this.fields){if(!d[f]){continue}if(d[f]==this.oldData[f]){continue}this.fields[f].dom.innerHTML=Ext.escapeHTML(d[f])}this.oldData=d}});Deluge.Details.add(new Ext.deluge.details.DetailsTab());(function(){function b(d){var c=d*100;return Deluge.progressBar(c,this.col.width,c.toFixed(2)+"%",0)}function a(c){if(isNaN(c)){return""}return String.format('{1}
',FILE_PRIORITY_CSS[c],_(FILE_PRIORITY[c]))}Ext.deluge.details.FilesTab=Ext.extend(Ext.ux.tree.TreeGrid,{constructor:function(c){c=Ext.apply({title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{xtype:"tgrendercolumn",header:_("Progress"),width:150,dataIndex:"progress",renderer:b},{xtype:"tgrendercolumn",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)},initComponent:function(){Ext.deluge.details.FilesTab.superclass.initComponent.call(this)},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,i){switch(j.id){case"expandAll":this.expandAll();break;default:var h={};function c(e){if(Ext.isEmpty(e.attributes.fileIndex)){return}h[e.attributes.fileIndex]=e.attributes.priority}this.getRootNode().cascade(c);var d=this.getSelectionModel().getSelectedNodes();Ext.each(d,function(k){if(!k.isLeaf()){function e(l){if(Ext.isEmpty(l.attributes.fileIndex)){return}h[l.attributes.fileIndex]=j.filePriority}k.cascade(e)}else{if(!Ext.isEmpty(k.attributes.fileIndex)){h[k.attributes.fileIndex]=j.filePriority;return}}});var g=new Array(Ext.keys(h).length);for(var f in h){g[f]=h[f]}Deluge.Client.core.set_torrent_file_priorities(this.torrentId,g,{success:function(){Ext.each(d,function(e){e.setColumnValue(3,j.filePriority)})},scope:this});break}},onRequestComplete:function(f,e){function d(j,h){for(var g in j.contents){var i=j.contents[g];var k=h.findChild("id",g);if(i.type=="dir"){if(!k){k=new Ext.tree.TreeNode({id:g,text:g,filename:g,size:i.size,progress:i.progress,priority:i.priority});h.appendChild(k)}d(i,k)}else{if(!k){k=new Ext.tree.TreeNode({id:g,filename:g,text:g,fileIndex:i.index,size:i.size,progress:i.progress,priority:i.priority,leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.ux.tree.TreeGridNodeUI});h.appendChild(k)}}}}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(f){var e=(f*100).toFixed(0);return Deluge.progressBar(e,this.width-8,e+"%")}function b(e){var f=e.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);return((((((+f[1])*256)+(+f[2]))*256)+(+f[3]))*256)+(+f[4])}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){if(!g){return}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.optionsManager=new Deluge.MultiOptionsManager({options:{max_download_speed:-1,max_upload_speed:-1,max_connections:-1,max_upload_slots:-1,auto_managed:false,stop_at_ratio:false,stop_ratio:2,remove_at_ratio:false,move_completed:null,"private":false,prioritize_first_last:false}});this.fieldsets.bandwidth=this.add({xtype:"fieldset",defaultType:"spinnerfield",bodyStyle:"padding: 5px",layout:"table",layoutConfig:{columns:3},labelWidth:150,style:"margin-left: 10px; margin-right: 5px; padding: 5px",title:_("Bandwidth"),width:250});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:70,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});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:70,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});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:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});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:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});this.fieldsets.queue=this.add({xtype:"fieldset",title:_("Queue"),style:"margin-left: 5px; margin-right: 5px; padding: 5px",width:210,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaults:{fieldLabel:"",labelSeparator:""}});this.fields.auto_managed=this.fieldsets.queue.add({xtype:"checkbox",fieldLabel:"",labelSeparator:"",name:"is_auto_managed",boxLabel:_("Auto Managed"),width:200,colspan:2});this.fields.stop_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"stop_at_ratio",width:120,boxLabel:_("Stop seed at ratio"),handler:this.onStopRatioChecked,scope:this});this.fields.stop_ratio=this.fieldsets.queue.add({xtype:"spinnerfield",id:"stop_ratio",name:"stop_ratio",disabled:true,width:50,value:2,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});this.fields.remove_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"remove_at_ratio",ctCls:"x-deluge-indent-checkbox",bodyStyle:"padding-left: 10px",boxLabel:_("Remove at ratio"),disabled:true,colspan:2});this.fields.move_completed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"move_completed",boxLabel:_("Move Completed"),colspan:2});this.rightColumn=this.add({border:false,autoHeight:true,style:"margin-left: 5px",width:210});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",disabled:true});this.fields.prioritize_first_last=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"});for(var a in this.fields){this.optionsManager.bind(a,this.fields[a])}this.buttonPanel=this.rightColumn.add({layout:"hbox",xtype:"panel",border:false});this.buttonPanel.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({id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px;",border:false,width:100,handler:this.onApply,scope:this})},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(){if(this.torrentId==null){return}this.torrentId=null;this.optionsManager.changeId(null)},reset:function(){if(this.torrentId){this.optionsManager.reset()}},update:function(a){if(this.torrentId&&!a){this.clear()}if(!a){return}if(this.torrentId!=a){this.torrentId=a;this.optionsManager.changeId(a)}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Options,{success:this.onRequestComplete,scope:this})},onApply:function(){var b=this.optionsManager.getDirty();if(!Ext.isEmpty(b.prioritize_first_last)){var a=b.prioritize_first_last;Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId,a,{success:function(){this.optionsManager.set("prioritize_first_last",a)},scope:this})}Deluge.Client.core.set_torrent_options([this.torrentId],b,{success:function(){this.optionsManager.commit()},scope:this})},onEditTrackers:function(){Deluge.EditTrackers.show()},onStopRatioChecked:function(b,a){this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)},onRequestComplete:function(c,b){this.fields["private"].setValue(c["private"]);this.fields["private"].setDisabled(true);delete c["private"];c.auto_managed=c.is_auto_managed;this.optionsManager.setDefault(c);var a=this.optionsManager.get("stop_at_ratio");this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!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.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,this);this.addEvents("add");this.form=this.add({xtype:"form",defaultType:"textarea",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Trackers"),name:"trackers",anchor:"100%"}]})},onAddClick: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("")},onCancelClick:function(){this.form.getForm().findField("trackers").setValue("");this.hide()}});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.onCancelClick,this);this.addButton(_("Save"),this.onSaveClick,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)},onCancelClick:function(){this.hide()},onHide:function(){this.form.getForm().findField("tracker").setValue("")},onSaveClick: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.onCancelClick,this);this.addButton(_("Ok"),this.onOkClick,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.onUpClick,scope:this},{cls:"x-btn-text-icon",text:_("Down"),icon:"/icons/down.png",handler:this.onDownClick,scope:this},"->",{cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAddClick,scope:this},{cls:"x-btn-text-icon",text:_("Edit"),icon:"/icons/edit_trackers.png",handler:this.onEditClick,scope:this},{cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemoveClick,scope:this}]})})},onAddClick: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)},onCancelClick:function(){this.hide()},onEditClick:function(){var a=this.grid.getSelectionModel().getSelected();this.editWindow.show(a)},onHide:function(){this.grid.getStore().removeAll()},onOkClick: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()})();Ext.namespace("Deluge");Deluge.FileBrowser=Ext.extend(Ext.Window,{title:"Filebrowser",initComponent:function(){Deluge.FileBrowser.superclass.initComponent.call(this)}});Ext.deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closable:false,closeAction:"hide",iconCls:"x-deluge-login-window-icon",layout:"fit",modal:true,plain:true,resizable:false,title:_("Login"),width:300,height:120,initComponent:function(){Ext.deluge.LoginWindow.superclass.initComponent.call(this);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:55,width:300,defaults:{width:200},defaultType:"textfield",});this.passwordField=this.form.add({xtype:"textfield",fieldLabel:_("Password"),id:"_password",name:"password",inputType:"password"});this.passwordField.on("specialkey",this.onSpecialKey,this)},logout:function(){Deluge.Events.fire("logout");Deluge.Client.auth.delete_session({success:function(a){this.show(true)},scope:this})},show:function(a){if(this.firstShow){Deluge.Client.on("error",this.onClientError,this);this.firstShow=false}if(a){return Ext.deluge.LoginWindow.superclass.show.call(this)}Deluge.Client.auth.check_session({success:function(b){if(b){Deluge.Events.fire("login")}else{this.show(true)}},failure:function(b){this.show(true)},scope:this})},onSpecialKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.passwordField;Deluge.Client.auth.login(a.getValue(),{success:function(b){if(b){Deluge.Events.fire("login");this.hide();a.setRawValue("")}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})},onClientError:function(c,b,a){if(c.error.code==1){Deluge.Events.fire("logout");this.show(true)}},onShow:function(){this.passwordField.focus(false,150);this.passwordField.setRawValue("")}});Deluge.Login=new Ext.deluge.LoginWindow();Ext.namespace("Ext.deluge");Ext.deluge.MoveStorage=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Move Storage"),width:375,height:110,layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-move-storage",plain:true,resizable:false},a);Ext.deluge.MoveStorage.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.MoveStorage.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Move"),this.onMove,this);this.form=this.add({xtype:"form",border:false,defaultType:"textfield",width:300,bodyStyle:"padding: 5px"});this.moveLocation=this.form.add({fieldLabel:_("Location"),name:"location",width:240})},hide:function(){Ext.deluge.MoveStorage.superclass.hide.call(this);this.torrentIds=null},show:function(a){Ext.deluge.MoveStorage.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide()},onMove:function(){var a=this.moveLocation.getValue();Deluge.Client.core.move_storage(this.torrentIds,a);this.hide()}});Deluge.MoveStorage=new Ext.deluge.MoveStorage();Deluge.Plugin=Ext.extend(Ext.util.Observable,{name:null,constructor:function(a){this.name=a.name;this.addEvents({enabled:true,disabled:true});this.isDelugePlugin=true;Deluge.Plugins[this.name]=this;Deluge.Plugin.superclass.constructor.call(this,a)},disable:function(){this.fireEvent("disabled",this);if(this.onDisable){this.onDisable()}},enable:function(){this.fireEvent("enable",this);if(this.onEnable){this.onEnable()}}});Ext.deluge.PreferencesWindow=Ext.extend(Ext.Window,{currentPage:null,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:false,title:_("Preferences"),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},]},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.add({region:"center",header:false,layout:"fit",height:400,autoScroll:true,margins:"5 5 5 5",cmargins:"5 5 5 5"});this.addButton(_("Close"),this.onClose,this);this.addButton(_("Apply"),this.onApply,this);this.addButton(_("Ok"),this.onOk,this);this.pages={};this.optionsManager=new Deluge.OptionsManager();this.on("show",this.onShow,this)},onApply:function(b){var c=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(c)){Deluge.Client.core.set_config(c,{success:this.onSetConfig,scope:this})}for(var a in this.pages){if(this.pages[a].onApply){this.pages[a].onApply()}}},onClose:function(){this.hide()},onOk:function(){Deluge.Client.core.set_config(this.optionsManager.getDirty());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);return this.pages[b]},removePage:function(c){var b=c.title;var a=this.categoriesGrid.getStore();a.removeAt(a.find("name",b));this.configPanel.remove(c);delete this.pages[c.title]},getOptionsManager:function(){return this.optionsManager},onGotConfig:function(a){this.getOptionsManager().set(a)},onPageSelect:function(a,e,c){if(this.currentPage==null){for(var d in this.pages){this.pages[d].hide()}}else{this.currentPage.hide()}var b=c.get("name");this.pages[b].show();this.currentPage=this.pages[b];this.configPanel.doLayout()},onSetConfig:function(){this.getOptionsManager().commit()},onShow:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}Deluge.Client.core.get_config({success:this.onGotConfig,scope:this})}});Deluge.Preferences=new Ext.deluge.PreferencesWindow();Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Downloads=Ext.extend(Ext.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Downloads"),layout:"form",autoHeight:true,width:320},a);Ext.deluge.preferences.Downloads.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Downloads.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Folders"),labelWidth:150,defaultType:"togglefield",autoHeight:true,labelAlign:"top",width:300,style:"margin-bottom: 5px; padding-bottom: 5px;"});b.bind("download_location",a.add({xtype:"textfield",name:"download_location",fieldLabel:_("Download to"),width:280}));var c=a.add({name:"move_completed_path",fieldLabel:_("Move completed to"),width:280});b.bind("move_completed",c.toggle);b.bind("move_completed_path",c.input);c=a.add({name:"torrentfiles_location",fieldLabel:_("Copy of .torrent files to"),width:280});b.bind("copy_torrent_file",c.toggle);b.bind("torrentfiles_location",c.input);c=a.add({name:"autoadd_location",fieldLabel:_("Autoadd .torrent files from"),width:280});b.bind("autoadd_enable",c.toggle);b.bind("autoadd_location",c.input);a=this.add({xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radiogroup",style:"margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;",width:240,});b.bind("compact_allocation",a.add({name:"compact_allocation",width:200,labelSeparator:"",disabled:true,defaults:{width:80,height:22,name:"compact_allocation"},items:[{boxLabel:_("Use Full"),inputValue:false},{boxLabel:_("Use Compact"),inputValue:true}]}));a=this.add({xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",style:"margin-bottom: 0; padding-bottom: 0;",width:280});b.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",labelSeparator:"",height:22,boxLabel:_("Prioritize first and last pieces of torrent")}));b.bind("add_paused",a.add({name:"add_paused",labelSeparator:"",height:22,boxLabel:_("Add torrents in Paused state")}));this.on("show",this.onShow,this)},onShow:function(){Ext.deluge.preferences.Downloads.superclass.onShow.call(this)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Downloads());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Network=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Network"),layout:"form"},a);Ext.deluge.preferences.Network.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Network.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Incoming Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_port",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_port",height:22,listeners:{check:{fn:function(d,c){this.listenPorts.setDisabled(c)},scope:this}}}));this.listenPorts=a.add({xtype:"uxspinnergroup",name:"listen_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("listen_ports",this.listenPorts);a=this.add({xtype:"fieldset",border:false,title:_("Outgoing Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_outgoing_ports",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_outgoing_ports",height:22,listeners:{check:{fn:function(d,c){this.outgoingPorts.setDisabled(c)},scope:this}}}));this.outgoingPorts=a.add({xtype:"uxspinnergroup",name:"outgoing_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("outgoing_ports",this.outgoingPorts);a=this.add({xtype:"fieldset",border:false,title:_("Network Interface"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"textfield"});b.bind("listen_interface",a.add({name:"listen_interface",fieldLabel:"",labelSeparator:"",width:200}));a=this.add({xtype:"fieldset",border:false,title:_("TOS"),style:"margin-bottom: 5px; padding-bottom: 0px;",bodyStyle:"margin: 0px; padding: 0px",autoHeight:true,defaultType:"textfield"});b.bind("peer_tos",a.add({name:"peer_tos",fieldLabel:_("Peer TOS Byte"),width:80}));a=this.add({xtype:"fieldset",border:false,title:_("Network Extras"),autoHeight:true,layout:"table",layoutConfig:{columns:3},defaultType:"checkbox"});b.bind("upnp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("UPnP"),name:"upnp"}));b.bind("natpmp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("NAT-PMP"),ctCls:"x-deluge-indent-checkbox",name:"natpmp"}));b.bind("utpex",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Peer Exchange"),ctCls:"x-deluge-indent-checkbox",name:"utpex"}));b.bind("lsd",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("LSD"),name:"lsd"}));b.bind("dht",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("DHT"),ctCls:"x-deluge-indent-checkbox",name:"dht"}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Network());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Encryption=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Encryption"),layout:"form"},a);Ext.deluge.preferences.Encryption.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Encryption.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,defaultType:"combo"});b.bind("enc_in_policy",a.add({fieldLabel:_("Inbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_out_policy",a.add({fieldLabel:_("Outbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_level",a.add({fieldLabel:_("Level"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Handshake")],[1,_("Full Stream")],[2,_("Either")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_prefer_rc4",a.add({xtype:"checkbox",name:"enc_prefer_rc4",height:40,hideLabel:true,boxLabel:_("Encrypt entire stream")}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Encryption());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Bandwidth=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Bandwidth"),layout:"form",labelWidth:10},a);Ext.deluge.preferences.Bandwidth.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Bandwidth.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),labelWidth:200,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",autoHeight:true});b.bind("max_connections_global",a.add({name:"max_connections_global",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_global",a.add({name:"max_upload_slots_global",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed",a.add({name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed",a.add({name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_half_open_connections",a.add({name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_connections_per_second",a.add({name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));a=this.add({xtype:"fieldset",border:false,title:"",defaultType:"checkbox",style:"padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;",autoHeight:true});b.bind("ignore_limits_on_local_network",a.add({name:"ignore_limits_on_local_network",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),}));b.bind("rate_limit_ip_overhead",a.add({name:"rate_limit_ip_overhead",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),}));a=this.add({xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"spinnerfield",labelWidth:200,autoHeight:true});b.bind("max_connections_per_torrent",a.add({name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_per_torrent",a.add({name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed_per_torrent",a.add({name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed_per_torrent",a.add({name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Bandwidth());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Interface=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Interface"),layout:"form"},a);Ext.deluge.preferences.Interface.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Interface.superclass.initComponent.call(this);var c=this.optionsManager=new Deluge.OptionsManager();this.on("show",this.onShow,this);var a=this.add({xtype:"fieldset",border:false,title:_("Interface"),style:"margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px",autoHeight:true,labelWidth:1,defaultType:"checkbox"});c.bind("show_session_speed",a.add({name:"show_session_speed",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar")}));c.bind("sidebar_show_zero",a.add({name:"sidebar_show_zero",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show filters with zero torrents")}));c.bind("sidebar_show_trackers",a.add({name:"sidebar_show_trackers",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show trackers with zero torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Password"),style:"margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px",autoHeight:true,labelWidth:110,defaultType:"textfield",defaults:{width:180,inputType:"password"}});this.oldPassword=a.add({name:"old_password",fieldLabel:_("Old Password")});this.newPassword=a.add({name:"new_password",fieldLabel:_("New Password")});this.confirmPassword=a.add({name:"confirm_password",fieldLabel:_("Confirm Password")});var b=a.add({xtype:"panel",autoHeight:true,border:false,width:320,bodyStyle:"padding-left: 230px"});b.add({xtype:"button",text:_("Change"),listeners:{click:{fn:this.onPasswordChange,scope:this}}});a=this.add({xtype:"fieldset",border:false,title:_("Server"),style:"margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px",autoHeight:true,labelWidth:110,defaultType:"spinnerfield",defaults:{width:80,}});c.bind("session_timeout",a.add({name:"session_timeout",fieldLabel:_("Session Timeout"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));c.bind("port",a.add({name:"port",fieldLabel:_("Port"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));this.httpsField=c.bind("https",a.add({xtype:"checkbox",name:"https",hideLabel:true,width:280,height:22,boxLabel:_("Use SSL (paths relative to Deluge config folder)")}));this.httpsField.on("check",this.onSSLCheck,this);this.pkeyField=c.bind("pkey",a.add({xtype:"textfield",disabled:true,name:"pkey",width:180,fieldLabel:_("Private Key")}));this.certField=c.bind("cert",a.add({xtype:"textfield",disabled:true,name:"cert",width:180,fieldLabel:_("Certificate")}))},onApply:function(){var a=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(a)){Deluge.Client.web.set_config(a,{success:this.onSetConfig,scope:this})}},onGotConfig:function(a){this.optionsManager.set(a)},onPasswordChange:function(){var b=this.newPassword.getValue();if(b!=this.confirmPassword.getValue()){Ext.MessageBox.show({title:_("Invalid Password"),msg:_("Your passwords don't match!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var a=this.oldPassword.getValue();Deluge.Client.auth.change_password(a,b,{success:function(c){if(!c){Ext.MessageBox.show({title:_("Password"),msg:_("Your old password was incorrect!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});this.oldPassword.setValue("")}else{Ext.MessageBox.show({title:_("Change Successful"),msg:_("Your password was successfully changed!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.INFO,iconCls:"x-deluge-icon-info"});this.oldPassword.setValue("");this.newPassword.setValue("");this.confirmPassword.setValue("")}},scope:this})},onSetConfig:function(){this.optionsManager.commit()},onShow:function(){Ext.deluge.preferences.Interface.superclass.onShow.call(this);Deluge.Client.web.get_config({success:this.onGotConfig,scope:this})},onSSLCheck:function(b,a){this.pkeyField.setDisabled(!a);this.certField.setDisabled(!a)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Interface());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Other=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Other"),layout:"form"},a);Ext.deluge.preferences.Other.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Other.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Updates"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:22,name:"new_release_check",boxLabel:_("Be alerted about new releases")}));a=this.add({xtype:"fieldset",border:false,title:_("System Information"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});a.add({xtype:"panel",border:false,bodyCfg:{html:_("Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.")}});b.bind("send_info",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Yes, please send anonymous statistics"),name:"send_info"}));a=this.add({xtype:"fieldset",border:false,title:_("GeoIP Database"),autoHeight:true,labelWidth:80,defaultType:"textfield"});b.bind("geoip_db_location",a.add({name:"geoip_db_location",fieldLabel:_("Location"),width:200}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Other());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Daemon=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Daemon"),layout:"form"},a);Ext.deluge.preferences.Daemon.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Daemon.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"spinnerfield"});b.bind("daemon_port",a.add({fieldLabel:_("Daemon port"),name:"daemon_port",value:58846,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("allow_remote",a.add({fieldLabel:"",height:22,labelSeparator:"",boxLabel:_("Allow Remote Connections"),name:"allow_remote"}));a=this.add({xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_release_check"}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Daemon());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Queue=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Queue"),layout:"form"},a);Ext.deluge.preferences.Queue.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Queue.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("General"),style:"padding-top: 5px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("queue_new_to_top",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Queue new torrents to top"),name:"queue_new_to_top"}));a=this.add({xtype:"fieldset",border:false,title:_("Active Torrents"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",});b.bind("max_active_limit",a.add({fieldLabel:_("Total Active"),name:"max_active_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_downloading",a.add({fieldLabel:_("Total Active Downloading"),name:"max_active_downloading",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_seeding",a.add({fieldLabel:_("Total Active Seeding"),name:"max_active_seeding",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("dont_count_slow_torrents",a.add({xtype:"checkbox",name:"dont_count_slow_torrents",height:40,hideLabel:true,boxLabel:_("Do not count slow torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Seeding"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;",});b.bind("share_ratio_limit",a.add({fieldLabel:_("Share Ratio Limit"),name:"share_ratio_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_ratio_limit",a.add({fieldLabel:_("Share Time Ratio"),name:"seed_time_ratio_limit",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_limit",a.add({fieldLabel:_("Seed Time (m)"),name:"seed_time_limit",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,autoHeight:true,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaultType:"checkbox",defaults:{fieldLabel:"",labelSeparator:""}});this.stopAtRatio=a.add({name:"stop_seed_at_ratio",boxLabel:_("Stop seeding when share ratio reaches:")});this.stopAtRatio.on("check",this.onStopRatioCheck,this);b.bind("stop_seed_at_ratio",this.stopAtRatio);this.stopRatio=a.add({xtype:"spinnerfield",name:"stop_seed_ratio",ctCls:"x-deluge-indent-checkbox",disabled:true,value:2,width:60,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});b.bind("stop_seed_ratio",this.stopRatio);this.removeAtRatio=a.add({name:"remove_seed_at_ratio",ctCls:"x-deluge-indent-checkbox",boxLabel:_("Remove torrent when share ratio is reached"),disabled:true,colspan:2});b.bind("remove_seed_at_ratio",this.removeAtRatio)},onStopRatioCheck:function(b,a){this.stopRatio.setDisabled(!a);this.removeAtRatio.setDisabled(!a)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Queue());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.ProxyField=Ext.extend(Ext.form.FieldSet,{constructor:function(a){a=Ext.apply({border:false,autoHeight:true,labelWidth:70},a);Ext.deluge.preferences.ProxyField.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.ProxyField.superclass.initComponent.call(this);this.type=this.add({xtype:"combo",fieldLabel:_("Type"),name:"type",mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("None")],[1,_("Socksv4")],[2,_("Socksv5")],[3,_("Socksv5 with Auth")],[4,_("HTTP")],[5,_("HTTP with Auth")],]}),value:0,triggerAction:"all",valueField:"id",displayField:"text"});this.hostname=this.add({xtype:"textfield",name:"hostname",fieldLabel:_("Host"),width:220});this.port=this.add({xtype:"spinnerfield",name:"port",fieldLabel:_("Port"),width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}});this.username=this.add({xtype:"textfield",name:"username",fieldLabel:_("Username"),width:220});this.password=this.add({xtype:"textfield",name:"password",fieldLabel:_("Password"),inputType:"password",width:220});this.type.on("change",this.onFieldChange,this);this.type.on("select",this.onTypeSelect,this);this.setting=false},getName:function(){return this.initialConfig.name},getValue:function(){return{type:this.type.getValue(),hostname:this.hostname.getValue(),port:Number(this.port.getValue()),username:this.username.getValue(),password:this.password.getValue()}},setValue:function(c){this.setting=true;this.type.setValue(c.type);var b=this.type.getStore().find("id",c.type);var a=this.type.getStore().getAt(b);this.hostname.setValue(c.hostname);this.port.setValue(c.port);this.username.setValue(c.username);this.password.setValue(c.password);this.onTypeSelect(this.type,a,b);this.setting=false},onFieldChange:function(e,d,c){if(this.setting){return}var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)},onTypeSelect:function(d,a,b){var c=a.get("id");if(c>0){this.hostname.show();this.port.show()}else{this.hostname.hide();this.port.hide()}if(c==3||c==5){this.username.show();this.password.show()}else{this.username.hide();this.password.hide()}}});Ext.deluge.preferences.Proxy=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Proxy"),layout:"form"},a);Ext.deluge.preferences.Proxy.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Proxy.superclass.initComponent.call(this);this.peer=this.add(new Ext.deluge.preferences.ProxyField({title:_("Peer"),name:"peer"}));this.peer.on("change",this.onProxyChange,this);this.web_seed=this.add(new Ext.deluge.preferences.ProxyField({title:_("Web Seed"),name:"web_seed"}));this.web_seed.on("change",this.onProxyChange,this);this.tracker=this.add(new Ext.deluge.preferences.ProxyField({title:_("Tracker"),name:"tracker"}));this.tracker.on("change",this.onProxyChange,this);this.dht=this.add(new Ext.deluge.preferences.ProxyField({title:_("DHT"),name:"dht"}));this.dht.on("change",this.onProxyChange,this);Deluge.Preferences.getOptionsManager().bind("proxies",this)},getValue:function(){return{dht:this.dht.getValue(),peer:this.peer.getValue(),tracker:this.tracker.getValue(),web_seed:this.web_seed.getValue()}},setValue:function(b){for(var a in b){this[a].setValue(b[a])}},onProxyChange:function(e,d,c){var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Proxy());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Cache=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Cache"),layout:"form"},a);Ext.deluge.preferences.Cache.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Cache.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,labelWidth:180,defaultType:"spinnerfield"});b.bind("cache_size",a.add({fieldLabel:_("Cache Size (16 KiB Blocks)"),name:"cache_size",width:60,value:512,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("cache_expiry",a.add({fieldLabel:_("Cache Expiry (seconds)"),name:"cache_expiry",width:60,value:60,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Cache());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.InstallPlugin=Ext.extend(Ext.Window,{height:115,width:350,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",iconCls:"x-deluge-install-plugin",layout:"fit",modal:true,plain:true,title:_("Install Plugin"),initComponent:function(){Ext.deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Install"),this.onInstall,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:70,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"pluginEgg",emptyText:_("Select an egg"),fieldLabel:_("Plugin Egg"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onInstall:function(b,a){this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your plugin..."),success:this.onUploadSuccess,scope:this})},onUploadPlugin:function(d,c,a,b){this.fireEvent("pluginadded")},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=this.form.getForm().findField("pluginEgg").value;var d=b.result.files[0];this.form.getForm().findField("pluginEgg").setValue("");Deluge.Client.web.upload_plugin(a,d,{success:this.onUploadPlugin,scope:this,filename:a})}}});Ext.deluge.preferences.Plugins=Ext.extend(Ext.Panel,{constructor:function(a){a=Ext.apply({border:false,title:_("Plugins"),layout:"border",height:400,cls:"x-deluge-plugins"},a);Ext.deluge.preferences.Plugins.superclass.constructor.call(this,a)},pluginTemplate:new Ext.Template('- Author:
- {author}
- Version:
- {version}
- Author Email:
- {email}
- Homepage:
- {homepage}
- Details:
- {details}
'),initComponent:function(){Ext.deluge.preferences.Plugins.superclass.initComponent.call(this);this.defaultValues={version:"",email:"",homepage:"",details:""};this.pluginTemplate.compile();var b=function(d,e,c){e.css+=" x-grid3-check-col-td";return'
'};this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"enabled",mapping:0},{name:"plugin",mapping:1}]}),columns:[{id:"enabled",header:_("Enabled"),width:50,sortable:true,renderer:b,dataIndex:"enabled"},{id:"plugin",header:_("Plugin"),sortable:true,dataIndex:"plugin"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPluginSelect,scope:this}}}),autoExpandColumn:"plugin",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",iconCls:"x-deluge-install-plugin",text:_("Install"),handler:this.onInstallPlugin,scope:this},"->",{cls:"x-btn-text-icon",text:_("Find More"),iconCls:"x-deluge-find-more",handler:this.onFindMorePlugins,scope:this}]})});var a=this.add({xtype:"fieldset",border:false,region:"south",title:_("Info"),autoHeight:true,labelWidth:1});this.pluginInfo=a.add({xtype:"panel",border:false,bodyCfg:{style:"margin-left: 10px"}});this.on("show",this.onShow,this);this.pluginInfo.on("render",this.onPluginInfoRender,this);this.grid.on("cellclick",this.onCellClick,this);Deluge.Preferences.on("show",this.onPreferencesShow,this);Deluge.Events.on("PluginDisabledEvent",this.onPluginDisabled,this);Deluge.Events.on("PluginEnabledEvent",this.onPluginEnabled,this)},disablePlugin:function(a){Deluge.Client.core.disable_plugin(a)},enablePlugin:function(a){Deluge.Client.core.enable_plugin(a)},setInfo:function(b){if(!this.pluginInfo.rendered){return}var a=b||this.defaultValues;this.pluginInfo.body.dom.innerHTML=this.pluginTemplate.apply(a)},updatePlugins:function(){Deluge.Client.web.get_plugins({success:this.onGotPlugins,scope:this})},updatePluginsGrid:function(){var a=[];Ext.each(this.availablePlugins,function(b){if(this.enabledPlugins.indexOf(b)>-1){a.push([true,b])}else{a.push([false,b])}},this);this.grid.getStore().loadData(a)},onCellClick:function(b,f,a,d){if(a!=0){return}var c=b.getStore().getAt(f);c.set("enabled",!c.get("enabled"));c.commit();if(c.get("enabled")){this.enablePlugin(c.get("plugin"))}else{this.disablePlugin(c.get("plugin"))}},onFindMorePlugins:function(){window.open("http://dev.deluge-torrent.org/wiki/Plugins")},onGotPlugins:function(a){this.enabledPlugins=a.enabled_plugins;this.availablePlugins=a.available_plugins;this.setInfo();this.updatePluginsGrid()},onGotPluginInfo:function(b){var a={author:b.Author,version:b.Version,email:b["Author-email"],homepage:b["Home-page"],details:b.Description};this.setInfo(a);delete b},onInstallPlugin:function(){if(!this.installWindow){this.installWindow=new Ext.deluge.preferences.InstallPlugin();this.installWindow.on("pluginadded",this.onPluginInstall,this)}this.installWindow.show()},onPluginEnabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",true);b.commit()},onPluginDisabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",false);b.commit()},onPluginInstall:function(){this.updatePlugins()},onPluginSelect:function(b,c,a){Deluge.Client.web.get_plugin_info(a.get("plugin"),{success:this.onGotPluginInfo,scope:this})},onPreferencesShow:function(){this.updatePlugins()},onPluginInfoRender:function(b,a){this.setInfo()}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());Ext.deluge.RemoveWindow=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Remove Torrent"),layout:"fit",width:350,height:100,buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-remove-window-icon"},a);Ext.deluge.RemoveWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.RemoveWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Remove With Data"),this.onRemoveData,this);this.addButton(_("Remove Torrent"),this.onRemove,this);this.add({border:false,bodyStyle:"padding: 5px; padding-left: 10px;",html:"Are you sure you wish to remove the torrent(s)?"})},remove:function(a){Ext.each(this.torrentIds,function(b){Deluge.Client.core.remove_torrent(b,a,{success:function(){this.onRemoved(b)},scope:this,torrentId:b})},this)},show:function(a){Ext.deluge.RemoveWindow.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide();this.torrentIds=null},onRemove:function(){this.remove(false)},onRemoveData:function(){this.remove(true)},onRemoved:function(a){Deluge.Events.fire("torrentRemoved",a);this.hide();Deluge.UI.update()}});Deluge.RemoveWindow=new Ext.deluge.RemoveWindow();(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",border:false,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});if(Deluge.config.sidebar_show_zero==false){d=this.removeZero(d)}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()}},removeZero:function(b){var c=[];Ext.each(b,function(d){if(d[1]>0||d[0]==_("All")){c.push(d)}});return c},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){this.panels[e]}},this)},updateFilter:function(c,b){if(Deluge.config.sidebar_show_zero==false){b=this.removeZero(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()})();Ext.deluge.Statusbar=Ext.extend(Ext.ux.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",tooltip:_("Connections"),menu:Deluge.Menus.Connections},"-",{id:"statusbar-downspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",tooltip:_("Download Speed"),menu:Deluge.Menus.Download},"-",{id:"statusbar-upspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",tooltip:_("Upload Speed"),menu:Deluge.Menus.Upload},"-",{id:"statusbar-traffic",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic",tooltip:_("Protocol Traffic Download/Upload")},"-",{id:"statusbar-dht",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-dht",tooltip:_("DHT Nodes")},"-",{id:"statusbar-freespace",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-freespace",tooltip:_("Freespace in download location")});this.created=true},onConnect:function(){if(!this.created){this.createButtons()}else{this.items.each(function(a){a.show();a.enable()})}},onDisconnect:function(){this.items.each(function(a){a.hide();a.disable()})},update:function(b){if(!b){return}function c(d){return d+" KiB/s"}var a=function(f,e){var g=this.items.get("statusbar-"+f);if(e.limit.value>0){var h=(e.value.formatter)?e.value.formatter(e.value.value):e.value.value;var d=(e.limit.formatter)?e.limit.formatter(e.limit.value):e.limit.value;var i=String.format(e.format,h,d)}else{var i=(e.value.formatter)?e.value.formatter(e.value.value):e.value.value}g.setText(i)}.createDelegate(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:c},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:c},format:"{0} ({1})"});a("traffic",{value:{value:b.download_protocol_rate,formatter:Deluge.Formatters.speed},limit:{value:b.upload_protocol_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.items.get("statusbar-dht").setText(b.dht_nodes);this.items.get("statusbar-freespace").setText(fsize(b.free_space));Deluge.Menus.Connections.setValue(b.max_num_connections);Deluge.Menus.Download.setValue(b.max_download);Deluge.Menus.Upload.setValue(b.max_upload)}});Deluge.Statusbar=new Ext.deluge.Statusbar();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"),iconCls:"x-deluge-preferences",handler:this.onPreferencesClick,scope:this},{id:"connectionman",cls:"x-btn-text-icon",text:_("Connection Manager"),iconCls:"x-deluge-connection-manager",handler:this.onConnectionManagerClick,scope:this},"->",{id:"help",cls:"x-btn-text-icon",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.Login.logout()},onConnectionManagerClick:function(){Deluge.ConnectionManager.show()},onHelpClick:function(){window.open("http://dev.deluge-torrent.org/wiki/UserGuide")},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.RemoveWindow.show(a);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();Deluge.Torrent=Ext.data.Record.create([{name:"queue",type:"int"},{name:"name",type:"string"},{name:"total_size",type:"int"},{name:"state",type:"string"},{name:"progress",type:"int"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_rate",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host",type:"string"}]);(function(){function c(j){return(j==99999)?"":j+1}function e(k,l,j){return String.format('{1}
',j.data.state.toLowerCase(),k)}function g(j){if(!j){return}return fspeed(j)}function i(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]);return Deluge.progressBar(m,k-8,o)}function a(k,l,j){if(j.data.total_seeds>-1){return String.format("{0} ({1})",k,j.data.total_seeds)}else{return k}}function d(k,l,j){if(j.data.total_peers>-1){return String.format("{0} ({1})",k,j.data.total_peers)}else{return k}}function b(k,l,j){return(k<0)?"∞":new Number(k).toFixed(3)}function f(k,l,j){return String.format('{0}
',k)}function h(j){return j*-1}Ext.deluge.TorrentGrid=Ext.extend(Ext.grid.GridPanel,{torrents:{},constructor:function(j){j=Ext.apply({id:"torrentGrid",store:new Ext.data.JsonStore({root:"torrents",idProperty:"id",fields:[{name:"queue"},{name:"name"},{name:"total_size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_speed",type:"int"},{name:"eta",type:"int",sortType:h},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host"}]}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:c,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:e,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"total_size"},{header:_("Progress"),width:150,sortable:true,renderer:i,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:a,dataIndex:"num_seeds"},{header:_("Peers"),width:60,sortable:true,renderer:d,dataIndex:"num_peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:g,dataIndex:"download_payload_rate"},{header:_("Up Speed"),width:80,sortable:true,renderer:g,dataIndex:"upload_payload_rate"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:b,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:b,dataIndex:"distributed_copies"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"time_added"},{header:_("Tracker"),width:120,sortable:true,renderer:f,dataIndex:"tracker_host"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0",stateful:true,view:new Ext.ux.grid.BufferView({rowHeight:26,scrollDelay:false})},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);Deluge.Events.on("logout",this.onDisconnect,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(p){var n=this.getStore();var l=[];for(var o in p){var q=p[o];if(this.torrents[o]){var j=n.getById(o);j.beginEdit();for(var m in q){if(j.get(m)!=q[m]){j.set(m,q[m])}}j.endEdit()}else{var j=new Deluge.Torrent(q);j.id=o;this.torrents[o]=1;l.push(j)}}n.add(l);n.each(function(k){if(!p[k.id]){n.remove(k)}});n.commitChanges()},onDisconnect:function(){this.getStore().removeAll()},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={errorCount:0,filters:null,initialize:function(){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"});for(var a in Deluge.Plugins){a=Deluge.Plugins[a];a.enable()}Ext.QuickTips.init();Deluge.Client.on("connected",function(b){Deluge.Login.show()},this,{single:true});this.update=this.update.createDelegate(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()},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){if(!a.connected){Deluge.Events.fire("disconnect")}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()},onPluginEnabled:function(a){Deluge.Client.web.get_plugin_resources(a,{success:this.onGotPluginResources,scope:this})},onGotPluginResources:function(b){var a=(Deluge.debug)?b.debug_scripts:b.scripts;Ext.each(a,function(c){Ext.ux.JSLoader({url:c,onLoad:this.onPluginLoaded,pluginName:b.name})},this)},onPluginDisabled:function(a){Deluge.Plugins[a].disable()},onPluginLoaded:function(a){if(!Deluge.Plugins[a.pluginName]){return}Deluge.Plugins[a.pluginName].enable()},stop:function(){if(this.running){clearInterval(this.running);this.running=false;Deluge.Torrents.getStore().removeAll()}}};Ext.onReady(function(a){Deluge.UI.initialize()});
\ No newline at end of file
+Ext.state.Manager.setProvider(new Ext.state.CookieProvider());(function(){Ext.apply(Ext,{escapeHTML:function(a){a=String(a).replace("<","<").replace(">",">");return a.replace("&","&")},isObjectEmpty:function(b){for(var a in b){return false}return true},isObjectsEqual:function(d,c){var b=true;if(!d||!c){return false}for(var a in d){if(d[a]!=c[a]){b=false}}return b},keys:function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b},values:function(c){var a=[];for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys;Ext.BLANK_IMAGE_URL=deluge.config.base+"images/s.gif";Ext.USE_NATIVE_JSON=true})();Deluge={progressTpl:'',progressBar:function(c,e,g,a){a=Ext.value(a,10);var b=((e/100)*c).toFixed(0);var d=b-1;var f=((b-a)>0?b-a:0);return String.format(Deluge.progressTpl,g,e,d,f)}};deluge.plugins={};FILE_PRIORITY={9:"Mixed",0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority",Mixed:9,"Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={9:"x-mixed-download",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.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"],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)});deluge.menus={onTorrentAction:function(c,f){var b=deluge.torrents.getSelections();var a=[];Ext.each(b,function(e){a.push(e.id)});var d=c.initialConfig.torrentAction;switch(d){case"pause":case"resume":deluge.client.core[d+"_torrent"](a,{success:function(){deluge.ui.update()}});break;case"top":case"up":case"down":case"bottom":deluge.client.core["queue_"+d](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.removeWindow.show(a);break;case"recheck":deluge.client.core.force_recheck(a,{success:function(){deluge.ui.update()}});break;case"move":deluge.moveStorage.show(a);break}}};deluge.menus.torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{torrentAction:"pause",text:_("Pause"),iconCls:"icon-pause",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"resume",text:_("Resume"),iconCls:"icon-resume",handler:deluge.menus.onTorrentAction,scope:deluge.menus},"-",{text:_("Options"),iconCls:"icon-options",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"),iconCls:"icon-upload-slots",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"),iconCls:"icon-queue",menu:new Ext.menu.Menu({items:[{torrentAction:"top",text:_("Top"),iconCls:"icon-top",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"up",text:_("Up"),iconCls:"icon-up",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"down",text:_("Down"),iconCls:"icon-down",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"bottom",text:_("Bottom"),iconCls:"icon-bottom",handler:deluge.menus.onTorrentAction,scope:deluge.menus}]})},"-",{torrentAction:"update",text:_("Update Tracker"),iconCls:"icon-update-tracker",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"edit_trackers",text:_("Edit Trackers"),iconCls:"icon-edit-trackers",handler:deluge.menus.onTorrentAction,scope:deluge.menus},"-",{torrentAction:"remove",text:_("Remove Torrent"),iconCls:"icon-remove",handler:deluge.menus.onTorrentAction,scope:deluge.menus},"-",{torrentAction:"recheck",text:_("Force Recheck"),iconCls:"icon-recheck",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"move",text:_("Move Storage"),iconCls:"icon-move",handler:deluge.menus.onTorrentAction,scope:deluge.menus}]});Deluge.StatusbarMenu=Ext.extend(Ext.menu.Menu,{setValue:function(b){var c=false;b=(b==0)?-1:b;this.items.each(function(d){if(d.setChecked){d.suspendEvents();if(d.value==b){d.setChecked(true);c=true}else{d.setChecked(false)}d.resumeEvents()}});if(c){return}var a=this.items.get("other");a.suspendEvents();a.setChecked(true);a.resumeEvents()}});deluge.menus.connections=new Deluge.StatusbarMenu({id:"connectionsMenu",items:[{text:"50",value:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"100",value:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"200",value:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"300",value:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"500",value:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:_("Unlimited"),value:"-1",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{text:_("Other"),value:"other",group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});deluge.menus.download=new Deluge.StatusbarMenu({id:"downspeedMenu",items:[{value:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{value:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});deluge.menus.upload=new Deluge.StatusbarMenu({id:"upspeedMenu",items:[{value:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{value:"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"),iconCls:"icon-expand-all"},"-",{id:"no_download",text:_("Do Not Download"),iconCls:"icon-do-not-download",filePriority:0},{id:"normal",text:_("Normal Priority"),iconCls:"icon-normal",filePriority:1},{id:"high",text:_("High Priority"),iconCls:"icon-high",filePriority:2},{id:"highest",text:_("Highest Priority"),iconCls:"icon-highest",filePriority:5}]});function onLimitChanged(b,a){if(b.value=="other"){}else{config={};config[b.group]=b.value;deluge.client.core.set_config(config,{success:function(){deluge.ui.update()}})}}Deluge.EventsManager=Ext.extend(Ext.util.Observable,{constructor:function(){this.toRegister=[];this.on("login",this.onLogin,this);Deluge.EventsManager.superclass.constructor.call(this)},addListener:function(a,c,b,d){this.addEvents(a);if(/[A-Z]/.test(a.substring(0,1))){if(!deluge.client){this.toRegister.push(a)}else{deluge.client.web.register_event_listener(a)}}Deluge.EventsManager.superclass.addListener.call(this,a,c,b,d)},getEvents:function(){deluge.client.web.get_events({success:this.onGetEventsSuccess,failure:this.onGetEventsFailure,scope:this})},start:function(){Ext.each(this.toRegister,function(a){deluge.client.web.register_event_listener(a)});this.running=true;this.getEvents()},stop:function(){this.running=false},onLogin:function(){this.start();this.on("PluginEnabledEvent",this.onPluginEnabled,this);this.on("PluginDisabledEvent",this.onPluginDisabled,this)},onGetEventsSuccess:function(a){if(!a){return}Ext.each(a,function(d){var c=d[0],b=d[1];b.splice(0,0,c);this.fireEvent.apply(this,b)},this);if(this.running){this.getEvents()}},onGetEventsFailure:function(a){if(this.running){this.getEvents()}}});Deluge.EventsManager.prototype.on=Deluge.EventsManager.prototype.addListener;Deluge.EventsManager.prototype.fire=Deluge.EventsManager.prototype.fireEvent;deluge.events=new Deluge.EventsManager();Ext.namespace("Deluge");Deluge.OptionsManager=Ext.extend(Ext.util.Observable,{constructor:function(a){a=a||{};this.binds={};this.changed={};this.options=(a&&a.options)||{};this.focused=null;this.addEvents({add:true,changed:true,reset:true});this.on("changed",this.onChange,this);Deluge.OptionsManager.superclass.constructor.call(this)},addOptions:function(a){this.options=Ext.applyIf(this.options,a)},bind:function(a,b){this.binds[a]=this.binds[a]||[];this.binds[a].push(b);b._doption=a;b.on("focus",this.onFieldFocus,this);b.on("blur",this.onFieldBlur,this);b.on("change",this.onFieldChange,this);b.on("check",this.onFieldChange,this);return b},commit:function(){this.options=Ext.apply(this.options,this.changed);this.reset()},convertValueType:function(a,b){if(Ext.type(a)!=Ext.type(b)){switch(Ext.type(a)){case"string":b=String(b);break;case"number":b=Number(b);break;case"boolean":if(Ext.type(b)=="string"){b=b.toLowerCase();b=(b=="true"||b=="1"||b=="on")?true:false}else{b=Boolean(b)}break}}return b},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[b]:this.options[b]}else{var a={};Ext.each(arguments,function(c){if(!this.has(c)){return}a[c]=(this.isDirty(c))?this.changed[c]:this.options[c]},this);return a}},getDefault:function(a){return this.options[a]},getDirty:function(){return this.changed},isDirty:function(a){return !Ext.isEmpty(this.changed[a])},has:function(a){return(this.options[a])},reset:function(){this.changed={}},set:function(b,c){if(b===undefined){return}else{if(typeof b=="object"){var a=b;this.options=Ext.apply(this.options,a);for(var b in a){this.onChange(b,a[b])}}else{this.options[b]=c;this.onChange(b,c)}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[d]}this.fireEvent("changed",d,e,b);return}this.changed[d]=e;this.fireEvent("changed",d,e,b)}}},onFieldBlur:function(b,a){if(this.focused==b){this.focused=null}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onFieldFocus:function(b,a){this.focused=b},onChange:function(b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(d){if(d==this.focused){return}d.setValue(c)},this)}});Deluge.MultiOptionsManager=Ext.extend(Deluge.OptionsManager,{constructor:function(a){this.currentId=null;this.stored={};Deluge.MultiOptionsManager.superclass.constructor.call(this,a)},changeId:function(d,b){var c=this.currentId;this.currentId=d;if(!b){for(var a in this.options){if(!this.binds[a]){continue}Ext.each(this.binds[a],function(e){e.setValue(this.get(a))},this)}}return c},commit:function(){this.stored[this.currentId]=Ext.apply(this.stored[this.currentId],this.changed[this.currentId]);this.reset()},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}else{if(arguments.length==0){var a={};for(var b in this.options){a[b]=(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}return a}else{var a={};Ext.each(arguments,function(c){a[c]=(this.isDirty(c))?this.changed[this.currentId][c]:this.getDefault(c)},this);return a}}},getDefault:function(a){return(this.has(a))?this.stored[this.currentId][a]:this.options[a]},getDirty:function(){return(this.changed[this.currentId])?this.changed[this.currentId]:{}},isDirty:function(a){return(this.changed[this.currentId]&&!Ext.isEmpty(this.changed[this.currentId][a]))},has:function(a){return(this.stored[this.currentId]&&!Ext.isEmpty(this.stored[this.currentId][a]))},reset:function(){if(this.changed[this.currentId]){delete this.changed[this.currentId]}if(this.stored[this.currentId]){delete this.stored[this.currentId]}},resetAll:function(){this.changed={};this.stored={};this.changeId(null)},setDefault:function(c,d){if(c===undefined){return}else{if(d===undefined){for(var b in c){this.setDefault(b,c[b])}}else{var a=this.getDefault(c);d=this.convertValueType(a,d);if(a==d){return}if(!this.stored[this.currentId]){this.stored[this.currentId]={}}this.stored[this.currentId][c]=d;if(!this.isDirty(c)){this.fireEvent("changed",this.currentId,c,d,a)}}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{if(!this.changed[this.currentId]){this.changed[this.currentId]={}}var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[this.currentId][d]}this.fireEvent("changed",this.currentId,d,e,b);return}else{this.changed[this.currentId][d]=e;this.fireEvent("changed",this.currentId,d,e,b)}}}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onChange:function(d,b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(e){if(e==this.focused){return}e.setValue(c)},this)}});Ext.namespace("Deluge.add");Deluge.add.OptionsPanel=Ext.extend(Ext.TabPanel,{torrents:{},constructor:function(a){a=Ext.apply({region:"south",margins:"5 5 5 5",activeTab:0,height:220},a);Deluge.add.OptionsPanel.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.OptionsPanel.superclass.initComponent.call(this);this.files=this.add(new Ext.ux.tree.TreeGrid({layout:"fit",title:_("Files"),rootVisible:false,autoScroll:true,height:170,border:false,animate:false,disabled:true,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:80,dataIndex:"size",renderer:fsize}]}));new Ext.tree.TreeSorter(this.files,{folderSort:true});this.optionsManager=new Deluge.MultiOptionsManager();this.form=this.add({xtype:"form",labelWidth:1,title:_("Options"),bodyStyle:"padding: 5px;",border:false,height:170,disabled:true});var a=this.form.add({xtype:"fieldset",title:_("Download Location"),border:false,autoHeight:true,defaultType:"textfield",labelWidth:1,fieldLabel:""});this.optionsManager.bind("download_location",a.add({fieldLabel:"",name:"download_location",width:400,labelSeparator:""}));var b=this.form.add({border:false,layout:"column",defaultType:"fieldset"});a=b.add({title:_("Allocation"),border:false,autoHeight:true,defaultType:"radio",width:100});this.optionsManager.bind("compact_allocation",a.add({xtype:"radiogroup",columns:1,vertical:true,labelSeparator:"",items:[{name:"compact_allocation",value:false,inputValue:false,boxLabel:_("Full"),fieldLabel:"",labelSeparator:""},{name:"compact_allocation",value:true,inputValue:true,boxLabel:_("Compact"),fieldLabel:"",labelSeparator:"",}]}));a=b.add({title:_("Bandwidth"),border:false,autoHeight:true,labelWidth:100,width:200,defaultType:"spinnerfield"});this.optionsManager.bind("max_download_speed",a.add({fieldLabel:_("Max Down Speed"),name:"max_download_speed",width:60}));this.optionsManager.bind("max_upload_speed",a.add({fieldLabel:_("Max Up Speed"),name:"max_upload_speed",width:60}));this.optionsManager.bind("max_connections",a.add({fieldLabel:_("Max Connections"),name:"max_connections",width:60}));this.optionsManager.bind("max_upload_slots",a.add({fieldLabel:_("Max Upload Slots"),name:"max_upload_slots",width:60}));a=b.add({title:_("General"),border:false,autoHeight:true,defaultType:"checkbox"});this.optionsManager.bind("add_paused",a.add({name:"add_paused",boxLabel:_("Add In Paused State"),fieldLabel:"",labelSeparator:"",}));this.optionsManager.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",boxLabel:_("Prioritize First/Last Pieces"),fieldLabel:"",labelSeparator:"",}));this.form.on("render",this.onFormRender,this)},onFormRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout()},addTorrent:function(c){this.torrents[c.info_hash]=c;var b={};this.walkFileTree(c.files_tree,function(e,g,h,f){if(g!="file"){return}b[h[0]]=h[2]},this);var a=[];Ext.each(Ext.keys(b),function(e){a[e]=b[e]});var d=this.optionsManager.changeId(c.info_hash,true);this.optionsManager.setDefault("file_priorities",a);this.optionsManager.changeId(d,true)},clear:function(){this.clearFiles();this.optionsManager.resetAll()},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(c){var b={file_priorities:[],add_paused:c.add_paused,compact_allocation:c.compact_allocation,download_location:c.download_location,max_connections:c.max_connections_per_torrent,max_download_speed:c.max_download_speed_per_torrent,max_upload_slots:c.max_upload_slots_per_torrent,max_upload_speed:c.max_upload_speed_per_torrent,prioritize_first_last_pieces:c.prioritize_first_last_pieces};this.optionsManager.options=b;this.optionsManager.resetAll()},scope:this})},getFilename:function(a){return this.torrents[a]["filename"]},getOptions:function(a){var c=this.optionsManager.changeId(a,true);var b=this.optionsManager.get();this.optionsManager.changeId(c,true);Ext.each(b.file_priorities,function(e,d){b.file_priorities[d]=(e)?1:0});return b},setTorrent:function(b){if(!b){return}this.torrentId=b;this.optionsManager.changeId(b);this.clearFiles();var a=this.files.getRootNode();var c=this.optionsManager.get("file_priorities");this.walkFileTree(this.torrents[b]["files_tree"],function(d,f,i,e){if(f=="dir"){var h=new Ext.tree.TreeNode({text:d,checked:true});h.on("checkchange",this.onFolderCheck,this);e.appendChild(h);return h}else{var g=new Ext.tree.TreeNode({filename:d,fileindex:i[0],text:d,size:fsize(i[1]),leaf:true,checked:c[i[0]],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});g.on("checkchange",this.onNodeCheck,this);e.appendChild(g)}},this,a);a.firstChild.expand()},walkFileTree:function(g,h,e,d){for(var a in g){var f=g[a];var c=(Ext.type(f)=="object")?"dir":"file";if(e){var b=h.apply(e,[a,c,f,d])}else{var b=h(a,c,f,d)}if(c=="dir"){this.walkFileTree(f,h,e,b)}}},onFolderCheck:function(c,b){var a=this.optionsManager.get("file_priorities");c.cascade(function(d){if(!d.ui.checkbox){d.attributes.checked=b}else{d.ui.checkbox.checked=b}a[d.attributes.fileindex]=b},this);this.optionsManager.setDefault("file_priorities",a)},onNodeCheck:function(c,b){var a=this.optionsManager.get("file_priorities");a[c.attributes.fileindex]=b;this.optionsManager.update("file_priorities",a)}});Deluge.add.Window=Ext.extend(Ext.Window,{initComponent:function(){Deluge.add.Window.superclass.initComponent.call(this);this.addEvents("beforeadd","add")},createTorrentId:function(){return new Date().getTime()}});Deluge.add.AddWindow=Ext.extend(Deluge.add.Window,{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);Deluge.add.AddWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.AddWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,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:[{iconCls:"x-deluge-add-file",text:_("File"),handler:this.onFile,scope:this},{text:_("Url"),iconCls:"icon-add-url",handler:this.onUrl,scope:this},{text:_("Infohash"),iconCls:"icon-add-magnet",disabled:true},"->",{text:_("Remove"),iconCls:"icon-remove",handler:this.onRemove,scope:this}]})});this.optionsPanel=this.add(new Deluge.add.OptionsPanel());this.on("hide",this.onHide,this);this.on("show",this.onShow,this)},clear:function(){this.grid.getStore().removeAll();this.optionsPanel.clear()},onAddClick:function(){var a=[];if(!this.grid){return}this.grid.getStore().each(function(b){var c=b.get("info_hash");a.push({path:this.optionsPanel.getFilename(c),options:this.optionsPanel.getOptions(c)})},this);deluge.client.web.add_torrents(a,{success:function(b){}});this.clear();this.hide()},onCancelClick:function(){this.clear();this.hide()},onFile:function(){this.file.show()},onHide:function(){this.optionsPanel.setActiveTab(0);this.optionsPanel.files.setDisabled(true);this.optionsPanel.form.setDisabled(true)},onRemove:function(){var a=this.grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();this.grid.getStore().remove(b);this.optionsPanel.clear();if(this.torrents&&this.torrents[b.id]){delete this.torrents[b.id]}},onSelect:function(b,c,a){this.optionsPanel.setTorrent(a.get("info_hash"));this.optionsPanel.files.setDisabled(false);this.optionsPanel.form.setDisabled(false)},onShow:function(){if(!this.url){this.url=new Deluge.add.UrlWindow();this.url.on("beforeadd",this.onTorrentBeforeAdd,this);this.url.on("add",this.onTorrentAdd,this)}if(!this.file){this.file=new Deluge.add.FileWindow();this.file.on("beforeadd",this.onTorrentBeforeAdd,this);this.file.on("add",this.onTorrentAdd,this)}this.optionsPanel.getDefaults()},onTorrentBeforeAdd:function(b,c){var a=this.grid.getStore();a.loadData([[b,null,c]],true)},onTorrentAdd:function(a,c){var b=this.grid.getStore().getById(a);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"});this.grid.getStore().remove(b)}else{b.set("info_hash",c.info_hash);b.set("text",c.name);this.grid.getStore().commitChanges();this.optionsPanel.addTorrent(c)}},onUrl:function(a,b){this.url.show()}});deluge.add=new Deluge.add.AddWindow();Ext.namespace("Ext.deluge.add");Deluge.add.FileWindow=Ext.extend(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"},a);Deluge.add.FileWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:35,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"torrentFile",width:280,emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onAddClick:function(c,b){if(this.form.getForm().isValid()){this.torrentId=this.createTorrentId();this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),failure:this.onUploadFailure,success:this.onUploadSuccess,scope:this});var a=this.form.getForm().findField("torrentFile").value;a=a.split("\\").slice(-1)[0];this.fireEvent("beforeadd",this.torrentId,a)}},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",this.torrentId,d)},onUploadFailure:function(a,b){this.hide()},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=b.result.files[0];this.form.getForm().findField("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a})}}});Ext.namespace("Deluge.add");Deluge.add.UrlWindow=Ext.extend(Deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:155,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon"},a);Deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.UrlWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);var a=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55});this.urlField=a.add({fieldLabel:_("Url"),id:"url",name:"url",anchor:"100%"});this.urlField.on("specialkey",this.onAdd,this);this.cookieField=a.add({fieldLabel:_("Cookies"),id:"cookies",name:"cookies",anchor:"100%"});this.cookieField.on("specialkey",this.onAdd,this)},onAddClick:function(f,d){if((f.id=="url"||f.id=="cookies")&&d.getKey()!=d.ENTER){return}var f=this.urlField;var b=f.getValue();var c=this.cookieField.getValue();var a=this.createTorrentId();deluge.client.web.download_torrent_from_url(b,c,{success:this.onDownload,scope:this,torrentId:a});this.hide();this.fireEvent("beforeadd",a,b)},onDownload:function(a,c,d,b){this.urlField.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");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","error");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:{msg:"HTTP: "+b.status+" "+b.statusText,code:255}};this.fireEvent("error",errorObj,b,a);if(Ext.type(c.failure)!="function"){return}if(c.scope){c.failure.call(c.scope,errorObj,b,a)}else{c.failure(errorObj,b,a)}},_onSuccess:function(c,a){var b=Ext.decode(c.responseText);var d=a.options;if(b.error){this.fireEvent("error",b,c,a);if(Ext.type(d.failure)!="function"){return}if(d.scope){d.failure.call(d.scope,b,c,a)}else{d.failure(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 i=a._parseArgs(arguments);return a._execute(h,i)};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};Deluge.AddConnectionWindow=Ext.extend(Ext.Window,{constructor:function(b){b=Ext.apply({layout:"fit",width:300,height:195,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Add Connection"),iconCls:"x-deluge-add-window-icon"},b);Deluge.AddConnectionWindow.superclass.constructor.call(this,b)},initComponent:function(){Deluge.AddConnectionWindow.superclass.initComponent.call(this);this.addEvents("hostadded");this.addButton(_("Close"),this.hide,this);this.addButton(_("Add"),this.onAddClick,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",id:"connectionAddForm",baseCls:"x-plain",labelWidth:55});this.hostField=this.form.add({fieldLabel:_("Host"),id:"host",name:"host",anchor:"100%",value:""});this.portField=this.form.add({fieldLabel:_("Port"),id:"port",xtype:"spinnerfield",name:"port",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:65535},value:"58846",anchor:"50%"});this.usernameField=this.form.add({fieldLabel:_("Username"),id:"username",name:"username",anchor:"100%",value:""});this.passwordField=this.form.add({fieldLabel:_("Password"),anchor:"100%",id:"_password",name:"_password",inputType:"password",value:""})},onAddClick:function(){var d=this.hostField.getValue();var b=this.portField.getValue();var e=this.usernameField.getValue();var c=this.passwordField.getValue();deluge.client.web.add_host(d,b,e,c,{success:function(f){if(!f[0]){Ext.MessageBox.show({title:_("Error"),msg:"Unable to add host: "+f[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.fireEvent("hostadded")}this.hide()},scope:this})},onHide:function(){this.form.getForm().reset()}});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(){Deluge.ConnectionManager.superclass.initComponent.call(this);this.on("hide",this.onHide,this);this.on("show",this.onShow,this);deluge.events.on("disconnect",this.onDisconnect,this);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},selectionchange:{fn:this.onSelectionChanged,scope:this}}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({buttons:[{id:"cm-add",cls:"x-btn-text-icon",text:_("Add"),iconCls:"icon-add",handler:this.onAddClick,scope:this},{id:"cm-remove",cls:"x-btn-text-icon",text:_("Remove"),iconCls:"icon-remove",handler:this.onRemove,disabled:true,scope:this},"->",{id:"cm-stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),iconCls:"icon-error",handler:this.onStop,disabled:true,scope:this}]})});this.update=this.update.createDelegate(this)},checkConnected:function(){deluge.client.web.connected({success:function(b){if(b){deluge.events.fire("connect")}else{this.show()}},scope:this})},disconnect:function(){deluge.events.fire("disconnect")},loadHosts:function(){deluge.client.web.get_hosts({success:this.onGetHosts,scope:this})},update:function(){this.grid.getStore().each(function(b){deluge.client.web.get_host_status(b.id,{success:this.onGetHostStatus,scope:this})},this)},updateButtons:function(c){var d=this.buttons[1],b=c.get("status");if(b==_("Connected")){d.enable();d.setText(_("Disconnect"))}else{if(b==_("Offline")){d.disable()}else{d.enable();d.setText(_("Connect"))}}if(b==_("Offline")){if(c.get("host")=="127.0.0.1"||c.get("host")=="localhost"){this.stopHostButton.enable();this.stopHostButton.setText(_("Start Daemon"))}else{this.stopHostButton.disable()}}else{this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}},onAddClick:function(b,c){if(!this.addWindow){this.addWindow=new Deluge.AddConnectionWindow();this.addWindow.on("hostadded",this.onHostAdded,this)}this.addWindow.show()},onHostAdded:function(){this.loadHosts()},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.update(this);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})}});this.hide()}},onDisconnect:function(){if(this.isVisible()){return}this.show()},onGetHosts:function(b){this.grid.getStore().loadData(b);Ext.each(b,function(c){deluge.client.web.get_host_status(c[0],{success:this.onGetHostStatus,scope:this})},this)},onGetHostStatus:function(c){var b=this.grid.getStore().getById(c[0]);b.set("status",c[3]);b.set("version",c[4]);b.commit();if(this.grid.getSelectionModel().getSelected()==b){this.updateButtons(b)}},onHide:function(){if(this.running){window.clearInterval(this.running)}},onLogin:function(){if(deluge.config.first_login){Ext.MessageBox.confirm("Change password","As this is your first login, we recommend that you change your password. Would you like to do this now?",function(b){this.checkConnected();if(b=="yes"){deluge.preferences.show();deluge.preferences.selectPage("Interface")}deluge.client.web.set_config({first_login:false})},this)}else{this.checkConnected()}},onLogout:function(){this.disconnect();if(!this.hidden&&this.rendered){this.hide()}},onRemove:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}deluge.client.web.remove_host(b.id,{success: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{this.grid.getStore().remove(b)}},scope:this})},onSelect:function(c,d,b){this.selectedRow=d},onSelectionChanged:function(c){var b=c.getSelected();if(c.hasSelection()){this.removeHostButton.enable();this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}else{this.removeHostButton.disable();this.stopHostButton.disable()}this.updateButtons(b)},onShow:function(){if(!this.addHostButton){var b=this.grid.getBottomToolbar();this.addHostButton=b.items.get("cm-add");this.removeHostButton=b.items.get("cm-remove");this.stopHostButton=b.items.get("cm-stop")}this.loadHosts();this.running=window.setInterval(this.update,2000,this)},onStop:function(c,d){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")=="Offline"){deluge.client.web.start_daemon(b.get("port"))}else{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 Deluge.ConnectionManager()})();(function(){Ext.namespace("Deluge.details");Deluge.details.TabPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",id:"torrentDetails",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0},a);Deluge.details.TabPanel.superclass.constructor.call(this,a)},clear:function(){this.items.each(function(a){if(a.clear){a.clear.defer(100,a);a.disable()}})},update:function(a){var b=deluge.torrents.getSelected();if(!b){this.clear();return}this.items.each(function(c){if(c.disabled){c.enable()}});a=a||this.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(b,a){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 Deluge.details.TabPanel()})();Deluge.details.StatusTab=Ext.extend(Ext.Panel,{title:_("Status"),autoScroll:true,onRender:function(b,a){Deluge.details.StatusTab.superclass.onRender.call(this,b,a);this.progressBar=this.add({xtype:"progress",cls:"x-deluge-status-progressbar"});this.status=this.add({cls:"x-deluge-status",id:"deluge-details-status",border:false,width:1000,listeners:{render:{fn:function(c){c.load({url:deluge.config.base+"render/tab_status.html",text:_("Loading")+"..."});c.getUpdater().on("update",this.onPanelUpdate,this)},scope:this}}})},clear:function(){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),uploaded:fsize(a.total_uploaded),share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:(a.download_payload_rate)?fspeed(a.download_payload_rate):"0.0 KiB/s",upspeed:(a.upload_payload_rate)?fspeed(a.upload_payload_rate):"0.0 KiB/s",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,time_added:fdate(a.time_added)};b.auto_managed=_((a.is_auto_managed)?"True":"False");b.downloaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";b.uploaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";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/100,d)}});deluge.details.add(new Deluge.details.StatusTab());Deluge.details.DetailsTab=Ext.extend(Ext.Panel,{title:_("Details"),fields:{},queuedItems:{},oldData:{},initComponent:function(){Deluge.details.DetailsTab.superclass.initComponent.call(this);this.addItem("torrent_name",_("Name"));this.addItem("hash",_("Hash"));this.addItem("path",_("Path"));this.addItem("size",_("Total Size"));this.addItem("files",_("# of files"));this.addItem("comment",_("Comment"));this.addItem("status",_("Status"));this.addItem("tracker",_("Tracker"))},onRender:function(b,a){Deluge.details.DetailsTab.superclass.onRender.call(this,b,a);this.body.setStyle("padding","10px");this.dl=Ext.DomHelper.append(this.body,{tag:"dl"},true);for(var c in this.queuedItems){this.doAddItem(c,this.queuedItems[c])}},addItem:function(b,a){if(!this.rendered){this.queuedItems[b]=a}else{this.doAddItem(b,a)}},doAddItem:function(b,a){Ext.DomHelper.append(this.dl,{tag:"dt",cls:b,html:a+":"});this.fields[b]=Ext.DomHelper.append(this.dl,{tag:"dd",cls:b,html:""},true)},clear:function(){if(!this.fields){return}for(var a in this.fields){this.fields[a].dom.innerHTML=""}},update:function(a){deluge.client.core.get_torrent_status(a,Deluge.Keys.Details,{success:this.onRequestComplete,scope:this,torrentId:a})},onRequestComplete:function(e,c,a,b){var d={torrent_name:e.name,hash:b.options.torrentId,path:e.save_path,size:fsize(e.total_size),files:e.num_files,status:e.tracker_status,tracker:e.tracker,comment:e.comment};for(var f in this.fields){if(!d[f]){continue}if(d[f]==this.oldData[f]){continue}this.fields[f].dom.innerHTML=Ext.escapeHTML(d[f])}this.oldData=d}});deluge.details.add(new Deluge.details.DetailsTab());(function(){function b(d){var c=d*100;return Deluge.progressBar(c,this.col.width,c.toFixed(2)+"%",0)}function a(c){if(isNaN(c)){return""}return String.format('{1}
',FILE_PRIORITY_CSS[c],_(FILE_PRIORITY[c]))}Deluge.details.FilesTab=Ext.extend(Ext.ux.tree.TreeGrid,{constructor:function(c){c=Ext.apply({title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{xtype:"tgrendercolumn",header:_("Progress"),width:150,dataIndex:"progress",renderer:b},{xtype:"tgrendercolumn",header:_("Priority"),width:150,dataIndex:"priority",renderer:a}],root:new Ext.tree.TreeNode({text:"Files"})},c);Deluge.details.FilesTab.superclass.constructor.call(this,c)},initComponent:function(){Deluge.details.FilesTab.superclass.initComponent.call(this)},onRender:function(d,c){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,i){switch(j.id){case"expandAll":this.expandAll();break;default:var h={};function c(e){if(Ext.isEmpty(e.attributes.fileIndex)){return}h[e.attributes.fileIndex]=e.attributes.priority}this.getRootNode().cascade(c);var d=this.getSelectionModel().getSelectedNodes();Ext.each(d,function(k){if(!k.isLeaf()){function e(l){if(Ext.isEmpty(l.attributes.fileIndex)){return}h[l.attributes.fileIndex]=j.filePriority}k.cascade(e)}else{if(!Ext.isEmpty(k.attributes.fileIndex)){h[k.attributes.fileIndex]=j.filePriority;return}}});var g=new Array(Ext.keys(h).length);for(var f in h){g[f]=h[f]}deluge.client.core.set_torrent_file_priorities(this.torrentId,g,{success:function(){Ext.each(d,function(e){e.setColumnValue(3,j.filePriority)})},scope:this});break}},onRequestComplete:function(f,e){function d(j,h){for(var g in j.contents){var i=j.contents[g];var k=h.findChild("id",g);if(i.type=="dir"){if(!k){k=new Ext.tree.TreeNode({id:g,text:g,filename:g,size:i.size,progress:i.progress,priority:i.priority});h.appendChild(k)}d(i,k)}else{if(!k){k=new Ext.tree.TreeNode({id:g,filename:g,text:g,fileIndex:i.index,size:i.size,progress:i.progress,priority:i.priority,leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.ux.tree.TreeGridNodeUI});h.appendChild(k)}}}}var c=this.getRootNode();d(f,c);c.firstChild.expand()}});deluge.details.add(new 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(f){var e=(f*100).toFixed(0);return Deluge.progressBar(e,this.width-8,e+"%")}function b(e){var f=e.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);return((((((+f[1])*256)+(+f[2]))*256)+(+f[3]))*256)+(+f[4])}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);Deluge.details.PeersTab.superclass.constructor.call(this,e)},onRender:function(f,e){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){if(!g){return}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 Deluge.details.PeersTab())})();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);Deluge.details.OptionsTab.superclass.constructor.call(this,a)},initComponent:function(){Deluge.details.OptionsTab.superclass.initComponent.call(this);this.fieldsets={},this.fields={};this.optionsManager=new Deluge.MultiOptionsManager({options:{max_download_speed:-1,max_upload_speed:-1,max_connections:-1,max_upload_slots:-1,auto_managed:false,stop_at_ratio:false,stop_ratio:2,remove_at_ratio:false,move_completed:null,"private":false,prioritize_first_last:false}});this.fieldsets.bandwidth=this.add({xtype:"fieldset",defaultType:"spinnerfield",bodyStyle:"padding: 5px",layout:"table",layoutConfig:{columns:3},labelWidth:150,style:"margin-left: 10px; margin-right: 5px; padding: 5px",title:_("Bandwidth"),width:250});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:70,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});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:70,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});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:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});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:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});this.fieldsets.queue=this.add({xtype:"fieldset",title:_("Queue"),style:"margin-left: 5px; margin-right: 5px; padding: 5px",width:210,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaults:{fieldLabel:"",labelSeparator:""}});this.fields.auto_managed=this.fieldsets.queue.add({xtype:"checkbox",fieldLabel:"",labelSeparator:"",name:"is_auto_managed",boxLabel:_("Auto Managed"),width:200,colspan:2});this.fields.stop_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"stop_at_ratio",width:120,boxLabel:_("Stop seed at ratio"),handler:this.onStopRatioChecked,scope:this});this.fields.stop_ratio=this.fieldsets.queue.add({xtype:"spinnerfield",id:"stop_ratio",name:"stop_ratio",disabled:true,width:50,value:2,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});this.fields.remove_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"remove_at_ratio",ctCls:"x-deluge-indent-checkbox",bodyStyle:"padding-left: 10px",boxLabel:_("Remove at ratio"),disabled:true,colspan:2});this.fields.move_completed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"move_completed",boxLabel:_("Move Completed"),colspan:2});this.rightColumn=this.add({border:false,autoHeight:true,style:"margin-left: 5px",width:210});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",disabled:true});this.fields.prioritize_first_last=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"});for(var a in this.fields){this.optionsManager.bind(a,this.fields[a])}this.buttonPanel=this.rightColumn.add({layout:"hbox",xtype:"panel",border:false});this.buttonPanel.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({id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px;",border:false,width:100,handler:this.onApply,scope:this})},onRender:function(b,a){Deluge.details.OptionsTab.superclass.onRender.call(this,b,a);this.layout=new Ext.layout.ColumnLayout();this.layout.setContainer(this);this.doLayout()},clear:function(){if(this.torrentId==null){return}this.torrentId=null;this.optionsManager.changeId(null)},reset:function(){if(this.torrentId){this.optionsManager.reset()}},update:function(a){if(this.torrentId&&!a){this.clear()}if(!a){return}if(this.torrentId!=a){this.torrentId=a;this.optionsManager.changeId(a)}deluge.client.core.get_torrent_status(a,Deluge.Keys.Options,{success:this.onRequestComplete,scope:this})},onApply:function(){var b=this.optionsManager.getDirty();if(!Ext.isEmpty(b.prioritize_first_last)){var a=b.prioritize_first_last;deluge.client.core.set_torrent_prioritize_first_last(this.torrentId,a,{success:function(){this.optionsManager.set("prioritize_first_last",a)},scope:this})}deluge.client.core.set_torrent_options([this.torrentId],b,{success:function(){this.optionsManager.commit()},scope:this})},onEditTrackers:function(){deluge.editTrackers.show()},onStopRatioChecked:function(b,a){this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)},onRequestComplete:function(c,b){this.fields["private"].setValue(c["private"]);this.fields["private"].setDisabled(true);delete c["private"];c.auto_managed=c.is_auto_managed;this.optionsManager.setDefault(c);var a=this.optionsManager.get("stop_at_ratio");this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)}});deluge.details.add(new Deluge.details.OptionsTab());(function(){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);Deluge.AddTracker.superclass.constructor.call(this,a)},initComponent:function(){Deluge.AddTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,this);this.addEvents("add");this.form=this.add({xtype:"form",defaultType:"textarea",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Trackers"),name:"trackers",anchor:"100%"}]})},onAddClick: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("")},onCancelClick:function(){this.form.getForm().findField("trackers").setValue("");this.hide()}});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);Deluge.EditTracker.superclass.constructor.call(this,a)},initComponent:function(){Deluge.EditTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Save"),this.onSaveClick,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){Deluge.EditTracker.superclass.show.call(this);this.record=a;this.form.getForm().findField("tracker").setValue(a.data.url)},onCancelClick:function(){this.hide()},onHide:function(){this.form.getForm().findField("tracker").setValue("")},onSaveClick:function(){var a=this.form.getForm().findField("tracker").getValue();this.record.set("url",a);this.record.commit();this.hide()}});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);Deluge.EditTrackers.superclass.constructor.call(this,a)},initComponent:function(){Deluge.EditTrackers.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Ok"),this.onOkClick,this);this.addEvents("save");this.on("show",this.onShow,this);this.on("save",this.onSave,this);this.addWindow=new Deluge.AddTracker();this.addWindow.on("add",this.onAddTrackers,this);this.editWindow=new 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:[{text:_("Up"),iconCls:"icon-up",handler:this.onUpClick,scope:this},{text:_("Down"),iconCls:"icon-down",handler:this.onDownClick,scope:this},"->",{text:_("Add"),iconCls:"icon-add",handler:this.onAddClick,scope:this},{text:_("Edit"),iconCls:"icon-edit-trackers",handler:this.onEditClick,scope:this},{text:_("Remove"),iconCls:"icon-remove",handler:this.onRemoveClick,scope:this}]})})},onAddClick: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)},onCancelClick:function(){this.hide()},onEditClick:function(){var a=this.grid.getSelectionModel().getSelected();this.editWindow.show(a)},onHide:function(){this.grid.getStore().removeAll()},onOkClick: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 Deluge.EditTrackers()})();Ext.namespace("Deluge");Deluge.FileBrowser=Ext.extend(Ext.Window,{title:_("File Browser"),width:500,height:400,initComponent:function(){Deluge.FileBrowser.superclass.initComponent.call(this);this.add({xtype:"toolbar",items:[{text:_("Back"),iconCls:"icon-back"},{text:_("Forward"),iconCls:"icon-forward"},{text:_("Up"),iconCls:"icon-up"},{text:_("Home"),iconCls:"icon-home"}]})}});Deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closable:false,closeAction:"hide",iconCls:"x-deluge-login-window-icon",layout:"fit",modal:true,plain:true,resizable:false,title:_("Login"),width:300,height:120,initComponent:function(){Deluge.LoginWindow.superclass.initComponent.call(this);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:55,width:300,defaults:{width:200},defaultType:"textfield",});this.passwordField=this.form.add({xtype:"textfield",fieldLabel:_("Password"),id:"_password",name:"password",inputType:"password"});this.passwordField.on("specialkey",this.onSpecialKey,this)},logout:function(){deluge.events.fire("logout");deluge.client.auth.delete_session({success:function(a){this.show(true)},scope:this})},show:function(a){if(this.firstShow){deluge.client.on("error",this.onClientError,this);this.firstShow=false}if(a){return Deluge.LoginWindow.superclass.show.call(this)}deluge.client.auth.check_session({success:function(b){if(b){deluge.events.fire("login")}else{this.show(true)}},failure:function(b){this.show(true)},scope:this})},onSpecialKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.passwordField;deluge.client.auth.login(a.getValue(),{success:function(b){if(b){deluge.events.fire("login");this.hide();a.setRawValue("")}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})},onClientError:function(c,b,a){if(c.error.code==1){deluge.events.fire("logout");this.show(true)}},onShow:function(){this.passwordField.focus(false,150);this.passwordField.setRawValue("")}});deluge.login=new Deluge.LoginWindow();Ext.namespace("Deluge");Deluge.MoveStorage=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Move Storage"),width:375,height:110,layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-move-storage",plain:true,resizable:false},a);Deluge.MoveStorage.superclass.constructor.call(this,a)},initComponent:function(){Deluge.MoveStorage.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Move"),this.onMove,this);this.form=this.add({xtype:"form",border:false,defaultType:"textfield",width:300,bodyStyle:"padding: 5px"});this.moveLocation=this.form.add({fieldLabel:_("Location"),name:"location",width:240});this.form.add({xtype:"button",text:_("Browse"),handler:function(){if(!this.fileBrowser){this.fileBrowser=new Deluge.FileBrowser()}this.fileBrowser.show()},scope:this})},hide:function(){Deluge.MoveStorage.superclass.hide.call(this);this.torrentIds=null},show:function(a){Deluge.MoveStorage.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide()},onMove:function(){var a=this.moveLocation.getValue();deluge.client.core.move_storage(this.torrentIds,a);this.hide()}});deluge.moveStorage=new Deluge.MoveStorage();Deluge.Plugin=Ext.extend(Ext.util.Observable,{name:null,constructor:function(a){this.name=a.name;this.addEvents({enabled:true,disabled:true});this.isDelugePlugin=true;Deluge.Plugins[this.name]=this;Deluge.Plugin.superclass.constructor.call(this,a)},disable:function(){this.fireEvent("disabled",this);if(this.onDisable){this.onDisable()}},enable:function(){this.fireEvent("enable",this);if(this.onEnable){this.onEnable()}}});Ext.namespace("Deluge.preferences");PreferencesRecord=Ext.data.Record.create([{name:"name",type:"string"}]);Deluge.preferences.PreferencesWindow=Ext.extend(Ext.Window,{currentPage:null,title:_("Preferences"),layout:"border",width:485,height:500,buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-preferences",plain:true,resizable:false,initComponent:function(){Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.add({xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.Store(),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});this.configPanel=this.add({type:"container",autoDestroy:false,region:"center",layout:"card",margins:"5 5 5 5",cmargins:"5 5 5 5"});this.addButton(_("Close"),this.onClose,this);this.addButton(_("Apply"),this.onApply,this);this.addButton(_("Ok"),this.onOk,this);this.pages={};this.optionsManager=new Deluge.OptionsManager();this.on("afterrender",this.onAfterRender,this);this.on("show",this.onShow,this)},onApply:function(b){var c=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(c)){deluge.client.core.set_config(c,{success:this.onSetConfig,scope:this})}for(var a in this.pages){if(this.pages[a].onApply){this.pages[a].onApply()}}},getOptionsManager:function(){return this.optionsManager},addPage:function(c){var a=this.categoriesGrid.getStore();var b=c.title;a.add([new PreferencesRecord({name:b})]);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);return this.pages[b]},removePage:function(c){var b=c.title;var a=this.categoriesGrid.getStore();a.removeAt(a.find("name",b));this.configPanel.remove(c);delete this.pages[c.title]},selectPage:function(b){var a=this.configPanel.items.indexOf(this.pages[b]);this.configPanel.getLayout().setActiveItem(a);this.currentPage=b},onGotConfig:function(a){this.getOptionsManager().set(a)},onPageSelect:function(a,c,b){this.selectPage(b.get("name"))},onSetConfig:function(){this.getOptionsManager().commit()},onAfterRender:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}this.configPanel.getLayout().setActiveItem(0)},onShow:function(){if(!deluge.client.core){return}deluge.client.core.get_config({success:this.onGotConfig,scope:this})},onClose:function(){this.hide()},onOk:function(){deluge.client.core.set_config(this.optionsManager.getDirty());this.hide()}});deluge.preferences=new Deluge.preferences.PreferencesWindow();Ext.namespace("Deluge.preferences");Deluge.preferences.Downloads=Ext.extend(Ext.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Downloads"),layout:"form",autoHeight:true,width:320},a);Deluge.preferences.Downloads.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Downloads.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Folders"),labelWidth:150,defaultType:"togglefield",autoHeight:true,labelAlign:"top",width:300,style:"margin-bottom: 5px; padding-bottom: 5px;"});b.bind("download_location",a.add({xtype:"textfield",name:"download_location",fieldLabel:_("Download to"),width:280}));var c=a.add({name:"move_completed_path",fieldLabel:_("Move completed to"),width:280});b.bind("move_completed",c.toggle);b.bind("move_completed_path",c.input);c=a.add({name:"torrentfiles_location",fieldLabel:_("Copy of .torrent files to"),width:280});b.bind("copy_torrent_file",c.toggle);b.bind("torrentfiles_location",c.input);c=a.add({name:"autoadd_location",fieldLabel:_("Autoadd .torrent files from"),width:280});b.bind("autoadd_enable",c.toggle);b.bind("autoadd_location",c.input);a=this.add({xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radiogroup",style:"margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;",width:240,});b.bind("compact_allocation",a.add({name:"compact_allocation",width:200,labelSeparator:"",disabled:true,defaults:{width:80,height:22,name:"compact_allocation"},items:[{boxLabel:_("Use Full"),inputValue:false},{boxLabel:_("Use Compact"),inputValue:true}]}));a=this.add({xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",style:"margin-bottom: 0; padding-bottom: 0;",width:280});b.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",labelSeparator:"",height:22,boxLabel:_("Prioritize first and last pieces of torrent")}));b.bind("add_paused",a.add({name:"add_paused",labelSeparator:"",height:22,boxLabel:_("Add torrents in Paused state")}));this.on("show",this.onShow,this)},onShow:function(){Deluge.preferences.Downloads.superclass.onShow.call(this)}});deluge.preferences.addPage(new Deluge.preferences.Downloads());Ext.namespace("Deluge.preferences");Deluge.preferences.Network=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Network"),layout:"form"},a);Deluge.preferences.Network.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Network.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Incoming Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_port",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_port",height:22,listeners:{check:{fn:function(d,c){this.listenPorts.setDisabled(c)},scope:this}}}));this.listenPorts=a.add({xtype:"uxspinnergroup",name:"listen_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("listen_ports",this.listenPorts);a=this.add({xtype:"fieldset",border:false,title:_("Outgoing Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_outgoing_ports",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_outgoing_ports",height:22,listeners:{check:{fn:function(d,c){this.outgoingPorts.setDisabled(c)},scope:this}}}));this.outgoingPorts=a.add({xtype:"uxspinnergroup",name:"outgoing_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("outgoing_ports",this.outgoingPorts);a=this.add({xtype:"fieldset",border:false,title:_("Network Interface"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"textfield"});b.bind("listen_interface",a.add({name:"listen_interface",fieldLabel:"",labelSeparator:"",width:200}));a=this.add({xtype:"fieldset",border:false,title:_("TOS"),style:"margin-bottom: 5px; padding-bottom: 0px;",bodyStyle:"margin: 0px; padding: 0px",autoHeight:true,defaultType:"textfield"});b.bind("peer_tos",a.add({name:"peer_tos",fieldLabel:_("Peer TOS Byte"),width:80}));a=this.add({xtype:"fieldset",border:false,title:_("Network Extras"),autoHeight:true,layout:"table",layoutConfig:{columns:3},defaultType:"checkbox"});b.bind("upnp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("UPnP"),name:"upnp"}));b.bind("natpmp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("NAT-PMP"),ctCls:"x-deluge-indent-checkbox",name:"natpmp"}));b.bind("utpex",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Peer Exchange"),ctCls:"x-deluge-indent-checkbox",name:"utpex"}));b.bind("lsd",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("LSD"),name:"lsd"}));b.bind("dht",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("DHT"),ctCls:"x-deluge-indent-checkbox",name:"dht"}))}});deluge.preferences.addPage(new Deluge.preferences.Network());Ext.namespace("Deluge.preferences");Deluge.preferences.Encryption=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Encryption"),layout:"form"},a);Deluge.preferences.Encryption.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Encryption.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,defaultType:"combo"});b.bind("enc_in_policy",a.add({fieldLabel:_("Inbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_out_policy",a.add({fieldLabel:_("Outbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_level",a.add({fieldLabel:_("Level"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Handshake")],[1,_("Full Stream")],[2,_("Either")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_prefer_rc4",a.add({xtype:"checkbox",name:"enc_prefer_rc4",height:40,hideLabel:true,boxLabel:_("Encrypt entire stream")}))}});deluge.preferences.addPage(new Deluge.preferences.Encryption());Ext.namespace("Deluge.preferences");Deluge.preferences.Bandwidth=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Bandwidth"),layout:"form",labelWidth:10},a);Deluge.preferences.Bandwidth.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Bandwidth.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),labelWidth:200,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",autoHeight:true});b.bind("max_connections_global",a.add({name:"max_connections_global",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_global",a.add({name:"max_upload_slots_global",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed",a.add({name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed",a.add({name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_half_open_connections",a.add({name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_connections_per_second",a.add({name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));a=this.add({xtype:"fieldset",border:false,title:"",defaultType:"checkbox",style:"padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;",autoHeight:true});b.bind("ignore_limits_on_local_network",a.add({name:"ignore_limits_on_local_network",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),}));b.bind("rate_limit_ip_overhead",a.add({name:"rate_limit_ip_overhead",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),}));a=this.add({xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"spinnerfield",labelWidth:200,autoHeight:true});b.bind("max_connections_per_torrent",a.add({name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_per_torrent",a.add({name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed_per_torrent",a.add({name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed_per_torrent",a.add({name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}))}});deluge.preferences.addPage(new Deluge.preferences.Bandwidth());Ext.namespace("Deluge.preferences");Deluge.preferences.Interface=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Interface"),layout:"form"},a);Deluge.preferences.Interface.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Interface.superclass.initComponent.call(this);var c=this.optionsManager=new Deluge.OptionsManager();this.on("show",this.onShow,this);var a=this.add({xtype:"fieldset",border:false,title:_("Interface"),style:"margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px",autoHeight:true,labelWidth:1,defaultType:"checkbox"});c.bind("show_session_speed",a.add({name:"show_session_speed",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar")}));c.bind("sidebar_show_zero",a.add({name:"sidebar_show_zero",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show filters with zero torrents")}));c.bind("sidebar_show_trackers",a.add({name:"sidebar_show_trackers",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show trackers with zero torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Password"),style:"margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px",autoHeight:true,labelWidth:110,defaultType:"textfield",defaults:{width:180,inputType:"password"}});this.oldPassword=a.add({name:"old_password",fieldLabel:_("Old Password")});this.newPassword=a.add({name:"new_password",fieldLabel:_("New Password")});this.confirmPassword=a.add({name:"confirm_password",fieldLabel:_("Confirm Password")});var b=a.add({xtype:"panel",autoHeight:true,border:false,width:320,bodyStyle:"padding-left: 230px"});b.add({xtype:"button",text:_("Change"),listeners:{click:{fn:this.onPasswordChange,scope:this}}});a=this.add({xtype:"fieldset",border:false,title:_("Server"),style:"margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px",autoHeight:true,labelWidth:110,defaultType:"spinnerfield",defaults:{width:80,}});c.bind("session_timeout",a.add({name:"session_timeout",fieldLabel:_("Session Timeout"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));c.bind("port",a.add({name:"port",fieldLabel:_("Port"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));this.httpsField=c.bind("https",a.add({xtype:"checkbox",name:"https",hideLabel:true,width:280,height:22,boxLabel:_("Use SSL (paths relative to Deluge config folder)")}));this.httpsField.on("check",this.onSSLCheck,this);this.pkeyField=c.bind("pkey",a.add({xtype:"textfield",disabled:true,name:"pkey",width:180,fieldLabel:_("Private Key")}));this.certField=c.bind("cert",a.add({xtype:"textfield",disabled:true,name:"cert",width:180,fieldLabel:_("Certificate")}))},onApply:function(){var a=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(a)){deluge.client.web.set_config(a,{success:this.onSetConfig,scope:this})}},onGotConfig:function(a){this.optionsManager.set(a)},onPasswordChange:function(){var b=this.newPassword.getValue();if(b!=this.confirmPassword.getValue()){Ext.MessageBox.show({title:_("Invalid Password"),msg:_("Your passwords don't match!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var a=this.oldPassword.getValue();deluge.client.auth.change_password(a,b,{success:function(c){if(!c){Ext.MessageBox.show({title:_("Password"),msg:_("Your old password was incorrect!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});this.oldPassword.setValue("")}else{Ext.MessageBox.show({title:_("Change Successful"),msg:_("Your password was successfully changed!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.INFO,iconCls:"x-deluge-icon-info"});this.oldPassword.setValue("");this.newPassword.setValue("");this.confirmPassword.setValue("")}},scope:this})},onSetConfig:function(){this.optionsManager.commit()},onShow:function(){Deluge.preferences.Interface.superclass.onShow.call(this);deluge.client.web.get_config({success:this.onGotConfig,scope:this})},onSSLCheck:function(b,a){this.pkeyField.setDisabled(!a);this.certField.setDisabled(!a)}});deluge.preferences.addPage(new Deluge.preferences.Interface());Ext.namespace("Deluge.preferences");Deluge.preferences.Other=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Other"),layout:"form"},a);Deluge.preferences.Other.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Other.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Updates"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:22,name:"new_release_check",boxLabel:_("Be alerted about new releases")}));a=this.add({xtype:"fieldset",border:false,title:_("System Information"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});a.add({xtype:"panel",border:false,bodyCfg:{html:_("Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.")}});b.bind("send_info",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Yes, please send anonymous statistics"),name:"send_info"}));a=this.add({xtype:"fieldset",border:false,title:_("GeoIP Database"),autoHeight:true,labelWidth:80,defaultType:"textfield"});b.bind("geoip_db_location",a.add({name:"geoip_db_location",fieldLabel:_("Location"),width:200}))}});deluge.preferences.addPage(new Deluge.preferences.Other());Ext.namespace("Deluge.preferences");Deluge.preferences.Daemon=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Daemon"),layout:"form"},a);Deluge.preferences.Daemon.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Daemon.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"spinnerfield"});b.bind("daemon_port",a.add({fieldLabel:_("Daemon port"),name:"daemon_port",value:58846,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("allow_remote",a.add({fieldLabel:"",height:22,labelSeparator:"",boxLabel:_("Allow Remote Connections"),name:"allow_remote"}));a=this.add({xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_release_check"}))}});deluge.preferences.addPage(new Deluge.preferences.Daemon());Ext.namespace("Deluge.preferences");Deluge.preferences.Queue=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Queue"),layout:"form"},a);Deluge.preferences.Queue.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Queue.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("General"),style:"padding-top: 5px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("queue_new_to_top",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Queue new torrents to top"),name:"queue_new_to_top"}));a=this.add({xtype:"fieldset",border:false,title:_("Active Torrents"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",});b.bind("max_active_limit",a.add({fieldLabel:_("Total Active"),name:"max_active_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_downloading",a.add({fieldLabel:_("Total Active Downloading"),name:"max_active_downloading",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_seeding",a.add({fieldLabel:_("Total Active Seeding"),name:"max_active_seeding",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("dont_count_slow_torrents",a.add({xtype:"checkbox",name:"dont_count_slow_torrents",height:40,hideLabel:true,boxLabel:_("Do not count slow torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Seeding"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;",});b.bind("share_ratio_limit",a.add({fieldLabel:_("Share Ratio Limit"),name:"share_ratio_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_ratio_limit",a.add({fieldLabel:_("Share Time Ratio"),name:"seed_time_ratio_limit",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_limit",a.add({fieldLabel:_("Seed Time (m)"),name:"seed_time_limit",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,autoHeight:true,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaultType:"checkbox",defaults:{fieldLabel:"",labelSeparator:""}});this.stopAtRatio=a.add({name:"stop_seed_at_ratio",boxLabel:_("Stop seeding when share ratio reaches:")});this.stopAtRatio.on("check",this.onStopRatioCheck,this);b.bind("stop_seed_at_ratio",this.stopAtRatio);this.stopRatio=a.add({xtype:"spinnerfield",name:"stop_seed_ratio",ctCls:"x-deluge-indent-checkbox",disabled:true,value:2,width:60,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});b.bind("stop_seed_ratio",this.stopRatio);this.removeAtRatio=a.add({name:"remove_seed_at_ratio",ctCls:"x-deluge-indent-checkbox",boxLabel:_("Remove torrent when share ratio is reached"),disabled:true,colspan:2});b.bind("remove_seed_at_ratio",this.removeAtRatio)},onStopRatioCheck:function(b,a){this.stopRatio.setDisabled(!a);this.removeAtRatio.setDisabled(!a)}});deluge.preferences.addPage(new Deluge.preferences.Queue());Ext.namespace("Deluge.preferences");Deluge.preferences.ProxyField=Ext.extend(Ext.form.FieldSet,{constructor:function(a){a=Ext.apply({border:false,autoHeight:true,labelWidth:70},a);Deluge.preferences.ProxyField.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.ProxyField.superclass.initComponent.call(this);this.type=this.add({xtype:"combo",fieldLabel:_("Type"),name:"type",mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("None")],[1,_("Socksv4")],[2,_("Socksv5")],[3,_("Socksv5 with Auth")],[4,_("HTTP")],[5,_("HTTP with Auth")],]}),value:0,triggerAction:"all",valueField:"id",displayField:"text"});this.hostname=this.add({xtype:"textfield",name:"hostname",fieldLabel:_("Host"),width:220});this.port=this.add({xtype:"spinnerfield",name:"port",fieldLabel:_("Port"),width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}});this.username=this.add({xtype:"textfield",name:"username",fieldLabel:_("Username"),width:220});this.password=this.add({xtype:"textfield",name:"password",fieldLabel:_("Password"),inputType:"password",width:220});this.type.on("change",this.onFieldChange,this);this.type.on("select",this.onTypeSelect,this);this.setting=false},getName:function(){return this.initialConfig.name},getValue:function(){return{type:this.type.getValue(),hostname:this.hostname.getValue(),port:Number(this.port.getValue()),username:this.username.getValue(),password:this.password.getValue()}},setValue:function(c){this.setting=true;this.type.setValue(c.type);var b=this.type.getStore().find("id",c.type);var a=this.type.getStore().getAt(b);this.hostname.setValue(c.hostname);this.port.setValue(c.port);this.username.setValue(c.username);this.password.setValue(c.password);this.onTypeSelect(this.type,a,b);this.setting=false},onFieldChange:function(e,d,c){if(this.setting){return}var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)},onTypeSelect:function(d,a,b){var c=a.get("id");if(c>0){this.hostname.show();this.port.show()}else{this.hostname.hide();this.port.hide()}if(c==3||c==5){this.username.show();this.password.show()}else{this.username.hide();this.password.hide()}}});Deluge.preferences.Proxy=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Proxy"),layout:"form"},a);Deluge.preferences.Proxy.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Proxy.superclass.initComponent.call(this);this.peer=this.add(new Deluge.preferences.ProxyField({title:_("Peer"),name:"peer"}));this.peer.on("change",this.onProxyChange,this);this.web_seed=this.add(new Deluge.preferences.ProxyField({title:_("Web Seed"),name:"web_seed"}));this.web_seed.on("change",this.onProxyChange,this);this.tracker=this.add(new Deluge.preferences.ProxyField({title:_("Tracker"),name:"tracker"}));this.tracker.on("change",this.onProxyChange,this);this.dht=this.add(new Deluge.preferences.ProxyField({title:_("DHT"),name:"dht"}));this.dht.on("change",this.onProxyChange,this);deluge.preferences.getOptionsManager().bind("proxies",this)},getValue:function(){return{dht:this.dht.getValue(),peer:this.peer.getValue(),tracker:this.tracker.getValue(),web_seed:this.web_seed.getValue()}},setValue:function(b){for(var a in b){this[a].setValue(b[a])}},onProxyChange:function(e,d,c){var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)}});deluge.preferences.addPage(new Deluge.preferences.Proxy());Ext.namespace("Deluge.preferences");Deluge.preferences.Cache=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Cache"),layout:"form"},a);Deluge.preferences.Cache.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Cache.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,labelWidth:180,defaultType:"spinnerfield"});b.bind("cache_size",a.add({fieldLabel:_("Cache Size (16 KiB Blocks)"),name:"cache_size",width:60,value:512,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("cache_expiry",a.add({fieldLabel:_("Cache Expiry (seconds)"),name:"cache_expiry",width:60,value:60,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}))}});deluge.preferences.addPage(new Deluge.preferences.Cache());Ext.namespace("Deluge.preferences");Deluge.preferences.InstallPluginWindow=Ext.extend(Ext.Window,{height:115,width:350,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",iconCls:"x-deluge-install-plugin",layout:"fit",modal:true,plain:true,title:_("Install Plugin"),initComponent:function(){Deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Install"),this.onInstall,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:70,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"pluginEgg",emptyText:_("Select an egg"),fieldLabel:_("Plugin Egg"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onInstall:function(b,a){this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your plugin..."),success:this.onUploadSuccess,scope:this})},onUploadPlugin:function(d,c,a,b){this.fireEvent("pluginadded")},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=this.form.getForm().findField("pluginEgg").value;var d=b.result.files[0];this.form.getForm().findField("pluginEgg").setValue("");deluge.client.web.upload_plugin(a,d,{success:this.onUploadPlugin,scope:this,filename:a})}}});Deluge.preferences.Plugins=Ext.extend(Ext.Panel,{constructor:function(a){a=Ext.apply({border:false,title:_("Plugins"),layout:"border",height:400,cls:"x-deluge-plugins"},a);Deluge.preferences.Plugins.superclass.constructor.call(this,a)},pluginTemplate:new Ext.Template('- Author:
- {author}
- Version:
- {version}
- Author Email:
- {email}
- Homepage:
- {homepage}
- Details:
- {details}
'),initComponent:function(){Deluge.preferences.Plugins.superclass.initComponent.call(this);this.defaultValues={version:"",email:"",homepage:"",details:""};this.pluginTemplate.compile();var b=function(d,e,c){e.css+=" x-grid3-check-col-td";return'
'};this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"enabled",mapping:0},{name:"plugin",mapping:1}]}),columns:[{id:"enabled",header:_("Enabled"),width:50,sortable:true,renderer:b,dataIndex:"enabled"},{id:"plugin",header:_("Plugin"),sortable:true,dataIndex:"plugin"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPluginSelect,scope:this}}}),autoExpandColumn:"plugin",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",iconCls:"x-deluge-install-plugin",text:_("Install"),handler:this.onInstallPluginWindow,scope:this},"->",{cls:"x-btn-text-icon",text:_("Find More"),iconCls:"x-deluge-find-more",handler:this.onFindMorePlugins,scope:this}]})});var a=this.add({xtype:"fieldset",border:false,region:"south",title:_("Info"),autoHeight:true,labelWidth:1});this.pluginInfo=a.add({xtype:"panel",border:false,bodyCfg:{style:"margin-left: 10px"}});this.on("show",this.onShow,this);this.pluginInfo.on("render",this.onPluginInfoRender,this);this.grid.on("cellclick",this.onCellClick,this);deluge.preferences.on("show",this.onPreferencesShow,this);deluge.events.on("PluginDisabledEvent",this.onPluginDisabled,this);deluge.events.on("PluginEnabledEvent",this.onPluginEnabled,this)},disablePlugin:function(a){deluge.client.core.disable_plugin(a)},enablePlugin:function(a){deluge.client.core.enable_plugin(a)},setInfo:function(b){if(!this.pluginInfo.rendered){return}var a=b||this.defaultValues;this.pluginInfo.body.dom.innerHTML=this.pluginTemplate.apply(a)},updatePlugins:function(){deluge.client.web.get_plugins({success:this.onGotPlugins,scope:this})},updatePluginsGrid:function(){var a=[];Ext.each(this.availablePlugins,function(b){if(this.enabledPlugins.indexOf(b)>-1){a.push([true,b])}else{a.push([false,b])}},this);this.grid.getStore().loadData(a)},onCellClick:function(b,f,a,d){if(a!=0){return}var c=b.getStore().getAt(f);c.set("enabled",!c.get("enabled"));c.commit();if(c.get("enabled")){this.enablePlugin(c.get("plugin"))}else{this.disablePlugin(c.get("plugin"))}},onFindMorePlugins:function(){window.open("http://dev.deluge-torrent.org/wiki/Plugins")},onGotPlugins:function(a){this.enabledPlugins=a.enabled_plugins;this.availablePlugins=a.available_plugins;this.setInfo();this.updatePluginsGrid()},onGotPluginInfo:function(b){var a={author:b.Author,version:b.Version,email:b["Author-email"],homepage:b["Home-page"],details:b.Description};this.setInfo(a);delete b},onInstallPluginWindow:function(){if(!this.installWindow){this.installWindow=new Deluge.preferences.InstallPluginWindow();this.installWindow.on("pluginadded",this.onPluginInstall,this)}this.installWindow.show()},onPluginEnabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",true);b.commit()},onPluginDisabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",false);b.commit()},onPluginInstall:function(){this.updatePlugins()},onPluginSelect:function(b,c,a){deluge.client.web.get_plugin_info(a.get("plugin"),{success:this.onGotPluginInfo,scope:this})},onPreferencesShow:function(){this.updatePlugins()},onPluginInfoRender:function(b,a){this.setInfo()}});deluge.preferences.addPage(new Deluge.preferences.Plugins());Deluge.RemoveWindow=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Remove Torrent"),layout:"fit",width:350,height:100,buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-remove-window-icon"},a);Deluge.RemoveWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.RemoveWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Remove With Data"),this.onRemoveData,this);this.addButton(_("Remove Torrent"),this.onRemove,this);this.add({border:false,bodyStyle:"padding: 5px; padding-left: 10px;",html:"Are you sure you wish to remove the torrent(s)?"})},remove:function(a){Ext.each(this.torrentIds,function(b){deluge.client.core.remove_torrent(b,a,{success:function(){this.onRemoved(b)},scope:this,torrentId:b})},this)},show:function(a){Deluge.RemoveWindow.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide();this.torrentIds=null},onRemove:function(){this.remove(false)},onRemoveData:function(){this.remove(true)},onRemoved:function(a){deluge.events.fire("torrentRemoved",a);this.hide();deluge.ui.update()}});deluge.removeWindow=new Deluge.RemoveWindow();(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("+deluge.config.base+"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)}}}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);Deluge.Sidebar.superclass.constructor.call(this,b)},initComponent:function(){Deluge.Sidebar.superclass.initComponent.call(this);deluge.events.on("disconnect",this.onDisconnect,this)},createFilter:function(e,d){var c=new Ext.data.ArrayStore({idIndex:0,fields:[{name:"filter"},{name:"count"}]});c.id=e;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",border:false,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});if(deluge.config.sidebar_show_zero==false){d=this.removeZero(d)}c.loadData(d);this.add(b);this.doLayout();this.panels[e]=b;b.getSelectionModel().selectFirstRow()},getFilters:function(){var b={};this.items.each(function(c){var f=c.getSelectionModel();if(!f.hasSelection()){return}var d=f.getSelected();var e=c.getStore().id;if(d.id=="All"){return}b[e]=d.id},this);return b},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){deluge.ui.update()},removeZero:function(b){var c=[];Ext.each(b,function(d){if(d[1]>0||d[0]==_("All")){c.push(d)}});return c},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){this.panels[e]}},this)},updateFilter:function(d,c){if(deluge.config.sidebar_show_zero==false){c=this.removeZero(c)}var b=this.panels[d].getStore();var e=[];Ext.each(c,function(h,g){var f=b.getById(h[0]);if(!f){f=new b.recordType({filter:h[0],count:h[1]});f.id=h[0];b.insert(g,[f])}f.beginEdit();f.set("filter",h[0]);f.set("count",h[1]);f.endEdit();e[h[0]]=true},this);b.each(function(f){if(e[f.id]){return}b.remove(f)},this);b.commitChanges()}});deluge.sidebar=new Deluge.Sidebar()})();Deluge.Statusbar=Ext.extend(Ext.ux.StatusBar,{constructor:function(a){a=Ext.apply({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected")},a);Deluge.Statusbar.superclass.constructor.call(this,a)},initComponent:function(){Deluge.Statusbar.superclass.initComponent.call(this);deluge.events.on("connect",this.onConnect,this);deluge.events.on("disconnect",this.onDisconnect,this)},createButtons:function(){this.buttons=this.add({id:"statusbar-connections",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",tooltip:_("Connections"),menu:deluge.menus.connections},"-",{id:"statusbar-downspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",tooltip:_("Download Speed"),menu:deluge.menus.download},"-",{id:"statusbar-upspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",tooltip:_("Upload Speed"),menu:deluge.menus.upload},"-",{id:"statusbar-traffic",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic",tooltip:_("Protocol Traffic Download/Upload")},"-",{id:"statusbar-dht",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-dht",tooltip:_("DHT Nodes")},"-",{id:"statusbar-freespace",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-freespace",tooltip:_("Freespace in download location")});this.created=true},onConnect:function(){this.setStatus({iconCls:"x-connected",text:""});if(!this.created){this.createButtons()}else{Ext.each(this.buttons,function(a){a.show();a.enable()})}this.doLayout()},onDisconnect:function(){this.clearStatus({useDefaults:true});Ext.each(this.buttons,function(a){a.hide();a.disable()});this.doLayout()},update:function(b){if(!b){return}function c(d){return d+" KiB/s"}var a=function(f,e){var g=this.items.get("statusbar-"+f);if(e.limit.value>0){var h=(e.value.formatter)?e.value.formatter(e.value.value,true):e.value.value;var d=(e.limit.formatter)?e.limit.formatter(e.limit.value,true):e.limit.value;var i=String.format(e.format,h,d)}else{var i=(e.value.formatter)?e.value.formatter(e.value.value,true):e.value.value}g.setText(i)}.createDelegate(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:c},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:c},format:"{0} ({1})"});a("traffic",{value:{value:b.download_protocol_rate,formatter:Deluge.Formatters.speed},limit:{value:b.upload_protocol_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.items.get("statusbar-dht").setText(b.dht_nodes);this.items.get("statusbar-freespace").setText(fsize(b.free_space));deluge.menus.connections.setValue(b.max_num_connections);deluge.menus.download.setValue(b.max_download);deluge.menus.upload.setValue(b.max_upload)}});deluge.statusbar=new Deluge.Statusbar();Deluge.Toolbar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=Ext.apply({items:[{id:"create",disabled:true,text:_("Create"),iconCls:"icon-create",handler:this.onTorrentAction},{id:"add",disabled:true,text:_("Add"),iconCls:"icon-add",handler:this.onTorrentAdd},{id:"remove",disabled:true,text:_("Remove"),iconCls:"icon-remove",handler:this.onTorrentAction},"|",{id:"pause",disabled:true,text:_("Pause"),iconCls:"icon-pause",handler:this.onTorrentAction},{id:"resume",disabled:true,text:_("Resume"),iconCls:"icon-resume",handler:this.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),iconCls:"icon-up",handler:this.onTorrentAction},{id:"down",disabled:true,text:_("Down"),iconCls:"icon-down",handler:this.onTorrentAction},"|",{id:"preferences",text:_("Preferences"),iconCls:"x-deluge-preferences",handler:this.onPreferencesClick,scope:this},{id:"connectionman",text:_("Connection Manager"),iconCls:"x-deluge-connection-manager",handler:this.onConnectionManagerClick,scope:this},"->",{id:"help",iconCls:"icon-help",text:_("Help"),handler:this.onHelpClick,scope:this},{id:"logout",iconCls:"icon-logout",disabled:true,text:_("Logout"),handler:this.onLogout,scope:this}]},a);Deluge.Toolbar.superclass.constructor.call(this,a)},connectedButtons:["add","remove","pause","resume","up","down"],initComponent:function(){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.login.logout()},onConnectionManagerClick:function(){deluge.connectionManager.show()},onHelpClick:function(){window.open("http://dev.deluge-torrent.org/wiki/UserGuide")},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.removeWindow.show(a);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 Deluge.Toolbar();Deluge.Torrent=Ext.data.Record.create([{name:"queue",type:"int"},{name:"name",type:"string"},{name:"total_size",type:"int"},{name:"state",type:"string"},{name:"progress",type:"int"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_rate",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host",type:"string"}]);(function(){function c(j){return(j==99999)?"":j+1}function e(k,l,j){return String.format('{1}
',j.data.state.toLowerCase(),k)}function g(j){if(!j){return}return fspeed(j)}function i(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]);return Deluge.progressBar(m,k-8,o)}function a(k,l,j){if(j.data.total_seeds>-1){return String.format("{0} ({1})",k,j.data.total_seeds)}else{return k}}function d(k,l,j){if(j.data.total_peers>-1){return String.format("{0} ({1})",k,j.data.total_peers)}else{return k}}function b(k,l,j){return(k<0)?"∞":new Number(k).toFixed(3)}function f(k,l,j){return String.format('{0}
',k)}function h(j){return j*-1}Deluge.TorrentGrid=Ext.extend(Ext.grid.GridPanel,{torrents:{},constructor:function(j){j=Ext.apply({id:"torrentGrid",store:new Ext.data.JsonStore({root:"torrents",idProperty:"id",fields:[{name:"queue"},{name:"name"},{name:"total_size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_speed",type:"int"},{name:"eta",type:"int",sortType:h},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host"}]}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:c,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:e,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"total_size"},{header:_("Progress"),width:150,sortable:true,renderer:i,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:a,dataIndex:"num_seeds"},{header:_("Peers"),width:60,sortable:true,renderer:d,dataIndex:"num_peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:g,dataIndex:"download_payload_rate"},{header:_("Up Speed"),width:80,sortable:true,renderer:g,dataIndex:"upload_payload_rate"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:b,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:b,dataIndex:"distributed_copies"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"time_added"},{header:_("Tracker"),width:120,sortable:true,renderer:f,dataIndex:"tracker_host"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0",stateful:true,view:new Ext.ux.grid.BufferView({rowHeight:26,scrollDelay:false})},j);Deluge.TorrentGrid.superclass.constructor.call(this,j)},initComponent:function(){Deluge.TorrentGrid.superclass.initComponent.call(this);deluge.events.on("torrentRemoved",this.onTorrentRemoved,this);deluge.events.on("logout",this.onDisconnect,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(q){var o=this.getStore();var m=[];for(var p in q){var r=q[p];if(this.torrents[p]){var l=o.getById(p);l.beginEdit();for(var n in r){if(l.get(n)!=r[n]){l.set(n,r[n])}}l.endEdit()}else{var l=new Deluge.Torrent(r);l.id=p;this.torrents[p]=1;m.push(l)}}o.add(m);o.each(function(k){if(!q[k.id]){o.remove(k);delete this.torrents[k.id]}},this);o.commitChanges();var j=o.getSortState();if(!j){return}o.sort(j.field,j.direction)},onDisconnect:function(){this.getStore().removeAll();this.torrents={}},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 Deluge.TorrentGrid()})();deluge.ui={errorCount:0,filters:null,initialize:function(){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:deluge.config.base+"json"});for(var a in deluge.dlugins){a=deluge.plugins[a];a.enable()}Ext.QuickTips.init();deluge.client.on("connected",function(b){deluge.login.show()},this,{single:true});this.update=this.update.createDelegate(this);this.originalTitle=document.title},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()},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){if(!a.connected){deluge.events.fire("disconnect")}if(deluge.config.show_session_speed){document.title=this.originalTitle+" (Down: "+fspeed(a.stats.download_rate,true)+" Up: "+fspeed(a.stats.upload_rate,true)+")"}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()},onPluginEnabled:function(a){deluge.client.web.get_plugin_resources(a,{success:this.onGotPluginResources,scope:this})},onGotPluginResources:function(b){var a=(deluge.debug)?b.debug_scripts:b.scripts;Ext.each(a,function(c){Ext.ux.JSLoader({url:c,onLoad:this.onPluginLoaded,pluginName:b.name})},this)},onPluginDisabled:function(a){deluge.plugins[a].disable()},onPluginLoaded:function(a){if(!deluge.plugins[a.pluginName]){return}deluge.plugins[a.pluginName].enable()},stop:function(){if(this.running){clearInterval(this.running);this.running=false;deluge.torrents.getStore().removeAll()}}};Ext.onReady(function(a){deluge.ui.initialize()});
\ No newline at end of file