From 1157fc1eeb4e8a659713a28e54fc172823e9dbec Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Tue, 21 Apr 2009 21:41:18 +0000 Subject: [PATCH] commit all new-style code so it can be versioned, NB: this is in a broken state currently. --- .../web/js/{deluge-add.js => Deluge.Add.js} | 0 deluge/ui/web/js/Deluge.ConnectionManager.js | 361 +++ deluge/ui/web/js/Deluge.Details.Details.js | 79 + deluge/ui/web/js/Deluge.Details.Files.js | 0 deluge/ui/web/js/Deluge.Details.Options.js | 0 deluge/ui/web/js/Deluge.Details.Peers.js | 0 deluge/ui/web/js/Deluge.Details.Status.js | 109 + .../{deluge-details.js => Deluge.Details.js} | 246 +- deluge/ui/web/js/Deluge.Formatters.js | 96 + deluge/ui/web/js/Deluge.Keys.js | 33 + .../js/{deluge-login.js => Deluge.Login.js} | 55 +- .../js/{deluge-menus.js => Deluge.Menus.js} | 0 .../ui/web/js/Deluge.Preferences.Bandwidth.js | 95 + deluge/ui/web/js/Deluge.Preferences.Daemon.js | 43 + .../ui/web/js/Deluge.Preferences.Downloads.js | 58 + .../ui/web/js/Deluge.Preferences.Interface.js | 47 + .../ui/web/js/Deluge.Preferences.Network.js | 7 + .../web/js/Deluge.Preferences.Notification.js | 7 + deluge/ui/web/js/Deluge.Preferences.Other.js | 7 + .../ui/web/js/Deluge.Preferences.Plugins.js | 7 + deluge/ui/web/js/Deluge.Preferences.Proxy.js | 8 + deluge/ui/web/js/Deluge.Preferences.Queue.js | 8 + deluge/ui/web/js/Deluge.Preferences.js | 122 + deluge/ui/web/js/Deluge.Sidebar.js | 202 ++ deluge/ui/web/js/Deluge.Statusbar.js | 147 ++ deluge/ui/web/js/Deluge.Toolbar.js | 195 ++ ...{deluge-torrents.js => Deluge.Torrents.js} | 34 +- .../ui/web/js/{deluge-ui.js => Deluge.UI.js} | 50 +- deluge/ui/web/js/Deluge.js | 103 + deluge/ui/web/js/deluge-bars.js | 501 ---- deluge/ui/web/js/deluge-connections.js | 322 --- deluge/ui/web/js/deluge-preferences.js | 398 --- deluge/ui/web/js/deluge-yc.js | 2 +- deluge/ui/web/js/deluge.js | 202 -- deluge/ui/web/js/ext-base-debug.js | 2189 +++++++++++++++++ deluge/ui/web/js/ext-base.js | 1 + deluge/ui/web/js/ext-mootools-adapter.js | 16 - deluge/ui/web/js/mootools-1.2.1-core-yc.js | 349 --- deluge/ui/web/js/mootools-bridge-debug.js | 364 --- deluge/ui/web/js/mootools-bridge.js | 1 - deluge/ui/web/js/rpc.js | 2 +- 41 files changed, 4060 insertions(+), 2406 deletions(-) rename deluge/ui/web/js/{deluge-add.js => Deluge.Add.js} (100%) create mode 100644 deluge/ui/web/js/Deluge.ConnectionManager.js create mode 100644 deluge/ui/web/js/Deluge.Details.Details.js create mode 100644 deluge/ui/web/js/Deluge.Details.Files.js create mode 100644 deluge/ui/web/js/Deluge.Details.Options.js create mode 100644 deluge/ui/web/js/Deluge.Details.Peers.js create mode 100644 deluge/ui/web/js/Deluge.Details.Status.js rename deluge/ui/web/js/{deluge-details.js => Deluge.Details.js} (71%) create mode 100644 deluge/ui/web/js/Deluge.Formatters.js create mode 100644 deluge/ui/web/js/Deluge.Keys.js rename deluge/ui/web/js/{deluge-login.js => Deluge.Login.js} (75%) rename deluge/ui/web/js/{deluge-menus.js => Deluge.Menus.js} (100%) create mode 100644 deluge/ui/web/js/Deluge.Preferences.Bandwidth.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Daemon.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Downloads.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Interface.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Network.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Notification.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Other.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Plugins.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Proxy.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.Queue.js create mode 100644 deluge/ui/web/js/Deluge.Preferences.js create mode 100644 deluge/ui/web/js/Deluge.Sidebar.js create mode 100644 deluge/ui/web/js/Deluge.Statusbar.js create mode 100644 deluge/ui/web/js/Deluge.Toolbar.js rename deluge/ui/web/js/{deluge-torrents.js => Deluge.Torrents.js} (87%) rename deluge/ui/web/js/{deluge-ui.js => Deluge.UI.js} (75%) create mode 100644 deluge/ui/web/js/Deluge.js delete mode 100644 deluge/ui/web/js/deluge-bars.js delete mode 100644 deluge/ui/web/js/deluge-connections.js delete mode 100644 deluge/ui/web/js/deluge-preferences.js delete mode 100644 deluge/ui/web/js/deluge.js create mode 100644 deluge/ui/web/js/ext-base-debug.js create mode 100644 deluge/ui/web/js/ext-base.js delete mode 100644 deluge/ui/web/js/ext-mootools-adapter.js delete mode 100644 deluge/ui/web/js/mootools-1.2.1-core-yc.js delete mode 100644 deluge/ui/web/js/mootools-bridge-debug.js delete mode 100644 deluge/ui/web/js/mootools-bridge.js diff --git a/deluge/ui/web/js/deluge-add.js b/deluge/ui/web/js/Deluge.Add.js similarity index 100% rename from deluge/ui/web/js/deluge-add.js rename to deluge/ui/web/js/Deluge.Add.js diff --git a/deluge/ui/web/js/Deluge.ConnectionManager.js b/deluge/ui/web/js/Deluge.ConnectionManager.js new file mode 100644 index 000000000..322ef6a32 --- /dev/null +++ b/deluge/ui/web/js/Deluge.ConnectionManager.js @@ -0,0 +1,361 @@ +/* +Script: deluge-connections.js + Contains all objects and functions related to the connection manager. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +(function() { + var hostRenderer = function(value, p, r) { + return value + ':' + r.data['port'] + } + + Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, { + + layout: 'fit', + width: 300, + height: 220, + bodyStyle: 'padding: 10px 5px;', + buttonAlign: 'right', + closeAction: 'hide', + closable: true, + plain: true, + title: _('Connection Manager'), + iconCls: 'x-deluge-connect-window-icon', + + initComponent: function() { + Ext.deluge.ConnectionManager.superclass.initComponent.call(this); + this.on({ + 'hide': this.onHide, + 'show': this.onShow + }); + Deluge.Events.on('login', this.onLogin, this); + Deluge.Events.on('logout', this.onLogout, this); + + this.addButton(_('Close'), this.onClose, this); + this.addButton(_('Connect'), this.onConnect, this); + + this.grid = this.add({ + xtype: 'grid', + store: new Ext.data.SimpleStore({ + fields: [ + {name: 'status', mapping: 3}, + {name: 'host', mapping: 1}, + {name: 'port', mapping: 2}, + {name: 'version', mapping: 4} + ], + id: 0 + }), + columns: [{ + header: _('Status'), + width: 65, + sortable: true, + renderer: fplain, + dataIndex: 'status' + }, { + id:'host', + header: _('Host'), + width: 150, + sortable: true, + renderer: hostRenderer, + dataIndex: 'host' + }, { + header: _('Version'), + width: 75, + sortable: true, + renderer: fplain, + dataIndex: 'version' + }], + stripeRows: true, + selModel: new Ext.grid.RowSelectionModel({ + singleSelect: true, + listeners: { + 'rowselect': {fn: this.onSelect, scope: this} + } + }), + autoExpandColumn: 'host', + deferredRender:false, + autoScroll:true, + margins: '0 0 0 0', + bbar: new Ext.Toolbar({ + items: [ + { + id: 'add', + cls: 'x-btn-text-icon', + text: _('Add'), + icon: '/icons/add.png', + handler: this.onAdd, + scope: this + }, { + id: 'remove', + cls: 'x-btn-text-icon', + text: _('Remove'), + icon: '/icons/remove.png', + handler: this.onRemove, + scope: this + }, '->', { + id: 'stop', + cls: 'x-btn-text-icon', + text: _('Stop Daemon'), + icon: '/icons/error.png', + handler: this.onStop, + scope: this + } + ] + }) + }); + }, + + disconnect: function() { + Deluge.Events.fire('disconnect'); + }, + + runCheck: function(callback, scope) { + callback = callback || this.onGetHosts; + scope = scope || this; + Deluge.Client.web.get_hosts({ + success: callback, + scope: scope + }); + }, + + onAdd: function(button, e) { + //Deluge.Connections.Add.show(); + }, + + onAddHost: function() { + var form = Deluge.Connections.Add.items.first(); + var host = form.items.get('host').getValue(); + var port = form.items.get('port').getValue(); + var username = form.items.get('username').getValue(); + var password = form.items.get('_password').getValue(); + + Deluge.Client.web.add_host(host, port, username, password, { + onSuccess: function(result) { + if (!result[0]) { + Ext.MessageBox.show({ + title: _('Error'), + msg: "Unable to add host: " + result[1], + buttons: Ext.MessageBox.OK, + modal: false, + icon: Ext.MessageBox.ERROR, + iconCls: 'x-deluge-icon-error' + }); + } else { + this.runCheck(); + } + Deluge.Connections.Add.hide(); + } + }); + }, + + onAddWindowHide: function() { + // Tidy up the form to ensure all the values are default. + var form = Deluge.Connections.Add.items.first(); + form.items.get('host').reset(); + form.items.get('port').reset(); + form.items.get('username').reset(); + form.items.get('_password').reset(); + }, + + onClose: function(e) { + if (this.running) window.clearInterval(this.running); + this.hide(); + }, + + onConnect: function(e) { + var selected = this.grid.getSelectionModel().getSelected(); + if (!selected) return; + + if (selected.get('status') == _('Connected')) { + Deluge.Client.web.disconnect({ + success: function(result) { + this.runCheck(); + Deluge.Events.fire('disconnect'); + }, + scope: this + }); + } else { + var id = selected.id; + Deluge.Client.web.connect(id, { + success: function(methods) { + Deluge.Client.reloadMethods(); + Deluge.Events.fire('connect'); + } + }); + if (this.running) window.clearInterval(this.running); + this.hide(); + } + }, + + onGetHosts: function(hosts) { + this.grid.getStore().loadData(hosts); + var selection = this.grid.getSelectionModel(); + selection.selectRow(this.selectedRow); + }, + + onLogin: function() { + Deluge.Client.web.connected({ + success: function(connected) { + if (connected) { + Deluge.Events.fire('connect'); + } else { + this.show(); + } + }, + scope: this + }); + }, + + onLogout: function() { + this.disconnect(); + this.hide(); + }, + + onRemove: function(button) { + var connection = Deluge.Connections.Grid.getSelectionModel().getSelected(); + Deluge.Client.web.remove_host(connection.id, { + onSuccess: function(result) { + if (!result) { + Ext.MessageBox.show({ + title: _('Error'), + msg: result[1], + buttons: Ext.MessageBox.OK, + modal: false, + icon: Ext.MessageBox.ERROR, + iconCls: 'x-deluge-icon-error' + }); + } else { + Deluge.Connections.Grid.store.remove(connection); + } + } + }); + }, + + onSelect: function(selModel, rowIndex, record) { + this.selectedRow = rowIndex; + var button = this.buttons[1]; + if (record.get('status') == _('Connected')) { + button.setText(_('Disconnect')); + } else { + button.setText(_('Connect')); + } + }, + + onShow: function() { + this.runCheck(); + this.running = window.setInterval(this.runCheck, 2000); + }, + + onStop: function(button, e) { + var connection = this.grid.getSelectionModel().getSelected(); + Deluge.Client.web.stop_daemon(connection.id, { + success: function(result) { + if (!result[0]) { + Ext.MessageBox.show({ + title: _('Error'), + msg: result[1], + buttons: Ext.MessageBox.OK, + modal: false, + icon: Ext.MessageBox.ERROR, + iconCls: 'x-deluge-icon-error' + }); + } + } + }); + } + }); + Deluge.ConnectionManager = new Ext.deluge.ConnectionManager(); +})(); + +/*Deluge.Connections = { + + loginShow: function() { + }, + + , + + +} + +Deluge.Connections.Store ; + + + +Deluge.Connections.Grid = new Ext.grid.GridPanel(); + +Deluge.Connections.Add = new Ext.Window({ + 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', + items: [new Ext.form.FormPanel({ + defaultType: 'textfield', + id: 'connectionAddForm', + baseCls: 'x-plain', + labelWidth: 55, + items: [{ + fieldLabel: _('Host'), + id: 'host', + name: 'host', + anchor: '100%', + listeners: {} + },{ + fieldLabel: _('Port'), + id: 'port', + xtype: 'uxspinner', + ctCls: 'x-form-uxspinner', + name: 'port', + strategy: Ext.ux.form.Spinner.NumberStrategy(), + value: '58846', + anchor: '50%', + listeners: {} + }, { + fieldLabel: _('Username'), + id: 'username', + name: 'username', + anchor: '100%', + listeners: {} + },{ + fieldLabel: _('Password'), + anchor: '100%', + id: '_password', + name: '_password', + inputType: 'password' + }] + })], + buttons: [{ + text: _('Close'), + handler: function() { + Deluge.Connections.Add.hide(); + } + },{ + text: _('Add'), + handler: Deluge.Connections.onAddHost + }], + listeners: { + 'hide': Deluge.Connections.onAddWindowHide + } +});*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Details.Details.js b/deluge/ui/web/js/Deluge.Details.Details.js new file mode 100644 index 000000000..0c450c5af --- /dev/null +++ b/deluge/ui/web/js/Deluge.Details.Details.js @@ -0,0 +1,79 @@ +/* +Script: Deluge.Details.Details.js + The details tab displayed in the details panel. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +(function() { + Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, { + title: _('Details'), + cls: 'x-deluge-status', + + onRender: function(ct, position) { + Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position); + this.load({ + url: '/render/tab_details.html', + text: _('Loading') + '...' + }); + this.getUpdater().on('update', this.onPanelUpdate, this); + }, + + clear: function() { + if (!this.fields) return; + for (var k in this.fields) { + this.fields[k].innerHTML = ''; + } + }, + + update: function(torrentId) { + if (!this.fields) this.getFields(); + Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, { + success: this.onRequestComplete, + scope: this, + torrentId: torrentId + }); + }, + + onPanelUpdate: function(el, response) { + this.fields = {}; + Ext.each(Ext.query('dd', this.body.dom), function(field) { + this.fields[field.className] = field; + }, this); + }, + + onRequestComplete: function(torrent, options) { + var data = { + torrent_name: torrent.name, + hash: options.torrentId, + path: torrent.save_path, + size: fsize(torrent.total_size), + files: torrent.num_files, + status: torrent.tracker_status, + tracker: torrent.tracker, + comment: torrent.comment + }; + + for (var field in this.fields) { + this.fields[field].innerHTML = data[field]; + } + } + }); + Deluge.Details.add(new Ext.deluge.details.DetailsTab()); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Details.Files.js b/deluge/ui/web/js/Deluge.Details.Files.js new file mode 100644 index 000000000..e69de29bb diff --git a/deluge/ui/web/js/Deluge.Details.Options.js b/deluge/ui/web/js/Deluge.Details.Options.js new file mode 100644 index 000000000..e69de29bb diff --git a/deluge/ui/web/js/Deluge.Details.Peers.js b/deluge/ui/web/js/Deluge.Details.Peers.js new file mode 100644 index 000000000..e69de29bb diff --git a/deluge/ui/web/js/Deluge.Details.Status.js b/deluge/ui/web/js/Deluge.Details.Status.js new file mode 100644 index 000000000..0fec89954 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Details.Status.js @@ -0,0 +1,109 @@ +/* +Script: Deluge.Details.Status.js + The status tab displayed in the details panel. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +(function() { + Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, { + title: _('Status'), + + onRender: function(ct, position) { + Ext.deluge.details.StatusTab.superclass.onRender.call(this, ct, position); + + this.progressBar = this.add({ + xtype: 'fullprogressbar', + cls: 'x-deluge-status-progressbar' + }); + + this.status = this.add({ + cls: 'x-deluge-status', + border: false, + listeners: { + 'render': { + fn: function(panel) { + panel.load({ + url: '/render/tab_status.html', + text: _('Loading') + '...' + }); + panel.getUpdater().on('update', this.onPanelUpdate, this); + }, + scope: this + } + } + }); + }, + + clear: function() { + if (!this.fields) return; + this.progressBar.updateProgress(0, ' '); + for (var k in this.fields) { + this.fields[k].innerHTML = ''; + } + }, + + update: function(torrentId) { + if (!this.fields) this.getFields(); + Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, { + success: this.onRequestComplete, + scope: this + }); + }, + + onPanelUpdate: function(el, response) { + this.fields = {}; + Ext.each(Ext.query('dd', this.status.body.dom), function(field) { + this.fields[field.className] = field; + }, this); + }, + + onRequestComplete: function(status) { + seeders = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds + peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers + var data = { + downloaded: fsize(status.total_done) + ' (' + fsize(status.total_payload_download) + ')', + uploaded: fsize(status.total_uploaded) + ' (' + fsize(status.total_payload_upload) + ')', + share: status.ratio.toFixed(3), + announce: ftime(status.next_announce), + tracker_status: status.tracker_status, + downspeed: fspeed(status.download_payload_rate), + upspeed: fspeed(status.upload_payload_rate), + eta: ftime(status.eta), + pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')', + seeders: seeders, + peers: peers, + avail: status.distributed_copies.toFixed(3), + active_time: ftime(status.active_time), + seeding_time: ftime(status.seeding_time), + seed_rank: status.seed_rank, + auto_managed: 'False', + time_added: fdate(status.time_added) + } + if (status.is_auto_managed) {data.auto_managed = 'True'} + + for (var field in this.fields) { + this.fields[field].innerHTML = data[field]; + } + var text = status.state + ' ' + status.progress.toFixed(2) + '%'; + this.progressBar.updateProgress(status.progress, text); + } + }); + Deluge.Details.add(new Ext.deluge.details.StatusTab()); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-details.js b/deluge/ui/web/js/Deluge.Details.js similarity index 71% rename from deluge/ui/web/js/deluge-details.js rename to deluge/ui/web/js/Deluge.Details.js index 5065d7ed3..538383bae 100644 --- a/deluge/ui/web/js/deluge-details.js +++ b/deluge/ui/web/js/Deluge.Details.js @@ -22,184 +22,63 @@ Copyright: Boston, MA 02110-1301, USA. */ -Deluge.Details = { - clear: function() { - this.Panel.items.each(function(item) { - if (item.clear) item.clear(); - }); - }, - - update: function(tab) { - var torrent = Deluge.Torrents.getSelected(); - if (!torrent) return; +(function() { + Ext.namespace('Ext.deluge.details'); + Ext.deluge.details.TabPanel = Ext.extend(Ext.TabPanel, { - tab = tab || this.Panel.getActiveTab(); - if (tab.update) { - tab.update(torrent.id); - } - }, - - onRender: function(panel) { - Deluge.Torrents.on('rowclick', this.onTorrentsClick.bindWithEvent(this)); + constructor: function(config) { + config = Ext.apply({ + region: 'south', + split: true, + height: 220, + minSize: 100, + collapsible: true, + margins: '0 5 5 5', + activeTab: 0 + }, config); + Ext.deluge.details.TabPanel.superclass.constructor.call(this, config); + }, - var selModel = Deluge.Torrents.getSelectionModel(); - selModel.on('selectionchange', function(selModel) { - if (!selModel.hasSelection()) { - this.clear.delay(10, this); - } - }.bindWithEvent(this)); - Deluge.Events.on('disconnect', this.clear.bind(this)); - }, - - onTabChange: function(panel, tab) { - this.update(tab); - }, - - onTorrentsClick: function(grid, rowIndex, e) { - this.update(); - } -} - -Deluge.Details.Status = { - onRender: function(panel) { - this.panel = panel; - this.progressBar = new Ext.ux.FullProgressBar({ - id: 'pbar-status', - cls: 'deluge-status-progressbar' - }); - this.panel.add(this.progressBar); - this.panel.add({ - id: 'status-details', - cls: 'deluge-status', - border: false, - listeners: {'render': Deluge.Details.Status.onStatusRender} - }); - this.panel.update = this.update.bind(this); - this.panel.clear = this.clear.bind(this); - }, - - onStatusRender: function(panel) { - this.status = panel; - this.status.load({ - url: '/render/tab_status.html', - text: _('Loading') + '...' - }); - }, - - onRequestComplete: function(status) { - seeders = status.total_seeds > -1 ? status.num_seeds + ' (' + status.total_seeds + ')' : status.num_seeds - peers = status.total_peers > -1 ? status.num_peers + ' (' + status.total_peers + ')' : status.num_peers - var data = { - downloaded: fsize(status.total_done) + ' (' + fsize(status.total_payload_download) + ')', - uploaded: fsize(status.total_uploaded) + ' (' + fsize(status.total_payload_upload) + ')', - share: status.ratio.toFixed(3), - announce: ftime(status.next_announce), - tracker_status: status.tracker_status, - downspeed: fspeed(status.download_payload_rate), - upspeed: fspeed(status.upload_payload_rate), - eta: ftime(status.eta), - pieces: status.num_pieces + ' (' + fsize(status.piece_length) + ')', - seeders: seeders, - peers: peers, - avail: status.distributed_copies.toFixed(3), - active_time: ftime(status.active_time), - seeding_time: ftime(status.seeding_time), - seed_rank: status.seed_rank, - auto_managed: 'False', - time_added: fdate(status.time_added) + clear: function() { + this.items.each(function(panel) { + if (panel.clear) panel.clear(); + }); + }, + + update: function(tab) { + var torrent = Deluge.Torrents.getSelected(); + if (!torrent) return; + + tab = tab || this.getActiveTab(); + if (tab.update) tab.update(torrent.id); + }, + + /* Event Handlers */ + + // 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.Torrents.getSelectionModel().on('selectionchange', function(selModel) { + if (!selModel.hasSelection()) this.clear(); + }, this); + }, + + onTabChange: function(panel, tab) { + this.update(tab); + }, + + onTorrentsClick: function(grid, rowIndex, e) { + this.update(); } - if (status.is_auto_managed) {data.auto_managed = 'True'} - this.fields.each(function(value, key) { - value.set('text', data[key]); - }, this); - var text = status.state + ' ' + status.progress.toFixed(2) + '%'; - this.progressBar.updateProgress(status.progress, text); - }, - - getFields: function() { - var panel = this.panel.items.get('status-details'); - this.fields = new Hash(); - $(panel.body.dom).getElements('dd').each(function(item) { - this.fields[item.getProperty('class')] = item; - }, this); - }, - - update: function(torrentId) { - if (!this.fields) this.getFields(); - Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, { - onSuccess: this.onRequestComplete.bind(this) - }); - }, - - clear: function() { - if (!this.fields) return; - this.progressBar.updateProgress(0, ' '); - this.fields.each(function(value, key) { - value.set('text', ''); - }, this); - } -} - -Deluge.Details.Details = { - onRender: function(panel) { - this.panel = panel; - panel.load({ - url: '/render/tab_details.html', - text: _('Loading') + '...', - callback: this.onLoaded.bindWithEvent(this) - }); - this.doUpdate = false; - this.panel.update = this.update.bind(this); - this.panel.clear = this.clear.bind(this); - }, - - onLoaded: function() { - this.getFields(); - this.doUpdate = true; - if (Deluge.Details.Panel.getActiveTab() == this.panel) { - Deluge.Details.update(this.panel); - } - }, - - onRequestComplete: function(torrent, torrentId) { - var data = { - torrent_name: torrent.name, - hash: torrentId, - path: torrent.save_path, - size: fsize(torrent.total_size), - files: torrent.num_files, - status: torrent.tracker_status, - tracker: torrent.tracker, - comment: torrent.comment - }; - this.fields.each(function(value, key) { - value.set('text', data[key]); - }, this); - }, - - getFields: function() { - this.fields = new Hash(); - $(this.panel.body.dom.firstChild).getElements('dd').each(function(item) { - this.fields[item.getProperty('class')] = item; - }, this); - }, - - update: function(torrentId) { - if (!this.doUpdate) return; - if (!this.fields) this.getFields(); - Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, { - onSuccess: this.onRequestComplete.bindWithEvent(this, torrentId) - }); - }, - - clear: function() { - if (!this.fields) return; - this.fields.each(function(value, key) { - value.set('text', ''); - }, this); - } -} + }); + Deluge.Details = new Ext.deluge.details.TabPanel(); +})(); +/* Deluge.Details.Files = { onRender: function(panel) { this.panel = panel; @@ -440,23 +319,8 @@ Deluge.Details.Peers.Store = new Ext.data.SimpleStore({ }); Deluge.Details.Panel = new Ext.TabPanel({ - region: 'south', - split: true, - height: 220, - minSize: 100, - collapsible: true, - margins: '0 5 5 5', - activeTab: 0, + , items: [{ - id: 'status', - title: _('Status'), - listeners: { - 'render': { - fn: Deluge.Details.Status.onRender, - scope: Deluge.Details.Status - } - } - }, { id: 'details', title: _('Details'), cls: 'deluge-status', @@ -708,4 +572,4 @@ Deluge.Details.Panel = new Ext.TabPanel({ 'render': {fn: Deluge.Details.onRender, scope: Deluge.Details}, 'tabchange': {fn: Deluge.Details.onTabChange, scope: Deluge.Details} } -}); \ No newline at end of file +});*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Formatters.js b/deluge/ui/web/js/Deluge.Formatters.js new file mode 100644 index 000000000..b7b74a18e --- /dev/null +++ b/deluge/ui/web/js/Deluge.Formatters.js @@ -0,0 +1,96 @@ +/* +Script: Deluge.Formatters.js + A collection of functions for string formatting values. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +Deluge.Formatters = { + date: function(timestamp) { + function zeroPad(num, count) { + var numZeropad = num + ''; + while (numZeropad.length < count) { + numZeropad = '0' + numZeropad; + } + return numZeropad; + } + timestamp = timestamp * 1000; + var date = new Date(timestamp); + return String.format('{0}/{1}/{2}', zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear()); + }, + size: function(bytes) { + bytes = bytes / 1024.0; + + if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; } + else { bytes = bytes / 1024; } + + if (bytes < 1024) { return bytes.toFixed(1) + ' MiB'; } + else { bytes = bytes / 1024; } + + return bytes.toFixed(1) + ' GiB' + }, + + speed: function(bits) { + return fsize(bits) + '/s' + }, + + timeRemaining: function(time) { + if (time == 0) { return '∞' } + if (time < 60) { return time + 's'; } + else { time = time / 60; } + + if (time < 60) { + var minutes = Math.floor(time) + var seconds = Math.round(60 * (time - minutes)) + if (seconds > 0) { + return minutes + 'm ' + seconds + 's'; + } else { + return minutes + 'm'; } + } + else { time = time / 60; } + + if (time < 24) { + var hours = Math.floor(time) + var minutes = Math.round(60 * (time - hours)) + if (minutes > 0) { + return hours + 'h ' + minutes + 'm'; + } else { + return hours + 'h'; + } + } + else { time = time / 24; } + + var days = Math.floor(time) + var hours = Math.round(24 * (time - days)) + if (hours > 0) { + return days + 'd ' + hours + 'h'; + } else { + return days + 'd'; + } + }, + + plain: function(value) { + return value; + } +} +var fsize = Deluge.Formatters.size; +var fspeed = Deluge.Formatters.speed; +var ftime = Deluge.Formatters.timeRemaining; +var fdate = Deluge.Formatters.date; +var fplain = Deluge.Formatters.plain; \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Keys.js b/deluge/ui/web/js/Deluge.Keys.js new file mode 100644 index 000000000..89de03444 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Keys.js @@ -0,0 +1,33 @@ +Deluge.Keys = { + Grid: [ + 'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds', + 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate', + 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', + 'is_auto_managed', 'time_added', 'tracker_host' + ], + Status: [ + 'total_done', 'total_payload_download', 'total_uploaded', + 'total_payload_upload', 'next_announce', 'tracker_status', 'num_pieces', + 'piece_length', 'is_auto_managed', 'active_time', 'seeding_time', + 'seed_rank' + ], + Files: [ + 'files', 'file_progress', 'file_priorities' + ], + Peers: [ + 'peers', 'seeds' + ], + Details: [ + 'name', 'save_path', 'total_size', 'num_files', 'tracker_status', + 'tracker', 'comment' + ], + Options: [ + 'max_download_speed', 'max_upload_speed', 'max_connections', + 'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio', + 'remove_at_ratio', 'private', 'prioritize_first_last' + ] +}; + +Ext.each(Deluge.Keys.Grid, function(key) { + Deluge.Keys.Status.push(key); +}); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-login.js b/deluge/ui/web/js/Deluge.Login.js similarity index 75% rename from deluge/ui/web/js/deluge-login.js rename to deluge/ui/web/js/Deluge.Login.js index b08eee199..69693d2ba 100644 --- a/deluge/ui/web/js/deluge-login.js +++ b/deluge/ui/web/js/Deluge.Login.js @@ -22,29 +22,28 @@ Copyright: */ (function(){ - var LoginWindow = function(config) { - Ext.apply(this, { - layout: 'fit', - width: 300, - height: 120, - bodyStyle: 'padding: 10px 5px;', - buttonAlign: 'center', - closeAction: 'hide', - closable: false, - modal: true, - plain: true, - resizable: false, - title: _('Login'), - iconCls: 'x-deluge-login-window-icon' - }); - Ext.apply(this, config); - LoginWindow.superclass.constructor.call(this); - }; - - Ext.extend(LoginWindow, Ext.Window, { + Ext.deluge.LoginWindow = Ext.extend(Ext.Window, { + constructor: function(config) { + config = Ext.apply({ + layout: 'fit', + width: 300, + height: 120, + bodyStyle: 'padding: 10px 5px;', + buttonAlign: 'center', + closeAction: 'hide', + closable: false, + modal: true, + plain: true, + resizable: false, + title: _('Login'), + iconCls: 'x-deluge-login-window-icon' + }, config); + Ext.deluge.LoginWindow.superclass.constructor.call(this, config); + }, + initComponent: function() { - LoginWindow.superclass.initComponent.call(); - Deluge.Events.on('logout', this.onLogout); + Ext.deluge.LoginWindow.superclass.initComponent.call(this); + Deluge.Events.on('logout', this.onLogout, this); this.on('show', this.onShow, this); this.addButton({ @@ -72,7 +71,7 @@ Copyright: } } }] - }); + }) }, onKey: function(field, e) { @@ -82,12 +81,11 @@ Copyright: onLogin: function() { var passwordField = this.loginForm.items.get('password'); Deluge.Client.web.login(passwordField.getValue(), { - onSuccess: function(result) { + success: function(result) { if (result == true) { + Deluge.Events.fire('login'); this.hide(); - Deluge.Connections.loginShow(); passwordField.setRawValue(''); - Deluge.Events.fire('login') } else { Ext.MessageBox.show({ title: _('Login Failed'), @@ -101,7 +99,8 @@ Copyright: iconCls: 'x-deluge-icon-warning' }); } - }.bindWithEvent(this) + }, + scope: this }); }, @@ -115,5 +114,5 @@ Copyright: } }); - Deluge.Login = new LoginWindow(); + Deluge.Login = new Ext.deluge.LoginWindow(); })(); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-menus.js b/deluge/ui/web/js/Deluge.Menus.js similarity index 100% rename from deluge/ui/web/js/deluge-menus.js rename to deluge/ui/web/js/Deluge.Menus.js diff --git a/deluge/ui/web/js/Deluge.Preferences.Bandwidth.js b/deluge/ui/web/js/Deluge.Preferences.Bandwidth.js new file mode 100644 index 000000000..5b0973560 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Bandwidth.js @@ -0,0 +1,95 @@ +Deluge.Preferences.addPage(_('Bandwidth'), { + border: false, + xtype: 'form', + layout: 'form', + labelWidth: 10, + items: [{ + xtype: 'fieldset', + border: false, + title: _('Global Bandwidth Usage'), + autoHeight: true, + labelWidth: 200, + style: 'margin-bottom: 0px; padding-bottom: 0px;', + defaultType: 'uxspinner', + items: [{ + name: 'max_connections', + fieldLabel: _('Maximum Connections'), + width: 60, + value: -1 + }, { + name: 'max_upload_slots', + fieldLabel: _('Maximum Upload Slots'), + width: 60, + value: -1 + }, { + name: 'max_download_speed', + fieldLabel: _('Maximum Download Speed (KiB/s)'), + width: 60, + value: -1 + }, { + name: 'max_upload_speed', + fieldLabel: _('Maximum Upload Speed (KiB/s)'), + width: 60, + value: -1 + }, { + name: 'max_half_open_connections', + fieldLabel: _('Maximum Half-Open Connections'), + width: 60, + value: -1 + }, { + name: 'max_connections_per_second', + fieldLabel: _('Maximum Connection Attempts per Second'), + width: 60, + value: -1 + }] + }, { + xtype: 'fieldset', + border: false, + title: '', + autoHeight: true, + style: 'padding-top: 0px; margin-top: 0px; margin-bottom: 0px;', + items: [{ + xtype: 'checkbox', + name: 'ignore_local', + fieldLabel: '', + labelSeparator: '', + boxLabel: _('Ignore limits on local network'), + value: -1 + }, { + xtype: 'checkbox', + name: 'limit_ip_overhead', + fieldLabel: '', + labelSeparator: '', + boxLabel: _('Rate limit IP overhead'), + value: -1 + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Per Torrent Bandwidth Usage'), + autoHeight: true, + labelWidth: 200, + defaultType: 'uxspinner', + items: [{ + name: 'max_connections_per_torrent', + fieldLabel: _('Maximum Connections'), + width: 60, + value: -1 + }, { + name: 'max_upload_slots_per_torrent', + fieldLabel: _('Maximum Upload Slots'), + width: 60, + value: -1 + }, { + name: 'max_download_speed_per_torrent', + fieldLabel: _('Maximum Download Speed (KiB/s)'), + width: 60, + value: -1 + }, { + name: 'max_upload_speed_per_torrent', + fieldLabel: _('Maximum Upload Speed (KiB/s)'), + width: 60, + value: -1 + }] + }] +}); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Daemon.js b/deluge/ui/web/js/Deluge.Preferences.Daemon.js new file mode 100644 index 000000000..15ae8d6bd --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Daemon.js @@ -0,0 +1,43 @@ +Deluge.Preferences.addPage(_('Daemon'), { + border: false, + xtype: 'form', + layout: 'form', + items: [{ + xtype: 'fieldset', + border: false, + title: _('Port'), + autoHeight: true, + defaultType: 'uxspinner', + items: [{ + fieldLabel: _('Daemon port'), + id: 'daemon_port' + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Connections'), + autoHeight: true, + labelWidth: 1, + defaultType: 'checkbox', + items: [{ + fieldLabel: '', + labelSeparator: '', + boxLabel: _('Allow Remote Connections'), + id: 'allow_remote' + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Other'), + autoHeight: true, + labelWidth: 1, + defaultType: 'checkbox', + items: [{ + fieldLabel: '', + labelSeparator: '', + height: 40, + boxLabel: _('Periodically check the website for new releases'), + id: 'new_releases' + }] + }] +}); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Downloads.js b/deluge/ui/web/js/Deluge.Preferences.Downloads.js new file mode 100644 index 000000000..141853c20 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Downloads.js @@ -0,0 +1,58 @@ +Deluge.Preferences.addPage(_('Downloads'), { + border: false, + xtype: 'form', + layout: 'form', + items: [{ + xtype: 'fieldset', + border: false, + title: _('Folders'), + labelWidth: 140, + defaultType: 'textfield', + autoHeight: true, + items: [{ + name: 'download_location', + fieldLabel: _('Download to'), + width: 125 + }, { + name: 'move_completed', + fieldLabel: _('Move completed to'), + width: 125 + }, { + name: 'copy_torrent_files', + fieldLabel: _('Copy of .torrent files to'), + width: 125 + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Allocation'), + autoHeight: true, + labelWidth: 1, + defaultType: 'radio', + items: [{ + name: 'compact_allocation', + labelSeparator: '', + boxLabel: _('Compact') + }, { + name: 'compact_allocation', + labelSeparator: '', + boxLabel: _('Full') + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Options'), + autoHeight: true, + labelWidth: 1, + defaultType: 'checkbox', + items: [{ + name: 'prioritize_first_last', + labelSeparator: '', + boxLabel: _('Prioritize first and last pieces of torrent') + }, { + name: 'add_paused', + labelSeparator: '', + boxLabel: _('Add torrents in Paused state') + }] + }] +}); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Interface.js b/deluge/ui/web/js/Deluge.Preferences.Interface.js new file mode 100644 index 000000000..1d93b5312 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Interface.js @@ -0,0 +1,47 @@ +Deluge.Preferences.addPage(_('Interface'), { + border: false, + xtype: 'form', + layout: 'form', + items: [{ + xtype: 'fieldset', + border: false, + title: _('Window'), + autoHeight: true, + labelWidth: 1, + items: [{ + xtype: 'checkbox', + fieldLabel: '', + labelSeparator: '', + boxLabel: _('Show session speed in titlebar'), + id: 'show_session_speed' + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Sidebar'), + autoHeight: true, + labelWidth: 1, + items: [{ + xtype: 'checkbox', + fieldLabel: '', + labelSeparator: '', + boxLabel: _('Hide filters with zero torrents'), + id: 'hide_sidebar_zero' + }] + }, { + xtype: 'fieldset', + border: false, + title: _('Password'), + autoHeight: true, + defaultType: 'textfield', + items: [{ + fieldLabel: 'New Password', + inputType: 'password', + id: 'new_password' + }, { + inputType: 'password', + fieldLabel: 'Confirm Password', + id: 'confirm_password' + }] + }] +}); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Network.js b/deluge/ui/web/js/Deluge.Preferences.Network.js new file mode 100644 index 000000000..807b8a930 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Network.js @@ -0,0 +1,7 @@ +/*Deluge.Preferences.addPage(_('Network'), { + border: false, + xtype: 'form', + layout: 'form', + items: [] +}); +*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Notification.js b/deluge/ui/web/js/Deluge.Preferences.Notification.js new file mode 100644 index 000000000..2024d8dae --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Notification.js @@ -0,0 +1,7 @@ +/*Deluge.Preferences.addPage(_('Notification'), { + border: false, + xtype: 'form', + layout: 'form', + items: [] +}); +*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Other.js b/deluge/ui/web/js/Deluge.Preferences.Other.js new file mode 100644 index 000000000..ab4074dce --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Other.js @@ -0,0 +1,7 @@ +/*Deluge.Preferences.addPage(_('Other'), { + border: false, + xtype: 'form', + layout: 'form', + items: [] +}); +*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Plugins.js b/deluge/ui/web/js/Deluge.Preferences.Plugins.js new file mode 100644 index 000000000..a745eb4af --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Plugins.js @@ -0,0 +1,7 @@ +/*Deluge.Preferences.addPage(_('Plugins'), { + border: false, + xtype: 'form', + layout: 'form', + items: [] +}); +*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Proxy.js b/deluge/ui/web/js/Deluge.Preferences.Proxy.js new file mode 100644 index 000000000..ea9b78aac --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Proxy.js @@ -0,0 +1,8 @@ +/* +Deluge.Preferences.addPage(_('Proxy'), { + border: false, + xtype: 'form', + layout: 'form', + items: [] +}); +*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.Queue.js b/deluge/ui/web/js/Deluge.Preferences.Queue.js new file mode 100644 index 000000000..5b7df2cd2 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.Queue.js @@ -0,0 +1,8 @@ +/* +Deluge.Preferences.addPage(_('Queue'), { + border: false, + xtype: 'form', + layout: 'form', + items: [] +}); +*/ \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Preferences.js b/deluge/ui/web/js/Deluge.Preferences.js new file mode 100644 index 000000000..66263b6ec --- /dev/null +++ b/deluge/ui/web/js/Deluge.Preferences.js @@ -0,0 +1,122 @@ +/* +Script: deluge-preferences.js + Contains the preferences window. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +(function() { + Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, { + 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: true, + title: _('Preferences'), + + buttons: [{ + text: _('Close'), + handler: this.onCloseButtonClick, + scope: this + },{ + text: _('Apply') + },{ + text: _('Ok') + }], + + currentPage: false, + items: [{ + xtype: 'grid', + region: 'west', + title: _('Categories'), + store: new Ext.data.SimpleStore({ + fields: [{name: 'name', mapping: 0}] + }), + columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}], + sm: new Ext.grid.RowSelectionModel({ + singleSelect: true, + listeners: {'rowselect': {fn: this.onPageSelect, scope: this}} + }), + hideHeaders: true, + autoExpandColumn: 'name', + deferredRender: false, + autoScroll: true, + margins: '5 0 5 5', + cmargins: '5 0 5 5', + width: 120, + collapsible: true + }, { + region: 'center', + title: ' ', + layout: 'fit', + height: 400, + margins: '5 5 5 5', + cmargins: '5 5 5 5' + }] + }, 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.items.get(1); + this.pages = {}; + this.on('show', this.onShow, this); + }, + + onCloseButtonClick: function() { + this.hide(); + }, + + addPage: function(name, page) { + var store = this.categoriesGrid.getStore(); + store.loadData([[name]], true); + page['bodyStyle'] = 'margin: 5px'; + this.pages[name] = this.configPanel.add(page); + this.pages[name].hide(); + }, + + onPageSelect: function(selModel, rowIndex, r) { + if (this.currentPage) { + this.currentPage.hide(); + } + var name = r.get('name'); + + this.pages[name].show(); + this.configPanel.setTitle(name); + this.currentPage = this.pages[name]; + this.configPanel.doLayout(); + }, + + onShow: function() { + if (!this.categoriesGrid.getSelectionModel().hasSelection()) { + this.categoriesGrid.getSelectionModel().selectFirstRow(); + } + } + }); + + Deluge.Preferences = new Ext.deluge.PreferencesWindow(); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Sidebar.js b/deluge/ui/web/js/Deluge.Sidebar.js new file mode 100644 index 000000000..135a3b333 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Sidebar.js @@ -0,0 +1,202 @@ +/* +Script: deluge-bars.js + Contains all objects and functions related to the statusbar, toolbar and + sidebar. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +// These are just so gen_gettext.js will pick up the strings +// _('State') +// _('Tracker Host') + +(function() { + // Renderer for the items in the filter grids. + function filterRenderer(value, p, r) { + var lname = value.toLowerCase().replace('.', '_'); + + var image = ''; + if (r.store.id == 'tracker_host') { + if (value != 'Error') { + image = String.format('url(/tracker/{0})', value); + } else { + lname = null; + } + } + if (image) { + return String.format('
{0} ({1})
', value, r.data['count'], image); + } else if (lname) { + return String.format('
{0} ({1})
', value, r.data['count'], lname); + } else { + return String.format('
{0} ({1})
', value, r.data['count']); + } + } + + Ext.deluge.Sidebar = Ext.extend(Ext.Panel, { + + // private + panels: {}, + + // private + selected: null, + + constructor: function(config) { + config = 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' + }, config); + Ext.deluge.Sidebar.superclass.constructor.call(this, config); + }, + + // private + initComponent: function() { + Ext.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, + fields: [ + {name: 'filter'}, + {name: 'count'} + ] + }); + + var title = filter.replace('_', ' '); + var parts = title.split(' '); + title = ''; + Ext.each(parts, function(part) { + firstLetter = part.substring(0, 1); + firstLetter = firstLetter.toUpperCase(); + part = firstLetter + part.substring(1); + title += part + ' '; + }); + + var panel = new Ext.grid.GridPanel({ + id: filter + '-panel', + store: store, + title: _(title), + columns: [ + {id: 'filter', sortable: false, renderer: filterRenderer, 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 + }); + store.loadData(states); + this.add(panel); + + this.doLayout(); + this.panels[filter] = panel; + + if (!this.selected) { + panel.getSelectionModel().selectFirstRow(); + this.selected = { + row: 0, + filter: states[0][0], + panel: panel + } + } + }, + + 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; + return filters; + }, + + // private + onDisconnect: function() { + Ext.each(Ext.getKeys(this.panels), function(filter) { + this.remove(filter + '-panel'); + }, this); + this.panels.empty(); + this.selected = null; + }, + + 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(); + }, + + update: function(filters) { + for (var filter in filters) { + var states = filters[filter]; + if (Ext.getKeys(this.panels).indexOf(filter) > -1) { + this.updateFilter(filter, states); + } else { + this.createFilter(filter, states); + } + } + + // Perform a cleanup of fitlers that aren't enabled any more + Ext.each(Ext.getKeys(this.panels), function(filter) { + if (Ext.getKeys(filters).indexOf(filter) == -1) { + // We need to remove the panel + } + }); + }, + + updateFilter: function(filter, states) { + this.panels[filter].store.loadData(states); + if (this.selected && this.selected.panel == this.panels[filter]) { + this.panels[filter].getSelectionModel().selectRow(this.selected.row); + } + } + + }); + Deluge.Sidebar = new Ext.deluge.Sidebar(); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Statusbar.js b/deluge/ui/web/js/Deluge.Statusbar.js new file mode 100644 index 000000000..ea9066e39 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Statusbar.js @@ -0,0 +1,147 @@ +(function() { + Ext.deluge.Statusbar = Ext.extend(Ext.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); + }, + + 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: '200 (200)', + cls: 'x-btn-text-icon', + iconCls: 'x-deluge-connections', + menu: Deluge.Menus.Connections + }, '-', { + id: 'statusbar-downspeed', + text: '9.8KiB/s (30 KiB/s)', + cls: 'x-btn-text-icon', + iconCls: 'x-deluge-downloading', + menu: Deluge.Menus.Download + }, '-', { + id: 'statusbar-upspeed', + text: '9.8KiB/s (30 KiB/s)', + cls: 'x-btn-text-icon', + iconCls: 'x-deluge-seeding', + menu: Deluge.Menus.Upload + }, '-', { + id: 'statusbar-traffic', + text: '1.53/2,65 KiB/s', + cls: 'x-btn-text-icon', + iconCls: 'x-deluge-traffic' + }, '-', { + id: 'statusbar-dht', + text: '161', + cls: 'x-btn-text-icon', + iconCls: 'x-deluge-dht' + }); + this.created = true; + }, + + onConnect: function() { + this.setStatus({ + iconCls: 'x-connected', + text: '' + }); + if (!this.created) this.createButtons(); + else { + this.items.each(function(item) { + item.show(); + item.enable(); + }); + } + }, + + onDisconnect: function() { + this.clearStatus({useDefaults:true}); + this.items.each(function(item) { + item.hide(); + item.disable(); + }); + }, + + update: function(stats) { + function addSpeed(val) {return val + ' KiB/s'} + + var updateStat = function(name, config) { + var item = this.items.get('statusbar-' + name); + if (config.limit.value == -1) { + var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value; + } else { + 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 str = String.format(config.format, value, limit); + } + item.setText(str); + }.bind(this); + + updateStat('connections', { + value: {value: stats.num_connections}, + limit: {value: stats.max_num_connections}, + format: '{0} ({1})' + }); + + updateStat('downspeed', { + value: { + value: stats.download_rate, + formatter: Deluge.Formatters.speed + }, + limit: { + value: stats.max_download, + formatter: addSpeed + }, + format: '{0} ({1})' + }); + + updateStat('upspeed', { + value: { + value: stats.upload_rate, + formatter: Deluge.Formatters.speed + }, + limit: { + value: stats.max_upload, + formatter: addSpeed + }, + format: '{0} ({1})' + }); + + updateStat('traffic', { + value: { + value: stats.payload_download_rate, + formatter: Deluge.Formatters.speed + }, + limit: { + value: stats.payload_upload_rate, + formatter: Deluge.Formatters.speed + }, + format: '{0}/{1}' + }); + + this.items.get('statusbar-dht').setText(stats.dht_nodes); + + function updateMenu(menu, stat) { + var item = menu.items.get(stat) + if (!item) { + item = menu.items.get('other') + } + item.setChecked(true); + } + + updateMenu(Deluge.Menus.Connections, stats.max_num_connections); + updateMenu(Deluge.Menus.Download, stats.max_download); + updateMenu(Deluge.Menus.Upload, stats.max_upload); + } + }); + Deluge.Statusbar = new Ext.deluge.Statusbar(); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.Toolbar.js b/deluge/ui/web/js/Deluge.Toolbar.js new file mode 100644 index 000000000..0324aff87 --- /dev/null +++ b/deluge/ui/web/js/Deluge.Toolbar.js @@ -0,0 +1,195 @@ +/* +Script: Deluge.Toolbar.js + Contains the Deluge toolbar. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +(function() { + Ext.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', + handler: this.onTorrentAction + },{ + id: 'add', + cls: 'x-btn-text-icon', + disabled: true, + text: _('Add'), + icon: '/icons/add.png', + handler: this.onTorrentAdd + },{ + id: 'remove', + cls: 'x-btn-text-icon', + disabled: true, + text: _('Remove'), + icon: '/icons/remove.png', + handler: this.onTorrentAction + },'|',{ + id: 'pause', + cls: 'x-btn-text-icon', + disabled: true, + text: _('Pause'), + icon: '/icons/pause.png', + handler: this.onTorrentAction + },{ + id: 'resume', + cls: 'x-btn-text-icon', + disabled: true, + text: _('Resume'), + icon: '/icons/start.png', + handler: this.onTorrentAction + },'|',{ + id: 'up', + cls: 'x-btn-text-icon', + disabled: true, + text: _('Up'), + icon: '/icons/up.png', + handler: this.onTorrentAction + },{ + id: 'down', + cls: 'x-btn-text-icon', + disabled: true, + text: _('Down'), + icon: '/icons/down.png', + handler: this.onTorrentAction + },'|',{ + id: 'preferences', + cls: 'x-btn-text-icon', + text: _('Preferences'), + icon: '/icons/preferences.png', + handler: this.onPreferencesClick, + scope: this + },{ + id: 'connectionman', + cls: 'x-btn-text-icon', + text: _('Connection Manager'), + iconCls: 'x-deluge-connections', + handler: this.onConnectionManagerClick, + scope: this + },'->',{ + id: 'help', + cls: 'x-btn-text-icon', + disabled: true, + icon: '/icons/help.png', + text: _('Help'), + handler: this.onHelpClick, + scope: this + },{ + id: 'logout', + cls: 'x-btn-text-icon', + icon: '/icons/logout.png', + disabled: true, + text: _('Logout'), + handler: this.onLogout, + scope: this + } + ] + }, config); + Ext.deluge.Toolbar.superclass.constructor.call(this, config); + }, + + 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(buttonId) { + this.items.get(buttonId).enable(); + }, this); + }, + + onDisconnect: function() { + Ext.each(this.connectedButtons, function(buttonId) { + this.items.get(buttonId).disable(); + }, this); + }, + + onLogin: function() { + this.items.get('logout').enable(); + }, + + onLogout: function() { + this.items.get('logout').disable(); + Deluge.Events.fire('logout'); + Deluge.Login.show(); + }, + + onConnectionManagerClick: function() { + Deluge.ConnectionManager.show(); + }, + + onPreferencesClick: function() { + Deluge.Preferences.show(); + }, + + onTorrentAction: function(item) { + var selection = Deluge.Torrents.getSelections(); + var ids = []; + Ext.each(selection, function(record) { + ids.push(record.id); + }); + + switch (item.id) { + case 'remove': + Deluge.Events.fire('torrentRemoved', ids); + Deluge.Client.core.remove_torrent(ids, null, { + success: function() { + Deluge.UI.update(); + } + }); + break; + case 'pause': + case 'resume': + Deluge.Client.core[item.id + '_torrent'](ids, { + success: function() { + Deluge.UI.update(); + } + }); + break; + case 'up': + case 'down': + Deluge.Client.core['queue_' + item.id](ids, { + success: function() { + Deluge.UI.update(); + } + }); + break; + } + }, + + onTorrentAdd: function() { + Deluge.Add.Window.show(); + } + }); + + Deluge.Toolbar = new Ext.deluge.Toolbar(); +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-torrents.js b/deluge/ui/web/js/Deluge.Torrents.js similarity index 87% rename from deluge/ui/web/js/deluge-torrents.js rename to deluge/ui/web/js/Deluge.Torrents.js index e779853a4..55d434698 100644 --- a/deluge/ui/web/js/deluge-torrents.js +++ b/deluge/ui/web/js/Deluge.Torrents.js @@ -22,7 +22,6 @@ Copyright: */ (function() { - /* Renderers for the Torrent Grid */ function queueRenderer(value) { return (value == -1) ? '' : value + 1; @@ -35,10 +34,11 @@ Copyright: return fspeed(value); } function torrentProgressRenderer(value, p, r) { - var progress = value.toInt(); + value = new Number(value); + var progress = value; var text = r.data['state'] + ' ' + value.toFixed(2) + '%' - var width = this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt() - 8; - return Deluge.progressBar(value.toInt(), width, text); + var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]) - 8; + return Deluge.progressBar(value, width, text); } function seedsRenderer(value, p, r) { if (r.data['total_seeds'] > -1) { @@ -55,15 +55,25 @@ Copyright: } } function availRenderer(value, p, r) { - value.toFixed(3); + return new Number(value).toFixed(3); } function trackerRenderer(value, p, r) { return String.format('
{0}
', value); } - Ext.namespace("Ext.deluge"); + /** + * Ext.deluge.TorrentGrid Class + * + * @author Damien Churchill + * @version 1.2 + * + * @class Ext.deluge.TorrentGrid + * @extends Ext.grid.GridPanel + * @constructor + * @param {Object} config Configuration options + */ Ext.deluge.TorrentGrid = function(config) { - Ext.deluge.TorrentGrid.superclass.constructor.call(this, { + config = Ext.apply({ id: 'torrentGrid', store: new Ext.data.SimpleStore({ fields: [ @@ -174,7 +184,8 @@ Copyright: deferredRender:false, autoScroll:true, margins: '5 5 0 0' - }); + }, config); + Ext.deluge.TorrentGrid.superclass.constructor.call(this, config); } Ext.extend(Ext.deluge.TorrentGrid, Ext.grid.GridPanel, { @@ -191,6 +202,12 @@ Copyright: }); }, + /** + * Returns the record representing the torrent at the specified index. + * + * @param {int} The row index of the torrent you wish to retrieve. + * @param {Ext.data.Record} The record representing the torrent. + */ getTorrent: function(rowIndex) { return this.getStore().getAt(rowIndex); }, @@ -203,6 +220,7 @@ Copyright: return this.getSelectionModel().getSelections(); }, + // private onTorrentRemoved: function(torrentIds) { var selModel = this.Grid.getSelectionModel(); $each(torrentIds, function(torrentId) { diff --git a/deluge/ui/web/js/deluge-ui.js b/deluge/ui/web/js/Deluge.UI.js similarity index 75% rename from deluge/ui/web/js/deluge-ui.js rename to deluge/ui/web/js/Deluge.UI.js index c3a389799..29b0c5b51 100644 --- a/deluge/ui/web/js/deluge-ui.js +++ b/deluge/ui/web/js/Deluge.UI.js @@ -31,13 +31,13 @@ Deluge.UI = { iconCls: 'x-deluge-main-panel', title: 'Deluge', layout: 'border', - tbar: Deluge.ToolBar.Bar, + tbar: Deluge.Toolbar, items: [ - Deluge.SideBar.Config, - Deluge.Details.Panel, + Deluge.Sidebar, + Deluge.Details, Deluge.Torrents ], - bbar: Deluge.StatusBar.Bar + bbar: Deluge.Statusbar }); this.Viewport = new Ext.Viewport({ @@ -47,20 +47,23 @@ Deluge.UI = { Deluge.Login.show(); - Deluge.Events.on("connect", this.onConnect.bindWithEvent(this)); - Deluge.Events.on("disconnect", this.onDisconnect.bindWithEvent(this)); - Deluge.Client = new JSON.RPC('/json'); + Deluge.Events.on("connect", this.onConnect, this); + Deluge.Events.on("disconnect", this.onDisconnect, this); + Deluge.Client = new Ext.ux.util.RpcClient({url: '/json'}); + this.update = this.update.bind(this); }, update: function() { - var filters = Deluge.SideBar.getFilters(); + var filters = Deluge.Sidebar.getFilters(); Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, { - onSuccess: this.onUpdate.bindWithEvent(this), - onFailure: this.onUpdateError.bindWithEvent(this) + success: this.onUpdate, + failure: this.onUpdateError, + scope: this }); Deluge.Details.update(); Deluge.Client.web.connected({ - onSuccess: this.onConnectedCheck.bindWithEvent(this) + success: this.onConnectedCheck, + scope: this }); }, @@ -83,10 +86,10 @@ Deluge.UI = { }, onUpdate: function(data) { - var torrents = new Array(); - $each(data['torrents'], function(torrent, id) { - torrents.include([ - torrent.queue, + var torrents = []; + for (var torrentId in data['torrents']) { + var torrent = data['torrents'][torrentId]; + torrents.push([torrent.queue, torrent.name, torrent.total_size, torrent.state, @@ -102,12 +105,12 @@ Deluge.UI = { torrent.distributed_copies, torrent.time_added, torrent.tracker_host, - id + torrentId ]); - }); + } Deluge.Torrents.getStore().loadData(torrents); - Deluge.StatusBar.update(data['stats']); - Deluge.SideBar.update(data['filters']); + Deluge.Statusbar.update(data['stats']); + Deluge.Sidebar.update(data['filters']); this.errorCount = 0; }, @@ -121,14 +124,13 @@ Deluge.UI = { */ onConnect: function() { if (!this.running) { - this.running = this.update.periodical(2000, this); + this.running = setInterval(this.update, 2000); this.update(); } }, onDisconnect: function() { this.stop(); - this.notify('Disconnected', 'Deluge has disconnected from the daemon'); }, /* @@ -141,13 +143,13 @@ Deluge.UI = { */ stop: function() { if (this.running) { - $clear(this.running); + clearInterval(this.running); this.running = false; - Deluge.Torrents.Store.loadData([]); + Deluge.Torrents.getStore().loadData([]); } } } -document.addEvent('domready', function(e) { +Ext.onReady(function(e) { Deluge.UI.initialize(); }); \ No newline at end of file diff --git a/deluge/ui/web/js/Deluge.js b/deluge/ui/web/js/Deluge.js new file mode 100644 index 000000000..a0f086c0e --- /dev/null +++ b/deluge/ui/web/js/Deluge.js @@ -0,0 +1,103 @@ +/* +Script: Deluge.js + Contains the keys for get_torrent(s)_status. + +Copyright: + (C) Damien Churchill 2009 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. +*/ + +Ext.namespace('Ext.deluge'); + +var Deluge = { + author: 'Damien Churchill ', + version: '1.2-dev' +}; + +(function() { + /* Add some helper functions to Ext */ + Ext.apply(Function.prototype, { + bind: function(scope) { + var self = this; + return function() { + return self.apply(scope, arguments); + } + } + }); + + Ext.apply(Ext, { + keys: function(obj) { + var keys = []; + for (i in obj) if (obj.hasOwnProperty(i)) + { + keys.push(i); + } + return keys; + }, + + splat: function(obj) { + var type = Ext.type(obj); + return (type) ? ((type != 'array') ? [obj] : obj) : []; + } + }); + Ext.getKeys = Ext.keys; +})(); + +(function() { + var tpl = '
' + + '
' + + '
' + + '
' + + '
{0}
' + + '
' + + '
' + + '
' + + '
{0}
' + + '
' + + '
' + + '
'; + + Deluge.progressBar = function(progress, width, text) { + var progressWidth = ((width / 100.0) * progress).toFixed(0); + var barWidth = progressWidth - 1; + var textWidth = ((progressWidth - 10) > 0 ? progressWidth - 10 : 0); + return String.format(tpl, text, width, barWidth, textWidth); + } +})(); + +// Hinting for gettext_gen.py +// _('Do Not Download') +// _('Normal Priority') +// _('High Priority') +// _('Highest Priority') +FILE_PRIORITY = { + 0: 'Do Not Download', + 1: 'Normal Priority', + 2: 'High Priority', + 5: 'Highest Priority', + 'Do Not Download': 0, + 'Normal Priority': 1, + 'High Priority': 2, + 'Highest Priority': 5 +} + +FILE_PRIORITY_CSS = { + 0: 'x-no-download', + 1: 'x-normal-download', + 2: 'x-high-download', + 5: 'x-highest-download' +} \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-bars.js b/deluge/ui/web/js/deluge-bars.js deleted file mode 100644 index febfb70fb..000000000 --- a/deluge/ui/web/js/deluge-bars.js +++ /dev/null @@ -1,501 +0,0 @@ -/* -Script: deluge-bars.js - Contains all objects and functions related to the statusbar, toolbar and - sidebar. - -Copyright: - (C) Damien Churchill 2009 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, write to: - The Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor - Boston, MA 02110-1301, USA. -*/ - -Deluge.ToolBar = { - connected_buttons: [ - 'add', 'remove', 'pause', 'resume', 'up', 'down' - ], - - onTorrentAdd: function() { - Deluge.Add.Window.show(); - }, - - onConnect: function() { - $each(this.connected_buttons, function(button_id) { - this.Bar.items.get(button_id).enable(); - }, this); - }, - - onDisconnect: function() { - $each(this.connected_buttons, function(button_id) { - this.Bar.items.get(button_id).disable(); - }, this); - }, - - onLogin: function() { - this.Bar.items.get('logout').enable(); - }, - - onLogout: function() { - this.Bar.items.get('logout').disable(); - Deluge.Events.fire('logout'); - Deluge.Login.show(); - }, - - onConnectionManagerClick: function(item) { - Deluge.Connections.Window.show(); - }, - - onPreferencesClick: function() { - Deluge.Preferences.show(); - }, - - onTorrentAction: function(item) { - var selection = Deluge.Torrents.getSelections(); - var ids = new Array(); - $each(selection, function(record) { - ids.include(record.id); - }); - - switch (item.id) { - case 'remove': - Deluge.Events.fire('torrentRemoved', ids); - Deluge.Client.core.remove_torrent(ids, null, { - onSuccess: function() { - Deluge.UI.update(); - } - }); - break; - case 'pause': - case 'resume': - Deluge.Client.core[item.id + '_torrent'](ids, { - onSuccess: function() { - Deluge.UI.update(); - } - }); - break; - case 'up': - case 'down': - Deluge.Client.core['queue_' + item.id](ids, { - onSuccess: function() { - Deluge.UI.update(); - } - }); - break; - } - }, - - onToolbarRender: function(toolbar) { - Deluge.Events.on('connect', this.onConnect.bindWithEvent(this)); - Deluge.Events.on('login', this.onLogin.bindWithEvent(this)); - } -} - -Deluge.ToolBar.Bar = new Ext.Toolbar({ - items: [ - { - id: 'create', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Create'), - icon: '/icons/create.png', - handler: Deluge.ToolBar.onTorrentAction - },{ - id: 'add', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Add'), - icon: '/icons/add.png', - handler: Deluge.ToolBar.onTorrentAdd - },{ - id: 'remove', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Remove'), - icon: '/icons/remove.png', - handler: Deluge.ToolBar.onTorrentAction - },'|',{ - id: 'pause', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Pause'), - icon: '/icons/pause.png', - handler: Deluge.ToolBar.onTorrentAction - },{ - id: 'resume', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Resume'), - icon: '/icons/start.png', - handler: Deluge.ToolBar.onTorrentAction - },'|',{ - id: 'up', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Up'), - icon: '/icons/up.png', - handler: Deluge.ToolBar.onTorrentAction - },{ - id: 'down', - cls: 'x-btn-text-icon', - disabled: true, - text: _('Down'), - icon: '/icons/down.png', - handler: Deluge.ToolBar.onTorrentAction - },'|',{ - id: 'preferences', - cls: 'x-btn-text-icon', - text: _('Preferences'), - icon: '/icons/preferences.png', - handler: Deluge.ToolBar.onPreferencesClick, - scope: Deluge.ToolBar - },{ - id: 'connectionman', - cls: 'x-btn-text-icon', - text: _('Connection Manager'), - iconCls: 'x-deluge-connections', - handler: Deluge.ToolBar.onConnectionManagerClick, - scope: Deluge.ToolBar - },'->',{ - id: 'help', - cls: 'x-btn-text-icon', - disabled: true, - icon: '/icons/help.png', - text: _('Help'), - handler: Deluge.ToolBar.onHelpClick, - scope: Deluge.ToolBar - },{ - id: 'logout', - cls: 'x-btn-text-icon', - icon: '/icons/logout.png', - disabled: true, - text: _('Logout'), - handler: Deluge.ToolBar.onLogout, - scope: Deluge.ToolBar - } - ], - listeners: {'render': Deluge.ToolBar.onToolbarRender, scope: Deluge.ToolBar} -}); - -Deluge.StatusBar = { - onRender: function() { - this.bound = { - onConnect: this.onConnect.bindWithEvent(this), - onDisconnect: this.onDisconnect.bindWithEvent(this) - } - - Deluge.Events.on('connect', this.bound.onConnect); - Deluge.Events.on('disconnect', this.bound.onDisconnect); - }, - - createButtons: function() { - this.Bar.add({ - id: 'statusbar-connections', - text: '200 (200)', - cls: 'x-btn-text-icon', - iconCls: 'x-deluge-connections', - menu: Deluge.Menus.Connections - }, '-', { - id: 'statusbar-downspeed', - text: '9.8KiB/s (30 KiB/s)', - cls: 'x-btn-text-icon', - iconCls: 'x-deluge-downloading', - menu: Deluge.Menus.Download - }, '-', { - id: 'statusbar-upspeed', - text: '9.8KiB/s (30 KiB/s)', - cls: 'x-btn-text-icon', - iconCls: 'x-deluge-seeding', - menu: Deluge.Menus.Upload - }, '-', { - id: 'statusbar-traffic', - text: '1.53/2,65 KiB/s', - cls: 'x-btn-text-icon', - iconCls: 'x-deluge-traffic' - }, '-', { - id: 'statusbar-dht', - text: '161', - cls: 'x-btn-text-icon', - iconCls: 'x-deluge-dht' - }); - this.created = true; - }, - - onConnect: function() { - this.Bar.setStatus({ - iconCls: 'x-connected', - text: '' - }); - if (!this.created) this.createButtons(); - else { - this.Bar.items.each(function(item) { - item.show(); - item.enable(); - }); - } - }, - - onDisconnect: function() { - this.Bar.clearStatus({useDefaults:true}); - this.Bar.items.each(function(item) { - item.hide(); - item.disable(); - }); - }, - - update: function(stats) { - function addSpeed(val) {return val + ' KiB/s'} - - var updateStat = function(name, config) { - var item = this.Bar.items.get('statusbar-' + name); - if (config.limit.value == -1) { - var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value; - } else { - 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 str = String.format(config.format, value, limit); - } - item.setText(str); - }.bind(this); - - updateStat('connections', { - value: {value: stats.num_connections}, - limit: {value: stats.max_num_connections}, - format: '{0} ({1})' - }); - - updateStat('downspeed', { - value: { - value: stats.download_rate, - formatter: Deluge.Formatters.speed - }, - limit: { - value: stats.max_download, - formatter: addSpeed - }, - format: '{0} ({1})' - }); - - updateStat('upspeed', { - value: { - value: stats.upload_rate, - formatter: Deluge.Formatters.speed - }, - limit: { - value: stats.max_upload, - formatter: addSpeed - }, - format: '{0} ({1})' - }); - - updateStat('traffic', { - value: { - value: stats.payload_download_rate, - formatter: Deluge.Formatters.speed - }, - limit: { - value: stats.payload_upload_rate, - formatter: Deluge.Formatters.speed - }, - format: '{0}/{1}' - }); - - this.Bar.items.get('statusbar-dht').setText(stats.dht_nodes); - - function updateMenu(menu, stat) { - var item = menu.items.get(stat) - if (!item) { - item = menu.items.get('other') - } - item.setChecked(true); - } - - updateMenu(Deluge.Menus.Connections, stats.max_num_connections); - updateMenu(Deluge.Menus.Download, stats.max_download); - updateMenu(Deluge.Menus.Upload, stats.max_upload); - } -} - -Deluge.StatusBar.Bar = new Ext.StatusBar({ - id: 'deluge-statusbar', - defaultIconCls: 'x-not-connected', - defaultText: _('Not Connected'), - listeners: {'render': {scope: Deluge.StatusBar, fn: Deluge.StatusBar.onRender}} -}); - - -// These are just so gen_gettext.js pick up the strings -// _('State') -// _('Tracker Host') -Deluge.SideBar = { - panels: new Hash(), - - onRender: function(bar) { - this.Bar = bar; - Deluge.Events.on("disconnect", this.onDisconnect.bindWithEvent(this)); - this.selected = null; - }, - - onDisconnect: function() { - this.panels.getKeys().each(function(el) { - this.Bar.remove(el + '-panel'); - }, this); - this.panels.empty(); - this.selected = null; - }, - - renderer: function(value, p, r) { - var lname = value.toLowerCase().replace('.', '_'); - - var image = ''; - if (r.store.id == 'tracker_host') { - if (value != 'Error') { - image = String.format('url(/tracker/{0})', value); - } else { - lname = null; - } - } - if (image) { - return String.format('
{0} ({1})
', value, r.data['count'], image); - } else if (lname) { - return String.format('
{0} ({1})
', value, r.data['count'], lname); - } else { - return String.format('
{0} ({1})
', value, r.data['count']); - } - }, - - 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; - return filters; - }, - - update: function(filters) { - filters = new Hash(filters); - filters.each(function(states, filter) { - if (this.panels.has(filter)) { - this.updateFilter(filter, states); - } else { - this.createFilter(filter, states); - } - }, this); - - // Perform a cleanup of fitlers that aren't enabled any more - $each(this.panels.getKeys(), function(filter) { - if (!filters.has(filter)) { - // We need to remove the panel - } - }); - }, - - createFilter: function(filter, states) { - var store = new Ext.data.SimpleStore({ - id: filter, - fields: [ - {name: 'filter'}, - {name: 'count'} - ] - }); - - var title = filter.replace('_', ' '); - var parts = title.split(' '); - title = ''; - parts.each(function(part) { - firstLetter = part.substring(0, 1); - firstLetter = firstLetter.toUpperCase(); - part = firstLetter + part.substring(1); - title += part + ' '; - }); - - var panel = new Ext.grid.GridPanel({ - id: filter + '-panel', - store: store, - title: _(title), - columns: [ - {id: 'filter', sortable: false, renderer: this.renderer, dataIndex: 'filter'} - ], - stripeRows: false, - selModel: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: { - 'rowselect': this.onSelect.bindWithEvent(this) - } - }), - hideHeaders: true, - autoExpandColumn: 'filter', - deferredRender: false, - autoScroll: true - }); - store.loadData(states); - this.Bar.add(panel); - - this.Bar.doLayout(); - this.panels[filter] = panel; - - if (!this.selected) { - panel.getSelectionModel().selectFirstRow(); - this.selected = { - row: 0, - filter: states[0][0], - panel: panel - } - } - }, - - onSelect: 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(); - }, - - updateFilter: function(filter, states) { - this.panels[filter].store.loadData(states); - if (this.selected && this.selected.panel == this.panels[filter]) { - this.panels[filter].getSelectionModel().selectRow(this.selected.row); - } - } -}; - -Deluge.SideBar.Config = { - region: 'west', - id: 'sidebar', - cls: 'deluge-sidebar', - title: _('Filters'), - layout: 'accordion', - split: true, - width: 200, - minSize: 175, - collapsible: true, - margins: '5 0 0 5', - cmargins: '5 5 0 5', - listeners: {'render': {scope: Deluge.SideBar, fn: Deluge.SideBar.onRender}} -} \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-connections.js b/deluge/ui/web/js/deluge-connections.js deleted file mode 100644 index e0347b7de..000000000 --- a/deluge/ui/web/js/deluge-connections.js +++ /dev/null @@ -1,322 +0,0 @@ -/* -Script: deluge-connections.js - Contains all objects and functions related to the connection manager. - -Copyright: - (C) Damien Churchill 2009 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, write to: - The Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor - Boston, MA 02110-1301, USA. -*/ - -Deluge.Connections = { - disconnect: function() { - Deluge.Events.fire('disconnect'); - }, - - loginShow: function() { - Deluge.Events.on('logout', function(e) { - Deluge.Connections.disconnect(); - Deluge.Connections.Window.hide(); - }); - - Deluge.Client.web.connected({ - onSuccess: function(connected) { - if (connected) { - Deluge.Events.fire('connect'); - } else { - Deluge.Connections.Window.show(); - } - } - }); - }, - - onAdd: function(button, e) { - Deluge.Connections.Add.show(); - }, - - onAddHost: function() { - var form = Deluge.Connections.Add.items.first(); - var host = form.items.get('host').getValue(); - var port = form.items.get('port').getValue(); - var username = form.items.get('username').getValue(); - var password = form.items.get('_password').getValue(); - - Deluge.Client.web.add_host(host, port, username, password, { - onSuccess: function(result) { - if (!result[0]) { - Ext.MessageBox.show({ - title: _('Error'), - msg: "Unable to add host: " + result[1], - buttons: Ext.MessageBox.OK, - modal: false, - icon: Ext.MessageBox.ERROR, - iconCls: 'x-deluge-icon-error' - }); - } else { - Deluge.Connections.runCheck(); - } - Deluge.Connections.Add.hide(); - } - }); - }, - - onAddWindowHide: function() { - // Tidy up the form to ensure all the values are default. - var form = Deluge.Connections.Add.items.first(); - form.items.get('host').reset(); - form.items.get('port').reset(); - form.items.get('username').reset(); - form.items.get('_password').reset(); - }, - - onClose: function(e) { - $clear(Deluge.Connections.running); - Deluge.Connections.Window.hide(); - }, - - onConnect: function(e) { - - var selected = Deluge.Connections.Grid.getSelectionModel().getSelected(); - if (!selected) return; - - if (selected.get('status') == _('Connected')) { - Deluge.Client.web.disconnect({ - onSuccess: function(result) { - Deluge.Connections.runCheck(); - Deluge.Events.fire('disconnect'); - } - }); - } else { - var id = selected.id; - Deluge.Client.web.connect(id, { - onSuccess: function(methods) { - Deluge.Client = new JSON.RPC('/json', { - methods: methods - }); - Deluge.Events.fire('connect'); - } - }); - $clear(Deluge.Connections.running); - Deluge.Connections.Window.hide(); - } - }, - - onGetHosts: function(hosts) { - Deluge.Connections.Store.loadData(hosts); - var selection = Deluge.Connections.Grid.getSelectionModel(); - selection.selectRow(Deluge.Connections.selectedRow); - }, - - onRemove: function(button) { - var connection = Deluge.Connections.Grid.getSelectionModel().getSelected(); - Deluge.Client.web.remove_host(connection.id, { - onSuccess: function(result) { - if (!result) { - Ext.MessageBox.show({ - title: _('Error'), - msg: result[1], - buttons: Ext.MessageBox.OK, - modal: false, - icon: Ext.MessageBox.ERROR, - iconCls: 'x-deluge-icon-error' - }); - } else { - Deluge.Connections.Grid.store.remove(connection); - } - } - }); - }, - - onSelect: function(selModel, rowIndex, record) { - Deluge.Connections.selectedRow = rowIndex; - var button = Deluge.Connections.Window.buttons[1]; - if (record.get('status') == _('Connected')) { - button.setText(_('Disconnect')); - } else { - button.setText(_('Connect')); - } - }, - - onShow: function(window) { - Deluge.Connections.running = Deluge.Connections.runCheck.periodical(2000); - Deluge.Connections.runCheck(); - }, - - onStop: function(button, e) { - var connection = Deluge.Connections.Grid.getSelectionModel().getSelected(); - Deluge.Client.web.stop_daemon(connection.id, { - onSuccess: function(result) { - if (!result[0]) { - Ext.MessageBox.show({ - title: _('Error'), - msg: result[1], - buttons: Ext.MessageBox.OK, - modal: false, - icon: Ext.MessageBox.ERROR, - iconCls: 'x-deluge-icon-error' - }); - } - } - }); - }, - - runCheck: function(callback) { - callback = $pick(callback, Deluge.Connections.onGetHosts); - Deluge.Client.web.get_hosts({ - onSuccess: callback - }); - } -} - -Deluge.Connections.Store = new Ext.data.SimpleStore({ - fields: [ - {name: 'status', mapping: 3}, - {name: 'host', mapping: 1}, - {name: 'port', mapping: 2}, - {name: 'version', mapping: 4} - ], - id: 0 -}); - -var renderHost = function(value, p, r) { - return value + ':' + r.data['port'] -} - -Deluge.Connections.Grid = new Ext.grid.GridPanel({ - store: Deluge.Connections.Store, - columns: [ - {header: 'Status', width: 65, sortable: true, renderer: Deluge.Formatters.plain, dataIndex: 'status'}, - {id:'host', header: 'Host', width: 150, sortable: true, renderer: renderHost, dataIndex: 'host'}, - {header: 'Version', width: 75, sortable: true, renderer: Deluge.Formatters.plain, dataIndex: 'version'} - ], - stripeRows: true, - selModel: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: {'rowselect': Deluge.Connections.onSelect} - }), - autoExpandColumn: 'host', - deferredRender:false, - autoScroll:true, - margins: '0 0 0 0', - bbar: new Ext.Toolbar({ - items: [ - { - id: 'add', - cls: 'x-btn-text-icon', - text: _('Add'), - icon: '/icons/add.png', - handler: Deluge.Connections.onAdd - }, { - id: 'remove', - cls: 'x-btn-text-icon', - text: _('Remove'), - icon: '/icons/remove.png', - handler: Deluge.Connections.onRemove - }, '->', { - id: 'stop', - cls: 'x-btn-text-icon', - text: _('Stop Daemon'), - icon: '/icons/error.png', - handler: Deluge.Connections.onStop - } - ] - }) -}); - -Deluge.Connections.Add = new Ext.Window({ - 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', - items: [new Ext.form.FormPanel({ - defaultType: 'textfield', - id: 'connectionAddForm', - baseCls: 'x-plain', - labelWidth: 55, - items: [{ - fieldLabel: _('Host'), - id: 'host', - name: 'host', - anchor: '100%', - listeners: {} - },{ - fieldLabel: _('Port'), - id: 'port', - xtype: 'uxspinner', - ctCls: 'x-form-uxspinner', - name: 'port', - strategy: Ext.ux.form.Spinner.NumberStrategy(), - value: '58846', - anchor: '50%', - listeners: {} - }, { - fieldLabel: _('Username'), - id: 'username', - name: 'username', - anchor: '100%', - listeners: {} - },{ - fieldLabel: _('Password'), - anchor: '100%', - id: '_password', - name: '_password', - inputType: 'password' - }] - })], - buttons: [{ - text: _('Close'), - handler: function() { - Deluge.Connections.Add.hide(); - } - },{ - text: _('Add'), - handler: Deluge.Connections.onAddHost - }], - listeners: { - 'hide': Deluge.Connections.onAddWindowHide - } -}); - -Deluge.Connections.Window = new 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', - items: [Deluge.Connections.Grid], - buttons: [{ - text: _('Close'), - handler: Deluge.Connections.onClose - },{ - text: _('Connect'), - handler: Deluge.Connections.onConnect - }], - listeners: { - 'hide': Deluge.Connections.onClose, - 'show': Deluge.Connections.onShow - } -}); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-preferences.js b/deluge/ui/web/js/deluge-preferences.js deleted file mode 100644 index 015157d33..000000000 --- a/deluge/ui/web/js/deluge-preferences.js +++ /dev/null @@ -1,398 +0,0 @@ -/* -Script: deluge-preferences.js - Contains the preferences window. - -Copyright: - (C) Damien Churchill 2009 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, write to: - The Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor - Boston, MA 02110-1301, USA. -*/ - -(function() { - PreferencesWindow = function(config) { - Ext.apply(this, config); - this.layout = 'border'; - this.width = 485; - this.height = 500; - this.buttonAlign = 'right'; - this.closeAction = 'hide'; - this.closable = true; - this.iconCls = 'x-deluge-preferences'; - this.plain = true; - this.resizable = false; - this.title = _('Preferences'); - this.buttons = [{ - text: _('Close'), - handler: this.onCloseButtonClick, - scope: this - },{ - text: _('Apply') - },{ - text: _('Ok') - }]; - this.currentPage = false; - this.items = [{ - xtype: 'grid', - region: 'west', - title: _('Categories'), - store: new Ext.data.SimpleStore({ - fields: [{name: 'name', mapping: 0}] - }), - columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}], - sm: new Ext.grid.RowSelectionModel({ - singleSelect: true, - listeners: {'rowselect': {fn: this.onPageSelect, scope: this}} - }), - hideHeaders: true, - autoExpandColumn: 'name', - deferredRender: false, - autoScroll: true, - margins: '5 0 5 5', - cmargins: '5 0 5 5', - width: 120, - collapsible: true - }, { - region: 'center', - title: ' ', - layout: 'fit', - height: 400, - margins: '5 5 5 5', - cmargins: '5 5 5 5' - }]; - PreferencesWindow.superclass.constructor.call(this); - }; - - Ext.extend(PreferencesWindow, Ext.Window, { - initComponent: function() { - PreferencesWindow.superclass.initComponent.call(this); - this.categoriesGrid = this.items.get(0); - this.configPanel = this.items.get(1); - this.pages = {}; - this.on('show', this.onShow.bindWithEvent(this)); - }, - - onCloseButtonClick: function() { - this.hide(); - }, - - addPage: function(name, page) { - var store = this.categoriesGrid.getStore(); - store.loadData([[name]], true); - page['bodyStyle'] = 'margin: 5px'; - this.pages[name] = this.configPanel.add(page); - this.pages[name].hide(); - }, - - onPageSelect: function(selModel, rowIndex, r) { - if (this.currentPage) { - this.currentPage.hide(); - } - var name = r.get('name'); - - this.pages[name].show(); - this.configPanel.setTitle(name); - this.currentPage = this.pages[name]; - this.configPanel.doLayout(); - }, - - onShow: function() { - if (!this.categoriesGrid.getSelectionModel().hasSelection()) { - this.categoriesGrid.getSelectionModel().selectFirstRow(); - } - } - }); - - Deluge.Preferences = new PreferencesWindow(); - Deluge.Preferences.addPage(_('Downloads'), { - border: false, - xtype: 'form', - layout: 'form', - items: [{ - xtype: 'fieldset', - border: false, - title: _('Folders'), - labelWidth: 140, - defaultType: 'textfield', - autoHeight: true, - items: [{ - name: 'download_location', - fieldLabel: _('Download to'), - width: 125 - }, { - name: 'move_completed', - fieldLabel: _('Move completed to'), - width: 125 - }, { - name: 'copy_torrent_files', - fieldLabel: _('Copy of .torrent files to'), - width: 125 - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Allocation'), - autoHeight: true, - labelWidth: 1, - defaultType: 'radio', - items: [{ - name: 'compact_allocation', - labelSeparator: '', - boxLabel: _('Compact') - }, { - name: 'compact_allocation', - labelSeparator: '', - boxLabel: _('Full') - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Options'), - autoHeight: true, - labelWidth: 1, - defaultType: 'checkbox', - items: [{ - name: 'prioritize_first_last', - labelSeparator: '', - boxLabel: _('Prioritize first and last pieces of torrent') - }, { - name: 'add_paused', - labelSeparator: '', - boxLabel: _('Add torrents in Paused state') - }] - }] - }); - /*Deluge.Preferences.addPage(_('Network'), { - border: false, - xtype: 'form', - layout: 'form', - items: [] - });*/ - Deluge.Preferences.addPage(_('Bandwidth'), { - border: false, - xtype: 'form', - layout: 'form', - labelWidth: 10, - items: [{ - xtype: 'fieldset', - border: false, - title: _('Global Bandwidth Usage'), - autoHeight: true, - labelWidth: 200, - style: 'margin-bottom: 0px; padding-bottom: 0px;', - defaultType: 'uxspinner', - items: [{ - name: 'max_connections', - fieldLabel: _('Maximum Connections'), - width: 60, - value: -1 - }, { - name: 'max_upload_slots', - fieldLabel: _('Maximum Upload Slots'), - width: 60, - value: -1 - }, { - name: 'max_download_speed', - fieldLabel: _('Maximum Download Speed (KiB/s)'), - width: 60, - value: -1 - }, { - name: 'max_upload_speed', - fieldLabel: _('Maximum Upload Speed (KiB/s)'), - width: 60, - value: -1 - }, { - name: 'max_half_open_connections', - fieldLabel: _('Maximum Half-Open Connections'), - width: 60, - value: -1 - }, { - name: 'max_connections_per_second', - fieldLabel: _('Maximum Connection Attempts per Second'), - width: 60, - value: -1 - }] - }, { - xtype: 'fieldset', - border: false, - title: '', - autoHeight: true, - style: 'padding-top: 0px; margin-top: 0px; margin-bottom: 0px;', - items: [{ - xtype: 'checkbox', - name: 'ignore_local', - fieldLabel: '', - labelSeparator: '', - boxLabel: _('Ignore limits on local network'), - value: -1 - }, { - xtype: 'checkbox', - name: 'limit_ip_overhead', - fieldLabel: '', - labelSeparator: '', - boxLabel: _('Rate limit IP overhead'), - value: -1 - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Per Torrent Bandwidth Usage'), - autoHeight: true, - labelWidth: 200, - defaultType: 'uxspinner', - items: [{ - name: 'max_connections_per_torrent', - fieldLabel: _('Maximum Connections'), - width: 60, - value: -1 - }, { - name: 'max_upload_slots_per_torrent', - fieldLabel: _('Maximum Upload Slots'), - width: 60, - value: -1 - }, { - name: 'max_download_speed_per_torrent', - fieldLabel: _('Maximum Download Speed (KiB/s)'), - width: 60, - value: -1 - }, { - name: 'max_upload_speed_per_torrent', - fieldLabel: _('Maximum Upload Speed (KiB/s)'), - width: 60, - value: -1 - }] - }] - }); - Deluge.Preferences.addPage(_('Interface'), { - border: false, - xtype: 'form', - layout: 'form', - items: [{ - xtype: 'fieldset', - border: false, - title: _('Window'), - autoHeight: true, - labelWidth: 1, - items: [{ - xtype: 'checkbox', - fieldLabel: '', - labelSeparator: '', - boxLabel: _('Show session speed in titlebar'), - id: 'show_session_speed' - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Sidebar'), - autoHeight: true, - labelWidth: 1, - items: [{ - xtype: 'checkbox', - fieldLabel: '', - labelSeparator: '', - boxLabel: _('Hide filters with zero torrents'), - id: 'hide_sidebar_zero' - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Password'), - autoHeight: true, - defaultType: 'textfield', - items: [{ - fieldLabel: 'New Password', - inputType: 'password', - id: 'new_password' - }, { - inputType: 'password', - fieldLabel: 'Confirm Password', - id: 'confirm_password' - }] - }] - }); - /*Deluge.Preferences.addPage(_('Other'), { - border: false, - xtype: 'form', - layout: 'form', - items: [] - });*/ - Deluge.Preferences.addPage(_('Daemon'), { - border: false, - xtype: 'form', - layout: 'form', - items: [{ - xtype: 'fieldset', - border: false, - title: _('Port'), - autoHeight: true, - defaultType: 'uxspinner', - items: [{ - fieldLabel: _('Daemon port'), - id: 'daemon_port' - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Connections'), - autoHeight: true, - labelWidth: 1, - defaultType: 'checkbox', - items: [{ - fieldLabel: '', - labelSeparator: '', - boxLabel: _('Allow Remote Connections'), - id: 'allow_remote' - }] - }, { - xtype: 'fieldset', - border: false, - title: _('Other'), - autoHeight: true, - labelWidth: 1, - defaultType: 'checkbox', - items: [{ - fieldLabel: '', - labelSeparator: '', - height: 40, - boxLabel: _('Periodically check the website for new releases'), - id: 'new_releases' - }] - }] - }); - /*Deluge.Preferences.addPage(_('Queue'), { - border: false, - xtype: 'form', - layout: 'form', - items: [] - }); - Deluge.Preferences.addPage(_('Proxy'), { - border: false, - xtype: 'form', - layout: 'form', - items: [] - }); - Deluge.Preferences.addPage(_('Notification'), { - border: false, - xtype: 'form', - layout: 'form', - items: [] - }); - Deluge.Preferences.addPage(_('Plugins'), { - border: false, - xtype: 'form', - layout: 'form', - items: [] - });*/ -})(); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge-yc.js b/deluge/ui/web/js/deluge-yc.js index 8bc7cb3b6..61ac5f0d3 100644 --- a/deluge/ui/web/js/deluge-yc.js +++ b/deluge/ui/web/js/deluge-yc.js @@ -1 +1 @@ -JSON.RPC=new Class({Implements:Options,options:{async:true,methods:[]},initialize:function(b,a){this.setOptions(a);this.url=b;if(this.options.methods.length==0){this._setMethods(this._execute("system.listMethods",{async:false}))}else{this._setMethods(this.options.methods)}},_setMethods:function(b){var a=new Hash();b.forEach(function(f){var e=f.split(".");var c=$pick(a[e[0]],new Hash());var d=function(){var g=this._parseargs(arguments);return this._execute(f,g)}.bind(this);c[e[1]]=d;a[e[0]]=c},this);a.each(function(c,d){this[d]=c},this)},_parseargs:function(c){var f=$A(c),b=f.getLast();if($type(b)=="object"){var a=["async","onRequest","onComplete","onSuccess","onFailure","onException","onCancel"],e=new Hash(b).getKeys(),d=false;a.each(function(g){if(e.contains(g)){d=true}});if(d){f.erase(b)}else{b={}}}else{b={}}b.params=f;return b},_execute:function(c,a){a=$pick(a,{});a.params=$pick(a.params,[]);a.async=$pick(a.async,this.options.async);data=JSON.encode({method:c,params:a.params,id:1});var b=new Request.JSON({url:this.url,async:a.async,onRequest:a.onRequest,onComplete:a.onComplete,onSuccess:function(d){if(a.onSuccess){a.onSuccess(d.result)}},onFailure:a.onFailure,onException:a.onException,onCancel:a.onCancel}).send(data);if(!a.async){return b.response.json.result}}});var Deluge={author:"Damien Churchill ",version:"1.2-dev"};(function(){var a='
{0}
{0}
';Deluge.progressBar=function(c,e,g){var b=(e/100)*c;var d=b.toInt()-1;var f=((b.toInt()-10)>0?b.toInt()-10:0);return String.format(a,g,e,d,f)}})();Deluge.Events={_events:new Hash(),fire:function(){arguments=$A(arguments);var b=arguments.shift();var a=arguments;if(!this._events[b]){return}$each(this._events[b],function(c){c.attempt(a)})},on:function(a,b){var c=$pick(this._events[a],new Array());c.include(b);this._events[a]=c},removeListener:function(a,b){if(!this._events[a]){return}this._events[a].remove(b)}};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}};FILE_PRIORITY={0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority","Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};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","seeds"],Details:["name","save_path","total_size","num_files","tracker_status","tracker","comment"],Options:["max_download_speed","max_upload_speed","max_connections","max_upload_slots","is_auto_managed","stop_at_ratio","stop_ratio","remove_at_ratio","private","prioritize_first_last"]};Deluge.Keys.Status.extend(Deluge.Keys.Grid);(function(){var a=function(b){Ext.apply(this,{layout:"fit",width:300,height:120,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",closable:false,modal:true,plain:true,resizable:false,title:_("Login"),iconCls:"x-deluge-login-window-icon"});Ext.apply(this,b);a.superclass.constructor.call(this)};Ext.extend(a,Ext.Window,{initComponent:function(){a.superclass.initComponent.call();Deluge.Events.on("logout",this.onLogout);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.loginForm=this.add({xtype:"form",defaultType:"textfield",id:"loginForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Password"),id:"password",name:"password",inputType:"password",anchor:"100%",listeners:{specialkey:{fn:this.onKey,scope:this}}}]})},onKey:function(c,b){if(b.getKey()==13){this.onLogin()}},onLogin:function(){var b=this.loginForm.items.get("password");Deluge.Client.web.login(b.getValue(),{onSuccess:function(c){if(c==true){this.hide();Deluge.Connections.loginShow();b.setRawValue("");Deluge.Events.fire("login")}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){b.focus()},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}}.bindWithEvent(this)})},onLogout:function(){this.show()},onShow:function(){var b=this.loginForm.items.get("password");b.focus(false,150)}});Deluge.Login=new a()})();Deluge.Menus={onTorrentAction:function(c,d){var b=Deluge.Torrents.getSelections();var a=new Array();$each(b,function(e){a.include(e.id)});switch(c.id){case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{onSuccess:function(){Deluge.UI.update()}});break;case"top":case"up":case"down":case"bottom":Deluge.Client.core["queue_"+c.id](a,{onSuccess:function(){Deluge.UI.update()}});break;case"update":Deluge.Client.core.force_reannounce(a,{onSuccess:function(){Deluge.UI.update()}});break;case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{onSuccess:function(){Deluge.UI.update()}});break;case"recheck":Deluge.Client.core.force_recheck(a,{onSuccess:function(){Deluge.UI.update()}});break}}};Deluge.Menus.Torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{id:"pause",text:_("Pause"),icon:"/icons/pause.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"resume",text:_("Resume"),icon:"/icons/start.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"options",text:_("Options"),icon:"/icons/preferences.png",menu:new Ext.menu.Menu({items:[{text:_("D/L Speed Limit"),iconCls:"x-deluge-downloading",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("U/L Speed Limit"),iconCls:"x-deluge-seeding",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("Connection Limit"),iconCls:"x-deluge-connections",menu:new Ext.menu.Menu({items:[{text:_("50")},{text:_("100")},{text:_("200")},{text:_("300")},{text:_("500")},{text:_("Unlimited")}]})},{text:_("Upload Slot Limit"),icon:"/icons/upload_slots.png",menu:new Ext.menu.Menu({items:[{text:_("0")},{text:_("1")},{text:_("2")},{text:_("3")},{text:_("5")},{text:_("Unlimited")}]})},{id:"auto_managed",text:_("Auto Managed"),checked:false}]})},"-",{text:_("Queue"),icon:"/icons/queue.png",menu:new Ext.menu.Menu({items:[{id:"top",text:_("Top"),icon:"/icons/top.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"up",text:_("Up"),icon:"/icons/up.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"down",text:_("Down"),icon:"/icons/down.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"bottom",text:_("Bottom"),icon:"/icons/bottom.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]})},"-",{id:"update",text:_("Update Tracker"),icon:"/icons/update.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{edit:"edit_trackers",text:_("Edit Trackers"),icon:"/icons/edit_trackers.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"remove",text:_("Remove Torrent"),icon:"/icons/remove.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"recheck",text:_("Force Recheck"),icon:"/icons/recheck.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"move",text:_("Move Storage"),icon:"/icons/move.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]});Deluge.Menus.Connections=new Ext.menu.Menu({id:"connectionsMenu",items:[{id:"50",text:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"100",text:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"200",text:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"500",text:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Download=new Ext.menu.Menu({id:"downspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Upload=new Ext.menu.Menu({id:"upspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.FilePriorities=new Ext.menu.Menu({id:"filePrioritiesMenu",items:[{id:"expandAll",text:_("Expand All"),icon:"/icons/expand_all.png"},"-",{id:"no_download",text:_("Do Not Download"),icon:"/icons/no_download.png",filePriority:0},{id:"normal",text:_("Normal Priority"),icon:"/icons/normal.png",filePriority:1},{id:"high",text:_("High Priority"),icon:"/icons/high.png",filePriority:2},{id:"highest",text:_("Highest Priority"),icon:"/icons/highest.png",filePriority:5}]});function onLimitChanged(b,a){if(b.id=="other"){}else{config={};config[b.group]=b.id;Deluge.Client.core.set_config(config,{onSuccess:function(){Deluge.UI.update()}})}}Deluge.ToolBar={connected_buttons:["add","remove","pause","resume","up","down"],onTorrentAdd:function(){Deluge.Add.Window.show()},onConnect:function(){$each(this.connected_buttons,function(a){this.Bar.items.get(a).enable()},this)},onDisconnect:function(){$each(this.connected_buttons,function(a){this.Bar.items.get(a).disable()},this)},onLogin:function(){this.Bar.items.get("logout").enable()},onLogout:function(){this.Bar.items.get("logout").disable();Deluge.Events.fire("logout");Deluge.Login.show()},onConnectionManagerClick:function(a){Deluge.Connections.Window.show()},onPreferencesClick:function(){Deluge.Preferences.show()},onTorrentAction:function(c){var b=Deluge.Torrents.getSelections();var a=new Array();$each(b,function(d){a.include(d.id)});switch(c.id){case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{onSuccess:function(){Deluge.UI.update()}});break;case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{onSuccess:function(){Deluge.UI.update()}});break;case"up":case"down":Deluge.Client.core["queue_"+c.id](a,{onSuccess:function(){Deluge.UI.update()}});break}},onToolbarRender:function(a){Deluge.Events.on("connect",this.onConnect.bindWithEvent(this));Deluge.Events.on("login",this.onLogin.bindWithEvent(this))}};Deluge.ToolBar.Bar=new Ext.Toolbar({items:[{id:"create",cls:"x-btn-text-icon",disabled:true,text:_("Create"),icon:"/icons/create.png",handler:Deluge.ToolBar.onTorrentAction},{id:"add",cls:"x-btn-text-icon",disabled:true,text:_("Add"),icon:"/icons/add.png",handler:Deluge.ToolBar.onTorrentAdd},{id:"remove",cls:"x-btn-text-icon",disabled:true,text:_("Remove"),icon:"/icons/remove.png",handler:Deluge.ToolBar.onTorrentAction},"|",{id:"pause",cls:"x-btn-text-icon",disabled:true,text:_("Pause"),icon:"/icons/pause.png",handler:Deluge.ToolBar.onTorrentAction},{id:"resume",cls:"x-btn-text-icon",disabled:true,text:_("Resume"),icon:"/icons/start.png",handler:Deluge.ToolBar.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),icon:"/icons/up.png",handler:Deluge.ToolBar.onTorrentAction},{id:"down",cls:"x-btn-text-icon",disabled:true,text:_("Down"),icon:"/icons/down.png",handler:Deluge.ToolBar.onTorrentAction},"|",{id:"preferences",cls:"x-btn-text-icon",text:_("Preferences"),icon:"/icons/preferences.png",handler:Deluge.ToolBar.onPreferencesClick,scope:Deluge.ToolBar},{id:"connectionman",cls:"x-btn-text-icon",text:_("Connection Manager"),iconCls:"x-deluge-connections",handler:Deluge.ToolBar.onConnectionManagerClick,scope:Deluge.ToolBar},"->",{id:"help",cls:"x-btn-text-icon",disabled:true,icon:"/icons/help.png",text:_("Help"),handler:Deluge.ToolBar.onHelpClick,scope:Deluge.ToolBar},{id:"logout",cls:"x-btn-text-icon",icon:"/icons/logout.png",disabled:true,text:_("Logout"),handler:Deluge.ToolBar.onLogout,scope:Deluge.ToolBar}],listeners:{render:Deluge.ToolBar.onToolbarRender,scope:Deluge.ToolBar}});Deluge.StatusBar={onRender:function(){this.bound={onConnect:this.onConnect.bindWithEvent(this),onDisconnect:this.onDisconnect.bindWithEvent(this)};Deluge.Events.on("connect",this.bound.onConnect);Deluge.Events.on("disconnect",this.bound.onDisconnect)},createButtons:function(){this.Bar.add({id:"statusbar-connections",text:"200 (200)",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",menu:Deluge.Menus.Connections},"-",{id:"statusbar-downspeed",text:"9.8KiB/s (30 KiB/s)",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",menu:Deluge.Menus.Download},"-",{id:"statusbar-upspeed",text:"9.8KiB/s (30 KiB/s)",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",menu:Deluge.Menus.Upload},"-",{id:"statusbar-traffic",text:"1.53/2,65 KiB/s",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic"},"-",{id:"statusbar-dht",text:"161",cls:"x-btn-text-icon",iconCls:"x-deluge-dht"});this.created=true},onConnect:function(){this.Bar.setStatus({iconCls:"x-connected",text:""});if(!this.created){this.createButtons()}else{this.Bar.items.each(function(a){a.show();a.enable()})}},onDisconnect:function(){this.Bar.clearStatus({useDefaults:true});this.Bar.items.each(function(a){a.hide();a.disable()})},update:function(b){function d(e){return e+" KiB/s"}var a=function(g,f){var h=this.Bar.items.get("statusbar-"+g);if(f.limit.value==-1){var j=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value}else{var i=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value;var e=(f.limit.formatter)?f.limit.formatter(f.limit.value):f.limit.value;var j=String.format(f.format,i,e)}h.setText(j)}.bind(this);a("connections",{value:{value:b.num_connections},limit:{value:b.max_num_connections},format:"{0} ({1})"});a("downspeed",{value:{value:b.download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_download,formatter:d},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:d},format:"{0} ({1})"});a("traffic",{value:{value:b.payload_download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.payload_upload_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.Bar.items.get("statusbar-dht").setText(b.dht_nodes);function c(g,e){var f=g.items.get(e);if(!f){f=g.items.get("other")}f.setChecked(true)}c(Deluge.Menus.Connections,b.max_num_connections);c(Deluge.Menus.Download,b.max_download);c(Deluge.Menus.Upload,b.max_upload)}};Deluge.StatusBar.Bar=new Ext.StatusBar({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected"),listeners:{render:{scope:Deluge.StatusBar,fn:Deluge.StatusBar.onRender}}});Deluge.SideBar={panels:new Hash(),onRender:function(a){this.Bar=a;Deluge.Events.on("disconnect",this.onDisconnect.bindWithEvent(this));this.selected=null},onDisconnect:function(){this.panels.getKeys().each(function(a){this.Bar.remove(a+"-panel")},this);this.panels.empty();this.selected=null},renderer:function(c,e,b){var a=c.toLowerCase().replace(".","_");var d="";if(b.store.id=="tracker_host"){if(c!="Error"){d=String.format("url(/tracker/{0})",c)}else{a=null}}if(d){return String.format('
{0} ({1})
',c,b.data.count,d)}else{if(a){return String.format('
{0} ({1})
',c,b.data.count,a)}else{return String.format('
{0} ({1})
',c,b.data.count)}}},getFilters:function(){var b={};if(!this.selected){return b}if(!this.selected.filter||!this.selected.panel){return b}var a=this.selected.panel.store.id;if(a=="state"&&this.selected.filter=="All"){return b}b[a]=this.selected.filter;return b},update:function(a){a=new Hash(a);a.each(function(b,c){if(this.panels.has(c)){this.updateFilter(c,b)}else{this.createFilter(c,b)}},this);$each(this.panels.getKeys(),function(b){if(!a.has(b)){}})},createFilter:function(d,c){var b=new Ext.data.SimpleStore({id:d,fields:[{name:"filter"},{name:"count"}]});var f=d.replace("_"," ");var e=f.split(" ");f="";e.each(function(g){firstLetter=g.substring(0,1);firstLetter=firstLetter.toUpperCase();g=firstLetter+g.substring(1);f+=g+" "});var a=new Ext.grid.GridPanel({id:d+"-panel",store:b,title:_(f),columns:[{id:"filter",sortable:false,renderer:this.renderer,dataIndex:"filter"}],stripeRows:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:this.onSelect.bindWithEvent(this)}}),hideHeaders:true,autoExpandColumn:"filter",deferredRender:false,autoScroll:true});b.loadData(c);this.Bar.add(a);this.Bar.doLayout();this.panels[d]=a;if(!this.selected){a.getSelectionModel().selectFirstRow();this.selected={row:0,filter:c[0][0],panel:a}}},onSelect:function(b,c,a){if(!this.selected){needsUpdate=true}else{if(this.selected.row!=c){needsUpdate=true}else{needsUpdate=false}}this.selected={row:c,filter:a.get("filter"),panel:this.panels[a.store.id]};if(needsUpdate){Deluge.UI.update()}},updateFilter:function(b,a){this.panels[b].store.loadData(a);if(this.selected&&this.selected.panel==this.panels[b]){this.panels[b].getSelectionModel().selectRow(this.selected.row)}}};Deluge.SideBar.Config={region:"west",id:"sidebar",cls:"deluge-sidebar",title:_("Filters"),layout:"accordion",split:true,width:200,minSize:175,collapsible:true,margins:"5 0 0 5",cmargins:"5 5 0 5",listeners:{render:{scope:Deluge.SideBar,fn:Deluge.SideBar.onRender}}};Deluge.Connections={disconnect:function(){Deluge.Events.fire("disconnect")},loginShow:function(){Deluge.Events.on("logout",function(a){Deluge.Connections.disconnect();Deluge.Connections.Window.hide()});Deluge.Client.web.connected({onSuccess:function(a){if(a){Deluge.Events.fire("connect")}else{Deluge.Connections.Window.show()}}})},onAdd:function(a,b){Deluge.Connections.Add.show()},onAddHost:function(){var d=Deluge.Connections.Add.items.first();var c=d.items.get("host").getValue();var a=d.items.get("port").getValue();var e=d.items.get("username").getValue();var b=d.items.get("_password").getValue();Deluge.Client.web.add_host(c,a,e,b,{onSuccess: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{Deluge.Connections.runCheck()}Deluge.Connections.Add.hide()}})},onAddWindowHide:function(){var a=Deluge.Connections.Add.items.first();a.items.get("host").reset();a.items.get("port").reset();a.items.get("username").reset();a.items.get("_password").reset()},onClose:function(a){$clear(Deluge.Connections.running);Deluge.Connections.Window.hide()},onConnect:function(b){var a=Deluge.Connections.Grid.getSelectionModel().getSelected();if(!a){return}if(a.get("status")==_("Connected")){Deluge.Client.web.disconnect({onSuccess:function(d){Deluge.Connections.runCheck();Deluge.Events.fire("disconnect")}})}else{var c=a.id;Deluge.Client.web.connect(c,{onSuccess:function(d){Deluge.Client=new JSON.RPC("/json",{methods:d});Deluge.Events.fire("connect")}});$clear(Deluge.Connections.running);Deluge.Connections.Window.hide()}},onGetHosts:function(a){Deluge.Connections.Store.loadData(a);var b=Deluge.Connections.Grid.getSelectionModel();b.selectRow(Deluge.Connections.selectedRow)},onRemove:function(b){var a=Deluge.Connections.Grid.getSelectionModel().getSelected();Deluge.Client.web.remove_host(a.id,{onSuccess:function(c){if(!c){Ext.MessageBox.show({title:_("Error"),msg:c[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{Deluge.Connections.Grid.store.remove(a)}}})},onSelect:function(b,d,a){Deluge.Connections.selectedRow=d;var c=Deluge.Connections.Window.buttons[1];if(a.get("status")==_("Connected")){c.setText(_("Disconnect"))}else{c.setText(_("Connect"))}},onShow:function(a){Deluge.Connections.running=Deluge.Connections.runCheck.periodical(2000);Deluge.Connections.runCheck()},onStop:function(b,c){var a=Deluge.Connections.Grid.getSelectionModel().getSelected();Deluge.Client.web.stop_daemon(a.id,{onSuccess:function(d){if(!d[0]){Ext.MessageBox.show({title:_("Error"),msg:d[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}}})},runCheck:function(a){a=$pick(a,Deluge.Connections.onGetHosts);Deluge.Client.web.get_hosts({onSuccess:a})}};Deluge.Connections.Store=new Ext.data.SimpleStore({fields:[{name:"status",mapping:3},{name:"host",mapping:1},{name:"port",mapping:2},{name:"version",mapping:4}],id:0});var renderHost=function(b,c,a){return b+":"+a.data.port};Deluge.Connections.Grid=new Ext.grid.GridPanel({store:Deluge.Connections.Store,columns:[{header:"Status",width:65,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"status"},{id:"host",header:"Host",width:150,sortable:true,renderer:renderHost,dataIndex:"host"},{header:"Version",width:75,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"version"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:Deluge.Connections.onSelect}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{id:"add",cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:Deluge.Connections.onAdd},{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:Deluge.Connections.onRemove},"->",{id:"stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),icon:"/icons/error.png",handler:Deluge.Connections.onStop}]})});Deluge.Connections.Add=new Ext.Window({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",items:[new Ext.form.FormPanel({defaultType:"textfield",id:"connectionAddForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Host"),id:"host",name:"host",anchor:"100%",listeners:{}},{fieldLabel:_("Port"),id:"port",xtype:"uxspinner",ctCls:"x-form-uxspinner",name:"port",strategy:Ext.ux.form.Spinner.NumberStrategy(),value:"58846",anchor:"50%",listeners:{}},{fieldLabel:_("Username"),id:"username",name:"username",anchor:"100%",listeners:{}},{fieldLabel:_("Password"),anchor:"100%",id:"_password",name:"_password",inputType:"password"}]})],buttons:[{text:_("Close"),handler:function(){Deluge.Connections.Add.hide()}},{text:_("Add"),handler:Deluge.Connections.onAddHost}],listeners:{hide:Deluge.Connections.onAddWindowHide}});Deluge.Connections.Window=new 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",items:[Deluge.Connections.Grid],buttons:[{text:_("Close"),handler:Deluge.Connections.onClose},{text:_("Connect"),handler:Deluge.Connections.onConnect}],listeners:{hide:Deluge.Connections.onClose,show:Deluge.Connections.onShow}});(function(){function f(i){return(i==-1)?"":i+1}function b(j,k,i){return String.format('
{1}
',i.data.state.toLowerCase(),j)}function h(i){if(!i){return}return fspeed(i)}function c(l,m,k){var i=l.toInt();var n=k.data.state+" "+l.toFixed(2)+"%";var j=this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt()-8;return Deluge.progressBar(l.toInt(),j,n)}function e(j,k,i){if(i.data.total_seeds>-1){return String.format("{0} ({1})",j,i.data.total_seeds)}else{return j}}function g(j,k,i){if(i.data.total_peers>-1){return String.format("{0} ({1})",j,i.data.total_peers)}else{return j}}function d(j,k,i){j.toFixed(3)}function a(j,k,i){return String.format('
{0}
',j)}Ext.namespace("Ext.deluge");Ext.deluge.TorrentGrid=function(i){Ext.deluge.TorrentGrid.superclass.constructor.call(this,{id:"torrentGrid",store:new Ext.data.SimpleStore({fields:[{name:"queue"},{name:"name"},{name:"size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"peers",type:"int"},{name:"total_peers",type:"int"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"avail",type:"float"},{name:"added",type:"int"},{name:"tracker"}],id:16}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:f,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:b,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"size"},{header:_("Progress"),width:150,sortable:true,renderer:c,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:e,dataIndex:"seeds"},{header:_("Peers"),width:60,sortable:true,renderer:g,dataIndex:"peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:h,dataIndex:"downspeed"},{header:_("Up Speed"),width:80,sortable:true,renderer:h,dataIndex:"upspeed"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:d,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:d,dataIndex:"avail"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"added"},{header:_("Tracker"),width:120,sortable:true,renderer:a,dataIndex:"tracker"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0"})};Ext.extend(Ext.deluge.TorrentGrid,Ext.grid.GridPanel,{initComponent:function(){Ext.deluge.TorrentGrid.superclass.initComponent.call(this);Deluge.Events.on("torrentRemoved",this.onTorrentRemoved,this);this.on("rowcontextmenu",function(i,l,k){k.stopEvent();var j=i.getSelectionModel();if(!j.hasSelection()){j.selectRow(l)}Deluge.Menus.Torrent.showAt(k.getPoint())})},getTorrent:function(i){return this.getStore().getAt(i)},getSelected:function(){return this.getSelectionModel().getSelected()},getSelections:function(){return this.getSelectionModel().getSelections()},onTorrentRemoved:function(j){var i=this.Grid.getSelectionModel();$each(j,function(l){var k=this.Store.getById(l);if(i.isSelected(k)){i.deselectRow(this.Store.indexOf(k))}this.Store.remove(k)},this)}});Deluge.Torrents=new Ext.deluge.TorrentGrid()})();Deluge.Details={clear:function(){this.Panel.items.each(function(a){if(a.clear){a.clear()}})},update:function(a){var b=Deluge.Torrents.getSelected();if(!b){return}a=a||this.Panel.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(a){Deluge.Torrents.on("rowclick",this.onTorrentsClick.bindWithEvent(this));var b=Deluge.Torrents.getSelectionModel();b.on("selectionchange",function(c){if(!c.hasSelection()){this.clear.delay(10,this)}}.bindWithEvent(this));Deluge.Events.on("disconnect",this.clear.bind(this))},onTabChange:function(a,b){this.update(b)},onTorrentsClick:function(a,c,b){this.update()}};Deluge.Details.Status={onRender:function(a){this.panel=a;this.progressBar=new Ext.ux.FullProgressBar({id:"pbar-status",cls:"deluge-status-progressbar"});this.panel.add(this.progressBar);this.panel.add({id:"status-details",cls:"deluge-status",border:false,listeners:{render:Deluge.Details.Status.onStatusRender}});this.panel.update=this.update.bind(this);this.panel.clear=this.clear.bind(this)},onStatusRender:function(a){this.status=a;this.status.load({url:"/render/tab_status.html",text:_("Loading")+"..."})},onRequestComplete:function(a){seeders=a.total_seeds>-1?a.num_seeds+" ("+a.total_seeds+")":a.num_seeds;peers=a.total_peers>-1?a.num_peers+" ("+a.total_peers+")":a.num_peers;var b={downloaded:fsize(a.total_done)+" ("+fsize(a.total_payload_download)+")",uploaded:fsize(a.total_uploaded)+" ("+fsize(a.total_payload_upload)+")",share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:fspeed(a.download_payload_rate),upspeed:fspeed(a.upload_payload_rate),eta:ftime(a.eta),pieces:a.num_pieces+" ("+fsize(a.piece_length)+")",seeders:seeders,peers:peers,avail:a.distributed_copies.toFixed(3),active_time:ftime(a.active_time),seeding_time:ftime(a.seeding_time),seed_rank:a.seed_rank,auto_managed:"False",time_added:fdate(a.time_added)};if(a.is_auto_managed){b.auto_managed="True"}this.fields.each(function(e,d){e.set("text",b[d])},this);var c=a.state+" "+a.progress.toFixed(2)+"%";this.progressBar.updateProgress(a.progress,c)},getFields:function(){var a=this.panel.items.get("status-details");this.fields=new Hash();$(a.body.dom).getElements("dd").each(function(b){this.fields[b.getProperty("class")]=b},this)},update:function(a){if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Status,{onSuccess:this.onRequestComplete.bind(this)})},clear:function(){if(!this.fields){return}this.progressBar.updateProgress(0," ");this.fields.each(function(b,a){b.set("text","")},this)}};Deluge.Details.Details={onRender:function(a){this.panel=a;a.load({url:"/render/tab_details.html",text:_("Loading")+"...",callback:this.onLoaded.bindWithEvent(this)});this.doUpdate=false;this.panel.update=this.update.bind(this);this.panel.clear=this.clear.bind(this)},onLoaded:function(){this.getFields();this.doUpdate=true;if(Deluge.Details.Panel.getActiveTab()==this.panel){Deluge.Details.update(this.panel)}},onRequestComplete:function(c,a){var b={torrent_name:c.name,hash:a,path:c.save_path,size:fsize(c.total_size),files:c.num_files,status:c.tracker_status,tracker:c.tracker,comment:c.comment};this.fields.each(function(e,d){e.set("text",b[d])},this)},getFields:function(){this.fields=new Hash();$(this.panel.body.dom.firstChild).getElements("dd").each(function(a){this.fields[a.getProperty("class")]=a},this)},update:function(a){if(!this.doUpdate){return}if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Details,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})},clear:function(){if(!this.fields){return}this.fields.each(function(b,a){b.set("text","")},this)}};Deluge.Details.Files={onRender:function(a){this.panel=a;this.panel.clear=this.clear.bind(this);this.panel.update=this.update.bind(this);new Ext.tree.TreeSorter(this.panel,{folderSort:true});Deluge.Menus.FilePriorities.on("itemclick",this.onItemClick.bindWithEvent(this))},onContextMenu:function(b,c){c.stopEvent();var a=this.panel.getSelectionModel();if(a.getSelectedNodes().length<2){a.clearSelections();b.select()}Deluge.Menus.FilePriorities.showAt(c.getPoint())},onItemClick:function(f,d){switch(f.id){case"expandAll":this.panel.expandAll();break;default:var c=new Hash();function a(e){if(!$defined(e.attributes.fileIndex)){return}c[e.attributes.fileIndex]=e.attributes.priority}this.panel.getRootNode().cascade(a);var b=this.panel.getSelectionModel().getSelectedNodes();$each(b,function(e){if(!$defined(e.attributes.fileIndex)){return}c[e.attributes.fileIndex]=f.filePriority});priorities=new Array(c.getLength());c.each(function(g,e){priorities[e]=g});Deluge.Client.core.set_torrent_file_priorities(this.torrentId,priorities,{onSuccess:function(){$each(b,function(e){e.setColumnValue(3,f.filePriority)})}.bind(this)});break}},onRequestComplete:function(d,c){if(this.torrentId!=c){this.clear();this.torrentId=c}function b(f,e){$each(f,function(h,g){var i=e.findChild("id",g);if($type(h)=="object"){if(!i){i=new Ext.tree.TreeNode({id:g,text:g});e.appendChild(i)}b(h,i)}else{if(!i){i=new Ext.tree.ColumnTreeNode({id:g,filename:g,text:g,fileIndex:h[0],size:h[1],progress:h[2],priority:h[3],leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});e.appendChild(i)}i.setColumnValue(1,h[1]);i.setColumnValue(2,h[2]);i.setColumnValue(3,h[3])}})}var a=this.panel.getRootNode();b(d,a);a.firstChild.expand()},clear:function(){var a=this.panel.getRootNode();if(!a.hasChildNodes()){return}a.cascade(function(c){var b=c.parentNode;if(!b){return}if(!b.ownerTree){return}b.removeChild(c)})},update:function(a){Deluge.Client.web.get_torrent_files(a,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})}};Deluge.Details.Peers={onRender:function(a){this.panel=a;this.panel.update=this.update.bind(this);this.panel.clear=this.clear.bind(this)},onRequestComplete:function(b){var a=new Array();b.peers.each(function(c){a.include([c.country,c.ip,c.client,c.progress,c.down_speed,c.up_speed,c.seed])},this);this.Store.loadData(a)},clear:function(){this.Store.loadData([])},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Peers,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})}};Deluge.Details.Options={onRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout();this.form=a.getForm()},onRequestComplete:function(a){},clear:function(){this.form.findField("max_download_speed").setValue(0);this.form.findField("max_upload_speed").setValue(0);this.form.findField("max_connections").setValue(0);this.form.findField("max_upload_slots").setValue(0);this.form.findField("stop_ratio").setValue(0);this.form.findField("is_auto_managed").setValue(false);this.form.findField("stop_at_ratio").setValue(false);this.form.findField("remove_at_ratio").setValue(false);this.form.findField("private").setValue(false);this.form.findField("prioritize_first_last").setValue(false)},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Options,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})},reset:function(){if(this.torrentId){delete this.changed[this.torrentId]}}};function flag(a){return String.format('',a)}function peer_address(c,d,b){var a=(b.data.seed==1024)?"x-deluge-seed":"x-deluge-peer";return String.format('
{1}
',a,c)}function file_progress(b){var a=b*100;return progressBar(a,this.width-50,a.toFixed(2)+"%")}function peer_progress(c){var a=(c*100).toInt();var b=this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt()-8;return progressBar(a,b,a+"%")}FILE_PRIORITY_CSS={0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};function priority_renderer(a){return String.format('
{1}
',FILE_PRIORITY_CSS[a],_(FILE_PRIORITY[a]))}function sort_address(c){var a=c.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);var b=0;var d=[a[1],a[2],a[3],a[4]];$each(d,function(f,e){f=parseInt(f);b=b|f<<((3-e)*8);alert("Total: "+b+"\nPart: "+f+"\nIndex: "+e+"\nCalc: "+(f<<((3-e)*8)))});return b}Deluge.Details.Peers.Store=new Ext.data.SimpleStore({fields:[{name:"country"},{name:"address",sortType:sort_address},{name:"client"},{name:"progress",type:"float"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"seed",type:"int"}],id:0});Deluge.Details.Panel=new Ext.TabPanel({region:"south",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0,items:[{id:"status",title:_("Status"),listeners:{render:{fn:Deluge.Details.Status.onRender,scope:Deluge.Details.Status}}},{id:"details",title:_("Details"),cls:"deluge-status",listeners:{render:{fn:Deluge.Details.Details.onRender,scope:Deluge.Details.Details}}},new Ext.tree.ColumnTree({id:"files",title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{header:_("Progress"),width:150,dataIndex:"progress",renderer:file_progress},{header:_("Priority"),width:150,dataIndex:"priority",renderer:priority_renderer}],root:new Ext.tree.TreeNode({text:"Files"}),listeners:{render:{fn:Deluge.Details.Files.onRender,scope:Deluge.Details.Files},contextmenu:{fn:Deluge.Details.Files.onContextMenu,scope:Deluge.Details.Files}}}),new Ext.grid.GridPanel({id:"peers",title:_("Peers"),cls:"x-deluge-peers",store:Deluge.Details.Peers.Store,columns:[{header:" ",width:30,sortable:true,renderer:flag,dataIndex:"country"},{header:"Address",width:125,sortable:true,renderer:peer_address,dataIndex:"address"},{header:"Client",width:125,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"client"},{header:"Progress",width:150,sortable:true,renderer:peer_progress,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,margins:"0 0 0 0",listeners:{render:{fn:Deluge.Details.Peers.onRender,scope:Deluge.Details.Peers}}}),new Ext.form.FormPanel({id:"options",title:_("Options"),frame:true,autoScroll:true,deferredRender:false,items:[{layout:"column",defaults:{border:false},items:[{bodyStyle:"padding-left: 5px; padding-right:5px;",width:300,items:[{xtype:"fieldset",title:_("Bandwidth"),layout:"table",layoutConfig:{columns:3},autoHeight:true,labelWidth:150,defaultType:"uxspinner",items:[{xtype:"label",text:_("Max Download Speed"),forId:"max_download_speed",cls:"x-deluge-options-label"},{id:"max_download_speed",width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{xtype:"label",text:"KiB/s",style:"margin-left: 10px;"},{xtype:"label",text:_("Max Upload Speed"),forId:"max_upload_speed",cls:"x-deluge-options-label"},{id:"max_upload_speed",width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{xtype:"label",text:"KiB/s",style:"margin-left: 10px;"},{xtype:"label",text:_("Max Connections"),forId:"max_connections",cls:"x-deluge-options-label"},{id:"max_connections",colspan:2,width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{xtype:"label",text:_("Max Upload Slots"),forId:"max_upload_slots",cls:"x-deluge-options-label"},{id:"max_upload_slots",colspan:2,width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})}]}]},{bodyStyle:"padding-left: 5px; padding-right:5px;",width:200,items:[{xtype:"fieldset",title:_("Queue"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Auto Managed"),id:"is_auto_managed"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Stop seed at ratio"),id:"stop_at_ratio"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Remove at ratio"),id:"remove_at_ratio"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Move Completed"),id:"move_completed"}]}]},{bodyStyle:"padding-left:5px;",width:200,items:[{xtype:"fieldset",title:_("General"),autoHeight:true,defaultType:"checkbox",labelWidth:1,items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Private"),id:"private"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"}]},{layout:"column",items:[{items:[{id:"edit_trackers",xtype:"button",text:_("Edit Trackers"),cls:"x-btn-text-icon",iconCls:"x-deluge-edit-trackers",width:100}]},{items:[{id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px",width:100}]}]}]}]}],listeners:{render:{fn:Deluge.Details.Options.onRender,scope:Deluge.Details.Options}}})],listeners:{render:{fn:Deluge.Details.onRender,scope:Deluge.Details},tabchange:{fn:Deluge.Details.onTabChange,scope:Deluge.Details}}});Deluge.Add={torrents:new Hash(),clear:function(){this.clearFiles();this.Store.loadData([]);this.torrents.empty()},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,{onSuccess:function(b){this.defaults=b;$each(b,function(e,d){var f=this.form.findField(d);if(!f){return}f.setValue(e)},this);var c=this.form.findField("compact_allocation");if(b.compact_allocation){c.items.get("compact_allocation_true").setValue(true);c.items.get("compact_allocation_false").setValue(false)}else{c.items.get("compact_allocation_false").setValue(true);c.items.get("compact_allocation_true").setValue(false)}}.bindWithEvent(this)})},onAdd:function(){torrents=new Array();this.torrents.each(function(b,a){torrents.include({path:b.filename,options:{}})});Deluge.Client.web.add_torrents(torrents,{onSuccess:function(a){}});this.clear();this.Window.hide()},onFile:function(){this.File.Window.show()},onOptionsRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout();this.form=a.getForm();this.getDefaults()},onRender:function(a){new Ext.tree.TreeSorter(this.Files,{folderSort:true})},onSelect:function(e,f,c){var d=Deluge.Add.torrents[c.id];function b(h,g){$each(h,function(j,i){if($type(j)=="object"){var k=new Ext.tree.TreeNode({text:i});b(j,k);g.appendChild(k)}else{g.appendChild(new Ext.tree.TreeNode({filename:i,text:i,size:fsize(j[0]),leaf:true,checked:j[1],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI}))}})}this.clearFiles();var a=this.Files.getRootNode();b(d.files_tree,a);a.firstChild.expand()},onTorrentAdded:function(b,a){if(!b){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}b.filename=a;this.Store.loadData([[b.info_hash,b.name]],true);this.torrents[b.info_hash]=b},onUrl:function(a,b){this.Url.Window.show()},onRemove:function(){var a=this.Grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();delete this.torrents[b.id];this.Store.remove(b);this.clearFiles()}};Deluge.Add.Files=new Ext.tree.ColumnTree({id:"files",layout:"fit",rootVisible:false,autoScroll:true,height:170,border:false,animate:false,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{header:_("Size"),width:80,dataIndex:"size"}],root:new Ext.tree.AsyncTreeNode({text:"Files"})});Deluge.Add.Store=new Ext.data.SimpleStore({fields:[{name:"torrent",mapping:1}],id:0});Deluge.Add.Grid=new Ext.grid.GridPanel({store:Deluge.Add.Store,region:"center",columns:[{id:"torrent",width:150,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"torrent"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:Deluge.Add.onSelect,scope:Deluge.Add}}}),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:Deluge.Add.onFile,scope:Deluge.Add},{id:"url",cls:"x-btn-text-icon",text:_("Url"),icon:"/icons/add_url.png",handler:Deluge.Add.onUrl,scope:Deluge.Add},{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:Deluge.Add.onRemove,scope:Deluge.Add}]})});Deluge.Add.Options=new Ext.TabPanel({region:"south",margins:"5 5 5 5",activeTab:0,height:220,items:[{id:"addFilesTab",title:_("Files"),items:[Deluge.Add.Files]},{id:"addOptionsTab",title:_("Options"),layout:"fit",items:[new Ext.form.FormPanel({id:"addOptionsForm",bodyStyle:"padding: 5px;",border:false,items:[{xtype:"fieldset",style:"padding: 0px; padding-top: 5px;",title:_("Download Location"),border:false,autoHeight:true,border:false,labelWidth:1,items:[{layout:"column",border:false,items:[{xtype:"textfield",id:"download_location",fieldLabel:"",labelSeparator:"",width:330},{border:false,style:"padding-left: 5px;",items:[{xtype:"button",text:_("Browse")+"...",disabled:true}]}]}]},{layout:"column",border:false,defaults:{border:false},items:[{xtype:"fieldset",bodyStyle:"margin-left: 5px; margin-right:5px;",title:_("Allocation"),autoHeight:true,border:false,labelWidth:1,width:100,items:[new Ext.form.RadioGroup({id:"compact_allocation",name:"compact_allocation",columns:1,labelSeparator:"",items:[{boxLabel:_("Full"),inputValue:"false",id:"compact_allocation_false",name:"compact_allocation",checked:true},{boxLabel:_("Compact"),inputValue:"true",id:"compact_allocation_true",name:"compact_allocation"}]})]},{xtype:"fieldset",title:_("Bandwidth"),layout:"form",autoHeight:true,defaultType:"uxspinner",labelWidth:100,items:[{id:"max_download_speed_per_torrent",fieldLabel:_("Max Down Speed"),width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{id:"max_upload_speed_per_torrent",fieldLabel:_("Max Up Speed"),width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{id:"max_connections_per_torrent",fieldLabel:_("Max Connections"),width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{id:"max_upload_slots_per_torrent",fieldLabel:_("Max Upload Slots"),colspan:2,width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})}]},{xtype:"fieldset",title:_("General"),autoHeight:true,border:false,labelWidth:10,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Add In Paused State"),id:"add_paused"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last Piece"),id:"prioritize_first_last_pieces"},{xtype:"button",text:_("Apply to All"),style:"margin-left: 20px; margin-top: 5px;"},{xtype:"button",text:_("Revert to Defaults"),style:"margin-left: 20px; margin-top: 5px;"}]}]}],listeners:{render:{fn:Deluge.Add.onOptionsRender,scope:Deluge.Add}}})]}]});Deluge.Add.File={onAdd:function(){if(this.form.getForm().isValid()){this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),success:this.onUploadSuccess.bindWithEvent(this)})}},onUploadSuccess:function(c,b){this.Window.hide();var a=b.result.toString();this.form.items.get("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{onSuccess:Deluge.Add.onTorrentAdded.bindWithEvent(Deluge.Add,a)})}};Deluge.Add.File.form=new Ext.form.FormPanel({fileUpload:true,id:"fileAddForm",baseCls:"x-plain",labelWidth:55,autoHeight:true,items:[{xtype:"fileuploadfield",id:"torrentFile",emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]});Deluge.Add.File.Window=new Ext.Window({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",items:Deluge.Add.File.form,buttons:[{text:_("Add"),handler:Deluge.Add.File.onAdd,scope:Deluge.Add.File}]});Deluge.Add.Url={onAdd:function(c,b){if(c.id=="url"&&b.getKey()!=b.ENTER){return}var c=this.form.items.get("url");var a=c.getValue();Deluge.Client.web.download_torrent_from_url(a,{onSuccess:this.onDownload.bindWithEvent(this)});this.Window.hide()},onDownload:function(a){this.form.items.get("url").setValue("");Deluge.Client.web.get_torrent_info(a,{onSuccess:Deluge.Add.onTorrentAdded.bindWithEvent(Deluge.Add,a)})}};Deluge.Add.Url.form=new Ext.form.FormPanel({defaultType:"textfield",id:"urlAddForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Url"),id:"url",name:"url",inputType:"url",anchor:"100%",listeners:{specialkey:{fn:Deluge.Add.Url.onAdd,scope:Deluge.Add.Url}}}]});Deluge.Add.Url.Window=new Ext.Window({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon",items:Deluge.Add.Url.form,buttons:[{text:_("Add"),handler:Deluge.Add.Url.onAdd,scope:Deluge.Add.Url}]});Deluge.Add.Window=new Ext.Window({layout:"border",width:470,height:450,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Add Torrents"),iconCls:"x-deluge-add-window-icon",items:[Deluge.Add.Grid,Deluge.Add.Options],buttons:[{text:_("Cancel"),handler:function(){Deluge.Add.clear();Deluge.Add.Window.hide()}},{text:_("Add"),handler:Deluge.Add.onAdd,scope:Deluge.Add}],listeners:{render:{fn:Deluge.Add.onRender,scope:Deluge.Add}}});(function(){PreferencesWindow=function(a){Ext.apply(this,a);this.layout="border";this.width=485;this.height=500;this.buttonAlign="right";this.closeAction="hide";this.closable=true;this.iconCls="x-deluge-preferences";this.plain=true;this.resizable=false;this.title=_("Preferences");this.buttons=[{text:_("Close"),handler:this.onCloseButtonClick,scope:this},{text:_("Apply")},{text:_("Ok")}];this.currentPage=false;this.items=[{xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.SimpleStore({fields:[{name:"name",mapping:0}]}),columns:[{id:"name",renderer:fplain,dataIndex:"name"}],sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPageSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 0 5 5",cmargins:"5 0 5 5",width:120,collapsible:true},{region:"center",title:" ",layout:"fit",height:400,margins:"5 5 5 5",cmargins:"5 5 5 5"}];PreferencesWindow.superclass.constructor.call(this)};Ext.extend(PreferencesWindow,Ext.Window,{initComponent:function(){PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.items.get(0);this.configPanel=this.items.get(1);this.pages={};this.on("show",this.onShow.bindWithEvent(this))},onCloseButtonClick:function(){this.hide()},addPage:function(b,c){var a=this.categoriesGrid.getStore();a.loadData([[b]],true);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);this.pages[b].hide()},onPageSelect:function(a,d,c){if(this.currentPage){this.currentPage.hide()}var b=c.get("name");this.pages[b].show();this.configPanel.setTitle(b);this.currentPage=this.pages[b];this.configPanel.doLayout()},onShow:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}}});Deluge.Preferences=new PreferencesWindow();Deluge.Preferences.addPage(_("Downloads"),{border:false,xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Folders"),labelWidth:140,defaultType:"textfield",autoHeight:true,items:[{name:"download_location",fieldLabel:_("Download to"),width:125},{name:"move_completed",fieldLabel:_("Move completed to"),width:125},{name:"copy_torrent_files",fieldLabel:_("Copy of .torrent files to"),width:125}]},{xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radio",items:[{name:"compact_allocation",labelSeparator:"",boxLabel:_("Compact")},{name:"compact_allocation",labelSeparator:"",boxLabel:_("Full")}]},{xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{name:"prioritize_first_last",labelSeparator:"",boxLabel:_("Prioritize first and last pieces of torrent")},{name:"add_paused",labelSeparator:"",boxLabel:_("Add torrents in Paused state")}]}]});Deluge.Preferences.addPage(_("Bandwidth"),{border:false,xtype:"form",layout:"form",labelWidth:10,items:[{xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),autoHeight:true,labelWidth:200,style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"uxspinner",items:[{name:"max_connections",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1},{name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:60,value:-1},{name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:60,value:-1}]},{xtype:"fieldset",border:false,title:"",autoHeight:true,style:"padding-top: 0px; margin-top: 0px; margin-bottom: 0px;",items:[{xtype:"checkbox",name:"ignore_local",fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),value:-1},{xtype:"checkbox",name:"limit_ip_overhead",fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),value:-1}]},{xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),autoHeight:true,labelWidth:200,defaultType:"uxspinner",items:[{name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1}]}]});Deluge.Preferences.addPage(_("Interface"),{border:false,xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Window"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar"),id:"show_session_speed"}]},{xtype:"fieldset",border:false,title:_("Sidebar"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Hide filters with zero torrents"),id:"hide_sidebar_zero"}]},{xtype:"fieldset",border:false,title:_("Password"),autoHeight:true,defaultType:"textfield",items:[{fieldLabel:"New Password",inputType:"password",id:"new_password"},{inputType:"password",fieldLabel:"Confirm Password",id:"confirm_password"}]}]});Deluge.Preferences.addPage(_("Daemon"),{border:false,xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"uxspinner",items:[{fieldLabel:_("Daemon port"),id:"daemon_port"}]},{xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Allow Remote Connections"),id:"allow_remote"}]},{xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_releases"}]}]})})();Deluge.UI={initialize:function(){this.errorCount=0;Ext.state.Manager.setProvider(new Ext.state.CookieProvider());this.MainPanel=new Ext.Panel({id:"mainPanel",iconCls:"x-deluge-main-panel",title:"Deluge",layout:"border",tbar:Deluge.ToolBar.Bar,items:[Deluge.SideBar.Config,Deluge.Details.Panel,Deluge.Torrents],bbar:Deluge.StatusBar.Bar});this.Viewport=new Ext.Viewport({layout:"fit",items:[this.MainPanel]});Deluge.Login.show();Deluge.Events.on("connect",this.onConnect.bindWithEvent(this));Deluge.Events.on("disconnect",this.onDisconnect.bindWithEvent(this));Deluge.Client=new JSON.RPC("/json")},update:function(){var a=Deluge.SideBar.getFilters();Deluge.Client.web.update_ui(Deluge.Keys.Grid,a,{onSuccess:this.onUpdate.bindWithEvent(this),onFailure:this.onUpdateError.bindWithEvent(this)});Deluge.Details.update();Deluge.Client.web.connected({onSuccess:this.onConnectedCheck.bindWithEvent(this)})},onConnectedCheck:function(a){if(!a){Deluge.Events.fire("disconnect")}},onUpdateError:function(a){if(this.errorCount==2){Ext.MessageBox.show({title:"Lost Connection",msg:"The connection to the webserver has been lost!",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}this.errorCount++},onUpdate:function(b){var a=new Array();$each(b.torrents,function(c,d){a.include([c.queue,c.name,c.total_size,c.state,c.progress,c.num_seeds,c.total_seeds,c.num_peers,c.total_peers,c.download_payload_rate,c.upload_payload_rate,c.eta,c.ratio,c.distributed_copies,c.time_added,c.tracker_host,d])});Deluge.Torrents.getStore().loadData(a);Deluge.StatusBar.update(b.stats);Deluge.SideBar.update(b.filters);this.errorCount=0},onConnect:function(){if(!this.running){this.running=this.update.periodical(2000,this);this.update()}},onDisconnect:function(){this.stop();this.notify("Disconnected","Deluge has disconnected from the daemon")},stop:function(){if(this.running){$clear(this.running);this.running=false;Deluge.Torrents.Store.loadData([])}}};document.addEvent("domready",function(a){Deluge.UI.initialize()}); \ No newline at end of file +JSON.RPC=new Class({Implements:Options,options:{async:true,methods:[]},initialize:function(b,a){this.setOptions(a);this.url=b;if(this.options.methods.length==0){this._setMethods(this._execute("system.listMethods",{async:false}))}else{this._setMethods(this.options.methods)}},_setMethods:function(b){var a=new Hash();b.forEach(function(f){var e=f.split(".");var c=$pick(a[e[0]],new Hash());var d=function(){var g=this._parseargs(arguments);return this._execute(f,g)}.bind(this);c[e[1]]=d;a[e[0]]=c},this);a.each(function(c,d){this[d]=c},this)},_parseargs:function(c){var f=$A(c),b=f.getLast();if($type(b)=="object"){var a=["async","onRequest","onComplete","onSuccess","onFailure","onException","onCancel"],e=new Hash(b).getKeys(),d=false;a.each(function(g){if(e.contains(g)){d=true}});if(d){f.erase(b)}else{b={}}}else{b={}}b.params=f;return b},_execute:function(c,a){a=$pick(a,{});a.params=$pick(a.params,[]);a.async=$pick(a.async,this.options.async);data=JSON.encode({method:c,params:a.params,id:1});var b=new Request.JSON({url:this.url,async:a.async,onRequest:a.onRequest,onComplete:a.onComplete,onSuccess:function(d){if(a.onSuccess){a.onSuccess(d.result)}},onFailure:a.onFailure,onException:a.onException,onCancel:a.onCancel}).send(data);if(!a.async){return b.response.json.result}}});var Deluge={author:"Damien Churchill ",version:"1.2-dev"};(function(){var a='
{0}
{0}
';Deluge.progressBar=function(c,e,g){var b=(e/100)*c;var d=b.toInt()-1;var f=((b.toInt()-10)>0?b.toInt()-10:0);return String.format(a,g,e,d,f)}})();Deluge.Events={_events:new Hash(),fire:function(){arguments=$A(arguments);var b=arguments.shift();var a=arguments;if(!this._events[b]){return}$each(this._events[b],function(c){c.attempt(a)})},on:function(a,b){var c=$pick(this._events[a],new Array());c.include(b);this._events[a]=c},removeListener:function(a,b){if(!this._events[a]){return}this._events[a].remove(b)}};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}};FILE_PRIORITY={0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority","Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};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","seeds"],Details:["name","save_path","total_size","num_files","tracker_status","tracker","comment"],Options:["max_download_speed","max_upload_speed","max_connections","max_upload_slots","is_auto_managed","stop_at_ratio","stop_ratio","remove_at_ratio","private","prioritize_first_last"]};Deluge.Keys.Status.extend(Deluge.Keys.Grid);(function(){var a=function(b){Ext.apply(this,{layout:"fit",width:300,height:120,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",closable:false,modal:true,plain:true,resizable:false,title:_("Login"),iconCls:"x-deluge-login-window-icon"});Ext.apply(this,b);a.superclass.constructor.call(this)};Ext.extend(a,Ext.Window,{initComponent:function(){a.superclass.initComponent.call();Deluge.Events.on("logout",this.onLogout);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.loginForm=this.add({xtype:"form",defaultType:"textfield",id:"loginForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Password"),id:"password",name:"password",inputType:"password",anchor:"100%",listeners:{specialkey:{fn:this.onKey,scope:this}}}]})},onKey:function(c,b){if(b.getKey()==13){this.onLogin()}},onLogin:function(){var b=this.loginForm.items.get("password");Deluge.Client.web.login(b.getValue(),{onSuccess:function(c){if(c==true){this.hide();Deluge.Connections.loginShow();b.setRawValue("");Deluge.Events.fire("login")}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){b.focus()},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}}.bindWithEvent(this)})},onLogout:function(){this.show()},onShow:function(){var b=this.loginForm.items.get("password");b.focus(false,150)}});Deluge.Login=new a()})();Deluge.Menus={onTorrentAction:function(c,d){var b=Deluge.Torrents.getSelections();var a=new Array();$each(b,function(e){a.include(e.id)});switch(c.id){case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{onSuccess:function(){Deluge.UI.update()}});break;case"top":case"up":case"down":case"bottom":Deluge.Client.core["queue_"+c.id](a,{onSuccess:function(){Deluge.UI.update()}});break;case"update":Deluge.Client.core.force_reannounce(a,{onSuccess:function(){Deluge.UI.update()}});break;case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{onSuccess:function(){Deluge.UI.update()}});break;case"recheck":Deluge.Client.core.force_recheck(a,{onSuccess:function(){Deluge.UI.update()}});break}}};Deluge.Menus.Torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{id:"pause",text:_("Pause"),icon:"/icons/pause.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"resume",text:_("Resume"),icon:"/icons/start.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"options",text:_("Options"),icon:"/icons/preferences.png",menu:new Ext.menu.Menu({items:[{text:_("D/L Speed Limit"),iconCls:"x-deluge-downloading",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("U/L Speed Limit"),iconCls:"x-deluge-seeding",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("Connection Limit"),iconCls:"x-deluge-connections",menu:new Ext.menu.Menu({items:[{text:_("50")},{text:_("100")},{text:_("200")},{text:_("300")},{text:_("500")},{text:_("Unlimited")}]})},{text:_("Upload Slot Limit"),icon:"/icons/upload_slots.png",menu:new Ext.menu.Menu({items:[{text:_("0")},{text:_("1")},{text:_("2")},{text:_("3")},{text:_("5")},{text:_("Unlimited")}]})},{id:"auto_managed",text:_("Auto Managed"),checked:false}]})},"-",{text:_("Queue"),icon:"/icons/queue.png",menu:new Ext.menu.Menu({items:[{id:"top",text:_("Top"),icon:"/icons/top.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"up",text:_("Up"),icon:"/icons/up.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"down",text:_("Down"),icon:"/icons/down.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"bottom",text:_("Bottom"),icon:"/icons/bottom.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]})},"-",{id:"update",text:_("Update Tracker"),icon:"/icons/update.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{edit:"edit_trackers",text:_("Edit Trackers"),icon:"/icons/edit_trackers.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"remove",text:_("Remove Torrent"),icon:"/icons/remove.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{id:"recheck",text:_("Force Recheck"),icon:"/icons/recheck.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{id:"move",text:_("Move Storage"),icon:"/icons/move.png",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]});Deluge.Menus.Connections=new Ext.menu.Menu({id:"connectionsMenu",items:[{id:"50",text:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"100",text:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"200",text:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"500",text:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Download=new Ext.menu.Menu({id:"downspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Upload=new Ext.menu.Menu({id:"upspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.FilePriorities=new Ext.menu.Menu({id:"filePrioritiesMenu",items:[{id:"expandAll",text:_("Expand All"),icon:"/icons/expand_all.png"},"-",{id:"no_download",text:_("Do Not Download"),icon:"/icons/no_download.png",filePriority:0},{id:"normal",text:_("Normal Priority"),icon:"/icons/normal.png",filePriority:1},{id:"high",text:_("High Priority"),icon:"/icons/high.png",filePriority:2},{id:"highest",text:_("Highest Priority"),icon:"/icons/highest.png",filePriority:5}]});function onLimitChanged(b,a){if(b.id=="other"){}else{config={};config[b.group]=b.id;Deluge.Client.core.set_config(config,{onSuccess:function(){Deluge.UI.update()}})}}Deluge.ToolBar={connected_buttons:["add","remove","pause","resume","up","down"],onTorrentAdd:function(){Deluge.Add.Window.show()},onConnect:function(){$each(this.connected_buttons,function(a){this.Bar.items.get(a).enable()},this)},onDisconnect:function(){$each(this.connected_buttons,function(a){this.Bar.items.get(a).disable()},this)},onLogin:function(){this.Bar.items.get("logout").enable()},onLogout:function(){this.Bar.items.get("logout").disable();Deluge.Events.fire("logout");Deluge.Login.show()},onConnectionManagerClick:function(a){Deluge.Connections.Window.show()},onPreferencesClick:function(){Deluge.Preferences.show()},onTorrentAction:function(c){var b=Deluge.Torrents.getSelections();var a=new Array();$each(b,function(d){a.include(d.id)});switch(c.id){case"remove":Deluge.Events.fire("torrentRemoved",a);Deluge.Client.core.remove_torrent(a,null,{onSuccess:function(){Deluge.UI.update()}});break;case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{onSuccess:function(){Deluge.UI.update()}});break;case"up":case"down":Deluge.Client.core["queue_"+c.id](a,{onSuccess:function(){Deluge.UI.update()}});break}},onToolbarRender:function(a){Deluge.Events.on("connect",this.onConnect.bindWithEvent(this));Deluge.Events.on("login",this.onLogin.bindWithEvent(this))}};Deluge.ToolBar.Bar=new Ext.Toolbar({items:[{id:"create",cls:"x-btn-text-icon",disabled:true,text:_("Create"),icon:"/icons/create.png",handler:Deluge.ToolBar.onTorrentAction},{id:"add",cls:"x-btn-text-icon",disabled:true,text:_("Add"),icon:"/icons/add.png",handler:Deluge.ToolBar.onTorrentAdd},{id:"remove",cls:"x-btn-text-icon",disabled:true,text:_("Remove"),icon:"/icons/remove.png",handler:Deluge.ToolBar.onTorrentAction},"|",{id:"pause",cls:"x-btn-text-icon",disabled:true,text:_("Pause"),icon:"/icons/pause.png",handler:Deluge.ToolBar.onTorrentAction},{id:"resume",cls:"x-btn-text-icon",disabled:true,text:_("Resume"),icon:"/icons/start.png",handler:Deluge.ToolBar.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),icon:"/icons/up.png",handler:Deluge.ToolBar.onTorrentAction},{id:"down",cls:"x-btn-text-icon",disabled:true,text:_("Down"),icon:"/icons/down.png",handler:Deluge.ToolBar.onTorrentAction},"|",{id:"preferences",cls:"x-btn-text-icon",text:_("Preferences"),icon:"/icons/preferences.png",handler:Deluge.ToolBar.onPreferencesClick,scope:Deluge.ToolBar},{id:"connectionman",cls:"x-btn-text-icon",text:_("Connection Manager"),iconCls:"x-deluge-connections",handler:Deluge.ToolBar.onConnectionManagerClick,scope:Deluge.ToolBar},"->",{id:"help",cls:"x-btn-text-icon",disabled:true,icon:"/icons/help.png",text:_("Help"),handler:Deluge.ToolBar.onHelpClick,scope:Deluge.ToolBar},{id:"logout",cls:"x-btn-text-icon",icon:"/icons/logout.png",disabled:true,text:_("Logout"),handler:Deluge.ToolBar.onLogout,scope:Deluge.ToolBar}],listeners:{render:Deluge.ToolBar.onToolbarRender,scope:Deluge.ToolBar}});Deluge.StatusBar={onRender:function(){this.bound={onConnect:this.onConnect.bindWithEvent(this),onDisconnect:this.onDisconnect.bindWithEvent(this)};Deluge.Events.on("connect",this.bound.onConnect);Deluge.Events.on("disconnect",this.bound.onDisconnect)},createButtons:function(){this.Bar.add({id:"statusbar-connections",text:"200 (200)",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",menu:Deluge.Menus.Connections},"-",{id:"statusbar-downspeed",text:"9.8KiB/s (30 KiB/s)",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",menu:Deluge.Menus.Download},"-",{id:"statusbar-upspeed",text:"9.8KiB/s (30 KiB/s)",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",menu:Deluge.Menus.Upload},"-",{id:"statusbar-traffic",text:"1.53/2,65 KiB/s",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic"},"-",{id:"statusbar-dht",text:"161",cls:"x-btn-text-icon",iconCls:"x-deluge-dht"});this.created=true},onConnect:function(){this.Bar.setStatus({iconCls:"x-connected",text:""});if(!this.created){this.createButtons()}else{this.Bar.items.each(function(a){a.show();a.enable()})}},onDisconnect:function(){this.Bar.clearStatus({useDefaults:true});this.Bar.items.each(function(a){a.hide();a.disable()})},update:function(b){function d(e){return e+" KiB/s"}var a=function(g,f){var h=this.Bar.items.get("statusbar-"+g);if(f.limit.value==-1){var j=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value}else{var i=(f.value.formatter)?f.value.formatter(f.value.value):f.value.value;var e=(f.limit.formatter)?f.limit.formatter(f.limit.value):f.limit.value;var j=String.format(f.format,i,e)}h.setText(j)}.bind(this);a("connections",{value:{value:b.num_connections},limit:{value:b.max_num_connections},format:"{0} ({1})"});a("downspeed",{value:{value:b.download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_download,formatter:d},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:d},format:"{0} ({1})"});a("traffic",{value:{value:b.payload_download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.payload_upload_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.Bar.items.get("statusbar-dht").setText(b.dht_nodes);function c(g,e){var f=g.items.get(e);if(!f){f=g.items.get("other")}f.setChecked(true)}c(Deluge.Menus.Connections,b.max_num_connections);c(Deluge.Menus.Download,b.max_download);c(Deluge.Menus.Upload,b.max_upload)}};Deluge.StatusBar.Bar=new Ext.StatusBar({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected"),listeners:{render:{scope:Deluge.StatusBar,fn:Deluge.StatusBar.onRender}}});Deluge.SideBar={panels:new Hash(),onRender:function(a){this.Bar=a;Deluge.Events.on("disconnect",this.onDisconnect.bindWithEvent(this));this.selected=null},onDisconnect:function(){this.panels.getKeys().each(function(a){this.Bar.remove(a+"-panel")},this);this.panels.empty();this.selected=null},renderer:function(c,e,b){var a=c.toLowerCase().replace(".","_");var d="";if(b.store.id=="tracker_host"){if(c!="Error"){d=String.format("url(/tracker/{0})",c)}else{a=null}}if(d){return String.format('
{0} ({1})
',c,b.data.count,d)}else{if(a){return String.format('
{0} ({1})
',c,b.data.count,a)}else{return String.format('
{0} ({1})
',c,b.data.count)}}},getFilters:function(){var b={};if(!this.selected){return b}if(!this.selected.filter||!this.selected.panel){return b}var a=this.selected.panel.store.id;if(a=="state"&&this.selected.filter=="All"){return b}b[a]=this.selected.filter;return b},update:function(a){a=new Hash(a);a.each(function(b,c){if(this.panels.has(c)){this.updateFilter(c,b)}else{this.createFilter(c,b)}},this);$each(this.panels.getKeys(),function(b){if(!a.has(b)){}})},createFilter:function(d,c){var b=new Ext.data.SimpleStore({id:d,fields:[{name:"filter"},{name:"count"}]});var f=d.replace("_"," ");var e=f.split(" ");f="";e.each(function(g){firstLetter=g.substring(0,1);firstLetter=firstLetter.toUpperCase();g=firstLetter+g.substring(1);f+=g+" "});var a=new Ext.grid.GridPanel({id:d+"-panel",store:b,title:_(f),columns:[{id:"filter",sortable:false,renderer:this.renderer,dataIndex:"filter"}],stripeRows:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:this.onSelect.bindWithEvent(this)}}),hideHeaders:true,autoExpandColumn:"filter",deferredRender:false,autoScroll:true});b.loadData(c);this.Bar.add(a);this.Bar.doLayout();this.panels[d]=a;if(!this.selected){a.getSelectionModel().selectFirstRow();this.selected={row:0,filter:c[0][0],panel:a}}},onSelect:function(b,c,a){if(!this.selected){needsUpdate=true}else{if(this.selected.row!=c){needsUpdate=true}else{needsUpdate=false}}this.selected={row:c,filter:a.get("filter"),panel:this.panels[a.store.id]};if(needsUpdate){Deluge.UI.update()}},updateFilter:function(b,a){this.panels[b].store.loadData(a);if(this.selected&&this.selected.panel==this.panels[b]){this.panels[b].getSelectionModel().selectRow(this.selected.row)}}};Deluge.SideBar.Config={region:"west",id:"sidebar",cls:"deluge-sidebar",title:_("Filters"),layout:"accordion",split:true,width:200,minSize:175,collapsible:true,margins:"5 0 0 5",cmargins:"5 5 0 5",listeners:{render:{scope:Deluge.SideBar,fn:Deluge.SideBar.onRender}}};Deluge.Connections={disconnect:function(){Deluge.Events.fire("disconnect")},loginShow:function(){Deluge.Events.on("logout",function(a){Deluge.Connections.disconnect();Deluge.Connections.Window.hide()});Deluge.Client.web.connected({onSuccess:function(a){if(a){Deluge.Events.fire("connect")}else{Deluge.Connections.Window.show()}}})},onAdd:function(a,b){Deluge.Connections.Add.show()},onAddHost:function(){var d=Deluge.Connections.Add.items.first();var c=d.items.get("host").getValue();var a=d.items.get("port").getValue();var e=d.items.get("username").getValue();var b=d.items.get("_password").getValue();Deluge.Client.web.add_host(c,a,e,b,{onSuccess: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{Deluge.Connections.runCheck()}Deluge.Connections.Add.hide()}})},onAddWindowHide:function(){var a=Deluge.Connections.Add.items.first();a.items.get("host").reset();a.items.get("port").reset();a.items.get("username").reset();a.items.get("_password").reset()},onClose:function(a){$clear(Deluge.Connections.running);Deluge.Connections.Window.hide()},onConnect:function(b){var a=Deluge.Connections.Grid.getSelectionModel().getSelected();if(!a){return}if(a.get("status")==_("Connected")){Deluge.Client.web.disconnect({onSuccess:function(d){Deluge.Connections.runCheck();Deluge.Events.fire("disconnect")}})}else{var c=a.id;Deluge.Client.web.connect(c,{onSuccess:function(d){Deluge.Client=new JSON.RPC("/json",{methods:d});Deluge.Events.fire("connect")}});$clear(Deluge.Connections.running);Deluge.Connections.Window.hide()}},onGetHosts:function(a){Deluge.Connections.Store.loadData(a);var b=Deluge.Connections.Grid.getSelectionModel();b.selectRow(Deluge.Connections.selectedRow)},onRemove:function(b){var a=Deluge.Connections.Grid.getSelectionModel().getSelected();Deluge.Client.web.remove_host(a.id,{onSuccess:function(c){if(!c){Ext.MessageBox.show({title:_("Error"),msg:c[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{Deluge.Connections.Grid.store.remove(a)}}})},onSelect:function(b,d,a){Deluge.Connections.selectedRow=d;var c=Deluge.Connections.Window.buttons[1];if(a.get("status")==_("Connected")){c.setText(_("Disconnect"))}else{c.setText(_("Connect"))}},onShow:function(a){Deluge.Connections.running=Deluge.Connections.runCheck.periodical(2000);Deluge.Connections.runCheck()},onStop:function(b,c){var a=Deluge.Connections.Grid.getSelectionModel().getSelected();Deluge.Client.web.stop_daemon(a.id,{onSuccess:function(d){if(!d[0]){Ext.MessageBox.show({title:_("Error"),msg:d[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}}})},runCheck:function(a){a=$pick(a,Deluge.Connections.onGetHosts);Deluge.Client.web.get_hosts({onSuccess:a})}};Deluge.Connections.Store=new Ext.data.SimpleStore({fields:[{name:"status",mapping:3},{name:"host",mapping:1},{name:"port",mapping:2},{name:"version",mapping:4}],id:0});var renderHost=function(b,c,a){return b+":"+a.data.port};Deluge.Connections.Grid=new Ext.grid.GridPanel({store:Deluge.Connections.Store,columns:[{header:"Status",width:65,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"status"},{id:"host",header:"Host",width:150,sortable:true,renderer:renderHost,dataIndex:"host"},{header:"Version",width:75,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"version"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:Deluge.Connections.onSelect}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{id:"add",cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:Deluge.Connections.onAdd},{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:Deluge.Connections.onRemove},"->",{id:"stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),icon:"/icons/error.png",handler:Deluge.Connections.onStop}]})});Deluge.Connections.Add=new Ext.Window({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",items:[new Ext.form.FormPanel({defaultType:"textfield",id:"connectionAddForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Host"),id:"host",name:"host",anchor:"100%",listeners:{}},{fieldLabel:_("Port"),id:"port",xtype:"uxspinner",ctCls:"x-form-uxspinner",name:"port",strategy:Ext.ux.form.Spinner.NumberStrategy(),value:"58846",anchor:"50%",listeners:{}},{fieldLabel:_("Username"),id:"username",name:"username",anchor:"100%",listeners:{}},{fieldLabel:_("Password"),anchor:"100%",id:"_password",name:"_password",inputType:"password"}]})],buttons:[{text:_("Close"),handler:function(){Deluge.Connections.Add.hide()}},{text:_("Add"),handler:Deluge.Connections.onAddHost}],listeners:{hide:Deluge.Connections.onAddWindowHide}});Deluge.Connections.Window=new 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",items:[Deluge.Connections.Grid],buttons:[{text:_("Close"),handler:Deluge.Connections.onClose},{text:_("Connect"),handler:Deluge.Connections.onConnect}],listeners:{hide:Deluge.Connections.onClose,show:Deluge.Connections.onShow}});(function(){function f(i){return(i==-1)?"":i+1}function b(j,k,i){return String.format('
{1}
',i.data.state.toLowerCase(),j)}function h(i){if(!i){return}return fspeed(i)}function c(l,m,k){var i=l.toInt();var n=k.data.state+" "+l.toFixed(2)+"%";var j=this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt()-8;return Deluge.progressBar(l.toInt(),j,n)}function e(j,k,i){if(i.data.total_seeds>-1){return String.format("{0} ({1})",j,i.data.total_seeds)}else{return j}}function g(j,k,i){if(i.data.total_peers>-1){return String.format("{0} ({1})",j,i.data.total_peers)}else{return j}}function d(j,k,i){j.toFixed(3)}function a(j,k,i){return String.format('
{0}
',j)}Ext.namespace("Ext.deluge");Ext.deluge.TorrentGrid=function(i){i=Ext.apply({id:"torrentGrid",store:new Ext.data.SimpleStore({fields:[{name:"queue"},{name:"name"},{name:"size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"peers",type:"int"},{name:"total_peers",type:"int"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"avail",type:"float"},{name:"added",type:"int"},{name:"tracker"}],id:16}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:f,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:b,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"size"},{header:_("Progress"),width:150,sortable:true,renderer:c,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:e,dataIndex:"seeds"},{header:_("Peers"),width:60,sortable:true,renderer:g,dataIndex:"peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:h,dataIndex:"downspeed"},{header:_("Up Speed"),width:80,sortable:true,renderer:h,dataIndex:"upspeed"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:d,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:d,dataIndex:"avail"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"added"},{header:_("Tracker"),width:120,sortable:true,renderer:a,dataIndex:"tracker"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0"},i);Ext.deluge.TorrentGrid.superclass.constructor.call(this,i)};Ext.extend(Ext.deluge.TorrentGrid,Ext.grid.GridPanel,{initComponent:function(){Ext.deluge.TorrentGrid.superclass.initComponent.call(this);Deluge.Events.on("torrentRemoved",this.onTorrentRemoved,this);this.on("rowcontextmenu",function(i,l,k){k.stopEvent();var j=i.getSelectionModel();if(!j.hasSelection()){j.selectRow(l)}Deluge.Menus.Torrent.showAt(k.getPoint())})},getTorrent:function(i){return this.getStore().getAt(i)},getSelected:function(){return this.getSelectionModel().getSelected()},getSelections:function(){return this.getSelectionModel().getSelections()},onTorrentRemoved:function(j){var i=this.Grid.getSelectionModel();$each(j,function(l){var k=this.Store.getById(l);if(i.isSelected(k)){i.deselectRow(this.Store.indexOf(k))}this.Store.remove(k)},this)}});Deluge.Torrents=new Ext.deluge.TorrentGrid()})();Deluge.Details={clear:function(){this.Panel.items.each(function(a){if(a.clear){a.clear()}})},update:function(a){var b=Deluge.Torrents.getSelected();if(!b){return}a=a||this.Panel.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(a){Deluge.Torrents.on("rowclick",this.onTorrentsClick.bindWithEvent(this));var b=Deluge.Torrents.getSelectionModel();b.on("selectionchange",function(c){if(!c.hasSelection()){this.clear.delay(10,this)}}.bindWithEvent(this));Deluge.Events.on("disconnect",this.clear.bind(this))},onTabChange:function(a,b){this.update(b)},onTorrentsClick:function(a,c,b){this.update()}};Deluge.Details.Status={onRender:function(a){this.panel=a;this.progressBar=new Ext.ux.FullProgressBar({id:"pbar-status",cls:"deluge-status-progressbar"});this.panel.add(this.progressBar);this.panel.add({id:"status-details",cls:"deluge-status",border:false,listeners:{render:Deluge.Details.Status.onStatusRender}});this.panel.update=this.update.bind(this);this.panel.clear=this.clear.bind(this)},onStatusRender:function(a){this.status=a;this.status.load({url:"/render/tab_status.html",text:_("Loading")+"..."})},onRequestComplete:function(a){seeders=a.total_seeds>-1?a.num_seeds+" ("+a.total_seeds+")":a.num_seeds;peers=a.total_peers>-1?a.num_peers+" ("+a.total_peers+")":a.num_peers;var b={downloaded:fsize(a.total_done)+" ("+fsize(a.total_payload_download)+")",uploaded:fsize(a.total_uploaded)+" ("+fsize(a.total_payload_upload)+")",share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:fspeed(a.download_payload_rate),upspeed:fspeed(a.upload_payload_rate),eta:ftime(a.eta),pieces:a.num_pieces+" ("+fsize(a.piece_length)+")",seeders:seeders,peers:peers,avail:a.distributed_copies.toFixed(3),active_time:ftime(a.active_time),seeding_time:ftime(a.seeding_time),seed_rank:a.seed_rank,auto_managed:"False",time_added:fdate(a.time_added)};if(a.is_auto_managed){b.auto_managed="True"}this.fields.each(function(e,d){e.set("text",b[d])},this);var c=a.state+" "+a.progress.toFixed(2)+"%";this.progressBar.updateProgress(a.progress,c)},getFields:function(){var a=this.panel.items.get("status-details");this.fields=new Hash();$(a.body.dom).getElements("dd").each(function(b){this.fields[b.getProperty("class")]=b},this)},update:function(a){if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Status,{onSuccess:this.onRequestComplete.bind(this)})},clear:function(){if(!this.fields){return}this.progressBar.updateProgress(0," ");this.fields.each(function(b,a){b.set("text","")},this)}};Deluge.Details.Details={onRender:function(a){this.panel=a;a.load({url:"/render/tab_details.html",text:_("Loading")+"...",callback:this.onLoaded.bindWithEvent(this)});this.doUpdate=false;this.panel.update=this.update.bind(this);this.panel.clear=this.clear.bind(this)},onLoaded:function(){this.getFields();this.doUpdate=true;if(Deluge.Details.Panel.getActiveTab()==this.panel){Deluge.Details.update(this.panel)}},onRequestComplete:function(c,a){var b={torrent_name:c.name,hash:a,path:c.save_path,size:fsize(c.total_size),files:c.num_files,status:c.tracker_status,tracker:c.tracker,comment:c.comment};this.fields.each(function(e,d){e.set("text",b[d])},this)},getFields:function(){this.fields=new Hash();$(this.panel.body.dom.firstChild).getElements("dd").each(function(a){this.fields[a.getProperty("class")]=a},this)},update:function(a){if(!this.doUpdate){return}if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Details,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})},clear:function(){if(!this.fields){return}this.fields.each(function(b,a){b.set("text","")},this)}};Deluge.Details.Files={onRender:function(a){this.panel=a;this.panel.clear=this.clear.bind(this);this.panel.update=this.update.bind(this);new Ext.tree.TreeSorter(this.panel,{folderSort:true});Deluge.Menus.FilePriorities.on("itemclick",this.onItemClick.bindWithEvent(this))},onContextMenu:function(b,c){c.stopEvent();var a=this.panel.getSelectionModel();if(a.getSelectedNodes().length<2){a.clearSelections();b.select()}Deluge.Menus.FilePriorities.showAt(c.getPoint())},onItemClick:function(f,d){switch(f.id){case"expandAll":this.panel.expandAll();break;default:var c=new Hash();function a(e){if(!$defined(e.attributes.fileIndex)){return}c[e.attributes.fileIndex]=e.attributes.priority}this.panel.getRootNode().cascade(a);var b=this.panel.getSelectionModel().getSelectedNodes();$each(b,function(e){if(!$defined(e.attributes.fileIndex)){return}c[e.attributes.fileIndex]=f.filePriority});priorities=new Array(c.getLength());c.each(function(g,e){priorities[e]=g});Deluge.Client.core.set_torrent_file_priorities(this.torrentId,priorities,{onSuccess:function(){$each(b,function(e){e.setColumnValue(3,f.filePriority)})}.bind(this)});break}},onRequestComplete:function(d,c){if(this.torrentId!=c){this.clear();this.torrentId=c}function b(f,e){$each(f,function(h,g){var i=e.findChild("id",g);if($type(h)=="object"){if(!i){i=new Ext.tree.TreeNode({id:g,text:g});e.appendChild(i)}b(h,i)}else{if(!i){i=new Ext.tree.ColumnTreeNode({id:g,filename:g,text:g,fileIndex:h[0],size:h[1],progress:h[2],priority:h[3],leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});e.appendChild(i)}i.setColumnValue(1,h[1]);i.setColumnValue(2,h[2]);i.setColumnValue(3,h[3])}})}var a=this.panel.getRootNode();b(d,a);a.firstChild.expand()},clear:function(){var a=this.panel.getRootNode();if(!a.hasChildNodes()){return}a.cascade(function(c){var b=c.parentNode;if(!b){return}if(!b.ownerTree){return}b.removeChild(c)})},update:function(a){Deluge.Client.web.get_torrent_files(a,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})}};Deluge.Details.Peers={onRender:function(a){this.panel=a;this.panel.update=this.update.bind(this);this.panel.clear=this.clear.bind(this)},onRequestComplete:function(b){var a=new Array();b.peers.each(function(c){a.include([c.country,c.ip,c.client,c.progress,c.down_speed,c.up_speed,c.seed])},this);this.Store.loadData(a)},clear:function(){this.Store.loadData([])},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Peers,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})}};Deluge.Details.Options={onRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout();this.form=a.getForm()},onRequestComplete:function(a){},clear:function(){this.form.findField("max_download_speed").setValue(0);this.form.findField("max_upload_speed").setValue(0);this.form.findField("max_connections").setValue(0);this.form.findField("max_upload_slots").setValue(0);this.form.findField("stop_ratio").setValue(0);this.form.findField("is_auto_managed").setValue(false);this.form.findField("stop_at_ratio").setValue(false);this.form.findField("remove_at_ratio").setValue(false);this.form.findField("private").setValue(false);this.form.findField("prioritize_first_last").setValue(false)},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Options,{onSuccess:this.onRequestComplete.bindWithEvent(this,a)})},reset:function(){if(this.torrentId){delete this.changed[this.torrentId]}}};function flag(a){return String.format('',a)}function peer_address(c,d,b){var a=(b.data.seed==1024)?"x-deluge-seed":"x-deluge-peer";return String.format('
{1}
',a,c)}function file_progress(b){var a=b*100;return progressBar(a,this.width-50,a.toFixed(2)+"%")}function peer_progress(c){var a=(c*100).toInt();var b=this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt()-8;return progressBar(a,b,a+"%")}FILE_PRIORITY_CSS={0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};function priority_renderer(a){return String.format('
{1}
',FILE_PRIORITY_CSS[a],_(FILE_PRIORITY[a]))}function sort_address(c){var a=c.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);var b=0;var d=[a[1],a[2],a[3],a[4]];$each(d,function(f,e){f=parseInt(f);b=b|f<<((3-e)*8);alert("Total: "+b+"\nPart: "+f+"\nIndex: "+e+"\nCalc: "+(f<<((3-e)*8)))});return b}Deluge.Details.Peers.Store=new Ext.data.SimpleStore({fields:[{name:"country"},{name:"address",sortType:sort_address},{name:"client"},{name:"progress",type:"float"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"seed",type:"int"}],id:0});Deluge.Details.Panel=new Ext.TabPanel({region:"south",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0,items:[{id:"status",title:_("Status"),listeners:{render:{fn:Deluge.Details.Status.onRender,scope:Deluge.Details.Status}}},{id:"details",title:_("Details"),cls:"deluge-status",listeners:{render:{fn:Deluge.Details.Details.onRender,scope:Deluge.Details.Details}}},new Ext.tree.ColumnTree({id:"files",title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{header:_("Progress"),width:150,dataIndex:"progress",renderer:file_progress},{header:_("Priority"),width:150,dataIndex:"priority",renderer:priority_renderer}],root:new Ext.tree.TreeNode({text:"Files"}),listeners:{render:{fn:Deluge.Details.Files.onRender,scope:Deluge.Details.Files},contextmenu:{fn:Deluge.Details.Files.onContextMenu,scope:Deluge.Details.Files}}}),new Ext.grid.GridPanel({id:"peers",title:_("Peers"),cls:"x-deluge-peers",store:Deluge.Details.Peers.Store,columns:[{header:" ",width:30,sortable:true,renderer:flag,dataIndex:"country"},{header:"Address",width:125,sortable:true,renderer:peer_address,dataIndex:"address"},{header:"Client",width:125,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"client"},{header:"Progress",width:150,sortable:true,renderer:peer_progress,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,margins:"0 0 0 0",listeners:{render:{fn:Deluge.Details.Peers.onRender,scope:Deluge.Details.Peers}}}),new Ext.form.FormPanel({id:"options",title:_("Options"),frame:true,autoScroll:true,deferredRender:false,items:[{layout:"column",defaults:{border:false},items:[{bodyStyle:"padding-left: 5px; padding-right:5px;",width:300,items:[{xtype:"fieldset",title:_("Bandwidth"),layout:"table",layoutConfig:{columns:3},autoHeight:true,labelWidth:150,defaultType:"uxspinner",items:[{xtype:"label",text:_("Max Download Speed"),forId:"max_download_speed",cls:"x-deluge-options-label"},{id:"max_download_speed",width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{xtype:"label",text:"KiB/s",style:"margin-left: 10px;"},{xtype:"label",text:_("Max Upload Speed"),forId:"max_upload_speed",cls:"x-deluge-options-label"},{id:"max_upload_speed",width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{xtype:"label",text:"KiB/s",style:"margin-left: 10px;"},{xtype:"label",text:_("Max Connections"),forId:"max_connections",cls:"x-deluge-options-label"},{id:"max_connections",colspan:2,width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{xtype:"label",text:_("Max Upload Slots"),forId:"max_upload_slots",cls:"x-deluge-options-label"},{id:"max_upload_slots",colspan:2,width:100,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})}]}]},{bodyStyle:"padding-left: 5px; padding-right:5px;",width:200,items:[{xtype:"fieldset",title:_("Queue"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Auto Managed"),id:"is_auto_managed"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Stop seed at ratio"),id:"stop_at_ratio"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Remove at ratio"),id:"remove_at_ratio"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Move Completed"),id:"move_completed"}]}]},{bodyStyle:"padding-left:5px;",width:200,items:[{xtype:"fieldset",title:_("General"),autoHeight:true,defaultType:"checkbox",labelWidth:1,items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Private"),id:"private"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"}]},{layout:"column",items:[{items:[{id:"edit_trackers",xtype:"button",text:_("Edit Trackers"),cls:"x-btn-text-icon",iconCls:"x-deluge-edit-trackers",width:100}]},{items:[{id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px",width:100}]}]}]}]}],listeners:{render:{fn:Deluge.Details.Options.onRender,scope:Deluge.Details.Options}}})],listeners:{render:{fn:Deluge.Details.onRender,scope:Deluge.Details},tabchange:{fn:Deluge.Details.onTabChange,scope:Deluge.Details}}});Deluge.Add={torrents:new Hash(),clear:function(){this.clearFiles();this.Store.loadData([]);this.torrents.empty()},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,{onSuccess:function(b){this.defaults=b;$each(b,function(e,d){var f=this.form.findField(d);if(!f){return}f.setValue(e)},this);var c=this.form.findField("compact_allocation");if(b.compact_allocation){c.items.get("compact_allocation_true").setValue(true);c.items.get("compact_allocation_false").setValue(false)}else{c.items.get("compact_allocation_false").setValue(true);c.items.get("compact_allocation_true").setValue(false)}}.bindWithEvent(this)})},onAdd:function(){torrents=new Array();this.torrents.each(function(b,a){torrents.include({path:b.filename,options:{}})});Deluge.Client.web.add_torrents(torrents,{onSuccess:function(a){}});this.clear();this.Window.hide()},onFile:function(){this.File.Window.show()},onOptionsRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout();this.form=a.getForm();this.getDefaults()},onRender:function(a){new Ext.tree.TreeSorter(this.Files,{folderSort:true})},onSelect:function(e,f,c){var d=Deluge.Add.torrents[c.id];function b(h,g){$each(h,function(j,i){if($type(j)=="object"){var k=new Ext.tree.TreeNode({text:i});b(j,k);g.appendChild(k)}else{g.appendChild(new Ext.tree.TreeNode({filename:i,text:i,size:fsize(j[0]),leaf:true,checked:j[1],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI}))}})}this.clearFiles();var a=this.Files.getRootNode();b(d.files_tree,a);a.firstChild.expand()},onTorrentAdded:function(b,a){if(!b){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}b.filename=a;this.Store.loadData([[b.info_hash,b.name]],true);this.torrents[b.info_hash]=b},onUrl:function(a,b){this.Url.Window.show()},onRemove:function(){var a=this.Grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();delete this.torrents[b.id];this.Store.remove(b);this.clearFiles()}};Deluge.Add.Files=new Ext.tree.ColumnTree({id:"files",layout:"fit",rootVisible:false,autoScroll:true,height:170,border:false,animate:false,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{header:_("Size"),width:80,dataIndex:"size"}],root:new Ext.tree.AsyncTreeNode({text:"Files"})});Deluge.Add.Store=new Ext.data.SimpleStore({fields:[{name:"torrent",mapping:1}],id:0});Deluge.Add.Grid=new Ext.grid.GridPanel({store:Deluge.Add.Store,region:"center",columns:[{id:"torrent",width:150,sortable:true,renderer:Deluge.Formatters.plain,dataIndex:"torrent"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:Deluge.Add.onSelect,scope:Deluge.Add}}}),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:Deluge.Add.onFile,scope:Deluge.Add},{id:"url",cls:"x-btn-text-icon",text:_("Url"),icon:"/icons/add_url.png",handler:Deluge.Add.onUrl,scope:Deluge.Add},{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:Deluge.Add.onRemove,scope:Deluge.Add}]})});Deluge.Add.Options=new Ext.TabPanel({region:"south",margins:"5 5 5 5",activeTab:0,height:220,items:[{id:"addFilesTab",title:_("Files"),items:[Deluge.Add.Files]},{id:"addOptionsTab",title:_("Options"),layout:"fit",items:[new Ext.form.FormPanel({id:"addOptionsForm",bodyStyle:"padding: 5px;",border:false,items:[{xtype:"fieldset",style:"padding: 0px; padding-top: 5px;",title:_("Download Location"),border:false,autoHeight:true,border:false,labelWidth:1,items:[{layout:"column",border:false,items:[{xtype:"textfield",id:"download_location",fieldLabel:"",labelSeparator:"",width:330},{border:false,style:"padding-left: 5px;",items:[{xtype:"button",text:_("Browse")+"...",disabled:true}]}]}]},{layout:"column",border:false,defaults:{border:false},items:[{xtype:"fieldset",bodyStyle:"margin-left: 5px; margin-right:5px;",title:_("Allocation"),autoHeight:true,border:false,labelWidth:1,width:100,items:[new Ext.form.RadioGroup({id:"compact_allocation",name:"compact_allocation",columns:1,labelSeparator:"",items:[{boxLabel:_("Full"),inputValue:"false",id:"compact_allocation_false",name:"compact_allocation",checked:true},{boxLabel:_("Compact"),inputValue:"true",id:"compact_allocation_true",name:"compact_allocation"}]})]},{xtype:"fieldset",title:_("Bandwidth"),layout:"form",autoHeight:true,defaultType:"uxspinner",labelWidth:100,items:[{id:"max_download_speed_per_torrent",fieldLabel:_("Max Down Speed"),width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{id:"max_upload_speed_per_torrent",fieldLabel:_("Max Up Speed"),width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{id:"max_connections_per_torrent",fieldLabel:_("Max Connections"),width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})},{id:"max_upload_slots_per_torrent",fieldLabel:_("Max Upload Slots"),colspan:2,width:60,value:-1,strategy:new Ext.ux.form.Spinner.NumberStrategy({minValue:-1,maxValue:99999,incrementValue:1})}]},{xtype:"fieldset",title:_("General"),autoHeight:true,border:false,labelWidth:10,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Add In Paused State"),id:"add_paused"},{fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last Piece"),id:"prioritize_first_last_pieces"},{xtype:"button",text:_("Apply to All"),style:"margin-left: 20px; margin-top: 5px;"},{xtype:"button",text:_("Revert to Defaults"),style:"margin-left: 20px; margin-top: 5px;"}]}]}],listeners:{render:{fn:Deluge.Add.onOptionsRender,scope:Deluge.Add}}})]}]});Deluge.Add.File={onAdd:function(){if(this.form.getForm().isValid()){this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),success:this.onUploadSuccess.bindWithEvent(this)})}},onUploadSuccess:function(c,b){this.Window.hide();var a=b.result.toString();this.form.items.get("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{onSuccess:Deluge.Add.onTorrentAdded.bindWithEvent(Deluge.Add,a)})}};Deluge.Add.File.form=new Ext.form.FormPanel({fileUpload:true,id:"fileAddForm",baseCls:"x-plain",labelWidth:55,autoHeight:true,items:[{xtype:"fileuploadfield",id:"torrentFile",emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]});Deluge.Add.File.Window=new Ext.Window({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",items:Deluge.Add.File.form,buttons:[{text:_("Add"),handler:Deluge.Add.File.onAdd,scope:Deluge.Add.File}]});Deluge.Add.Url={onAdd:function(c,b){if(c.id=="url"&&b.getKey()!=b.ENTER){return}var c=this.form.items.get("url");var a=c.getValue();Deluge.Client.web.download_torrent_from_url(a,{onSuccess:this.onDownload.bindWithEvent(this)});this.Window.hide()},onDownload:function(a){this.form.items.get("url").setValue("");Deluge.Client.web.get_torrent_info(a,{onSuccess:Deluge.Add.onTorrentAdded.bindWithEvent(Deluge.Add,a)})}};Deluge.Add.Url.form=new Ext.form.FormPanel({defaultType:"textfield",id:"urlAddForm",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Url"),id:"url",name:"url",inputType:"url",anchor:"100%",listeners:{specialkey:{fn:Deluge.Add.Url.onAdd,scope:Deluge.Add.Url}}}]});Deluge.Add.Url.Window=new Ext.Window({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon",items:Deluge.Add.Url.form,buttons:[{text:_("Add"),handler:Deluge.Add.Url.onAdd,scope:Deluge.Add.Url}]});Deluge.Add.Window=new Ext.Window({layout:"border",width:470,height:450,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Add Torrents"),iconCls:"x-deluge-add-window-icon",items:[Deluge.Add.Grid,Deluge.Add.Options],buttons:[{text:_("Cancel"),handler:function(){Deluge.Add.clear();Deluge.Add.Window.hide()}},{text:_("Add"),handler:Deluge.Add.onAdd,scope:Deluge.Add}],listeners:{render:{fn:Deluge.Add.onRender,scope:Deluge.Add}}});(function(){PreferencesWindow=function(a){Ext.apply(this,a);this.layout="border";this.width=485;this.height=500;this.buttonAlign="right";this.closeAction="hide";this.closable=true;this.iconCls="x-deluge-preferences";this.plain=true;this.resizable=false;this.title=_("Preferences");this.buttons=[{text:_("Close"),handler:this.onCloseButtonClick,scope:this},{text:_("Apply")},{text:_("Ok")}];this.currentPage=false;this.items=[{xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.SimpleStore({fields:[{name:"name",mapping:0}]}),columns:[{id:"name",renderer:fplain,dataIndex:"name"}],sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPageSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 0 5 5",cmargins:"5 0 5 5",width:120,collapsible:true},{region:"center",title:" ",layout:"fit",height:400,margins:"5 5 5 5",cmargins:"5 5 5 5"}];PreferencesWindow.superclass.constructor.call(this)};Ext.extend(PreferencesWindow,Ext.Window,{initComponent:function(){PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.items.get(0);this.configPanel=this.items.get(1);this.pages={};this.on("show",this.onShow.bindWithEvent(this))},onCloseButtonClick:function(){this.hide()},addPage:function(b,c){var a=this.categoriesGrid.getStore();a.loadData([[b]],true);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);this.pages[b].hide()},onPageSelect:function(a,d,c){if(this.currentPage){this.currentPage.hide()}var b=c.get("name");this.pages[b].show();this.configPanel.setTitle(b);this.currentPage=this.pages[b];this.configPanel.doLayout()},onShow:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}}});Deluge.Preferences=new PreferencesWindow();Deluge.Preferences.addPage(_("Downloads"),{border:false,xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Folders"),labelWidth:140,defaultType:"textfield",autoHeight:true,items:[{name:"download_location",fieldLabel:_("Download to"),width:125},{name:"move_completed",fieldLabel:_("Move completed to"),width:125},{name:"copy_torrent_files",fieldLabel:_("Copy of .torrent files to"),width:125}]},{xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radio",items:[{name:"compact_allocation",labelSeparator:"",boxLabel:_("Compact")},{name:"compact_allocation",labelSeparator:"",boxLabel:_("Full")}]},{xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{name:"prioritize_first_last",labelSeparator:"",boxLabel:_("Prioritize first and last pieces of torrent")},{name:"add_paused",labelSeparator:"",boxLabel:_("Add torrents in Paused state")}]}]});Deluge.Preferences.addPage(_("Bandwidth"),{border:false,xtype:"form",layout:"form",labelWidth:10,items:[{xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),autoHeight:true,labelWidth:200,style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"uxspinner",items:[{name:"max_connections",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1},{name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:60,value:-1},{name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:60,value:-1}]},{xtype:"fieldset",border:false,title:"",autoHeight:true,style:"padding-top: 0px; margin-top: 0px; margin-bottom: 0px;",items:[{xtype:"checkbox",name:"ignore_local",fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),value:-1},{xtype:"checkbox",name:"limit_ip_overhead",fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),value:-1}]},{xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),autoHeight:true,labelWidth:200,defaultType:"uxspinner",items:[{name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:60,value:-1},{name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:60,value:-1},{name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:60,value:-1},{name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:60,value:-1}]}]});Deluge.Preferences.addPage(_("Interface"),{border:false,xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Window"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar"),id:"show_session_speed"}]},{xtype:"fieldset",border:false,title:_("Sidebar"),autoHeight:true,labelWidth:1,items:[{xtype:"checkbox",fieldLabel:"",labelSeparator:"",boxLabel:_("Hide filters with zero torrents"),id:"hide_sidebar_zero"}]},{xtype:"fieldset",border:false,title:_("Password"),autoHeight:true,defaultType:"textfield",items:[{fieldLabel:"New Password",inputType:"password",id:"new_password"},{inputType:"password",fieldLabel:"Confirm Password",id:"confirm_password"}]}]});Deluge.Preferences.addPage(_("Daemon"),{border:false,xtype:"form",layout:"form",items:[{xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"uxspinner",items:[{fieldLabel:_("Daemon port"),id:"daemon_port"}]},{xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",boxLabel:_("Allow Remote Connections"),id:"allow_remote"}]},{xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox",items:[{fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_releases"}]}]})})();Deluge.UI={initialize:function(){this.errorCount=0;Ext.state.Manager.setProvider(new Ext.state.CookieProvider());this.MainPanel=new Ext.Panel({id:"mainPanel",iconCls:"x-deluge-main-panel",title:"Deluge",layout:"border",tbar:Deluge.ToolBar.Bar,items:[Deluge.SideBar.Config,Deluge.Details.Panel,Deluge.Torrents],bbar:Deluge.StatusBar.Bar});this.Viewport=new Ext.Viewport({layout:"fit",items:[this.MainPanel]});Deluge.Login.show();Deluge.Events.on("connect",this.onConnect.bindWithEvent(this));Deluge.Events.on("disconnect",this.onDisconnect.bindWithEvent(this));Deluge.Client=new JSON.RPC("/json")},update:function(){var a=Deluge.SideBar.getFilters();Deluge.Client.web.update_ui(Deluge.Keys.Grid,a,{onSuccess:this.onUpdate.bindWithEvent(this),onFailure:this.onUpdateError.bindWithEvent(this)});Deluge.Details.update();Deluge.Client.web.connected({onSuccess:this.onConnectedCheck.bindWithEvent(this)})},onConnectedCheck:function(a){if(!a){Deluge.Events.fire("disconnect")}},onUpdateError:function(a){if(this.errorCount==2){Ext.MessageBox.show({title:"Lost Connection",msg:"The connection to the webserver has been lost!",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}this.errorCount++},onUpdate:function(b){var a=new Array();$each(b.torrents,function(c,d){a.include([c.queue,c.name,c.total_size,c.state,c.progress,c.num_seeds,c.total_seeds,c.num_peers,c.total_peers,c.download_payload_rate,c.upload_payload_rate,c.eta,c.ratio,c.distributed_copies,c.time_added,c.tracker_host,d])});Deluge.Torrents.getStore().loadData(a);Deluge.StatusBar.update(b.stats);Deluge.SideBar.update(b.filters);this.errorCount=0},onConnect:function(){if(!this.running){this.running=this.update.periodical(2000,this);this.update()}},onDisconnect:function(){this.stop();this.notify("Disconnected","Deluge has disconnected from the daemon")},stop:function(){if(this.running){$clear(this.running);this.running=false;Deluge.Torrents.Store.loadData([])}}};document.addEvent("domready",function(a){Deluge.UI.initialize()}); \ No newline at end of file diff --git a/deluge/ui/web/js/deluge.js b/deluge/ui/web/js/deluge.js deleted file mode 100644 index 43832a9c5..000000000 --- a/deluge/ui/web/js/deluge.js +++ /dev/null @@ -1,202 +0,0 @@ -/* -Script: deluge.js - Contains the events object, formatters and keys for get_torrent(s)_status. - -Copyright: - (C) Damien Churchill 2009 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, write to: - The Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor - Boston, MA 02110-1301, USA. -*/ - -var Deluge = { - author: 'Damien Churchill ', - version: '1.2-dev' -}; - -(function() { - var tpl = '
' + - '
' + - '
' + - '
' + - '
{0}
' + - '
' + - '
' + - '
' + - '
{0}
' + - '
' + - '
' + - '
'; - - Deluge.progressBar = function(progress, width, text) { - var progressWidth = (width / 100.0) * progress; - var barWidth = progressWidth.toInt() - 1; - var textWidth = ((progressWidth.toInt() - 10) > 0 ? progressWidth.toInt() - 10 : 0); - return String.format(tpl, text, width, barWidth, textWidth); - } -})(); - -Deluge.Events = { - _events: new Hash(), - - fire: function() { - arguments = $A(arguments); - var eventName = arguments.shift(); - var eventArgs = arguments; - if (!this._events[eventName]) return; - $each(this._events[eventName], function(fn) { - fn.attempt(eventArgs); - }); - }, - - on: function(eventName, fn) { - var e = $pick(this._events[eventName], new Array()); - e.include(fn); - this._events[eventName] = e; - }, - - removeListener: function(eventName, fn) { - if (!this._events[eventName]) return; - this._events[eventName].remove(fn); - } -}; - -Deluge.Formatters = { - date: function(timestamp) { - function zeroPad(num, count) { - var numZeropad = num + ''; - while (numZeropad.length < count) { - numZeropad = '0' + numZeropad; - } - return numZeropad; - } - timestamp = timestamp * 1000; - var date = new Date(timestamp); - return String.format('{0}/{1}/{2}', zeroPad(date.getDate(), 2), zeroPad(date.getMonth() + 1, 2), date.getFullYear()); - }, - size: function(bytes) { - bytes = bytes / 1024.0; - - if (bytes < 1024) { return bytes.toFixed(1) + ' KiB'; } - else { bytes = bytes / 1024; } - - if (bytes < 1024) { return bytes.toFixed(1) + ' MiB'; } - else { bytes = bytes / 1024; } - - return bytes.toFixed(1) + ' GiB' - }, - - speed: function(bits) { - return fsize(bits) + '/s' - }, - - timeRemaining: function(time) { - if (time == 0) { return '∞' } - if (time < 60) { return time + 's'; } - else { time = time / 60; } - - if (time < 60) { - var minutes = Math.floor(time) - var seconds = Math.round(60 * (time - minutes)) - if (seconds > 0) { - return minutes + 'm ' + seconds + 's'; - } else { - return minutes + 'm'; } - } - else { time = time / 60; } - - if (time < 24) { - var hours = Math.floor(time) - var minutes = Math.round(60 * (time - hours)) - if (minutes > 0) { - return hours + 'h ' + minutes + 'm'; - } else { - return hours + 'h'; - } - } - else { time = time / 24; } - - var days = Math.floor(time) - var hours = Math.round(24 * (time - days)) - if (hours > 0) { - return days + 'd ' + hours + 'h'; - } else { - return days + 'd'; - } - }, - - plain: function(value) { - return value; - } -} - -// _('Do Not Download') -// _('Normal Priority') -// _('High Priority') -// _('Highest Priority') -FILE_PRIORITY = { - 0: 'Do Not Download', - 1: 'Normal Priority', - 2: 'High Priority', - 5: 'Highest Priority', - 'Do Not Download': 0, - 'Normal Priority': 1, - 'High Priority': 2, - 'Highest Priority': 5 -} - -FILE_PRIORITY_CSS = { - 0: 'x-no-download', - 1: 'x-normal-download', - 2: 'x-high-download', - 5: 'x-highest-download' -} - -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', 'seeds' - ], - Details: [ - 'name', 'save_path', 'total_size', 'num_files', 'tracker_status', - 'tracker', 'comment' - ], - Options: [ - 'max_download_speed', 'max_upload_speed', 'max_connections', - 'max_upload_slots','is_auto_managed', 'stop_at_ratio', 'stop_ratio', - 'remove_at_ratio', 'private', 'prioritize_first_last' - ] -}; -Deluge.Keys.Status.extend(Deluge.Keys.Grid); \ No newline at end of file diff --git a/deluge/ui/web/js/ext-base-debug.js b/deluge/ui/web/js/ext-base-debug.js new file mode 100644 index 000000000..9c9d44396 --- /dev/null +++ b/deluge/ui/web/js/ext-base-debug.js @@ -0,0 +1,2189 @@ +/* + * Ext JS Library 2.2.1 + * Copyright(c) 2006-2009, Ext JS, LLC. + * licensing@extjs.com + * + * http://extjs.com/license + */ + +(function() { + var libFlyweight; + + Ext.lib.Dom = { + getViewWidth : function(full) { + return full ? this.getDocumentWidth() : this.getViewportWidth(); + }, + + getViewHeight : function(full) { + return full ? this.getDocumentHeight() : this.getViewportHeight(); + }, + + getDocumentHeight: function() { + var scrollHeight = (document.compatMode != "CSS1Compat") ? document.body.scrollHeight : document.documentElement.scrollHeight; + return Math.max(scrollHeight, this.getViewportHeight()); + }, + + getDocumentWidth: function() { + var scrollWidth = (document.compatMode != "CSS1Compat") ? document.body.scrollWidth : document.documentElement.scrollWidth; + return Math.max(scrollWidth, this.getViewportWidth()); + }, + + getViewportHeight: function(){ + if(Ext.isIE){ + return Ext.isStrict ? document.documentElement.clientHeight : + document.body.clientHeight; + }else{ + return self.innerHeight; + } + }, + + getViewportWidth: function() { + if(Ext.isIE){ + return Ext.isStrict ? document.documentElement.clientWidth : + document.body.clientWidth; + }else{ + return self.innerWidth; + } + }, + + isAncestor : function(p, c) { + p = Ext.getDom(p); + c = Ext.getDom(c); + if (!p || !c) { + return false; + } + + if (p.contains && !Ext.isSafari) { + return p.contains(c); + } else if (p.compareDocumentPosition) { + return !!(p.compareDocumentPosition(c) & 16); + } else { + var parent = c.parentNode; + while (parent) { + if (parent == p) { + return true; + } + else if (!parent.tagName || parent.tagName.toUpperCase() == "HTML") { + return false; + } + parent = parent.parentNode; + } + return false; + } + }, + + getRegion : function(el) { + return Ext.lib.Region.getRegion(el); + }, + + getY : function(el) { + return this.getXY(el)[1]; + }, + + getX : function(el) { + return this.getXY(el)[0]; + }, + + + getXY : function(el) { + var p, pe, b, scroll, bd = (document.body || document.documentElement); + el = Ext.getDom(el); + + if(el == bd){ + return [0, 0]; + } + + if (el.getBoundingClientRect) { + b = el.getBoundingClientRect(); + scroll = fly(document).getScroll(); + return [b.left + scroll.left, b.top + scroll.top]; + } + var x = 0, y = 0; + + p = el; + + var hasAbsolute = fly(el).getStyle("position") == "absolute"; + + while (p) { + + x += p.offsetLeft; + y += p.offsetTop; + + if (!hasAbsolute && fly(p).getStyle("position") == "absolute") { + hasAbsolute = true; + } + + if (Ext.isGecko) { + pe = fly(p); + + var bt = parseInt(pe.getStyle("borderTopWidth"), 10) || 0; + var bl = parseInt(pe.getStyle("borderLeftWidth"), 10) || 0; + + + x += bl; + y += bt; + + + if (p != el && pe.getStyle('overflow') != 'visible') { + x += bl; + y += bt; + } + } + p = p.offsetParent; + } + + if (Ext.isSafari && hasAbsolute) { + x -= bd.offsetLeft; + y -= bd.offsetTop; + } + + if (Ext.isGecko && !hasAbsolute) { + var dbd = fly(bd); + x += parseInt(dbd.getStyle("borderLeftWidth"), 10) || 0; + y += parseInt(dbd.getStyle("borderTopWidth"), 10) || 0; + } + + p = el.parentNode; + while (p && p != bd) { + if (!Ext.isOpera || (p.tagName != 'TR' && fly(p).getStyle("display") != "inline")) { + x -= p.scrollLeft; + y -= p.scrollTop; + } + p = p.parentNode; + } + return [x, y]; + }, + + setXY : function(el, xy) { + el = Ext.fly(el, '_setXY'); + el.position(); + var pts = el.translatePoints(xy); + if (xy[0] !== false) { + el.dom.style.left = pts.left + "px"; + } + if (xy[1] !== false) { + el.dom.style.top = pts.top + "px"; + } + }, + + setX : function(el, x) { + this.setXY(el, [x, false]); + }, + + setY : function(el, y) { + this.setXY(el, [false, y]); + } + }; + +/* + * Portions of this file are based on pieces of Yahoo User Interface Library + * Copyright (c) 2007, Yahoo! Inc. All rights reserved. + * YUI licensed under the BSD License: + * http://developer.yahoo.net/yui/license.txt + */ + Ext.lib.Event = function() { + var loadComplete = false; + var listeners = []; + var unloadListeners = []; + var retryCount = 0; + var onAvailStack = []; + var counter = 0; + var lastError = null; + + return { + POLL_RETRYS: 200, + POLL_INTERVAL: 20, + EL: 0, + TYPE: 1, + FN: 2, + WFN: 3, + OBJ: 3, + ADJ_SCOPE: 4, + _interval: null, + + startInterval: function() { + if (!this._interval) { + var self = this; + var callback = function() { + self._tryPreloadAttach(); + }; + this._interval = setInterval(callback, this.POLL_INTERVAL); + + } + }, + + onAvailable: function(p_id, p_fn, p_obj, p_override) { + onAvailStack.push({ id: p_id, + fn: p_fn, + obj: p_obj, + override: p_override, + checkReady: false }); + + retryCount = this.POLL_RETRYS; + this.startInterval(); + }, + + + addListener: function(el, eventName, fn) { + el = Ext.getDom(el); + if (!el || !fn) { + return false; + } + + if ("unload" == eventName) { + unloadListeners[unloadListeners.length] = + [el, eventName, fn]; + return true; + } + + // prevent unload errors with simple check + var wrappedFn = function(e) { + return typeof Ext != 'undefined' ? fn(Ext.lib.Event.getEvent(e)) : false; + }; + + var li = [el, eventName, fn, wrappedFn]; + + var index = listeners.length; + listeners[index] = li; + + this.doAdd(el, eventName, wrappedFn, false); + return true; + + }, + + + removeListener: function(el, eventName, fn) { + var i, len; + + el = Ext.getDom(el); + + if(!fn) { + return this.purgeElement(el, false, eventName); + } + + + if ("unload" == eventName) { + + for (i = 0,len = unloadListeners.length; i < len; i++) { + var li = unloadListeners[i]; + if (li && + li[0] == el && + li[1] == eventName && + li[2] == fn) { + unloadListeners.splice(i, 1); + return true; + } + } + + return false; + } + + var cacheItem = null; + + + var index = arguments[3]; + + if ("undefined" == typeof index) { + index = this._getCacheIndex(el, eventName, fn); + } + + if (index >= 0) { + cacheItem = listeners[index]; + } + + if (!el || !cacheItem) { + return false; + } + + this.doRemove(el, eventName, cacheItem[this.WFN], false); + + delete listeners[index][this.WFN]; + delete listeners[index][this.FN]; + listeners.splice(index, 1); + + return true; + + }, + + + getTarget: function(ev, resolveTextNode) { + ev = ev.browserEvent || ev; + var t = ev.target || ev.srcElement; + return this.resolveTextNode(t); + }, + + + resolveTextNode: function(node) { + if (Ext.isSafari && node && 3 == node.nodeType) { + return node.parentNode; + } else { + return node; + } + }, + + + getPageX: function(ev) { + ev = ev.browserEvent || ev; + var x = ev.pageX; + if (!x && 0 !== x) { + x = ev.clientX || 0; + + if (Ext.isIE) { + x += this.getScroll()[1]; + } + } + + return x; + }, + + + getPageY: function(ev) { + ev = ev.browserEvent || ev; + var y = ev.pageY; + if (!y && 0 !== y) { + y = ev.clientY || 0; + + if (Ext.isIE) { + y += this.getScroll()[0]; + } + } + + + return y; + }, + + + getXY: function(ev) { + ev = ev.browserEvent || ev; + return [this.getPageX(ev), this.getPageY(ev)]; + }, + + + getRelatedTarget: function(ev) { + ev = ev.browserEvent || ev; + var t = ev.relatedTarget; + if (!t) { + if (ev.type == "mouseout") { + t = ev.toElement; + } else if (ev.type == "mouseover") { + t = ev.fromElement; + } + } + + return this.resolveTextNode(t); + }, + + + getTime: function(ev) { + ev = ev.browserEvent || ev; + if (!ev.time) { + var t = new Date().getTime(); + try { + ev.time = t; + } catch(ex) { + this.lastError = ex; + return t; + } + } + + return ev.time; + }, + + + stopEvent: function(ev) { + this.stopPropagation(ev); + this.preventDefault(ev); + }, + + + stopPropagation: function(ev) { + ev = ev.browserEvent || ev; + if (ev.stopPropagation) { + ev.stopPropagation(); + } else { + ev.cancelBubble = true; + } + }, + + + preventDefault: function(ev) { + ev = ev.browserEvent || ev; + if(ev.preventDefault) { + ev.preventDefault(); + } else { + ev.returnValue = false; + } + }, + + + getEvent: function(e) { + var ev = e || window.event; + if (!ev) { + var c = this.getEvent.caller; + while (c) { + ev = c.arguments[0]; + if (ev && Event == ev.constructor) { + break; + } + c = c.caller; + } + } + return ev; + }, + + + getCharCode: function(ev) { + ev = ev.browserEvent || ev; + return ev.charCode || ev.keyCode || 0; + }, + + + _getCacheIndex: function(el, eventName, fn) { + for (var i = 0,len = listeners.length; i < len; ++i) { + var li = listeners[i]; + if (li && + li[this.FN] == fn && + li[this.EL] == el && + li[this.TYPE] == eventName) { + return i; + } + } + + return -1; + }, + + + elCache: {}, + + + getEl: function(id) { + return document.getElementById(id); + }, + + + clearCache: function() { + }, + + + _load: function(e) { + loadComplete = true; + var EU = Ext.lib.Event; + + + if (Ext.isIE) { + EU.doRemove(window, "load", EU._load); + } + }, + + + _tryPreloadAttach: function() { + + if (this.locked) { + return false; + } + + this.locked = true; + + + var tryAgain = !loadComplete; + if (!tryAgain) { + tryAgain = (retryCount > 0); + } + + + var notAvail = []; + for (var i = 0,len = onAvailStack.length; i < len; ++i) { + var item = onAvailStack[i]; + if (item) { + var el = this.getEl(item.id); + + if (el) { + if (!item.checkReady || + loadComplete || + el.nextSibling || + (document && document.body)) { + + var scope = el; + if (item.override) { + if (item.override === true) { + scope = item.obj; + } else { + scope = item.override; + } + } + item.fn.call(scope, item.obj); + onAvailStack[i] = null; + } + } else { + notAvail.push(item); + } + } + } + + retryCount = (notAvail.length === 0) ? 0 : retryCount - 1; + + if (tryAgain) { + + this.startInterval(); + } else { + clearInterval(this._interval); + this._interval = null; + } + + this.locked = false; + + return true; + + }, + + + purgeElement: function(el, recurse, eventName) { + var elListeners = this.getListeners(el, eventName); + if (elListeners) { + for (var i = 0,len = elListeners.length; i < len; ++i) { + var l = elListeners[i]; + this.removeListener(el, l.type, l.fn); + } + } + + if (recurse && el && el.childNodes) { + for (i = 0,len = el.childNodes.length; i < len; ++i) { + this.purgeElement(el.childNodes[i], recurse, eventName); + } + } + }, + + + getListeners: function(el, eventName) { + var results = [], searchLists; + if (!eventName) { + searchLists = [listeners, unloadListeners]; + } else if (eventName == "unload") { + searchLists = [unloadListeners]; + } else { + searchLists = [listeners]; + } + + for (var j = 0; j < searchLists.length; ++j) { + var searchList = searchLists[j]; + if (searchList && searchList.length > 0) { + for (var i = 0,len = searchList.length; i < len; ++i) { + var l = searchList[i]; + if (l && l[this.EL] === el && + (!eventName || eventName === l[this.TYPE])) { + results.push({ + type: l[this.TYPE], + fn: l[this.FN], + obj: l[this.OBJ], + adjust: l[this.ADJ_SCOPE], + index: i + }); + } + } + } + } + + return (results.length) ? results : null; + }, + + + _unload: function(e) { + + var EU = Ext.lib.Event, i, j, l, len, index; + + for (i = 0,len = unloadListeners.length; i < len; ++i) { + l = unloadListeners[i]; + if (l) { + var scope = window; + if (l[EU.ADJ_SCOPE]) { + if (l[EU.ADJ_SCOPE] === true) { + scope = l[EU.OBJ]; + } else { + scope = l[EU.ADJ_SCOPE]; + } + } + l[EU.FN].call(scope, EU.getEvent(e), l[EU.OBJ]); + unloadListeners[i] = null; + l = null; + scope = null; + } + } + + unloadListeners = null; + + if (listeners && listeners.length > 0) { + j = listeners.length; + while (j) { + index = j - 1; + l = listeners[index]; + if (l) { + EU.removeListener(l[EU.EL], l[EU.TYPE], + l[EU.FN], index); + } + j = j - 1; + } + l = null; + + EU.clearCache(); + } + + EU.doRemove(window, "unload", EU._unload); + + }, + + + getScroll: function() { + var dd = document.documentElement, db = document.body; + if (dd && (dd.scrollTop || dd.scrollLeft)) { + return [dd.scrollTop, dd.scrollLeft]; + } else if (db) { + return [db.scrollTop, db.scrollLeft]; + } else { + return [0, 0]; + } + }, + + + doAdd: function () { + if (window.addEventListener) { + return function(el, eventName, fn, capture) { + el.addEventListener(eventName, fn, (capture)); + }; + } else if (window.attachEvent) { + return function(el, eventName, fn, capture) { + el.attachEvent("on" + eventName, fn); + }; + } else { + return function() { + }; + } + }(), + + + doRemove: function() { + if (window.removeEventListener) { + return function (el, eventName, fn, capture) { + el.removeEventListener(eventName, fn, (capture)); + }; + } else if (window.detachEvent) { + return function (el, eventName, fn) { + el.detachEvent("on" + eventName, fn); + }; + } else { + return function() { + }; + } + }() + }; + + }(); + + var E = Ext.lib.Event; + E.on = E.addListener; + E.un = E.removeListener; + if(document && document.body) { + E._load(); + } else { + E.doAdd(window, "load", E._load); + } + E.doAdd(window, "unload", E._unload); + E._tryPreloadAttach(); + + Ext.lib.Ajax = { + request : function(method, uri, cb, data, options) { + if(options){ + var hs = options.headers; + if(hs){ + for(var h in hs){ + if(hs.hasOwnProperty(h)){ + this.initHeader(h, hs[h], false); + } + } + } + if(options.xmlData){ + if (!hs || !hs['Content-Type']){ + this.initHeader('Content-Type', 'text/xml', false); + } + method = (method ? method : (options.method ? options.method : 'POST')); + data = options.xmlData; + }else if(options.jsonData){ + if (!hs || !hs['Content-Type']){ + this.initHeader('Content-Type', 'application/json', false); + } + method = (method ? method : (options.method ? options.method : 'POST')); + data = typeof options.jsonData == 'object' ? Ext.encode(options.jsonData) : options.jsonData; + } + } + + return this.asyncRequest(method, uri, cb, data); + }, + + serializeForm : function(form) { + if(typeof form == 'string') { + form = (document.getElementById(form) || document.forms[form]); + } + + var el, name, val, disabled, data = '', hasSubmit = false; + for (var i = 0; i < form.elements.length; i++) { + el = form.elements[i]; + disabled = form.elements[i].disabled; + name = form.elements[i].name; + val = form.elements[i].value; + + if (!disabled && name){ + switch (el.type) + { + case 'select-one': + case 'select-multiple': + for (var j = 0; j < el.options.length; j++) { + if (el.options[j].selected) { + if (Ext.isIE) { + data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].attributes['value'].specified ? el.options[j].value : el.options[j].text) + '&'; + } + else { + data += encodeURIComponent(name) + '=' + encodeURIComponent(el.options[j].hasAttribute('value') ? el.options[j].value : el.options[j].text) + '&'; + } + } + } + break; + case 'radio': + case 'checkbox': + if (el.checked) { + data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&'; + } + break; + case 'file': + + case undefined: + + case 'reset': + + case 'button': + + break; + case 'submit': + if(hasSubmit == false) { + data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&'; + hasSubmit = true; + } + break; + default: + data += encodeURIComponent(name) + '=' + encodeURIComponent(val) + '&'; + break; + } + } + } + data = data.substr(0, data.length - 1); + return data; + }, + + headers:{}, + + hasHeaders:false, + + useDefaultHeader:true, + + defaultPostHeader:'application/x-www-form-urlencoded; charset=UTF-8', + + useDefaultXhrHeader:true, + + defaultXhrHeader:'XMLHttpRequest', + + hasDefaultHeaders:true, + + defaultHeaders:{}, + + poll:{}, + + timeout:{}, + + pollInterval:50, + + transactionId:0, + + setProgId:function(id) + { + this.activeX.unshift(id); + }, + + setDefaultPostHeader:function(b) + { + this.useDefaultHeader = b; + }, + + setDefaultXhrHeader:function(b) + { + this.useDefaultXhrHeader = b; + }, + + setPollingInterval:function(i) + { + if (typeof i == 'number' && isFinite(i)) { + this.pollInterval = i; + } + }, + + createXhrObject:function(transactionId) + { + var obj,http; + try + { + + http = new XMLHttpRequest(); + + obj = { conn:http, tId:transactionId }; + } + catch(e) + { + for (var i = 0; i < this.activeX.length; ++i) { + try + { + + http = new ActiveXObject(this.activeX[i]); + + obj = { conn:http, tId:transactionId }; + break; + } + catch(e) { + } + } + } + finally + { + return obj; + } + }, + + getConnectionObject:function() + { + var o; + var tId = this.transactionId; + + try + { + o = this.createXhrObject(tId); + if (o) { + this.transactionId++; + } + } + catch(e) { + } + finally + { + return o; + } + }, + + asyncRequest:function(method, uri, callback, postData) + { + var o = this.getConnectionObject(); + + if (!o) { + return null; + } + else { + o.conn.open(method, uri, true); + + if (this.useDefaultXhrHeader) { + if (!this.defaultHeaders['X-Requested-With']) { + this.initHeader('X-Requested-With', this.defaultXhrHeader, true); + } + } + + if(postData && this.useDefaultHeader && (!this.hasHeaders || !this.headers['Content-Type'])){ + this.initHeader('Content-Type', this.defaultPostHeader); + } + + if (this.hasDefaultHeaders || this.hasHeaders) { + this.setHeader(o); + } + + this.handleReadyState(o, callback); + o.conn.send(postData || null); + + return o; + } + }, + + handleReadyState:function(o, callback) + { + var oConn = this; + + if (callback && callback.timeout) { + this.timeout[o.tId] = window.setTimeout(function() { + oConn.abort(o, callback, true); + }, callback.timeout); + } + + this.poll[o.tId] = window.setInterval( + function() { + if (o.conn && o.conn.readyState == 4) { + window.clearInterval(oConn.poll[o.tId]); + delete oConn.poll[o.tId]; + + if (callback && callback.timeout) { + window.clearTimeout(oConn.timeout[o.tId]); + delete oConn.timeout[o.tId]; + } + + oConn.handleTransactionResponse(o, callback); + } + } + , this.pollInterval); + }, + + handleTransactionResponse:function(o, callback, isAbort) + { + + if (!callback) { + this.releaseObject(o); + return; + } + + var httpStatus, responseObject; + + try + { + if (o.conn.status !== undefined && o.conn.status != 0) { + httpStatus = o.conn.status; + } + else { + httpStatus = 13030; + } + } + catch(e) { + + + httpStatus = 13030; + } + + if ((httpStatus >= 200 && httpStatus < 300) || (Ext.isIE && httpStatus == 1223)) { + responseObject = this.createResponseObject(o, callback.argument); + if (callback.success) { + if (!callback.scope) { + callback.success(responseObject); + } + else { + + + callback.success.apply(callback.scope, [responseObject]); + } + } + } + else { + switch (httpStatus) { + + case 12002: + case 12029: + case 12030: + case 12031: + case 12152: + case 13030: + responseObject = this.createExceptionObject(o.tId, callback.argument, (isAbort ? isAbort : false)); + if (callback.failure) { + if (!callback.scope) { + callback.failure(responseObject); + } + else { + callback.failure.apply(callback.scope, [responseObject]); + } + } + break; + default: + responseObject = this.createResponseObject(o, callback.argument); + if (callback.failure) { + if (!callback.scope) { + callback.failure(responseObject); + } + else { + callback.failure.apply(callback.scope, [responseObject]); + } + } + } + } + + this.releaseObject(o); + responseObject = null; + }, + + createResponseObject:function(o, callbackArg) + { + var obj = {}; + var headerObj = {}; + + try + { + var headerStr = o.conn.getAllResponseHeaders(); + var header = headerStr.split('\n'); + for (var i = 0; i < header.length; i++) { + var delimitPos = header[i].indexOf(':'); + if (delimitPos != -1) { + headerObj[header[i].substring(0, delimitPos)] = header[i].substring(delimitPos + 2); + } + } + } + catch(e) { + } + + obj.tId = o.tId; + obj.status = o.conn.status; + obj.statusText = o.conn.statusText; + obj.getResponseHeader = headerObj; + obj.getAllResponseHeaders = headerStr; + obj.responseText = o.conn.responseText; + obj.responseXML = o.conn.responseXML; + + if (typeof callbackArg !== undefined) { + obj.argument = callbackArg; + } + + return obj; + }, + + createExceptionObject:function(tId, callbackArg, isAbort) + { + var COMM_CODE = 0; + var COMM_ERROR = 'communication failure'; + var ABORT_CODE = -1; + var ABORT_ERROR = 'transaction aborted'; + + var obj = {}; + + obj.tId = tId; + if (isAbort) { + obj.status = ABORT_CODE; + obj.statusText = ABORT_ERROR; + } + else { + obj.status = COMM_CODE; + obj.statusText = COMM_ERROR; + } + + if (callbackArg) { + obj.argument = callbackArg; + } + + return obj; + }, + + initHeader:function(label, value, isDefault) + { + var headerObj = (isDefault) ? this.defaultHeaders : this.headers; + + if (headerObj[label] === undefined) { + headerObj[label] = value; + } + else { + + + headerObj[label] = value + "," + headerObj[label]; + } + + if (isDefault) { + this.hasDefaultHeaders = true; + } + else { + this.hasHeaders = true; + } + }, + + + setHeader:function(o) + { + if (this.hasDefaultHeaders) { + for (var prop in this.defaultHeaders) { + if (this.defaultHeaders.hasOwnProperty(prop)) { + o.conn.setRequestHeader(prop, this.defaultHeaders[prop]); + } + } + } + + if (this.hasHeaders) { + for (var prop in this.headers) { + if (this.headers.hasOwnProperty(prop)) { + o.conn.setRequestHeader(prop, this.headers[prop]); + } + } + this.headers = {}; + this.hasHeaders = false; + } + }, + + resetDefaultHeaders:function() { + delete this.defaultHeaders; + this.defaultHeaders = {}; + this.hasDefaultHeaders = false; + }, + + abort:function(o, callback, isTimeout) + { + if (this.isCallInProgress(o)) { + o.conn.abort(); + window.clearInterval(this.poll[o.tId]); + delete this.poll[o.tId]; + if (isTimeout) { + delete this.timeout[o.tId]; + } + + this.handleTransactionResponse(o, callback, true); + + return true; + } + else { + return false; + } + }, + + + isCallInProgress:function(o) + { + + + if (o.conn) { + return o.conn.readyState != 4 && o.conn.readyState != 0; + } + else { + + return false; + } + }, + + + releaseObject:function(o) + { + + o.conn = null; + + o = null; + }, + + activeX:[ + 'MSXML2.XMLHTTP.3.0', + 'MSXML2.XMLHTTP', + 'Microsoft.XMLHTTP' + ] + + + }; + + + Ext.lib.Region = function(t, r, b, l) { + this.top = t; + this[1] = t; + this.right = r; + this.bottom = b; + this.left = l; + this[0] = l; + }; + + Ext.lib.Region.prototype = { + contains : function(region) { + return ( region.left >= this.left && + region.right <= this.right && + region.top >= this.top && + region.bottom <= this.bottom ); + + }, + + getArea : function() { + return ( (this.bottom - this.top) * (this.right - this.left) ); + }, + + intersect : function(region) { + var t = Math.max(this.top, region.top); + var r = Math.min(this.right, region.right); + var b = Math.min(this.bottom, region.bottom); + var l = Math.max(this.left, region.left); + + if (b >= t && r >= l) { + return new Ext.lib.Region(t, r, b, l); + } else { + return null; + } + }, + union : function(region) { + var t = Math.min(this.top, region.top); + var r = Math.max(this.right, region.right); + var b = Math.max(this.bottom, region.bottom); + var l = Math.min(this.left, region.left); + + return new Ext.lib.Region(t, r, b, l); + }, + + constrainTo : function(r) { + this.top = this.top.constrain(r.top, r.bottom); + this.bottom = this.bottom.constrain(r.top, r.bottom); + this.left = this.left.constrain(r.left, r.right); + this.right = this.right.constrain(r.left, r.right); + return this; + }, + + adjust : function(t, l, b, r) { + this.top += t; + this.left += l; + this.right += r; + this.bottom += b; + return this; + } + }; + + Ext.lib.Region.getRegion = function(el) { + var p = Ext.lib.Dom.getXY(el); + + var t = p[1]; + var r = p[0] + el.offsetWidth; + var b = p[1] + el.offsetHeight; + var l = p[0]; + + return new Ext.lib.Region(t, r, b, l); + }; + + Ext.lib.Point = function(x, y) { + if (Ext.isArray(x)) { + y = x[1]; + x = x[0]; + } + this.x = this.right = this.left = this[0] = x; + this.y = this.top = this.bottom = this[1] = y; + }; + + Ext.lib.Point.prototype = new Ext.lib.Region(); + + + Ext.lib.Anim = { + scroll : function(el, args, duration, easing, cb, scope) { + return this.run(el, args, duration, easing, cb, scope, Ext.lib.Scroll); + }, + + motion : function(el, args, duration, easing, cb, scope) { + return this.run(el, args, duration, easing, cb, scope, Ext.lib.Motion); + }, + + color : function(el, args, duration, easing, cb, scope) { + return this.run(el, args, duration, easing, cb, scope, Ext.lib.ColorAnim); + }, + + run : function(el, args, duration, easing, cb, scope, type) { + type = type || Ext.lib.AnimBase; + if (typeof easing == "string") { + easing = Ext.lib.Easing[easing]; + } + var anim = new type(el, args, duration, easing); + anim.animateX(function() { + Ext.callback(cb, scope); + }); + return anim; + } + }; + + + function fly(el) { + if (!libFlyweight) { + libFlyweight = new Ext.Element.Flyweight(); + } + libFlyweight.dom = el; + return libFlyweight; + } + + + if(Ext.isIE) { + function fnCleanUp() { + var p = Function.prototype; + delete p.createSequence; + delete p.defer; + delete p.createDelegate; + delete p.createCallback; + delete p.createInterceptor; + + window.detachEvent("onunload", fnCleanUp); + } + window.attachEvent("onunload", fnCleanUp); + } + + Ext.lib.AnimBase = function(el, attributes, duration, method) { + if (el) { + this.init(el, attributes, duration, method); + } + }; + + Ext.lib.AnimBase.prototype = { + + toString: function() { + var el = this.getEl(); + var id = el.id || el.tagName; + return ("Anim " + id); + }, + + patterns: { + noNegatives: /width|height|opacity|padding/i, + offsetAttribute: /^((width|height)|(top|left))$/, + defaultUnit: /width|height|top$|bottom$|left$|right$/i, + offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i + }, + + + doMethod: function(attr, start, end) { + return this.method(this.currentFrame, start, end - start, this.totalFrames); + }, + + + setAttribute: function(attr, val, unit) { + if (this.patterns.noNegatives.test(attr)) { + val = (val > 0) ? val : 0; + } + + Ext.fly(this.getEl(), '_anim').setStyle(attr, val + unit); + }, + + + getAttribute: function(attr) { + var el = this.getEl(); + var val = fly(el).getStyle(attr); + + if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) { + return parseFloat(val); + } + + var a = this.patterns.offsetAttribute.exec(attr) || []; + var pos = !!( a[3] ); + var box = !!( a[2] ); + + + if (box || (fly(el).getStyle('position') == 'absolute' && pos)) { + val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)]; + } else { + val = 0; + } + + return val; + }, + + + getDefaultUnit: function(attr) { + if (this.patterns.defaultUnit.test(attr)) { + return 'px'; + } + + return ''; + }, + + animateX : function(callback, scope) { + var f = function() { + this.onComplete.removeListener(f); + if (typeof callback == "function") { + callback.call(scope || this, this); + } + }; + this.onComplete.addListener(f, this); + this.animate(); + }, + + + setRuntimeAttribute: function(attr) { + var start; + var end; + var attributes = this.attributes; + + this.runtimeAttributes[attr] = {}; + + var isset = function(prop) { + return (typeof prop !== 'undefined'); + }; + + if (!isset(attributes[attr]['to']) && !isset(attributes[attr]['by'])) { + return false; + } + + start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr); + + + if (isset(attributes[attr]['to'])) { + end = attributes[attr]['to']; + } else if (isset(attributes[attr]['by'])) { + if (start.constructor == Array) { + end = []; + for (var i = 0, len = start.length; i < len; ++i) { + end[i] = start[i] + attributes[attr]['by'][i]; + } + } else { + end = start + attributes[attr]['by']; + } + } + + this.runtimeAttributes[attr].start = start; + this.runtimeAttributes[attr].end = end; + + + this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr); + }, + + + init: function(el, attributes, duration, method) { + + var isAnimated = false; + + + var startTime = null; + + + var actualFrames = 0; + + + el = Ext.getDom(el); + + + this.attributes = attributes || {}; + + + this.duration = duration || 1; + + + this.method = method || Ext.lib.Easing.easeNone; + + + this.useSeconds = true; + + + this.currentFrame = 0; + + + this.totalFrames = Ext.lib.AnimMgr.fps; + + + this.getEl = function() { + return el; + }; + + + this.isAnimated = function() { + return isAnimated; + }; + + + this.getStartTime = function() { + return startTime; + }; + + this.runtimeAttributes = {}; + + + this.animate = function() { + if (this.isAnimated()) { + return false; + } + + this.currentFrame = 0; + + this.totalFrames = ( this.useSeconds ) ? Math.ceil(Ext.lib.AnimMgr.fps * this.duration) : this.duration; + + Ext.lib.AnimMgr.registerElement(this); + }; + + + this.stop = function(finish) { + if (finish) { + this.currentFrame = this.totalFrames; + this._onTween.fire(); + } + Ext.lib.AnimMgr.stop(this); + }; + + var onStart = function() { + this.onStart.fire(); + + this.runtimeAttributes = {}; + for (var attr in this.attributes) { + this.setRuntimeAttribute(attr); + } + + isAnimated = true; + actualFrames = 0; + startTime = new Date(); + }; + + + var onTween = function() { + var data = { + duration: new Date() - this.getStartTime(), + currentFrame: this.currentFrame + }; + + data.toString = function() { + return ( + 'duration: ' + data.duration + + ', currentFrame: ' + data.currentFrame + ); + }; + + this.onTween.fire(data); + + var runtimeAttributes = this.runtimeAttributes; + + for (var attr in runtimeAttributes) { + this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit); + } + + actualFrames += 1; + }; + + var onComplete = function() { + var actual_duration = (new Date() - startTime) / 1000 ; + + var data = { + duration: actual_duration, + frames: actualFrames, + fps: actualFrames / actual_duration + }; + + data.toString = function() { + return ( + 'duration: ' + data.duration + + ', frames: ' + data.frames + + ', fps: ' + data.fps + ); + }; + + isAnimated = false; + actualFrames = 0; + this.onComplete.fire(data); + }; + + + this._onStart = new Ext.util.Event(this); + this.onStart = new Ext.util.Event(this); + this.onTween = new Ext.util.Event(this); + this._onTween = new Ext.util.Event(this); + this.onComplete = new Ext.util.Event(this); + this._onComplete = new Ext.util.Event(this); + this._onStart.addListener(onStart); + this._onTween.addListener(onTween); + this._onComplete.addListener(onComplete); + } + }; + + + Ext.lib.AnimMgr = new function() { + + var thread = null; + + + var queue = []; + + + var tweenCount = 0; + + + this.fps = 1000; + + + this.delay = 1; + + + this.registerElement = function(tween) { + queue[queue.length] = tween; + tweenCount += 1; + tween._onStart.fire(); + this.start(); + }; + + + this.unRegister = function(tween, index) { + tween._onComplete.fire(); + index = index || getIndex(tween); + if (index != -1) { + queue.splice(index, 1); + } + + tweenCount -= 1; + if (tweenCount <= 0) { + this.stop(); + } + }; + + + this.start = function() { + if (thread === null) { + thread = setInterval(this.run, this.delay); + } + }; + + + this.stop = function(tween) { + if (!tween) { + clearInterval(thread); + + for (var i = 0, len = queue.length; i < len; ++i) { + if (queue[0].isAnimated()) { + this.unRegister(queue[0], 0); + } + } + + queue = []; + thread = null; + tweenCount = 0; + } + else { + this.unRegister(tween); + } + }; + + + this.run = function() { + for (var i = 0, len = queue.length; i < len; ++i) { + var tween = queue[i]; + if (!tween || !tween.isAnimated()) { + continue; + } + + if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null) + { + tween.currentFrame += 1; + + if (tween.useSeconds) { + correctFrame(tween); + } + tween._onTween.fire(); + } + else { + Ext.lib.AnimMgr.stop(tween, i); + } + } + }; + + var getIndex = function(anim) { + for (var i = 0, len = queue.length; i < len; ++i) { + if (queue[i] == anim) { + return i; + } + } + return -1; + }; + + + var correctFrame = function(tween) { + var frames = tween.totalFrames; + var frame = tween.currentFrame; + var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames); + var elapsed = (new Date() - tween.getStartTime()); + var tweak = 0; + + if (elapsed < tween.duration * 1000) { + tweak = Math.round((elapsed / expected - 1) * tween.currentFrame); + } else { + tweak = frames - (frame + 1); + } + if (tweak > 0 && isFinite(tweak)) { + if (tween.currentFrame + tweak >= frames) { + tweak = frames - (frame + 1); + } + + tween.currentFrame += tweak; + } + }; + }; + + Ext.lib.Bezier = new function() { + + this.getPosition = function(points, t) { + var n = points.length; + var tmp = []; + + for (var i = 0; i < n; ++i) { + tmp[i] = [points[i][0], points[i][1]]; + } + + for (var j = 1; j < n; ++j) { + for (i = 0; i < n - j; ++i) { + tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0]; + tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1]; + } + } + + return [ tmp[0][0], tmp[0][1] ]; + + }; + }; + (function() { + + Ext.lib.ColorAnim = function(el, attributes, duration, method) { + Ext.lib.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method); + }; + + Ext.extend(Ext.lib.ColorAnim, Ext.lib.AnimBase); + + + var Y = Ext.lib; + var superclass = Y.ColorAnim.superclass; + var proto = Y.ColorAnim.prototype; + + proto.toString = function() { + var el = this.getEl(); + var id = el.id || el.tagName; + return ("ColorAnim " + id); + }; + + proto.patterns.color = /color$/i; + proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i; + proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i; + proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i; + proto.patterns.transparent = /^transparent|rgba\(0, 0, 0, 0\)$/; + + + proto.parseColor = function(s) { + if (s.length == 3) { + return s; + } + + var c = this.patterns.hex.exec(s); + if (c && c.length == 4) { + return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ]; + } + + c = this.patterns.rgb.exec(s); + if (c && c.length == 4) { + return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ]; + } + + c = this.patterns.hex3.exec(s); + if (c && c.length == 4) { + return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ]; + } + + return null; + }; + + proto.getAttribute = function(attr) { + var el = this.getEl(); + if (this.patterns.color.test(attr)) { + var val = fly(el).getStyle(attr); + + if (this.patterns.transparent.test(val)) { + var parent = el.parentNode; + val = fly(parent).getStyle(attr); + + while (parent && this.patterns.transparent.test(val)) { + parent = parent.parentNode; + val = fly(parent).getStyle(attr); + if (parent.tagName.toUpperCase() == 'HTML') { + val = '#fff'; + } + } + } + } else { + val = superclass.getAttribute.call(this, attr); + } + + return val; + }; + + proto.doMethod = function(attr, start, end) { + var val; + + if (this.patterns.color.test(attr)) { + val = []; + for (var i = 0, len = start.length; i < len; ++i) { + val[i] = superclass.doMethod.call(this, attr, start[i], end[i]); + } + + val = 'rgb(' + Math.floor(val[0]) + ',' + Math.floor(val[1]) + ',' + Math.floor(val[2]) + ')'; + } + else { + val = superclass.doMethod.call(this, attr, start, end); + } + + return val; + }; + + proto.setRuntimeAttribute = function(attr) { + superclass.setRuntimeAttribute.call(this, attr); + + if (this.patterns.color.test(attr)) { + var attributes = this.attributes; + var start = this.parseColor(this.runtimeAttributes[attr].start); + var end = this.parseColor(this.runtimeAttributes[attr].end); + + if (typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined') { + end = this.parseColor(attributes[attr].by); + + for (var i = 0, len = start.length; i < len; ++i) { + end[i] = start[i] + end[i]; + } + } + + this.runtimeAttributes[attr].start = start; + this.runtimeAttributes[attr].end = end; + } + }; + })(); + + + Ext.lib.Easing = { + + + easeNone: function (t, b, c, d) { + return c * t / d + b; + }, + + + easeIn: function (t, b, c, d) { + return c * (t /= d) * t + b; + }, + + + easeOut: function (t, b, c, d) { + return -c * (t /= d) * (t - 2) + b; + }, + + + easeBoth: function (t, b, c, d) { + if ((t /= d / 2) < 1) { + return c / 2 * t * t + b; + } + + return -c / 2 * ((--t) * (t - 2) - 1) + b; + }, + + + easeInStrong: function (t, b, c, d) { + return c * (t /= d) * t * t * t + b; + }, + + + easeOutStrong: function (t, b, c, d) { + return -c * ((t = t / d - 1) * t * t * t - 1) + b; + }, + + + easeBothStrong: function (t, b, c, d) { + if ((t /= d / 2) < 1) { + return c / 2 * t * t * t * t + b; + } + + return -c / 2 * ((t -= 2) * t * t * t - 2) + b; + }, + + + + elasticIn: function (t, b, c, d, a, p) { + if (t == 0) { + return b; + } + if ((t /= d) == 1) { + return b + c; + } + if (!p) { + p = d * .3; + } + + if (!a || a < Math.abs(c)) { + a = c; + var s = p / 4; + } + else { + var s = p / (2 * Math.PI) * Math.asin(c / a); + } + + return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; + }, + + + elasticOut: function (t, b, c, d, a, p) { + if (t == 0) { + return b; + } + if ((t /= d) == 1) { + return b + c; + } + if (!p) { + p = d * .3; + } + + if (!a || a < Math.abs(c)) { + a = c; + var s = p / 4; + } + else { + var s = p / (2 * Math.PI) * Math.asin(c / a); + } + + return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b; + }, + + + elasticBoth: function (t, b, c, d, a, p) { + if (t == 0) { + return b; + } + + if ((t /= d / 2) == 2) { + return b + c; + } + + if (!p) { + p = d * (.3 * 1.5); + } + + if (!a || a < Math.abs(c)) { + a = c; + var s = p / 4; + } + else { + var s = p / (2 * Math.PI) * Math.asin(c / a); + } + + if (t < 1) { + return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * + Math.sin((t * d - s) * (2 * Math.PI) / p)) + b; + } + return a * Math.pow(2, -10 * (t -= 1)) * + Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b; + }, + + + + backIn: function (t, b, c, d, s) { + if (typeof s == 'undefined') { + s = 1.70158; + } + return c * (t /= d) * t * ((s + 1) * t - s) + b; + }, + + + backOut: function (t, b, c, d, s) { + if (typeof s == 'undefined') { + s = 1.70158; + } + return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; + }, + + + backBoth: function (t, b, c, d, s) { + if (typeof s == 'undefined') { + s = 1.70158; + } + + if ((t /= d / 2 ) < 1) { + return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b; + } + return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b; + }, + + + bounceIn: function (t, b, c, d) { + return c - Ext.lib.Easing.bounceOut(d - t, 0, c, d) + b; + }, + + + bounceOut: function (t, b, c, d) { + if ((t /= d) < (1 / 2.75)) { + return c * (7.5625 * t * t) + b; + } else if (t < (2 / 2.75)) { + return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b; + } else if (t < (2.5 / 2.75)) { + return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b; + } + return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b; + }, + + + bounceBoth: function (t, b, c, d) { + if (t < d / 2) { + return Ext.lib.Easing.bounceIn(t * 2, 0, c, d) * .5 + b; + } + return Ext.lib.Easing.bounceOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b; + } + }; + + (function() { + Ext.lib.Motion = function(el, attributes, duration, method) { + if (el) { + Ext.lib.Motion.superclass.constructor.call(this, el, attributes, duration, method); + } + }; + + Ext.extend(Ext.lib.Motion, Ext.lib.ColorAnim); + + + var Y = Ext.lib; + var superclass = Y.Motion.superclass; + var proto = Y.Motion.prototype; + + proto.toString = function() { + var el = this.getEl(); + var id = el.id || el.tagName; + return ("Motion " + id); + }; + + proto.patterns.points = /^points$/i; + + proto.setAttribute = function(attr, val, unit) { + if (this.patterns.points.test(attr)) { + unit = unit || 'px'; + superclass.setAttribute.call(this, 'left', val[0], unit); + superclass.setAttribute.call(this, 'top', val[1], unit); + } else { + superclass.setAttribute.call(this, attr, val, unit); + } + }; + + proto.getAttribute = function(attr) { + if (this.patterns.points.test(attr)) { + var val = [ + superclass.getAttribute.call(this, 'left'), + superclass.getAttribute.call(this, 'top') + ]; + } else { + val = superclass.getAttribute.call(this, attr); + } + + return val; + }; + + proto.doMethod = function(attr, start, end) { + var val = null; + + if (this.patterns.points.test(attr)) { + var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100; + val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t); + } else { + val = superclass.doMethod.call(this, attr, start, end); + } + return val; + }; + + proto.setRuntimeAttribute = function(attr) { + if (this.patterns.points.test(attr)) { + var el = this.getEl(); + var attributes = this.attributes; + var start; + var control = attributes['points']['control'] || []; + var end; + var i, len; + + if (control.length > 0 && !Ext.isArray(control[0])) { + control = [control]; + } else { + var tmp = []; + for (i = 0,len = control.length; i < len; ++i) { + tmp[i] = control[i]; + } + control = tmp; + } + + Ext.fly(el, '_anim').position(); + + if (isset(attributes['points']['from'])) { + Ext.lib.Dom.setXY(el, attributes['points']['from']); + } + else { + Ext.lib.Dom.setXY(el, Ext.lib.Dom.getXY(el)); + } + + start = this.getAttribute('points'); + + + if (isset(attributes['points']['to'])) { + end = translateValues.call(this, attributes['points']['to'], start); + + var pageXY = Ext.lib.Dom.getXY(this.getEl()); + for (i = 0,len = control.length; i < len; ++i) { + control[i] = translateValues.call(this, control[i], start); + } + + + } else if (isset(attributes['points']['by'])) { + end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ]; + + for (i = 0,len = control.length; i < len; ++i) { + control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ]; + } + } + + this.runtimeAttributes[attr] = [start]; + + if (control.length > 0) { + this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control); + } + + this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end; + } + else { + superclass.setRuntimeAttribute.call(this, attr); + } + }; + + var translateValues = function(val, start) { + var pageXY = Ext.lib.Dom.getXY(this.getEl()); + val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ]; + + return val; + }; + + var isset = function(prop) { + return (typeof prop !== 'undefined'); + }; + })(); + + + (function() { + Ext.lib.Scroll = function(el, attributes, duration, method) { + if (el) { + Ext.lib.Scroll.superclass.constructor.call(this, el, attributes, duration, method); + } + }; + + Ext.extend(Ext.lib.Scroll, Ext.lib.ColorAnim); + + + var Y = Ext.lib; + var superclass = Y.Scroll.superclass; + var proto = Y.Scroll.prototype; + + proto.toString = function() { + var el = this.getEl(); + var id = el.id || el.tagName; + return ("Scroll " + id); + }; + + proto.doMethod = function(attr, start, end) { + var val = null; + + if (attr == 'scroll') { + val = [ + this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames), + this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames) + ]; + + } else { + val = superclass.doMethod.call(this, attr, start, end); + } + return val; + }; + + proto.getAttribute = function(attr) { + var val = null; + var el = this.getEl(); + + if (attr == 'scroll') { + val = [ el.scrollLeft, el.scrollTop ]; + } else { + val = superclass.getAttribute.call(this, attr); + } + + return val; + }; + + proto.setAttribute = function(attr, val, unit) { + var el = this.getEl(); + + if (attr == 'scroll') { + el.scrollLeft = val[0]; + el.scrollTop = val[1]; + } else { + superclass.setAttribute.call(this, attr, val, unit); + } + }; + })(); + + +})(); \ No newline at end of file diff --git a/deluge/ui/web/js/ext-base.js b/deluge/ui/web/js/ext-base.js new file mode 100644 index 000000000..b3ba70ef7 --- /dev/null +++ b/deluge/ui/web/js/ext-base.js @@ -0,0 +1 @@ +Ext={version:"2.2.1"};window["undefined"]=window["undefined"];Ext.apply=function(d,e,b){if(b){Ext.apply(d,b)}if(d&&e&&typeof e=="object"){for(var a in e){d[a]=e[a]}}return d};(function(){var idSeed=0;var ua=navigator.userAgent.toLowerCase();var isStrict=document.compatMode=="CSS1Compat",isOpera=ua.indexOf("opera")>-1,isChrome=ua.indexOf("chrome")>-1,isSafari=!isChrome&&(/webkit|khtml/).test(ua),isSafari3=isSafari&&ua.indexOf("webkit/5")!=-1,isIE=!isOpera&&ua.indexOf("msie")>-1,isIE7=!isOpera&&ua.indexOf("msie 7")>-1,isIE8=!isOpera&&ua.indexOf("msie 8")>-1,isGecko=!isSafari&&!isChrome&&ua.indexOf("gecko")>-1,isGecko3=isGecko&&ua.indexOf("rv:1.9")>-1,isBorderBox=isIE&&!isStrict,isWindows=(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1),isMac=(ua.indexOf("macintosh")!=-1||ua.indexOf("mac os x")!=-1),isAir=(ua.indexOf("adobeair")!=-1),isLinux=(ua.indexOf("linux")!=-1),isSecure=window.location.href.toLowerCase().indexOf("https")===0;if(isIE&&!isIE7){try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}}Ext.apply(Ext,{isStrict:isStrict,isSecure:isSecure,isReady:false,enableGarbageCollector:true,enableListenerCollection:false,SSL_SECURE_URL:"javascript:false",BLANK_IMAGE_URL:"http://extjs.com/s.gif",emptyFn:function(){},applyIf:function(o,c){if(o&&c){for(var p in c){if(typeof o[p]=="undefined"){o[p]=c[p]}}}return o},addBehaviors:function(o){if(!Ext.isReady){Ext.onReady(function(){Ext.addBehaviors(o)});return}var cache={};for(var b in o){var parts=b.split("@");if(parts[1]){var s=parts[0];if(!cache[s]){cache[s]=Ext.select(s)}cache[s].on(parts[1],o[b])}}cache=null},id:function(el,prefix){prefix=prefix||"ext-gen";el=Ext.getDom(el);var id=prefix+(++idSeed);return el?(el.id?el.id:(el.id=id)):id},extend:function(){var io=function(o){for(var m in o){this[m]=o[m]}};var oc=Object.prototype.constructor;return function(sb,sp,overrides){if(typeof sp=="object"){overrides=sp;sp=sb;sb=overrides.constructor!=oc?overrides.constructor:function(){sp.apply(this,arguments)}}var F=function(){},sbp,spp=sp.prototype;F.prototype=spp;sbp=sb.prototype=new F();sbp.constructor=sb;sb.superclass=spp;if(spp.constructor==oc){spp.constructor=sp}sb.override=function(o){Ext.override(sb,o)};sbp.override=io;Ext.override(sb,overrides);sb.extend=function(o){Ext.extend(sb,o)};return sb}}(),override:function(origclass,overrides){if(overrides){var p=origclass.prototype;for(var method in overrides){p[method]=overrides[method]}if(Ext.isIE&&overrides.toString!=origclass.toString){p.toString=overrides.toString}}},namespace:function(){var a=arguments,o=null,i,j,d,rt;for(i=0;i=0){l=g[p]}if(!s||!l){return false}this.doRemove(s,o,l[this.WFN],false);delete g[p][this.WFN];delete g[p][this.FN];g.splice(p,1);return true},getTarget:function(n,m){n=n.browserEvent||n;var l=n.target||n.srcElement;return this.resolveTextNode(l)},resolveTextNode:function(l){if(Ext.isSafari&&l&&3==l.nodeType){return l.parentNode}else{return l}},getPageX:function(m){m=m.browserEvent||m;var l=m.pageX;if(!l&&0!==l){l=m.clientX||0;if(Ext.isIE){l+=this.getScroll()[1]}}return l},getPageY:function(l){l=l.browserEvent||l;var m=l.pageY;if(!m&&0!==m){m=l.clientY||0;if(Ext.isIE){m+=this.getScroll()[0]}}return m},getXY:function(l){l=l.browserEvent||l;return[this.getPageX(l),this.getPageY(l)]},getRelatedTarget:function(m){m=m.browserEvent||m;var l=m.relatedTarget;if(!l){if(m.type=="mouseout"){l=m.toElement}else{if(m.type=="mouseover"){l=m.fromElement}}}return this.resolveTextNode(l)},getTime:function(n){n=n.browserEvent||n;if(!n.time){var m=new Date().getTime();try{n.time=m}catch(l){this.lastError=l;return m}}return n.time},stopEvent:function(l){this.stopPropagation(l);this.preventDefault(l)},stopPropagation:function(l){l=l.browserEvent||l;if(l.stopPropagation){l.stopPropagation()}else{l.cancelBubble=true}},preventDefault:function(l){l=l.browserEvent||l;if(l.preventDefault){l.preventDefault()}else{l.returnValue=false}},getEvent:function(m){var l=m||window.event;if(!l){var n=this.getEvent.caller;while(n){l=n.arguments[0];if(l&&Event==l.constructor){break}n=n.caller}}return l},getCharCode:function(l){l=l.browserEvent||l;return l.charCode||l.keyCode||0},_getCacheIndex:function(q,n,p){for(var o=0,m=g.length;o0)}var q=[];for(var m=0,l=h.length;m0){for(var r=0,t=u.length;r0){p=g.length;while(p){o=p-1;n=g[o];if(n){s.removeListener(n[s.EL],n[s.TYPE],n[s.FN],o)}p=p-1}n=null;s.clearCache()}s.doRemove(window,"unload",s._unload)},getScroll:function(){var l=document.documentElement,m=document.body;if(l&&(l.scrollTop||l.scrollLeft)){return[l.scrollTop,l.scrollLeft]}else{if(m){return[m.scrollTop,m.scrollLeft]}else{return[0,0]}}},doAdd:function(){if(window.addEventListener){return function(o,m,n,l){o.addEventListener(m,n,(l))}}else{if(window.attachEvent){return function(o,m,n,l){o.attachEvent("on"+m,n)}}else{return function(){}}}}(),doRemove:function(){if(window.removeEventListener){return function(o,m,n,l){o.removeEventListener(m,n,(l))}}else{if(window.detachEvent){return function(n,l,m){n.detachEvent("on"+l,m)}}else{return function(){}}}}()}}();var d=Ext.lib.Event;d.on=d.addListener;d.un=d.removeListener;if(document&&document.body){d._load()}else{d.doAdd(window,"load",d._load)}d.doAdd(window,"unload",d._unload);d._tryPreloadAttach();Ext.lib.Ajax={request:function(l,j,e,k,f){if(f){var g=f.headers;if(g){for(var i in g){if(g.hasOwnProperty(i)){this.initHeader(i,g[i],false)}}}if(f.xmlData){if(!g||!g["Content-Type"]){this.initHeader("Content-Type","text/xml",false)}l=(l?l:(f.method?f.method:"POST"));k=f.xmlData}else{if(f.jsonData){if(!g||!g["Content-Type"]){this.initHeader("Content-Type","application/json",false)}l=(l?l:(f.method?f.method:"POST"));k=typeof f.jsonData=="object"?Ext.encode(f.jsonData):f.jsonData}}}return this.asyncRequest(l,j,e,k)},serializeForm:function(f){if(typeof f=="string"){f=(document.getElementById(f)||document.forms[f])}var g,e,h,l,m="",o=false;for(var n=0;n=200&&h<300)||(Ext.isIE&&h==1223)){g=this.createResponseObject(j,k.argument);if(k.success){if(!k.scope){k.success(g)}else{k.success.apply(k.scope,[g])}}}else{switch(h){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:g=this.createExceptionObject(j.tId,k.argument,(f?f:false));if(k.failure){if(!k.scope){k.failure(g)}else{k.failure.apply(k.scope,[g])}}break;default:g=this.createResponseObject(j,k.argument);if(k.failure){if(!k.scope){k.failure(g)}else{k.failure.apply(k.scope,[g])}}}}this.releaseObject(j);g=null},createResponseObject:function(f,m){var j={};var p={};try{var h=f.conn.getAllResponseHeaders();var l=h.split("\n");for(var k=0;k=this.left&&e.right<=this.right&&e.top>=this.top&&e.bottom<=this.bottom)},getArea:function(){return((this.bottom-this.top)*(this.right-this.left))},intersect:function(i){var g=Math.max(this.top,i.top);var h=Math.min(this.right,i.right);var e=Math.min(this.bottom,i.bottom);var f=Math.max(this.left,i.left);if(e>=g&&h>=f){return new Ext.lib.Region(g,h,e,f)}else{return null}},union:function(i){var g=Math.min(this.top,i.top);var h=Math.max(this.right,i.right);var e=Math.max(this.bottom,i.bottom);var f=Math.min(this.left,i.left);return new Ext.lib.Region(g,h,e,f)},constrainTo:function(e){this.top=this.top.constrain(e.top,e.bottom);this.bottom=this.bottom.constrain(e.top,e.bottom);this.left=this.left.constrain(e.left,e.right);this.right=this.right.constrain(e.left,e.right);return this},adjust:function(g,f,e,h){this.top+=g;this.left+=f;this.right+=h;this.bottom+=e;return this}};Ext.lib.Region.getRegion=function(h){var j=Ext.lib.Dom.getXY(h);var g=j[1];var i=j[0]+h.offsetWidth;var e=j[1]+h.offsetHeight;var f=j[0];return new Ext.lib.Region(g,i,e,f)};Ext.lib.Point=function(e,f){if(Ext.isArray(e)){f=e[1];e=e[0]}this.x=this.right=this.left=this[0]=e;this.y=this.top=this.bottom=this[1]=f};Ext.lib.Point.prototype=new Ext.lib.Region();Ext.lib.Anim={scroll:function(h,f,i,j,e,g){return this.run(h,f,i,j,e,g,Ext.lib.Scroll)},motion:function(h,f,i,j,e,g){return this.run(h,f,i,j,e,g,Ext.lib.Motion)},color:function(h,f,i,j,e,g){return this.run(h,f,i,j,e,g,Ext.lib.ColorAnim)},run:function(i,f,k,l,e,h,g){g=g||Ext.lib.AnimBase;if(typeof l=="string"){l=Ext.lib.Easing[l]}var j=new g(i,f,k,l);j.animateX(function(){Ext.callback(e,h)});return j}};function c(e){if(!b){b=new Ext.Element.Flyweight()}b.dom=e;return b}if(Ext.isIE){function a(){var e=Function.prototype;delete e.createSequence;delete e.defer;delete e.createDelegate;delete e.createCallback;delete e.createInterceptor;window.detachEvent("onunload",a)}window.attachEvent("onunload",a)}Ext.lib.AnimBase=function(f,e,g,h){if(f){this.init(f,e,g,h)}};Ext.lib.AnimBase.prototype={toString:function(){var e=this.getEl();var f=e.id||e.tagName;return("Anim "+f)},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(e,g,f){return this.method(this.currentFrame,g,f-g,this.totalFrames)},setAttribute:function(e,g,f){if(this.patterns.noNegatives.test(e)){g=(g>0)?g:0}Ext.fly(this.getEl(),"_anim").setStyle(e,g+f)},getAttribute:function(e){var g=this.getEl();var i=c(g).getStyle(e);if(i!=="auto"&&!this.patterns.offsetUnit.test(i)){return parseFloat(i)}var f=this.patterns.offsetAttribute.exec(e)||[];var j=!!(f[3]);var h=!!(f[2]);if(h||(c(g).getStyle("position")=="absolute"&&j)){i=g["offset"+f[0].charAt(0).toUpperCase()+f[0].substr(1)]}else{i=0}return i},getDefaultUnit:function(e){if(this.patterns.defaultUnit.test(e)){return"px"}return""},animateX:function(h,e){var g=function(){this.onComplete.removeListener(g);if(typeof h=="function"){h.call(e||this,this)}};this.onComplete.addListener(g,this);this.animate()},setRuntimeAttribute:function(f){var l;var g;var h=this.attributes;this.runtimeAttributes[f]={};var k=function(i){return(typeof i!=="undefined")};if(!k(h[f]["to"])&&!k(h[f]["by"])){return false}l=(k(h[f]["from"]))?h[f]["from"]:this.getAttribute(f);if(k(h[f]["to"])){g=h[f]["to"]}else{if(k(h[f]["by"])){if(l.constructor==Array){g=[];for(var j=0,e=l.length;j0&&isFinite(o)){if(k.currentFrame+o>=n){o=n-(m+1)}k.currentFrame+=o}}};Ext.lib.Bezier=new function(){this.getPosition=function(k,h){var l=k.length;var g=[];for(var f=0;f0&&!Ext.isArray(o[0])){o=[o]}else{var n=[];for(p=0,r=o.length;p0){this.runtimeAttributes[s]=this.runtimeAttributes[s].concat(o)}this.runtimeAttributes[s][this.runtimeAttributes[s].length]=l}else{i.setRuntimeAttribute.call(this,s)}};var e=function(j,l){var k=Ext.lib.Dom.getXY(this.getEl());j=[j[0]-k[0]+l[0],j[1]-k[1]+l[1]];return j};var g=function(j){return(typeof j!=="undefined")}})();(function(){Ext.lib.Scroll=function(i,h,j,k){if(i){Ext.lib.Scroll.superclass.constructor.call(this,i,h,j,k)}};Ext.extend(Ext.lib.Scroll,Ext.lib.ColorAnim);var f=Ext.lib;var g=f.Scroll.superclass;var e=f.Scroll.prototype;e.toString=function(){var h=this.getEl();var i=h.id||h.tagName;return("Scroll "+i)};e.doMethod=function(h,k,i){var j=null;if(h=="scroll"){j=[this.method(this.currentFrame,k[0],i[0]-k[0],this.totalFrames),this.method(this.currentFrame,k[1],i[1]-k[1],this.totalFrames)]}else{j=g.doMethod.call(this,h,k,i)}return j};e.getAttribute=function(h){var j=null;var i=this.getEl();if(h=="scroll"){j=[i.scrollLeft,i.scrollTop]}else{j=g.getAttribute.call(this,h)}return j};e.setAttribute=function(h,k,j){var i=this.getEl();if(h=="scroll"){i.scrollLeft=k[0];i.scrollTop=k[1]}else{g.setAttribute.call(this,h,k,j)}}})()})(); \ No newline at end of file diff --git a/deluge/ui/web/js/ext-mootools-adapter.js b/deluge/ui/web/js/ext-mootools-adapter.js deleted file mode 100644 index 4a51e281e..000000000 --- a/deluge/ui/web/js/ext-mootools-adapter.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Mootools Ext Adapter - * Author: christoph.pojer@gmail.com - http://og5.net/christoph - * Last Update: 6 April 2008 - * Version: 0.9a - */ - -Ext={version:"2.0.2"};window["undefined"]=window["undefined"];Ext.apply=function(C,D,B){if(B){Ext.apply(C,B)}if(C&&D&&typeof D=="object"){for(var A in D){C[A]=D[A]}}return C};(function(){var idSeed=0;var ua=navigator.userAgent.toLowerCase();var isStrict=document.compatMode=="CSS1Compat",isOpera=ua.indexOf("opera")>-1,isSafari=(/webkit|khtml/).test(ua),isSafari3=isSafari&&ua.indexOf("webkit/5")!=-1,isIE=!isOpera&&ua.indexOf("msie")>-1,isIE7=!isOpera&&ua.indexOf("msie 7")>-1,isGecko=!isSafari&&ua.indexOf("gecko")>-1,isBorderBox=isIE&&!isStrict,isWindows=(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1),isMac=(ua.indexOf("macintosh")!=-1||ua.indexOf("mac os x")!=-1),isAir=(ua.indexOf("adobeair")!=-1),isLinux=(ua.indexOf("linux")!=-1),isSecure=window.location.href.toLowerCase().indexOf("https")===0;if(isIE&&!isIE7){try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}}Ext.apply(Ext,{isStrict:isStrict,isSecure:isSecure,isReady:false,enableGarbageCollector:true,enableListenerCollection:false,SSL_SECURE_URL:"javascript:false",BLANK_IMAGE_URL:"/images/s.gif",emptyFn:function(){},applyIf:function(o,c){if(o&&c){for(var p in c){if(typeof o[p]=="undefined"){o[p]=c[p]}}}return o},addBehaviors:function(o){if(!Ext.isReady){Ext.onReady(function(){Ext.addBehaviors(o)});return }var cache={};for(var b in o){var parts=b.split("@");if(parts[1]){var s=parts[0];if(!cache[s]){cache[s]=Ext.select(s)}cache[s].on(parts[1],o[b])}}cache=null},id:function(el,prefix){prefix=prefix||"ext-gen";el=Ext.getDom(el);var id=prefix+(++idSeed);return el?(el.id?el.id:(el.id=id)):id},extend:function(){var io=function(o){for(var m in o){this[m]=o[m]}};var oc=Object.prototype.constructor;return function(sb,sp,overrides){if(typeof sp=="object"){overrides=sp;sp=sb;sb=overrides.constructor!=oc?overrides.constructor:function(){sp.apply(this,arguments)}}var F=function(){},sbp,spp=sp.prototype;F.prototype=spp;sbp=sb.prototype=new F();sbp.constructor=sb;sb.superclass=spp;if(spp.constructor==oc){spp.constructor=sp}sb.override=function(o){Ext.override(sb,o)};sbp.override=io;Ext.override(sb,overrides);sb.extend=function(o){Ext.extend(sb,o)};return sb}}(),override:function(origclass,overrides){if(overrides){var p=origclass.prototype;for(var method in overrides){p[method]=overrides[method]}}},namespace:function(){var a=arguments,o=null,i,j,d,rt;for(i=0;i=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);},getArea:function(){return((this.bottom-this.top)*(this.right-this.left));},intersect:function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new Ext.lib.Region(t,r,b,l);}else{return null;}},union:function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new Ext.lib.Region(t,r,b,l);},constrainTo:function(r){this.top=this.top.constrain(r.top,r.bottom);this.bottom=this.bottom.constrain(r.top,r.bottom);this.left=this.left.constrain(r.left,r.right);this.right=this.right.constrain(r.left,r.right);return this;},adjust:function(t,l,b,r){this.top+=t;this.left+=l;this.right+=r;this.bottom+=b;return this;}};Ext.lib.Region.getRegion=function(el){var p=Ext.lib.Dom.getXY(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new Ext.lib.Region(t,r,b,l);};Ext.lib.Point=function(x,y){if(Ext.isArray(x)){y=x[1];x=x[0];} -this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};Ext.lib.Point.prototype=new Ext.lib.Region();})(); diff --git a/deluge/ui/web/js/mootools-1.2.1-core-yc.js b/deluge/ui/web/js/mootools-1.2.1-core-yc.js deleted file mode 100644 index 752b98ce0..000000000 --- a/deluge/ui/web/js/mootools-1.2.1-core-yc.js +++ /dev/null @@ -1,349 +0,0 @@ -//MooTools, , My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License. - -var MooTools={version:"1.2.1",build:"0d4845aab3d9a4fdee2f0d4a6dd59210e4b697cf"};var Native=function(K){K=K||{};var A=K.name;var I=K.legacy;var B=K.protect; -var C=K.implement;var H=K.generics;var F=K.initialize;var G=K.afterImplement||function(){};var D=F||I;H=H!==false;D.constructor=Native;D.$family={name:"native"}; -if(I&&F){D.prototype=I.prototype;}D.prototype.constructor=D;if(A){var E=A.toLowerCase();D.prototype.$family={name:E};Native.typize(D,E);}var J=function(N,L,O,M){if(!B||M||!N.prototype[L]){N.prototype[L]=O; -}if(H){Native.genericize(N,L,B);}G.call(N,L,O);return N;};D.alias=function(N,L,O){if(typeof N=="string"){if((N=this.prototype[N])){return J(this,L,N,O); -}}for(var M in N){this.alias(M,N[M],L);}return this;};D.implement=function(M,L,O){if(typeof M=="string"){return J(this,M,L,O);}for(var N in M){J(this,N,M[N],L); -}return this;};if(C){D.implement(C);}return D;};Native.genericize=function(B,C,A){if((!A||!B[C])&&typeof B.prototype[C]=="function"){B[C]=function(){var D=Array.prototype.slice.call(arguments); -return B.prototype[C].apply(D.shift(),D);};}};Native.implement=function(D,C){for(var B=0,A=D.length;B-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim(); -},camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase()); -});},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1"); -},toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); -return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A=""; -var C=this.replace(/]*>([\s\S]*?)<\/script>/gi,function(){A+=arguments[1]+"\n";return"";});if(B===true){$exec(A);}else{if($type(B)=="function"){B(A,C); -}}return C;},substitute:function(A,B){return this.replace(B||(/\\?\{([^{}]+)\}/g),function(D,C){if(D.charAt(0)=="\\"){return D.slice(1);}return(A[C]!=undefined)?A[C]:""; -});}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(B){for(var A in this){if(this.hasOwnProperty(A)&&this[A]===B){return A;}}return null; -},hasValue:function(A){return(Hash.keyOf(this,A)!==null);},extend:function(A){Hash.each(A,function(C,B){Hash.set(this,B,C);},this);return this;},combine:function(A){Hash.each(A,function(C,B){Hash.include(this,B,C); -},this);return this;},erase:function(A){if(this.hasOwnProperty(A)){delete this[A];}return this;},get:function(A){return(this.hasOwnProperty(A))?this[A]:null; -},set:function(A,B){if(!this[A]||this.hasOwnProperty(A)){this[A]=B;}return this;},empty:function(){Hash.each(this,function(B,A){delete this[A];},this); -return this;},include:function(B,C){var A=this[B];if(A==undefined){this[B]=C;}return this;},map:function(B,C){var A=new Hash;Hash.each(this,function(E,D){A.set(D,B.call(C,E,D,this)); -},this);return A;},filter:function(B,C){var A=new Hash;Hash.each(this,function(E,D){if(B.call(C,E,D,this)){A.set(D,E);}},this);return A;},every:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&!B.call(C,this[A],A)){return false; -}}return true;},some:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&B.call(C,this[A],A)){return true;}}return false;},getKeys:function(){var A=[]; -Hash.each(this,function(C,B){A.push(B);});return A;},getValues:function(){var A=[];Hash.each(this,function(B){A.push(B);});return A;},toQueryString:function(A){var B=[]; -Hash.each(this,function(F,E){if(A){E=A+"["+E+"]";}var D;switch($type(F)){case"object":D=Hash.toQueryString(F,E);break;case"array":var C={};F.each(function(H,G){C[G]=H; -});D=Hash.toQueryString(C,E);break;default:D=E+"="+encodeURIComponent(F);}if(F!=undefined){B.push(D);}});return B.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"}); -var Event=new Native({name:"Event",initialize:function(A,F){F=F||window;var K=F.document;A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type; -var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.test(/key/)){var B=A.which||A.keyCode;var M=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111; -if(D>0&&D<13){M="f"+D;}}M=M||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){K=(!K.compatMode||K.compatMode=="CSS1Compat")?K.html:K.body; -var I={x:A.pageX||A.clientX+K.scrollLeft,y:A.pageY||A.clientY+K.scrollTop};var C={x:(A.pageX)?A.pageX-F.pageXOffset:A.clientX,y:(A.pageY)?A.pageY-F.pageYOffset:A.clientY}; -if(J.match(/DOMMouseScroll|mousewheel/)){var H=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}var E=(A.which==3)||(A.button==2);var L=null;if(J.match(/over|out/)){switch(J){case"mouseover":L=A.relatedTarget||A.fromElement; -break;case"mouseout":L=A.relatedTarget||A.toElement;}if(!(function(){while(L&&L.nodeType==3){L=L.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){L=false; -}}}}return $extend(this,{event:A,type:J,page:I,client:C,rightClick:E,wheel:H,relatedTarget:L,target:G,code:B,key:M,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey}); -}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); -},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); -}else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(){for(var E in this){if($type(this[E])!="function"){this[E]=$unlink(this[E]); -}}this.constructor=A;if(Class.prototyping){return this;}var D=(this.initialize)?this.initialize.apply(this,arguments):this;if(this.options&&this.options.initialize){this.options.initialize.call(this); -}return D;};for(var C in Class.Mutators){if(!B[C]){continue;}B=Class.Mutators[C](B,B[C]);delete B[C];}$extend(A,this);A.constructor=Class;A.prototype=B; -return A;}});Class.Mutators={Extends:function(C,A){Class.prototyping=A.prototype;var B=new A;delete B.parent;B=Class.inherit(B,C);delete Class.prototyping; -return B;},Implements:function(A,B){$splat(B).each(function(C){Class.prototying=C;$extend(A,($type(C)=="class")?new C:C);delete Class.prototyping;});return A; -}};Class.extend({inherit:function(B,E){var A=arguments.callee.caller;for(var D in E){var C=E[D];var G=B[D];var F=$type(C);if(G&&F=="function"){if(C!=G){if(A){C.__parent=G; -B[D]=C;}else{Class.override(B,D,C);}}}else{if(F=="object"){B[D]=$merge(G,C);}else{B[D]=C;}}}if(A){B.parent=function(){return arguments.callee.caller.__parent.apply(this,arguments); -};}return B;},override:function(B,A,E){var D=Class.prototyping;if(D&&B[A]!=D[A]){D=null;}var C=function(){var F=this.parent;this.parent=D?D[A]:B[A];var G=E.apply(this,arguments); -this.parent=F;return G;};B[A]=C;}});Class.implement({implement:function(){var A=this.prototype;$each(arguments,function(B){Class.inherit(A,B);});return this; -}});var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false; -},clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){this.$events[C]=this.$events[C]||[]; -this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){C=Events.removeOn(C); -if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,"arguments":B})();},this);return this;},removeEvent:function(B,A){B=Events.removeOn(B); -if(!this.$events[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){if($type(C)=="object"){for(var D in C){this.removeEvent(D,C[D]); -}return this;}if(C){C=Events.removeOn(C);}for(var D in this.$events){if(C&&C!=D){continue;}var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]); -}}return this;}});Events.removeOn=function(A){return A.replace(/^on([A-Z])/,function(B,C){return C.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments)); -if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue;}this.addEvent(A,this.options[A]); -delete this.options[A];}return this;}});var Element=new Native({name:"Element",legacy:window.Element,initialize:function(A,B){var C=Element.Constructors.get(A); -if(C){return C(B);}if(typeof A=="string"){return document.newElement(A,B);}return $(A).set(B);},afterImplement:function(A,B){Element.Prototype[A]=B;if(Array[A]){return ; -}Elements.implement(A,function(){var C=[],G=true;for(var E=0,D=this.length;E";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A); -},getDocument:function(){return this;},getWindow:function(){return this.window;}});Window.implement({$:function(B,C){if(B&&B.$family&&B.uid){return B;}var A=$type(B); -return($[A])?$[A](B,C,this.document):null;},$$:function(A){if(arguments.length==1&&typeof A=="string"){return this.document.getElements(A);}var F=[];var C=Array.flatten(arguments); -for(var D=0,B=C.length;D1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D}); -}});(function(){var H={},F={};var I={input:"checked",option:"selected",textarea:(Browser.Engine.webkit&&Browser.Engine.version<420)?"innerHTML":"value"}; -var C=function(L){return(F[L]||(F[L]={}));};var G=function(N,L){if(!N){return ;}var M=N.uid;if(Browser.Engine.trident){if(N.clearAttributes){var P=L&&N.cloneNode(false); -N.clearAttributes();if(P){N.mergeAttributes(P);}}else{if(N.removeEvents){N.removeEvents();}}if((/object/i).test(N.tagName)){for(var O in N){if(typeof N[O]=="function"){N[O]=$empty; -}}Element.dispose(N);}}if(!M){return ;}H[M]=F[M]=null;};var D=function(){Hash.each(H,G);if(Browser.Engine.trident){$A(document.getElementsByTagName("object")).each(G); -}if(window.CollectGarbage){CollectGarbage();}H=F=null;};var J=function(N,L,S,M,P,R){var O=N[S||L];var Q=[];while(O){if(O.nodeType==1&&(!M||Element.match(O,M))){if(!P){return $(O,R); -}Q.push(O);}O=O[L];}return(P)?new Elements(Q,{ddup:false,cash:!R}):null;};var E={html:"innerHTML","class":"className","for":"htmlFor",text:(Browser.Engine.trident||(Browser.Engine.webkit&&Browser.Engine.version<420))?"innerText":"textContent"}; -var B=["compact","nowrap","ismap","declare","noshade","checked","disabled","readonly","multiple","selected","noresize","defer"];var K=["value","accessKey","cellPadding","cellSpacing","colSpan","frameBorder","maxLength","readOnly","rowSpan","tabIndex","useMap"]; -Hash.extend(E,B.associate(B));Hash.extend(E,K.associate(K.map(String.toLowerCase)));var A={before:function(M,L){if(L.parentNode){L.parentNode.insertBefore(M,L); -}},after:function(M,L){if(!L.parentNode){return ;}var N=L.nextSibling;(N)?L.parentNode.insertBefore(M,N):L.parentNode.appendChild(M);},bottom:function(M,L){L.appendChild(M); -},top:function(M,L){var N=L.firstChild;(N)?L.insertBefore(M,N):L.appendChild(M);}};A.inside=A.bottom;Hash.each(A,function(L,M){M=M.capitalize();Element.implement("inject"+M,function(N){L(this,$(N,true)); -return this;});Element.implement("grab"+M,function(N){L($(N,true),this);return this;});});Element.implement({set:function(O,M){switch($type(O)){case"object":for(var N in O){this.set(N,O[N]); -}break;case"string":var L=Element.Properties.get(O);(L&&L.set)?L.set.apply(this,Array.slice(arguments,1)):this.setProperty(O,M);}return this;},get:function(M){var L=Element.Properties.get(M); -return(L&&L.get)?L.get.apply(this,Array.slice(arguments,1)):this.getProperty(M);},erase:function(M){var L=Element.Properties.get(M);(L&&L.erase)?L.erase.apply(this):this.removeProperty(M); -return this;},setProperty:function(M,N){var L=E[M];if(N==undefined){return this.removeProperty(M);}if(L&&B[M]){N=!!N;}(L)?this[L]=N:this.setAttribute(M,""+N); -return this;},setProperties:function(L){for(var M in L){this.setProperty(M,L[M]);}return this;},getProperty:function(M){var L=E[M];var N=(L)?this[L]:this.getAttribute(M,2); -return(B[M])?!!N:(L)?N:N||null;},getProperties:function(){var L=$A(arguments);return L.map(this.getProperty,this).associate(L);},removeProperty:function(M){var L=E[M]; -(L)?this[L]=(L&&B[M])?false:"":this.removeAttribute(M);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this; -},hasClass:function(L){return this.className.contains(L," ");},addClass:function(L){if(!this.hasClass(L)){this.className=(this.className+" "+L).clean(); -}return this;},removeClass:function(L){this.className=this.className.replace(new RegExp("(^|\\s)"+L+"(?:\\s|$)"),"$1");return this;},toggleClass:function(L){return this.hasClass(L)?this.removeClass(L):this.addClass(L); -},adopt:function(){Array.flatten(arguments).each(function(L){L=$(L,true);if(L){this.appendChild(L);}},this);return this;},appendText:function(M,L){return this.grab(this.getDocument().newTextNode(M),L); -},grab:function(M,L){A[L||"bottom"]($(M,true),this);return this;},inject:function(M,L){A[L||"bottom"](this,$(M,true));return this;},replaces:function(L){L=$(L,true); -L.parentNode.replaceChild(this,L);return this;},wraps:function(M,L){M=$(M,true);return this.replaces(M).grab(M,L);},getPrevious:function(L,M){return J(this,"previousSibling",null,L,false,M); -},getAllPrevious:function(L,M){return J(this,"previousSibling",null,L,true,M);},getNext:function(L,M){return J(this,"nextSibling",null,L,false,M);},getAllNext:function(L,M){return J(this,"nextSibling",null,L,true,M); -},getFirst:function(L,M){return J(this,"nextSibling","firstChild",L,false,M);},getLast:function(L,M){return J(this,"previousSibling","lastChild",L,false,M); -},getParent:function(L,M){return J(this,"parentNode",null,L,false,M);},getParents:function(L,M){return J(this,"parentNode",null,L,true,M);},getChildren:function(L,M){return J(this,"nextSibling","firstChild",L,true,M); -},getWindow:function(){return this.ownerDocument.window;},getDocument:function(){return this.ownerDocument;},getElementById:function(O,N){var M=this.ownerDocument.getElementById(O); -if(!M){return null;}for(var L=M.parentNode;L!=this;L=L.parentNode){if(!L){return null;}}return $.element(M,N);},getSelected:function(){return new Elements($A(this.options).filter(function(L){return L.selected; -}));},getComputedStyle:function(M){if(this.currentStyle){return this.currentStyle[M.camelCase()];}var L=this.getDocument().defaultView.getComputedStyle(this,null); -return(L)?L.getPropertyValue([M.hyphenate()]):null;},toQueryString:function(){var L=[];this.getElements("input, select, textarea",true).each(function(M){if(!M.name||M.disabled){return ; -}var N=(M.tagName.toLowerCase()=="select")?Element.getSelected(M).map(function(O){return O.value;}):((M.type=="radio"||M.type=="checkbox")&&!M.checked)?null:M.value; -$splat(N).each(function(O){if(typeof O!="undefined"){L.push(M.name+"="+encodeURIComponent(O));}});});return L.join("&");},clone:function(O,L){O=O!==false; -var R=this.cloneNode(O);var N=function(V,U){if(!L){V.removeAttribute("id");}if(Browser.Engine.trident){V.clearAttributes();V.mergeAttributes(U);V.removeAttribute("uid"); -if(V.options){var W=V.options,S=U.options;for(var T=W.length;T--;){W[T].selected=S[T].selected;}}}var X=I[U.tagName.toLowerCase()];if(X&&U[X]){V[X]=U[X]; -}};if(O){var P=R.getElementsByTagName("*"),Q=this.getElementsByTagName("*");for(var M=P.length;M--;){N(P[M],Q[M]);}}N(R,this);return $(R);},destroy:function(){Element.empty(this); -Element.dispose(this);G(this,true);return null;},empty:function(){$A(this.childNodes).each(function(L){Element.destroy(L);});return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this; -},hasChild:function(L){L=$(L,true);if(!L){return false;}if(Browser.Engine.webkit&&Browser.Engine.version<420){return $A(this.getElementsByTagName(L.tagName)).contains(L); -}return(this.contains)?(this!=L&&this.contains(L)):!!(this.compareDocumentPosition(L)&16);},match:function(L){return(!L||(L==this)||(Element.get(this,"tag")==L)); -}});Native.implement([Element,Window,Document],{addListener:function(O,N){if(O=="unload"){var L=N,M=this;N=function(){M.removeListener("unload",N);L(); -};}else{H[this.uid]=this;}if(this.addEventListener){this.addEventListener(O,N,false);}else{this.attachEvent("on"+O,N);}return this;},removeListener:function(M,L){if(this.removeEventListener){this.removeEventListener(M,L,false); -}else{this.detachEvent("on"+M,L);}return this;},retrieve:function(M,L){var O=C(this.uid),N=O[M];if(L!=undefined&&N==undefined){N=O[M]=L;}return $pick(N); -},store:function(M,L){var N=C(this.uid);N[M]=L;return this;},eliminate:function(L){var M=C(this.uid);delete M[L];return this;}});window.addListener("unload",D); -})();Element.Properties=new Hash;Element.Properties.style={set:function(A){this.style.cssText=A;},get:function(){return this.style.cssText;},erase:function(){this.style.cssText=""; -}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase();}};Element.Properties.html=(function(){var C=document.createElement("div"); -var A={table:[1,"","
"],select:[1,""],tbody:[2,"","
"],tr:[3,"","
"]}; -A.thead=A.tfoot=A.tbody;var B={set:function(){var E=Array.flatten(arguments).join("");var F=Browser.Engine.trident&&A[this.get("tag")];if(F){var G=C;G.innerHTML=F[1]+E+F[2]; -for(var D=F[0];D--;){G=G.firstChild;}this.empty().adopt(G.childNodes);}else{this.innerHTML=E;}}};B.erase=B.set;return B;})();if(Browser.Engine.webkit&&Browser.Engine.version<420){Element.Properties.text={get:function(){if(this.innerText){return this.innerText; -}var A=this.ownerDocument.newElement("div",{html:this.innerHTML}).inject(this.ownerDocument.body);var B=A.innerText;A.destroy();return B;}};}Element.Properties.events={set:function(A){this.addEvents(A); -}};Native.implement([Element,Window,Document],{addEvent:function(E,G){var H=this.retrieve("events",{});H[E]=H[E]||{keys:[],values:[]};if(H[E].keys.contains(G)){return this; -}H[E].keys.push(G);var F=E,A=Element.Events.get(E),C=G,I=this;if(A){if(A.onAdd){A.onAdd.call(this,G);}if(A.condition){C=function(J){if(A.condition.call(this,J)){return G.call(this,J); -}return true;};}F=A.base||F;}var D=function(){return G.call(I);};var B=Element.NativeEvents[F];if(B){if(B==2){D=function(J){J=new Event(J,I.getWindow()); -if(C.call(I,J)===false){J.stop();}};}this.addListener(F,D);}H[E].values.push(D);return this;},removeEvent:function(C,B){var A=this.retrieve("events");if(!A||!A[C]){return this; -}var F=A[C].keys.indexOf(B);if(F==-1){return this;}A[C].keys.splice(F,1);var E=A[C].values.splice(F,1)[0];var D=Element.Events.get(C);if(D){if(D.onRemove){D.onRemove.call(this,B); -}C=D.base||C;}return(Element.NativeEvents[C])?this.removeListener(C,E):this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this; -},removeEvents:function(A){if($type(A)=="object"){for(var C in A){this.removeEvent(C,A[C]);}return this;}var B=this.retrieve("events");if(!B){return this; -}if(!A){for(var C in B){this.removeEvents(C);}this.eliminate("events");}else{if(B[A]){while(B[A].keys[0]){this.removeEvent(A,B[A].keys[0]);}B[A]=null;}}return this; -},fireEvent:function(D,B,A){var C=this.retrieve("events");if(!C||!C[D]){return this;}C[D].keys.each(function(E){E.create({bind:this,delay:A,"arguments":B})(); -},this);return this;},cloneEvents:function(D,A){D=$(D);var C=D.retrieve("events");if(!C){return this;}if(!A){for(var B in C){this.cloneEvents(D,B);}}else{if(C[A]){C[A].keys.each(function(E){this.addEvent(A,E); -},this);}}return this;}});Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1}; -(function(){var A=function(B){var C=B.relatedTarget;if(C==undefined){return true;}if(C===false){return false;}return($type(this)!="document"&&C!=this&&C.prefix!="xul"&&!this.hasChild(C)); -};Element.Events=new Hash({mouseenter:{base:"mouseover",condition:A},mouseleave:{base:"mouseout",condition:A},mousewheel:{base:(Browser.Engine.gecko)?"DOMMouseScroll":"mousewheel"}}); -})();Element.Properties.styles={set:function(A){this.setStyles(A);}};Element.Properties.opacity={set:function(A,B){if(!B){if(A==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden"; -}}else{if(this.style.visibility!="visible"){this.style.visibility="visible";}}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(Browser.Engine.trident){this.style.filter=(A==1)?"":"alpha(opacity="+A*100+")"; -}this.style.opacity=A;this.store("opacity",A);},get:function(){return this.retrieve("opacity",1);}};Element.implement({setOpacity:function(A){return this.set("opacity",A,true); -},getOpacity:function(){return this.get("opacity");},setStyle:function(B,A){switch(B){case"opacity":return this.set("opacity",parseFloat(A));case"float":B=(Browser.Engine.trident)?"styleFloat":"cssFloat"; -}B=B.camelCase();if($type(A)!="string"){var C=(Element.Styles.get(B)||"@").split(" ");A=$splat(A).map(function(E,D){if(!C[D]){return"";}return($type(E)=="number")?C[D].replace("@",Math.round(E)):E; -}).join(" ");}else{if(A==String(Number(A))){A=Math.round(A);}}this.style[B]=A;return this;},getStyle:function(G){switch(G){case"opacity":return this.get("opacity"); -case"float":G=(Browser.Engine.trident)?"styleFloat":"cssFloat";}G=G.camelCase();var A=this.style[G];if(!$chk(A)){A=[];for(var F in Element.ShortStyles){if(G!=F){continue; -}for(var E in Element.ShortStyles[F]){A.push(this.getStyle(E));}return A.join(" ");}A=this.getComputedStyle(G);}if(A){A=String(A);var C=A.match(/rgba?\([\d\s,]+\)/); -if(C){A=A.replace(C[0],C[0].rgbToHex());}}if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(A)))){if(G.test(/^(height|width)$/)){var B=(G=="width")?["left","right"]:["top","bottom"],D=0; -B.each(function(H){D+=this.getStyle("border-"+H+"-width").toInt()+this.getStyle("padding-"+H).toInt();},this);return this["offset"+G.capitalize()]-D+"px"; -}if((Browser.Engine.presto)&&String(A).test("px")){return A;}if(G.test(/(border(.+)Width|margin|padding)/)){return"0px";}}return A;},setStyles:function(B){for(var A in B){this.setStyle(A,B[A]); -}return this;},getStyles:function(){var A={};Array.each(arguments,function(B){A[B]=this.getStyle(B);},this);return A;}});Element.Styles=new Hash({left:"@px",top:"@px",bottom:"@px",right:"@px",width:"@px",height:"@px",maxWidth:"@px",maxHeight:"@px",minWidth:"@px",minHeight:"@px",backgroundColor:"rgb(@, @, @)",backgroundPosition:"@px @px",color:"rgb(@, @, @)",fontSize:"@px",letterSpacing:"@px",lineHeight:"@px",clip:"rect(@px @px @px @px)",margin:"@px @px @px @px",padding:"@px @px @px @px",border:"@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)",borderWidth:"@px @px @px @px",borderStyle:"@ @ @ @",borderColor:"rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)",zIndex:"@",zoom:"@",fontWeight:"@",textIndent:"@px",opacity:"@"}); -Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};["Top","Right","Bottom","Left"].each(function(G){var F=Element.ShortStyles; -var B=Element.Styles;["margin","padding"].each(function(H){var I=H+G;F[H][I]=B[I]="@px";});var E="border"+G;F.border[E]=B[E]="@px @ rgb(@, @, @)";var D=E+"Width",A=E+"Style",C=E+"Color"; -F[E]={};F.borderWidth[D]=F[E][D]=B[D]="@px";F.borderStyle[A]=F[E][A]=B[A]="@";F.borderColor[C]=F[E][C]=B[C]="rgb(@, @, @)";});(function(){Element.implement({scrollTo:function(H,I){if(B(this)){this.getWindow().scrollTo(H,I); -}else{this.scrollLeft=H;this.scrollTop=I;}return this;},getSize:function(){if(B(this)){return this.getWindow().getSize();}return{x:this.offsetWidth,y:this.offsetHeight}; -},getScrollSize:function(){if(B(this)){return this.getWindow().getScrollSize();}return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(B(this)){return this.getWindow().getScroll(); -}return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var I=this,H={x:0,y:0};while(I&&!B(I)){H.x+=I.scrollLeft;H.y+=I.scrollTop;I=I.parentNode; -}return H;},getOffsetParent:function(){var H=this;if(B(H)){return null;}if(!Browser.Engine.trident){return H.offsetParent;}while((H=H.parentNode)&&!B(H)){if(D(H,"position")!="static"){return H; -}}return null;},getOffsets:function(){if(Browser.Engine.trident){var L=this.getBoundingClientRect(),J=this.getDocument().documentElement;return{x:L.left+J.scrollLeft-J.clientLeft,y:L.top+J.scrollTop-J.clientTop}; -}var I=this,H={x:0,y:0};if(B(this)){return H;}while(I&&!B(I)){H.x+=I.offsetLeft;H.y+=I.offsetTop;if(Browser.Engine.gecko){if(!F(I)){H.x+=C(I);H.y+=G(I); -}var K=I.parentNode;if(K&&D(K,"overflow")!="visible"){H.x+=C(K);H.y+=G(K);}}else{if(I!=this&&Browser.Engine.webkit){H.x+=C(I);H.y+=G(I);}}I=I.offsetParent; -}if(Browser.Engine.gecko&&!F(this)){H.x-=C(this);H.y-=G(this);}return H;},getPosition:function(K){if(B(this)){return{x:0,y:0};}var L=this.getOffsets(),I=this.getScrolls(); -var H={x:L.x-I.x,y:L.y-I.y};var J=(K&&(K=$(K)))?K.getPosition():{x:0,y:0};return{x:H.x-J.x,y:H.y-J.y};},getCoordinates:function(J){if(B(this)){return this.getWindow().getCoordinates(); -}var H=this.getPosition(J),I=this.getSize();var K={left:H.x,top:H.y,width:I.x,height:I.y};K.right=K.left+K.width;K.bottom=K.top+K.height;return K;},computePosition:function(H){return{left:H.x-E(this,"margin-left"),top:H.y-E(this,"margin-top")}; -},position:function(H){return this.setStyles(this.computePosition(H));}});Native.implement([Document,Window],{getSize:function(){var I=this.getWindow(); -if(Browser.Engine.presto||Browser.Engine.webkit){return{x:I.innerWidth,y:I.innerHeight};}var H=A(this);return{x:H.clientWidth,y:H.clientHeight};},getScroll:function(){var I=this.getWindow(); -var H=A(this);return{x:I.pageXOffset||H.scrollLeft,y:I.pageYOffset||H.scrollTop};},getScrollSize:function(){var I=A(this);var H=this.getSize();return{x:Math.max(I.scrollWidth,H.x),y:Math.max(I.scrollHeight,H.y)}; -},getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var H=this.getSize();return{top:0,left:0,bottom:H.y,right:H.x,height:H.y,width:H.x}; -}});var D=Element.getComputedStyle;function E(H,I){return D(H,I).toInt()||0;}function F(H){return D(H,"-moz-box-sizing")=="border-box";}function G(H){return E(H,"border-top-width"); -}function C(H){return E(H,"border-left-width");}function B(H){return(/^(?:body|html)$/i).test(H.tagName);}function A(H){var I=H.getDocument();return(!I.compatMode||I.compatMode=="CSS1Compat")?I.html:I.body; -}})();Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y; -},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x; -},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});Native.implement([Document,Element],{getElements:function(H,G){H=H.split(","); -var C,E={};for(var D=0,B=H.length;D1),cash:!G});}});Element.implement({match:function(B){if(!B||(B==this)){return true;}var D=Selectors.Utils.parseTagAndID(B); -var A=D[0],E=D[1];if(!Selectors.Filters.byID(this,E)||!Selectors.Filters.byTag(this,A)){return false;}var C=Selectors.Utils.parseSelector(B);return(C)?Selectors.Utils.filter(this,C,{}):true; -}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)}; -Selectors.Utils={chk:function(B,C){if(!C){return true;}var A=$uid(B);if(!C[A]){return C[A]=true;}return false;},parseNthArgument:function(F){if(Selectors.Cache.nth[F]){return Selectors.Cache.nth[F]; -}var C=F.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!C){return false;}var E=parseInt(C[1]);var B=(E||E===0)?E:1;var D=C[2]||false;var A=parseInt(C[3])||0; -if(B!=0){A--;while(A<1){A+=B;}while(A>=B){A-=B;}}else{B=A;D="index";}switch(D){case"n":C={a:B,b:A,special:"n"};break;case"odd":C={a:2,b:0,special:"n"}; -break;case"even":C={a:2,b:1,special:"n"};break;case"first":C={a:0,special:"index"};break;case"last":C={special:"last-child"};break;case"only":C={special:"only-child"}; -break;default:C={a:(B-1),special:"index"};}return Selectors.Cache.nth[F]=C;},parseSelector:function(E){if(Selectors.Cache.parsed[E]){return Selectors.Cache.parsed[E]; -}var D,H={classes:[],pseudos:[],attributes:[]};while((D=Selectors.RegExps.combined.exec(E))){var I=D[1],G=D[2],F=D[3],B=D[5],C=D[6],J=D[7];if(I){H.classes.push(I); -}else{if(C){var A=Selectors.Pseudo.get(C);if(A){H.pseudos.push({parser:A,argument:J});}else{H.attributes.push({name:C,operator:"=",value:J});}}else{if(G){H.attributes.push({name:G,operator:F,value:B}); -}}}}if(!H.classes.length){delete H.classes;}if(!H.attributes.length){delete H.attributes;}if(!H.pseudos.length){delete H.pseudos;}if(!H.classes&&!H.attributes&&!H.pseudos){H=null; -}return Selectors.Cache.parsed[E]=H;},parseTagAndID:function(B){var A=B.match(Selectors.RegExps.tag);var C=B.match(Selectors.RegExps.id);return[(A)?A[1]:"*",(C)?C[1]:false]; -},filter:function(F,C,E){var D;if(C.classes){for(D=C.classes.length;D--;D){var G=C.classes[D];if(!Selectors.Filters.byClass(F,G)){return false;}}}if(C.attributes){for(D=C.attributes.length; -D--;D){var B=C.attributes[D];if(!Selectors.Filters.byAttribute(F,B.name,B.operator,B.value)){return false;}}}if(C.pseudos){for(D=C.pseudos.length;D--;D){var A=C.pseudos[D]; -if(!Selectors.Filters.byPseudo(F,A.parser,A.argument,E)){return false;}}}return true;},getByTagAndID:function(B,A,D){if(D){var C=(B.getElementById)?B.getElementById(D,true):Element.getElementById(B,D,true); -return(C&&Selectors.Filters.byTag(C,A))?[C]:[];}else{return B.getElementsByTagName(A);}},search:function(I,H,N){var B=[];var C=H.trim().replace(Selectors.RegExps.splitter,function(Y,X,W){B.push(X); -return":)"+W;}).split(":)");var J,E,U;for(var T=0,P=C.length;T":function(H,G,I,A,F){var C=Selectors.Utils.getByTagAndID(G,I,A);for(var E=0,D=C.length;EA){return false;}}return(C==A);},even:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n+1",A); -},odd:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n",A);}});Element.Events.domready={onAdd:function(A){if(Browser.loaded){A.call(this); -}}};(function(){var B=function(){if(Browser.loaded){return ;}Browser.loaded=true;window.fireEvent("domready");document.fireEvent("domready");};if(Browser.Engine.trident){var A=document.createElement("div"); -(function(){($try(function(){A.doScroll("left");return $(A).inject(document.body).set("html","temp").dispose();}))?B():arguments.callee.delay(50);})(); -}else{if(Browser.Engine.webkit&&Browser.Engine.version<525){(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50); -})();}else{window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}}})();var JSON=new Hash({$specialChars:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},$replaceChars:function(A){return JSON.$specialChars[A]||"\\u00"+Math.floor(A.charCodeAt()/16).toString(16)+(A.charCodeAt()%16).toString(16); -},encode:function(B){switch($type(B)){case"string":return'"'+B.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case"array":return"["+String(B.map(JSON.encode).filter($defined))+"]"; -case"object":case"hash":var A=[];Hash.each(B,function(E,D){var C=JSON.encode(E);if(C){A.push(JSON.encode(D)+":"+C);}});return"{"+A+"}";case"number":case"boolean":return String(B); -case false:return"null";}return null;},decode:function(string,secure){if($type(string)!="string"||!string.length){return null;}if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,""))){return null; -}return eval("("+string+")");}});Native.implement([Hash,Array,String,Number],{toJSON:function(){return JSON.encode(this);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(B,A){this.key=B; -this.setOptions(A);},write:function(B){B=encodeURIComponent(B);if(this.options.domain){B+="; domain="+this.options.domain;}if(this.options.path){B+="; path="+this.options.path; -}if(this.options.duration){var A=new Date();A.setTime(A.getTime()+this.options.duration*24*60*60*1000);B+="; expires="+A.toGMTString();}if(this.options.secure){B+="; secure"; -}this.options.document.cookie=this.key+"="+B;return this;},read:function(){var A=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); -return(A)?decodeURIComponent(A[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(B,C,A){return new Cookie(B,A).write(C); -};Cookie.read=function(A){return new Cookie(A).read();};Cookie.dispose=function(B,A){return new Cookie(B,A).dispose();};var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:"high",allowScriptAccess:"always",wMode:"transparent",swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object; -},initialize:function(L,M){this.instance="Swiff_"+$time();this.setOptions(M);M=this.options;var B=this.id=M.id||this.instance;var A=$(M.container);Swiff.CallBacks[this.instance]={}; -var E=M.params,G=M.vars,F=M.callBacks;var H=$extend({height:M.height,width:M.width},M.properties);var K=this;for(var D in F){Swiff.CallBacks[this.instance][D]=(function(N){return function(){return N.apply(K.object,arguments); -};})(F[D]);G[D]="Swiff.CallBacks."+this.instance+"."+D;}E.flashVars=Hash.toQueryString(G);if(Browser.Engine.trident){H.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; -E.movie=L;}else{H.type="application/x-shockwave-flash";H.data=L;}var J=''; -}}J+="";this.object=((A)?A.empty():new Element("div")).set("html",J).firstChild;},replaces:function(A){A=$(A,true);A.parentNode.replaceChild(this.toElement(),A); -return this;},inject:function(A){$(A,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments)); -}});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction(''+__flash__argumentsToXML(arguments,2)+""); -return eval(rs);};var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:"ignore"},initialize:function(A){this.subject=this.subject||this; -this.setOptions(A);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var B=this.options.wait;if(B===false){this.options.link="cancel"; -}},getTransition:function(){return function(A){return -(Math.cos(Math.PI*A)-1)/2;};},step:function(){var A=$time();if(A=(7-4*B)/11){C=A*A-Math.pow((11-6*B-11*D)/4,2); -break;}}return C;},Elastic:function(B,A){return Math.pow(2,10*--B)*Math.cos(20*B*Math.PI*(A[0]||1)/3);}});["Quad","Cubic","Quart","Quint"].each(function(B,A){Fx.Transitions[B]=new Fx.Transition(function(C){return Math.pow(C,[A+2]); -});});var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(A){this.xhr=new Browser.Request(); -this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ; -}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; -this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300)); -},processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts); -},success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); -},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B); -return this;},getHeader:function(A){return $try(function(){return this.xhr.getResponseHeader(A);}.bind(this));},check:function(A){if(!this.running){return true; -}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));return false;}return false; -},send:function(I){if(!this.check(arguments.callee,I)){return this;}this.running=true;var G=$type(I);if(G=="string"||G=="element"){I={data:I};}var D=this.options; -I=$extend({data:D.data,url:D.url,method:D.method},I);var E=I.data,B=I.url,A=I.method;switch($type(E)){case"element":E=$(E).toQueryString();break;case"object":case"hash":E=Hash.toQueryString(E); -}if(this.options.format){var H="format="+this.options.format;E=(E)?H+"&"+E:H;}if(this.options.emulation&&["put","delete"].contains(A)){var F="_method="+A; -E=(E)?F+"&"+E:F;A="post";}if(this.options.urlEncoded&&A=="post"){var C=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+C); -}if(E&&A=="get"){B=B+(B.contains("?")?"&":"?")+E;E=null;}this.xhr.open(A.toUpperCase(),B,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this); -this.headers.each(function(K,J){try{this.xhr.setRequestHeader(J,K);}catch(L){this.fireEvent("exception",[J,K]);}},this);this.fireEvent("request");this.xhr.send(E); -if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this;}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty; -this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var A={};["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(B){A[B]=function(){var C=Array.link(arguments,{url:String.type,data:$defined}); -return this.send($extend(C,{method:B.toLowerCase()}));};});Request.implement(A);})();Element.Properties.send={set:function(A){var B=this.retrieve("send"); -if(B){B.cancel();}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},A)); -},get:function(A){if(A||!this.retrieve("send")){if(A||!this.retrieve("send:options")){this.set("send",A);}this.store("send",new Request(this.retrieve("send:options"))); -}return this.retrieve("send");}};Element.implement({send:function(A){var B=this.get("send");B.send({data:this,url:A||B.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,evalScripts:true,filter:false},processHTML:function(C){var B=C.match(/]*>([\s\S]*?)<\/body>/i); -C=(B)?B[1]:C;var A=new Element("div");return $try(function(){var D=""+C+"",G;if(Browser.Engine.trident){G=new ActiveXObject("Microsoft.XMLDOM"); -G.async=false;G.loadXML(D);}else{G=new DOMParser().parseFromString(D,"text/xml");}D=G.getElementsByTagName("root")[0];for(var F=0,E=D.childNodes.length; -F= this.left && - region.right <= this.right && - region.top >= this.top && - region.bottom <= this.bottom ); - - }, - - getArea : function() { - return ( (this.bottom - this.top) * (this.right - this.left) ); - }, - - intersect : function(region) { - var t = Math.max( this.top, region.top ); - var r = Math.min( this.right, region.right ); - var b = Math.min( this.bottom, region.bottom ); - var l = Math.max( this.left, region.left ); - - if (b >= t && r >= l) { - return new Ext.lib.Region(t, r, b, l); - } else { - return null; - } - }, - union : function(region) { - var t = Math.min( this.top, region.top ); - var r = Math.max( this.right, region.right ); - var b = Math.max( this.bottom, region.bottom ); - var l = Math.min( this.left, region.left ); - - return new Ext.lib.Region(t, r, b, l); - }, - - constrainTo : function(r) { - this.top = this.top.constrain(r.top, r.bottom); - this.bottom = this.bottom.constrain(r.top, r.bottom); - this.left = this.left.constrain(r.left, r.right); - this.right = this.right.constrain(r.left, r.right); - return this; - }, - - adjust : function(t, l, b, r){ - this.top += t; - this.left += l; - this.right += r; - this.bottom += b; - return this; - } -}; - -Ext.lib.Region.getRegion = function(el) { - var p = Ext.lib.Dom.getXY(el); - - var t = p[1]; - var r = p[0] + el.offsetWidth; - var b = p[1] + el.offsetHeight; - var l = p[0]; - - return new Ext.lib.Region(t, r, b, l); -}; - -Ext.lib.Point = function(x, y) { - if (Ext.isArray(x)) { - y = x[1]; - x = x[0]; - } - this.x = this.right = this.left = this[0] = x; - this.y = this.top = this.bottom = this[1] = y; -}; - -Ext.lib.Point.prototype = new Ext.lib.Region(); -})(); \ No newline at end of file diff --git a/deluge/ui/web/js/mootools-bridge.js b/deluge/ui/web/js/mootools-bridge.js deleted file mode 100644 index 00ebde519..000000000 --- a/deluge/ui/web/js/mootools-bridge.js +++ /dev/null @@ -1 +0,0 @@ -(function(){Ext.lib.Dom={getViewWidth:function(b){return document["get"+(b?"Scroll":"")+"Width"]()},getViewHeight:function(b){return document["get"+(b?"Scroll":"")+"Height"]()},getDocumentHeight:function(){return document.getScrollHeight()},getDocumentWidth:function(){return document.getScrollWidth()},getViewportHeight:function(){return document.getHeight()},getViewportWidth:function(){return document.getWidth()},isAncestor:function(b,d){return $(b).hasChild(d)},getRegion:function(b){return Ext.lib.Region.getRegion(b)},getY:function(b){return $(b).getTop()},getX:function(b){return $(b).getLeft()},getXY:function(b){return Hash.getValues($(b).getPosition())},setXY:function(b,c){var d=Ext.get(b).translatePoints(c);Hash.each(d,function(e,f){if(!e){return}$(b).setStyle(f,e+"px")})},setX:function(c,b){this.setXY(c,[b,false])},setY:function(b,c){this.setXY(b,[false,c])}};function a(b){if($type(b)=="object"){return new Document(b)}return $(b)}Ext.lib.Event={getPageX:function(b){return new Event(b.browserEvent||b).page.x},getPageY:function(b){return new Event(b.browserEvent||b).page.y},getXY:function(c){var b=new Event(c.browserEvent||c).page;return b?[b.x,b.y]:[0,0]},getTarget:function(b){return new Event(b.browserEvent||b).target},resolveTextNode:function(b){return b&&3==b.nodeType?b.parentNode:b},getRelatedTarget:function(b){return new Event(b.browserEvent||b).relatedTarget},on:function(c,d,b){c=a(c);if(c){c.addListener(d,b)}},un:function(c,d,b){c=a(c);if(c){c.removeListener(d,b)}},purgeElement:function(b){b=a(b);if(b){b.removeEvents()}},preventDefault:function(b){new Event(b.browserEvent||b).preventDefault()},stopPropagation:function(b){new Event(b.browserEvent||b).stopPropagation()},stopEvent:function(b){new Event(b.browserEvent||b).stop()},onAvailable:function(d,c,b){if(Browser.loaded){c.call(b||window,$(d))}else{document.addEvent("domready",c)}}};Ext.lib.Ajax=function(){var c=function(d){return d.success?function(f,e){d.success.call(d.scope||window,{responseText:f,responseXML:e,argument:d.argument})}:Ext.emptyFn};var b=function(d){return d.failure?function(f,e){d.failure.call(d.scope||window,{responseText:f,responseXML:e,argument:d.argument})}:Ext.emptyFn};return{request:function(j,f,d,g,e){var h={url:f,method:j.toLowerCase(),data:g||"",onSuccess:c(d),onFailure:b(d)};if(e){if(e.headers){h.headers=e.headers}if(e.xmlData){h.method="post";h.headers={"Content-type":"text/xml"};h.data=e.xmlData}if(e.jsonData){h.method="post";h.headers={"Content-type":"text/javascript"};h.data=typeof e.jsonData=="object"?Ext.encode(e.jsonData):e.jsonData}}new Request(h).send()},formRequest:function(h,g,e,j,d,f){new Request({url:g,method:(Ext.getDom(h).method||"post").toLowerCase(),data:$(h).toQueryString()+(j?"&"+j:""),onSuccess:c(e),onFailure:b(e)}).send()},isCallInProgress:function(d){return false},abort:function(d){return false},serializeForm:function(d){return $(d.dom||d).toQueryString()}}}();Ext.lib.Anim=function(){var d=function(e,f){return{stop:function(g){this.effect.pause()},isAnimated:function(){return !!this.effect.timer},proxyCallback:function(){Ext.callback(e,f)}}};var c=function(e){if(!Fx.Transitions[e]){e="linear"}return Fx.Transitions[e]};var b={scroll:function(h,f,k,l,e,g){var j=d(e,g);j.effect=new Fx.Scroll(h,{duration:k*1000,transisions:c(l),onComplete:j.proxyCallback}).start(f);return j},run:function(h,q,k,o,j,s,r){if(o=="easeNone"){o="linear"}var l=d(j,s);var f={};for(i in q){if(i=="points"){var n,g,m=Ext.fly(h,"_animrun");m.position();if(n=q[i].by){var t=m.getXY();g=m.translatePoints([t[0]+n[0],t[1]+n[1]])}else{g=m.translatePoints(q[i].to)}f.left=g.left;f.top=g.top}else{f[i]=q[i].from?[q[i].from,q[i].to]:[q[i].to]}}l.effect=new Fx.Morph(h,{duration:k*1000,transition:c(o),onComplete:l.proxyCallback}).start(f);return l}};return Hash.extend(b,{motion:b.run,color:b.run})}();Ext.lib.Region=function(e,f,c,d){this.top=e;this[1]=e;this.right=f;this.bottom=c;this.left=d;this[0]=d};Ext.lib.Region.prototype={contains:function(b){return(b.left>=this.left&&b.right<=this.right&&b.top>=this.top&&b.bottom<=this.bottom)},getArea:function(){return((this.bottom-this.top)*(this.right-this.left))},intersect:function(g){var e=Math.max(this.top,g.top);var f=Math.min(this.right,g.right);var c=Math.min(this.bottom,g.bottom);var d=Math.max(this.left,g.left);if(c>=e&&f>=d){return new Ext.lib.Region(e,f,c,d)}else{return null}},union:function(g){var e=Math.min(this.top,g.top);var f=Math.max(this.right,g.right);var c=Math.max(this.bottom,g.bottom);var d=Math.min(this.left,g.left);return new Ext.lib.Region(e,f,c,d)},constrainTo:function(b){this.top=this.top.constrain(b.top,b.bottom);this.bottom=this.bottom.constrain(b.top,b.bottom);this.left=this.left.constrain(b.left,b.right);this.right=this.right.constrain(b.left,b.right);return this},adjust:function(e,d,c,f){this.top+=e;this.left+=d;this.right+=f;this.bottom+=c;return this}};Ext.lib.Region.getRegion=function(f){var h=Ext.lib.Dom.getXY(f);var e=h[1];var g=h[0]+f.offsetWidth;var c=h[1]+f.offsetHeight;var d=h[0];return new Ext.lib.Region(e,g,c,d)};Ext.lib.Point=function(b,c){if(Ext.isArray(b)){c=b[1];b=b[0]}this.x=this.right=this.left=this[0]=b;this.y=this.top=this.bottom=this[1]=c};Ext.lib.Point.prototype=new Ext.lib.Region()})(); \ No newline at end of file diff --git a/deluge/ui/web/js/rpc.js b/deluge/ui/web/js/rpc.js index 59e0187aa..4d12d763e 100644 --- a/deluge/ui/web/js/rpc.js +++ b/deluge/ui/web/js/rpc.js @@ -40,7 +40,7 @@ Example: Returns: The proxy that can be used to directly call methods on the server. */ -JSON.RPC = new Class({ +RPC = new Class({ Implements: Options, options: {