Changeset ee8531a


Ignore:
Timestamp:
03/24/2010 06:04:06 PM (15 years ago)
Author:
Damien Churchill <damoxc@gmail.com>
Branches:
2.0.x, develop, extjs4-port, master
Children:
afbca0
Parents:
7d27b8
Message:

update the debug and compressed js files

Location:
deluge/ui/web/js
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • deluge/ui/web/js/deluge-all-debug.js

    r7d27b8 ree8531a  
    3232*/
    3333
    34 // Create the namespace Ext.deluge
    35 Ext.namespace('Ext.deluge');
    3634
    3735// Setup the state manager
    3836Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
    3937
     38// Add some additional functions to ext and setup some of the
     39// configurable parameters
    4040(function() {
     41
    4142    Ext.apply(Ext, {
    4243                escapeHTML: function(text) {
     
    8687    });
    8788    Ext.getKeys = Ext.keys;
    88     Ext.BLANK_IMAGE_URL = '/images/s.gif';
     89    Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif';
    8990        Ext.USE_NATIVE_JSON = true;
    9091})();
    9192
    92 (function() {
    93         var tpl = '<div class="x-progress-wrap x-progress-renderered">' +
    94                 '<div class="x-progress-inner">' +
    95                         '<div style="width: {2}px" class="x-progress-bar">' +
    96                                 '<div style="z-index: 99; width: {3}px" class="x-progress-text">' +
    97                                         '<div style="width: {1}px;">{0}</div>' +
    98                                 '</div>' +
    99                         '</div>' +
    100                         '<div class="x-progress-text x-progress-text-back">' +
    101                                 '<div style="width: {1}px;">{0}</div>' +
    102                         '</div>' +
    103                 '</div>' +
    104         '</div>';
    105        
    106         Deluge.progressBar =  function(progress, width, text, modifier) {
     93// Create the Deluge namespace
     94Deluge = {
     95       
     96        // private
     97        progressTpl:    '<div class="x-progress-wrap x-progress-renderered">' +
     98                                                '<div class="x-progress-inner">' +
     99                                                        '<div style="width: {2}px" class="x-progress-bar">' +
     100                                                                '<div style="z-index: 99; width: {3}px" class="x-progress-text">' +
     101                                                                        '<div style="width: {1}px;">{0}</div>' +
     102                                                                '</div>' +
     103                                                        '</div>' +
     104                                                        '<div class="x-progress-text x-progress-text-back">' +
     105                                                                '<div style="width: {1}px;">{0}</div>' +
     106                                                        '</div>' +
     107                                                '</div>' +
     108                                        '</div>',
     109
     110       
     111        /**
     112         * A method to create a progress bar that can be used by renderers
     113         * to display a bar within a grid or tree.
     114         * @param {Number} progress The bars progress
     115         * @param {Number} width The width of the bar
     116         * @param {String} text The text to display on the bar
     117         * @param {Number} modified Amount to subtract from the width allowing for fixes
     118         */
     119        progressBar: function(progress, width, text, modifier) {
    107120                modifier = Ext.value(modifier, 10);
    108121                var progressWidth = ((width / 100.0) * progress).toFixed(0);
    109122                var barWidth = progressWidth - 1;
    110123                var textWidth = ((progressWidth - modifier) > 0 ? progressWidth - modifier : 0);
    111                 return String.format(tpl, text, width, barWidth, textWidth);
     124                return String.format(Deluge.progressTpl, text, width, barWidth, textWidth);
    112125        }
    113126       
    114         Deluge.Plugins = {};
    115 })();
     127}
     128
     129// Setup a space for plugins to insert themselves
     130deluge.plugins = {};
    116131
    117132// Hinting for gettext_gen.py
     
    206221         *
    207222         * @param {Number} bytes the filesize in bytes
     223         * @param {Boolean} showZero pass in true to displays 0 values
    208224         * @return {String} formatted string with KiB, MiB or GiB units.
    209225         */
    210         size: function(bytes) {
    211                 if (!bytes) return '';
     226        size: function(bytes, showZero) {
     227                if (!bytes && !showZero) return '';
    212228                bytes = bytes / 1024.0;
    213229       
     
    225241         *
    226242         * @param {Number} bits the number of bits per second
     243         * @param {Boolean} showZero pass in true to displays 0 values
    227244         * @return {String} formatted string with KiB, MiB or GiB units.
    228245         */
    229         speed: function(bits) {
    230                 return (!bits) ? '' : fsize(bits) + '/s';
     246        speed: function(bits, showZero) {
     247                return (!bits && !showZero) ? '' : fsize(bits, showZero) + '/s';
    231248        },
    232249       
     
    400417});
    401418/*
    402 Script: deluge-menus.js
     419Script: deluge.menus.js
    403420    Contains all the menus contained within the UI for easy access and editing.
    404421
     
    433450*/
    434451
    435 Deluge.Menus = {
     452deluge.menus = {
    436453        onTorrentAction: function(item, e) {
    437                 var selection = Deluge.Torrents.getSelections();
     454                var selection = deluge.torrents.getSelections();
    438455                var ids = [];
    439456                Ext.each(selection, function(record) {
     
    445462                        case 'pause':
    446463                        case 'resume':
    447                                 Deluge.Client.core[action + '_torrent'](ids, {
     464                                deluge.client.core[action + '_torrent'](ids, {
    448465                                        success: function() {
    449                                                 Deluge.UI.update();
     466                                                deluge.ui.update();
    450467                                        }
    451468                                });
     
    455472                        case 'down':
    456473                        case 'bottom':
    457                                 Deluge.Client.core['queue_' + action](ids, {
     474                                deluge.client.core['queue_' + action](ids, {
    458475                                        success: function() {
    459                                                 Deluge.UI.update();
     476                                                deluge.ui.update();
    460477                                        }
    461478                                });
    462479                                break;
    463480                        case 'edit_trackers':
    464                                 Deluge.EditTrackers.show();
     481                                deluge.editTrackers.show();
    465482                                break;
    466483                        case 'update':
    467                                 Deluge.Client.core.force_reannounce(ids, {
     484                                deluge.client.core.force_reannounce(ids, {
    468485                                        success: function() {
    469                                                 Deluge.UI.update();
     486                                                deluge.ui.update();
    470487                                        }
    471488                                });
    472489                                break;
    473490                        case 'remove':
    474                                 Deluge.RemoveWindow.show(ids);
     491                                deluge.removeWindow.show(ids);
    475492                                break;
    476493                        case 'recheck':
    477                                 Deluge.Client.core.force_recheck(ids, {
     494                                deluge.client.core.force_recheck(ids, {
    478495                                        success: function() {   
    479                                                 Deluge.UI.update();
     496                                                deluge.ui.update();
    480497                                        }
    481498                                });
    482499                                break;
    483500                        case 'move':
    484                                 Deluge.MoveStorage.show(ids);
     501                                deluge.moveStorage.show(ids);
    485502                                break;
    486503                }
     
    488505}
    489506
    490 Deluge.Menus.Torrent = new Ext.menu.Menu({
     507deluge.menus.torrent = new Ext.menu.Menu({
    491508        id: 'torrentMenu',
    492509        items: [{
     
    494511                text: _('Pause'),
    495512                iconCls: 'icon-pause',
    496                 handler: Deluge.Menus.onTorrentAction,
    497                 scope: Deluge.Menus
     513                handler: deluge.menus.onTorrentAction,
     514                scope: deluge.menus
    498515        }, {
    499516                torrentAction: 'resume',
    500517                text: _('Resume'),
    501518                iconCls: 'icon-resume',
    502                 handler: Deluge.Menus.onTorrentAction,
    503                 scope: Deluge.Menus
     519                handler: deluge.menus.onTorrentAction,
     520                scope: deluge.menus
    504521        }, '-', {
    505522                text: _('Options'),
     
    562579                        }, {
    563580                                text: _('Upload Slot Limit'),
    564                                 icon: '/icons/upload_slots.png',
     581                                iconCls: 'icon-upload-slots',
    565582                                menu: new Ext.menu.Menu({
    566583                                        items: [{
     
    592609                                text: _('Top'),
    593610                                iconCls: 'icon-top',
    594                                 handler: Deluge.Menus.onTorrentAction,
    595                                 scope: Deluge.Menus
     611                                handler: deluge.menus.onTorrentAction,
     612                                scope: deluge.menus
    596613                        },{
    597614                                torrentAction: 'up',
    598615                                text: _('Up'),
    599616                                iconCls: 'icon-up',
    600                                 handler: Deluge.Menus.onTorrentAction,
    601                                 scope: Deluge.Menus
     617                                handler: deluge.menus.onTorrentAction,
     618                                scope: deluge.menus
    602619                        },{
    603620                                torrentAction: 'down',
    604621                                text: _('Down'),
    605622                                iconCls: 'icon-down',
    606                                 handler: Deluge.Menus.onTorrentAction,
    607                                 scope: Deluge.Menus
     623                                handler: deluge.menus.onTorrentAction,
     624                                scope: deluge.menus
    608625                        },{
    609626                                torrentAction: 'bottom',
    610627                                text: _('Bottom'),
    611628                                iconCls: 'icon-bottom',
    612                                 handler: Deluge.Menus.onTorrentAction,
    613                                 scope: Deluge.Menus
     629                                handler: deluge.menus.onTorrentAction,
     630                                scope: deluge.menus
    614631                        }]
    615632                })
     
    618635                text: _('Update Tracker'),
    619636                iconCls: 'icon-update-tracker',
    620                 handler: Deluge.Menus.onTorrentAction,
    621                 scope: Deluge.Menus
     637                handler: deluge.menus.onTorrentAction,
     638                scope: deluge.menus
    622639        }, {
    623640                torrentAction: 'edit_trackers',
    624641                text: _('Edit Trackers'),
    625642                iconCls: 'icon-edit-trackers',
    626                 handler: Deluge.Menus.onTorrentAction,
    627                 scope: Deluge.Menus
     643                handler: deluge.menus.onTorrentAction,
     644                scope: deluge.menus
    628645        }, '-', {
    629646                torrentAction: 'remove',
    630647                text: _('Remove Torrent'),
    631648                iconCls: 'icon-remove',
    632                 handler: Deluge.Menus.onTorrentAction,
    633                 scope: Deluge.Menus
     649                handler: deluge.menus.onTorrentAction,
     650                scope: deluge.menus
    634651        }, '-', {
    635652                torrentAction: 'recheck',
    636653                text: _('Force Recheck'),
    637654                iconCls: 'icon-recheck',
    638                 handler: Deluge.Menus.onTorrentAction,
    639                 scope: Deluge.Menus
     655                handler: deluge.menus.onTorrentAction,
     656                scope: deluge.menus
    640657        }, {
    641658                torrentAction: 'move',
    642659                text: _('Move Storage'),
    643660                iconCls: 'icon-move',
    644                 handler: Deluge.Menus.onTorrentAction,
    645                 scope: Deluge.Menus
     661                handler: deluge.menus.onTorrentAction,
     662                scope: deluge.menus
    646663        }]
    647664});
    648665
    649 Ext.deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
     666Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {
    650667       
    651668        setValue: function(value) {
     669                var beenSet = false;
     670                // set the new value
    652671                value = (value == 0) ? -1 : value;
    653                 var item = this.items.get(value);
    654                 if (!item) item = this.items.get('other')
     672
     673                // uncheck all items
     674                this.items.each(function(item) {
     675                        if (item.setChecked) {
     676                                item.suspendEvents();
     677                                if (item.value == value) {
     678                                        item.setChecked(true);
     679                                        beenSet = true;
     680                                } else {
     681                                        item.setChecked(false);
     682                                }
     683                                item.resumeEvents();
     684                        }
     685                });
     686
     687                if (beenSet) return;
     688
     689                var item = this.items.get('other');
    655690                item.suspendEvents();
    656691                item.setChecked(true);
     
    659694});
    660695
    661 Deluge.Menus.Connections = new Ext.deluge.StatusbarMenu({
     696deluge.menus.connections = new Deluge.StatusbarMenu({
    662697        id: 'connectionsMenu',
    663698        items: [{
    664                 id: '50',
    665699                text: '50',
     700                value: '50',
    666701                group: 'max_connections_global',
    667702                checked: false,
    668703                checkHandler: onLimitChanged
    669704        },{
    670                 id: '100',
    671705                text: '100',
     706                value: '100',
    672707                group: 'max_connections_global',
    673708                checked: false,
    674709                checkHandler: onLimitChanged
    675710        },{
    676                 id: '200',
    677711                text: '200',
     712                value: '200',
    678713                group: 'max_connections_global',
    679714                checked: false,
    680715                checkHandler: onLimitChanged
    681716        },{
    682                 id: '300',
    683717                text: '300',
     718                value: '300',
    684719                group: 'max_connections_global',
    685720                checked: false,
    686721                checkHandler: onLimitChanged
    687722        },{
    688                 id: '500',
    689723                text: '500',
     724                value: '500',
    690725                group: 'max_connections_global',
    691726                checked: false,
    692727                checkHandler: onLimitChanged
    693728        },{
    694                 id: '-1',
    695729                text: _('Unlimited'),
     730                value: '-1',
    696731                group: 'max_connections_global',
    697732                checked: false,
    698733                checkHandler: onLimitChanged
    699734        },'-',{
    700                 id: 'other',
    701735                text: _('Other'),
     736                value: 'other',
    702737                group: 'max_connections_global',
    703738                checked: false,
     
    706741});
    707742
    708 Deluge.Menus.Download = new Ext.deluge.StatusbarMenu({
     743deluge.menus.download = new Deluge.StatusbarMenu({
    709744        id: 'downspeedMenu',
    710745        items: [{
    711                 id: '5',
     746                value: '5',
    712747                text: '5 KiB/s',
    713748                group: 'max_download_speed',
     
    715750                checkHandler: onLimitChanged
    716751        },{
    717                 id: '10',
     752                value: '10',
    718753                text: '10 KiB/s',
    719754                group: 'max_download_speed',
     
    721756                checkHandler: onLimitChanged
    722757        },{
    723                 id: '30',
     758                value: '30',
    724759                text: '30 KiB/s',
    725760                group: 'max_download_speed',
     
    727762                checkHandler: onLimitChanged
    728763        },{
    729                 id: '80',
     764                value: '80',
    730765                text: '80 KiB/s',
    731766                group: 'max_download_speed',
     
    733768                checkHandler: onLimitChanged
    734769        },{
    735                 id: '300',
     770                value: '300',
    736771                text: '300 KiB/s',
    737772                group: 'max_download_speed',
     
    739774                checkHandler: onLimitChanged
    740775        },{
    741                 id: '-1',
     776                value: '-1',
    742777                text: _('Unlimited'),
    743778                group: 'max_download_speed',
     
    745780                checkHandler: onLimitChanged
    746781        },'-',{
    747                 id: 'other',
     782                value: 'other',
    748783                text: _('Other'),
    749784                group: 'max_download_speed',
     
    753788});
    754789
    755 Deluge.Menus.Upload = new Ext.deluge.StatusbarMenu({
     790deluge.menus.upload = new Deluge.StatusbarMenu({
    756791        id: 'upspeedMenu',
    757792        items: [{
    758                 id: '5',
     793                value: '5',
    759794                text: '5 KiB/s',
    760795                group: 'max_upload_speed',
     
    762797                checkHandler: onLimitChanged
    763798        },{
    764                 id: '10',
     799                value: '10',
    765800                text: '10 KiB/s',
    766801                group: 'max_upload_speed',
     
    768803                checkHandler: onLimitChanged
    769804        },{
    770                 id: '30',
     805                value: '30',
    771806                text: '30 KiB/s',
    772807                group: 'max_upload_speed',
     
    774809                checkHandler: onLimitChanged
    775810        },{
    776                 id: '80',
     811                value: '80',
    777812                text: '80 KiB/s',
    778813                group: 'max_upload_speed',
     
    780815                checkHandler: onLimitChanged
    781816        },{
    782                 id: '300',
     817                value: '300',
    783818                text: '300 KiB/s',
    784819                group: 'max_upload_speed',
     
    786821                checkHandler: onLimitChanged
    787822        },{
    788                 id: '-1',
     823                value: '-1',
    789824                text: _('Unlimited'),
    790825                group: 'max_upload_speed',
     
    792827                checkHandler: onLimitChanged
    793828        },'-',{
    794                 id: 'other',
     829                value: 'other',
    795830                text: _('Other'),
    796831                group: 'max_upload_speed',
     
    800835});
    801836
    802 Deluge.Menus.FilePriorities = new Ext.menu.Menu({
     837deluge.menus.filePriorities = new Ext.menu.Menu({
    803838        id: 'filePrioritiesMenu',
    804839        items: [{
    805840                id: 'expandAll',
    806841                text: _('Expand All'),
    807                 icon: '/icons/expand_all.png'
     842                iconCls: 'icon-expand-all'
    808843        }, '-', {
    809844                id: 'no_download',
    810845                text: _('Do Not Download'),
    811                 icon: '/icons/no_download.png',
     846                iconCls: 'icon-do-not-download',
    812847                filePriority: 0
    813848        }, {
    814849                id: 'normal',
    815850                text: _('Normal Priority'),
    816                 icon: '/icons/normal.png',
     851                iconCls: 'icon-normal',
    817852                filePriority: 1
    818853        }, {
    819854                id: 'high',
    820855                text: _('High Priority'),
    821                 icon: '/icons/high.png',
     856                iconCls: 'icon-high',
    822857                filePriority: 2
    823858        }, {
    824859                id: 'highest',
    825860                text: _('Highest Priority'),
    826                 icon: '/icons/highest.png',
     861                iconCls: 'icon-highest',
    827862                filePriority: 5
    828863        }]
     
    830865
    831866function onLimitChanged(item, checked) {
    832         if (item.id == "other") {
     867        if (item.value == "other") {
    833868        } else {
    834869                config = {}
    835                 config[item.group] = item.id
    836                 Deluge.Client.core.set_config(config, {
     870                config[item.group] = item.value
     871                deluge.client.core.set_config(config, {
    837872                        success: function() {
    838                                 Deluge.UI.update();
     873                                deluge.ui.update();
    839874                        }
    840875                });
     
    842877}
    843878/*
    844 Script: Deluge.Events.js
     879Script: Deluge.EventsManager.js
    845880        Class for holding global events that occur within the UI.
    846881
     
    874909*/
    875910
    876 (function() {
     911/**
     912 * @class Deluge.EventsManager
     913 * @extends Ext.util.Observable
     914 * <p>Deluge.EventsManager is instantated as <tt>deluge.events</tt> and can be used by components of the UI to fire global events</p>
     915 * Class for holding global events that occur within the UI.
     916 */
     917Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
     918        constructor: function() {
     919                this.toRegister = [];
     920                this.on('login', this.onLogin, this);
     921                Deluge.EventsManager.superclass.constructor.call(this);
     922        },
     923       
    877924        /**
    878          * @class Deluge.Events
    879          * <p>Deluge.Events is a singleton that components of the UI can use to fire global events</p>
    880          * @singleton
    881          * Class for holding global events that occur within the UI.
     925         * Append an event handler to this object.
    882926         */
    883         Events = Ext.extend(Ext.util.Observable, {
    884                 constructor: function() {
    885                         this.toRegister = [];
    886                         this.on('login', this.onLogin, this);
    887                         Events.superclass.constructor.call(this);
    888                 },
    889                
    890                 /**
    891                  * Append an event handler to this object.
    892                  */
    893                 addListener: function(eventName, fn, scope, o) {
    894                         this.addEvents(eventName);
    895                         if (/[A-Z]/.test(eventName.substring(0, 1))) {
    896                                 if (!Deluge.Client) {
    897                                         this.toRegister.push(eventName);
    898                                 } else {
    899                                         Deluge.Client.web.register_event_listener(eventName);
    900                                 }
     927        addListener: function(eventName, fn, scope, o) {
     928                this.addEvents(eventName);
     929                if (/[A-Z]/.test(eventName.substring(0, 1))) {
     930                        if (!deluge.client) {
     931                                this.toRegister.push(eventName);
     932                        } else {
     933                                deluge.client.web.register_event_listener(eventName);
    901934                        }
    902                         Events.superclass.addListener.call(this, eventName, fn, scope, o);
    903                 },
    904        
    905                 getEvents: function() {
    906                         Deluge.Client.web.get_events({
    907                                 success: this.onGetEventsSuccess,
    908                                 failure: this.onGetEventsFailure,
    909                                 scope: this
    910                         });
    911                 },
    912        
    913                 /**
    914                  * Starts the EventsManager checking for events.
    915                  */
    916                 start: function() {
    917                         Ext.each(this.toRegister, function(eventName) {
    918                                 Deluge.Client.web.register_event_listener(eventName);
    919                         });
    920                         this.running = true;
    921                         this.getEvents();
    922                 },
    923        
    924                 /**
    925                  * Stops the EventsManager checking for events.
    926                  */
    927                 stop: function() {
    928                         this.running = false;
    929                 },
    930 
    931                 // private
    932                 onLogin: function() {
    933                         this.start();
    934                         this.on('PluginEnabledEvent', this.onPluginEnabled, this);
    935                         this.on('PluginDisabledEvent', this.onPluginDisabled, this);
    936                 },
    937 
    938                 onGetEventsSuccess: function(events) {
    939                         if (!events) return;
    940                         Ext.each(events, function(event) {
    941                                 var name = event[0], args = event[1];
    942                                 args.splice(0, 0, name);
    943                                 this.fireEvent.apply(this, args);
    944                         }, this);
    945                         if (this.running) this.getEvents();
    946                 },
    947        
    948                 // private
    949                 onGetEventsFailure: function(events) {
    950                         // the request timed out so we just want to open up another
    951                         // one.
    952                         if (this.running) this.getEvents();
    953935                }
    954         });
     936                Deluge.EventsManager.superclass.addListener.call(this, eventName, fn, scope, o);
     937        },
     938
     939        getEvents: function() {
     940                deluge.client.web.get_events({
     941                        success: this.onGetEventsSuccess,
     942                        failure: this.onGetEventsFailure,
     943                        scope: this
     944                });
     945        },
    955946
    956947        /**
    957          * Appends an event handler to this object (shorthand for {@link #addListener})
    958          * @method
     948         * Starts the EventsManagerManager checking for events.
    959949         */
    960         Events.prototype.on = Events.prototype.addListener
     950        start: function() {
     951                Ext.each(this.toRegister, function(eventName) {
     952                        deluge.client.web.register_event_listener(eventName);
     953                });
     954                this.running = true;
     955                this.getEvents();
     956        },
    961957
    962958        /**
    963          * Fires the specified event with the passed parameters (minus the
    964          * event name).
    965          * @method
     959         * Stops the EventsManagerManager checking for events.
    966960         */
    967         Events.prototype.fire = Events.prototype.fireEvent
    968         Deluge.Events = new Events();
    969 })();
     961        stop: function() {
     962                this.running = false;
     963        },
     964
     965        // private
     966        onLogin: function() {
     967                this.start();
     968                this.on('PluginEnabledEvent', this.onPluginEnabled, this);
     969                this.on('PluginDisabledEvent', this.onPluginDisabled, this);
     970        },
     971
     972        onGetEventsSuccess: function(events) {
     973                if (!events) return;
     974                Ext.each(events, function(event) {
     975                        var name = event[0], args = event[1];
     976                        args.splice(0, 0, name);
     977                        this.fireEvent.apply(this, args);
     978                }, this);
     979                if (this.running) this.getEvents();
     980        },
     981
     982        // private
     983        onGetEventsFailure: function(events) {
     984                // the request timed out so we just want to open up another
     985                // one.
     986                if (this.running) this.getEvents();
     987        }
     988});
     989
     990/**
     991 * Appends an event handler to this object (shorthand for {@link #addListener})
     992 * @method
     993 */
     994Deluge.EventsManager.prototype.on = Deluge.EventsManager.prototype.addListener
     995
     996/**
     997 * Fires the specified event with the passed parameters (minus the
     998 * event name).
     999 * @method
     1000 */
     1001Deluge.EventsManager.prototype.fire = Deluge.EventsManager.prototype.fireEvent
     1002deluge.events = new Deluge.EventsManager();
    9701003/*
    9711004Script:
     
    15351568*/
    15361569
    1537 Ext.namespace('Ext.deluge.add');
    1538 Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
     1570Ext.namespace('Deluge.add');
     1571Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
    15391572
    15401573        torrents: {},
     
    15471580                        height: 220
    15481581                }, config);
    1549                 Ext.deluge.add.OptionsPanel.superclass.constructor.call(this, config);
     1582                Deluge.add.OptionsPanel.superclass.constructor.call(this, config);
    15501583        },
    15511584
    15521585        initComponent: function() {
    1553                 Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);
     1586                Deluge.add.OptionsPanel.superclass.initComponent.call(this);
    15541587                this.files = this.add(new Ext.ux.tree.TreeGrid({
    15551588                        layout: 'fit',
     
    17401773                'prioritize_first_last_pieces'];
    17411774
    1742                 Deluge.Client.core.get_config_values(keys, {
     1775                deluge.client.core.get_config_values(keys, {
    17431776                        success: function(config) {
    17441777                                var options = {
     
    18461879});
    18471880
    1848 Ext.deluge.add.Window = Ext.extend(Ext.Window, {
     1881Deluge.add.Window = Ext.extend(Ext.Window, {
    18491882        initComponent: function() {
    1850                 Ext.deluge.add.Window.superclass.initComponent.call(this);
     1883                Deluge.add.Window.superclass.initComponent.call(this);
    18511884                this.addEvents(
    18521885                        'beforeadd',
     
    18601893});
    18611894
    1862 Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
     1895Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
    18631896
    18641897        constructor: function(config) {
     
    18751908                        iconCls: 'x-deluge-add-window-icon'
    18761909                }, config);
    1877                 Ext.deluge.add.AddWindow.superclass.constructor.call(this, config);
     1910                Deluge.add.AddWindow.superclass.constructor.call(this, config);
    18781911        },
    18791912
    18801913        initComponent: function() {
    1881                 Ext.deluge.add.AddWindow.superclass.initComponent.call(this);
     1914                Deluge.add.AddWindow.superclass.initComponent.call(this);
    18821915
    18831916                this.addButton(_('Cancel'), this.onCancelClick, this);
     
    19261959                        bbar: new Ext.Toolbar({
    19271960                                items: [{
    1928                                         id: 'file',
    1929                                         cls: 'x-btn-text-icon',
    19301961                                        iconCls: 'x-deluge-add-file',
    19311962                                        text: _('File'),
     
    19331964                                        scope: this
    19341965                                }, {
    1935                                         id: 'url',
    1936                                         cls: 'x-btn-text-icon',
    19371966                                        text: _('Url'),
    1938                                         icon: '/icons/add_url.png',
     1967                                        iconCls: 'icon-add-url',
    19391968                                        handler: this.onUrl,
    19401969                                        scope: this
    19411970                                }, {
    1942                                         id: 'infohash',
    1943                                         cls: 'x-btn-text-icon',
    19441971                                        text: _('Infohash'),
    1945                                         icon: '/icons/add_magnet.png',
     1972                                        iconCls: 'icon-add-magnet',
    19461973                                        disabled: true
    19471974                                }, '->', {
    1948                                         id: 'remove',
    1949                                         cls: 'x-btn-text-icon',
    19501975                                        text: _('Remove'),
    1951                                         icon: '/icons/remove.png',
     1976                                        iconCls: 'icon-remove',
    19521977                                        handler: this.onRemove,
    19531978                                        scope: this
     
    19561981                });
    19571982       
    1958                 this.optionsPanel = this.add(new Ext.deluge.add.OptionsPanel());
     1983                this.optionsPanel = this.add(new Deluge.add.OptionsPanel());
    19591984                this.on('hide', this.onHide, this);
    19601985                this.on('show', this.onShow, this);
     
    19772002                }, this);
    19782003
    1979                 Deluge.Client.web.add_torrents(torrents, {
     2004                deluge.client.web.add_torrents(torrents, {
    19802005                        success: function(result) {
    19812006                        }
     
    20182043        onShow: function() {
    20192044                if (!this.url) {
    2020                         this.url = new Ext.deluge.add.UrlWindow();
     2045                        this.url = new Deluge.add.UrlWindow();
    20212046                        this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
    20222047                        this.url.on('add', this.onTorrentAdd, this);
     
    20242049
    20252050                if (!this.file) {
    2026                         this.file = new Ext.deluge.add.FileWindow();
     2051                        this.file = new Deluge.add.FileWindow();
    20272052                        this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
    20282053                        this.file.on('add', this.onTorrentAdd, this);
     
    20382063
    20392064        onTorrentAdd: function(torrentId, info) {
     2065                var r = this.grid.getStore().getById(torrentId);
    20402066                if (!info) {
    20412067                        Ext.MessageBox.show({
     
    20472073                                iconCls: 'x-deluge-icon-error'
    20482074                        });
    2049                         return;
     2075                        this.grid.getStore().remove(r);
     2076                } else {
     2077                        r.set('info_hash', info['info_hash']);
     2078                        r.set('text', info['name']);
     2079                        this.grid.getStore().commitChanges();
     2080                        this.optionsPanel.addTorrent(info);
    20502081                }
    2051 
    2052                 var r = this.grid.getStore().getById(torrentId);
    2053                 r.set('info_hash', info['info_hash']);
    2054                 r.set('text', info['name']);
    2055                 this.grid.getStore().commitChanges();
    2056                 this.optionsPanel.addTorrent(info);
    20572082        },
    20582083
     
    20612086        }
    20622087});
    2063 Deluge.Add = new Ext.deluge.add.AddWindow();
     2088deluge.add = new Deluge.add.AddWindow();
    20642089/*
    20652090Script: Deluge.Add.File.js
     
    20972122
    20982123Ext.namespace('Ext.deluge.add');
    2099 Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
     2124Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, {
    21002125        constructor: function(config) {
    21012126                config = Ext.apply({
     
    21112136                        iconCls: 'x-deluge-add-file'
    21122137                }, config);
    2113                 Ext.deluge.add.FileWindow.superclass.constructor.call(this, config);
     2138                Deluge.add.FileWindow.superclass.constructor.call(this, config);
    21142139        },
    21152140       
    21162141        initComponent: function() {
    2117                 Ext.deluge.add.FileWindow.superclass.initComponent.call(this);
     2142                Deluge.add.FileWindow.superclass.initComponent.call(this);
    21182143                this.addButton(_('Add'), this.onAddClick, this);
    21192144               
     
    21442169                                url: '/upload',
    21452170                                waitMsg: _('Uploading your torrent...'),
     2171                                failure: this.onUploadFailure,
    21462172                                success: this.onUploadSuccess,
    21472173                                scope: this
    21482174                        });
    21492175                        var name = this.form.getForm().findField('torrentFile').value;
     2176                        name = name.split('\\').slice(-1)[0];
    21502177                        this.fireEvent('beforeadd', this.torrentId, name);
    21512178                }
     
    21552182                info['filename'] = request.options.filename;
    21562183                this.fireEvent('add', this.torrentId, info);
     2184        },
     2185
     2186        onUploadFailure: function(form, action) {
     2187                this.hide();
    21572188        },
    21582189       
     
    22042235*/
    22052236
    2206 Ext.namespace('Ext.deluge.add');
    2207 Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
     2237Ext.namespace('Deluge.add');
     2238Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
    22082239        constructor: function(config) {
    22092240                config = Ext.apply({
     
    22192250                        iconCls: 'x-deluge-add-url-window-icon'
    22202251                }, config);
    2221                 Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
     2252                Deluge.add.UrlWindow.superclass.constructor.call(this, config);
    22222253        },
    22232254       
    22242255        initComponent: function() {
    2225                 Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
     2256                Deluge.add.UrlWindow.superclass.initComponent.call(this);
    22262257                this.addButton(_('Add'), this.onAddClick, this);
    22272258               
     
    22582289                var torrentId = this.createTorrentId();
    22592290               
    2260                 Deluge.Client.web.download_torrent_from_url(url, cookies, {
     2291                deluge.client.web.download_torrent_from_url(url, cookies, {
    22612292                        success: this.onDownload,
    22622293                        scope: this,
     
    22692300        onDownload: function(filename, obj, resp, req) {
    22702301                this.urlField.setValue('');
    2271                 Deluge.Client.web.get_torrent_info(filename, {
     2302                deluge.client.web.get_torrent_info(filename, {
    22722303                        success: this.onGotInfo,
    22732304                        scope: this,
     
    24792510});
    24802511/*
    2481 Script: deluge-connections.js
     2512Script: Deluge.ConnectionManager.js
    24822513        Contains all objects and functions related to the connection manager.
    24832514
     
    25172548        }
    25182549
    2519         Ext.deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
     2550        Deluge.AddConnectionWindow = Ext.extend(Ext.Window, {
    25202551
    25212552                constructor: function(config) {
     
    25322563                                iconCls: 'x-deluge-add-window-icon'
    25332564                        }, config);
    2534                         Ext.deluge.AddConnectionWindow.superclass.constructor.call(this, config);
     2565                        Deluge.AddConnectionWindow.superclass.constructor.call(this, config);
    25352566                },
    25362567       
    25372568                initComponent: function() {
    2538                         Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this);
     2569                        Deluge.AddConnectionWindow.superclass.initComponent.call(this);
    25392570       
    25402571                        this.addEvents('hostadded');
     
    25642595                                fieldLabel: _('Port'),
    25652596                                id: 'port',
    2566                                 xtype: 'uxspinner',
    2567                                 ctCls: 'x-form-uxspinner',
     2597                                xtype: 'spinnerfield',
    25682598                                name: 'port',
    25692599                                strategy: {
     
    26012631                        var password = this.passwordField.getValue();
    26022632       
    2603                         Deluge.Client.web.add_host(host, port, username, password, {
     2633                        deluge.client.web.add_host(host, port, username, password, {
    26042634                                success: function(result) {
    26052635                                        if (!result[0]) {
     
    26262656        });
    26272657
    2628         Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, {
     2658        Deluge.ConnectionManager = Ext.extend(Ext.Window, {
    26292659
    26302660                layout: 'fit',
     
    26402670       
    26412671                initComponent: function() {
    2642                         Ext.deluge.ConnectionManager.superclass.initComponent.call(this);
     2672                        Deluge.ConnectionManager.superclass.initComponent.call(this);
    26432673                        this.on('hide',  this.onHide, this);
    26442674                        this.on('show', this.onShow, this);
    2645                         Deluge.Events.on('login', this.onLogin, this);
    2646                         Deluge.Events.on('logout', this.onLogout, this);
     2675
     2676                        deluge.events.on('disconnect', this.onDisconnect, this);
     2677                        deluge.events.on('login', this.onLogin, this);
     2678                        deluge.events.on('logout', this.onLogout, this);
    26472679       
    26482680                        this.addButton(_('Close'), this.onClose, this);
     
    26982730                                                        cls: 'x-btn-text-icon',
    26992731                                                        text: _('Add'),
    2700                                                         icon: '/icons/add.png',
     2732                                                        iconCls: 'icon-add',
    27012733                                                        handler: this.onAddClick,
    27022734                                                        scope: this
     
    27052737                                                        cls: 'x-btn-text-icon',
    27062738                                                        text: _('Remove'),
    2707                                                         icon: '/icons/remove.png',
     2739                                                        iconCls: 'icon-remove',
    27082740                                                        handler: this.onRemove,
    27092741                                                        disabled: true,
     
    27132745                                                        cls: 'x-btn-text-icon',
    27142746                                                        text: _('Stop Daemon'),
    2715                                                         icon: '/icons/error.png',
     2747                                                        iconCls: 'icon-error',
    27162748                                                        handler: this.onStop,
    27172749                                                        disabled: true,
     
    27252757                },
    27262758
     2759                /**
     2760                 * Check to see if the the web interface is currently connected
     2761                 * to a Deluge Daemon and show the Connection Manager if not.
     2762                 */
     2763                checkConnected: function() {
     2764                        deluge.client.web.connected({
     2765                                success: function(connected) {
     2766                                        if (connected) {
     2767                                                deluge.events.fire('connect');
     2768                                        } else {
     2769                                                this.show();
     2770                                        }
     2771                                },
     2772                                scope: this
     2773                        });
     2774                },
     2775
    27272776                disconnect: function() {
    2728                         Deluge.Events.fire('disconnect');
     2777                        deluge.events.fire('disconnect');
    27292778                },
    27302779       
    27312780                loadHosts: function() {
    2732                         Deluge.Client.web.get_hosts({
     2781                        deluge.client.web.get_hosts({
    27332782                                success: this.onGetHosts,
    27342783                                scope: this
     
    27382787                update: function() {
    27392788                        this.grid.getStore().each(function(r) {
    2740                                 Deluge.Client.web.get_host_status(r.id, {
     2789                                deluge.client.web.get_host_status(r.id, {
    27412790                                        success: this.onGetHostStatus,
    27422791                                        scope: this
     
    27802829                onAddClick: function(button, e) {
    27812830                        if (!this.addWindow) {
    2782                                 this.addWindow = new Ext.deluge.AddConnectionWindow();
     2831                                this.addWindow = new Deluge.AddConnectionWindow();
    27832832                                this.addWindow.on('hostadded', this.onHostAdded, this);
    27842833                        }
     
    27902839                },
    27912840       
     2841                // private
    27922842                onClose: function(e) {
    27932843                        if (this.running) window.clearInterval(this.running);
     
    27952845                },
    27962846       
     2847                // private
    27972848                onConnect: function(e) {
    27982849                        var selected = this.grid.getSelectionModel().getSelected();
     
    28002851       
    28012852                        if (selected.get('status') == _('Connected')) {
    2802                                 Deluge.Client.web.disconnect({
     2853                                deluge.client.web.disconnect({
    28032854                                        success: function(result) {
    28042855                                                this.update(this);
     
    28092860                        } else {
    28102861                                var id = selected.id;
    2811                                 Deluge.Client.web.connect(id, {
     2862                                deluge.client.web.connect(id, {
    28122863                                        success: function(methods) {
    2813                                                 Deluge.Client.reloadMethods();
    2814                                                 Deluge.Client.on('connected', function(e) {
    2815                                                         Deluge.Events.fire('connect');
     2864                                                deluge.client.reloadMethods();
     2865                                                deluge.client.on('connected', function(e) {
     2866                                                        deluge.events.fire('connect');
    28162867                                                }, this, {single: true});
    28172868                                        }
     
    28212872                },
    28222873
     2874                onDisconnect: function() {
     2875                        if (this.isVisible()) return;
     2876                        this.show();
     2877                },
     2878
     2879                // private
    28232880                onGetHosts: function(hosts) {
    28242881                        this.grid.getStore().loadData(hosts);
    28252882                        Ext.each(hosts, function(host) {
    2826                                 Deluge.Client.web.get_host_status(host[0], {
     2883                                deluge.client.web.get_host_status(host[0], {
    28272884                                        success: this.onGetHostStatus,
    28282885                                        scope: this
     
    28312888                },
    28322889       
     2890                // private
    28332891                onGetHostStatus: function(host) {
    28342892                        var record = this.grid.getStore().getById(host[0]);
     
    28392897                },
    28402898
     2899                // private
    28412900                onHide: function() {
    28422901                        if (this.running) window.clearInterval(this.running);   
    28432902                },
    28442903
     2904                // private
    28452905                onLogin: function() {
    2846                         Deluge.Client.web.connected({
    2847                                 success: function(connected) {
    2848                                         if (connected) {
    2849                                                 Deluge.Events.fire('connect');
    2850                                         } else {
    2851                                                 this.show();
    2852                                         }
    2853                                 },
    2854                                 scope: this
    2855                         });
     2906                        if (deluge.config.first_login) {
     2907                                Ext.MessageBox.confirm('Change password',
     2908                                        'As this is your first login, we recommend that you ' +
     2909                                        'change your password. Would you like to ' +
     2910                                        'do this now?', function(res) {
     2911                                                this.checkConnected();
     2912                                                if (res == 'yes') {
     2913                                                        deluge.preferences.show();
     2914                                                        deluge.preferences.selectPage('Interface');
     2915                                                }
     2916                                                deluge.client.web.set_config({first_login: false});
     2917                                        }, this);
     2918                        } else {
     2919                                this.checkConnected();
     2920                        }
    28562921                },
    28572922
     2923                // private
    28582924                onLogout: function() {
    28592925                        this.disconnect();
     
    28632929                },
    28642930       
     2931                // private
    28652932                onRemove: function(button) {
    28662933                        var connection = this.grid.getSelectionModel().getSelected();
    28672934                        if (!connection) return;
    28682935       
    2869                         Deluge.Client.web.remove_host(connection.id, {
     2936                        deluge.client.web.remove_host(connection.id, {
    28702937                                success: function(result) {
    28712938                                        if (!result) {
     
    28862953                },
    28872954
     2955                // private
    28882956                onSelect: function(selModel, rowIndex, record) {
    28892957                        this.selectedRow = rowIndex;
    28902958                },
    28912959
     2960                // private
    28922961                onSelectionChanged: function(selModel) {
    28932962                        var record = selModel.getSelected();
     
    29032972                },
    29042973
     2974                // private
    29052975                onShow: function() {
    29062976                        if (!this.addHostButton) {
     
    29132983                        this.running = window.setInterval(this.update, 2000, this);
    29142984                },
    2915 
     2985               
     2986                // private
    29162987                onStop: function(button, e) {
    29172988                        var connection = this.grid.getSelectionModel().getSelected();
     
    29202991                        if (connection.get('status') == 'Offline') {
    29212992                                // This means we need to start the daemon
    2922                                 Deluge.Client.web.start_daemon(connection.get('port'));
     2993                                deluge.client.web.start_daemon(connection.get('port'));
    29232994                        } else {
    29242995                                // This means we need to stop the daemon
    2925                                 Deluge.Client.web.stop_daemon(connection.id, {
     2996                                deluge.client.web.stop_daemon(connection.id, {
    29262997                                        success: function(result) {
    29272998                                                if (!result[0]) {
     
    29403011                }
    29413012        });
    2942         Deluge.ConnectionManager = new Ext.deluge.ConnectionManager();
     3013        deluge.connectionManager = new Deluge.ConnectionManager();
    29433014})();
    29443015/*
     
    29773048
    29783049(function() {
    2979         Ext.namespace('Ext.deluge.details');
    2980         Ext.deluge.details.TabPanel = Ext.extend(Ext.TabPanel, {
     3050        Ext.namespace('Deluge.details');
     3051        Deluge.details.TabPanel = Ext.extend(Ext.TabPanel, {
    29813052               
    29823053                constructor: function(config) {
     
    29913062                                activeTab: 0
    29923063                        }, config);
    2993                         Ext.deluge.details.TabPanel.superclass.constructor.call(this, config);
     3064                        Deluge.details.TabPanel.superclass.constructor.call(this, config);
    29943065                },
    29953066               
     
    30053076               
    30063077                update: function(tab) {
    3007                         var torrent = Deluge.Torrents.getSelected();
     3078                        var torrent = deluge.torrents.getSelected();
    30083079                        if (!torrent) {
    30093080                                this.clear();
     
    30243095                // been created yet.
    30253096                onRender: function(ct, position) {
    3026                         Ext.deluge.details.TabPanel.superclass.onRender.call(this, ct, position);
    3027                         Deluge.Events.on('disconnect', this.clear, this);
    3028                         Deluge.Torrents.on('rowclick', this.onTorrentsClick, this);
     3097                        Deluge.details.TabPanel.superclass.onRender.call(this, ct, position);
     3098                        deluge.events.on('disconnect', this.clear, this);
     3099                        deluge.torrents.on('rowclick', this.onTorrentsClick, this);
    30293100                        this.on('tabchange', this.onTabChange, this);
    30303101                       
    3031                         Deluge.Torrents.getSelectionModel().on('selectionchange', function(selModel) {
     3102                        deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) {
    30323103                                if (!selModel.hasSelection()) this.clear();
    30333104                        }, this);
     
    30423113                }
    30433114        });
    3044         Deluge.Details = new Ext.deluge.details.TabPanel();
     3115        deluge.details = new Deluge.details.TabPanel();
    30453116})();
    30463117/*
     
    30773148*/
    30783149
    3079 Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {
     3150Deluge.details.StatusTab = Ext.extend(Ext.Panel, {
    30803151        title: _('Status'),
    30813152        autoScroll: true,
    30823153       
    30833154        onRender: function(ct, position) {
    3084                 Ext.deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
     3155                Deluge.details.StatusTab.superclass.onRender.call(this, ct, position);
    30853156               
    30863157                this.progressBar = this.add({
     
    30993170                                        fn: function(panel) {
    31003171                                                panel.load({
    3101                                                         url: '/render/tab_status.html',
     3172                                                        url: deluge.config.base + 'render/tab_status.html',
    31023173                                                        text: _('Loading') + '...'
    31033174                                                });
     
    31193190        update: function(torrentId) {
    31203191                if (!this.fields) this.getFields();
    3121                 Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Status, {
     3192                deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Status, {
    31223193                        success: this.onRequestComplete,
    31233194                        scope: this
     
    31623233                }
    31633234                var text = status.state + ' ' + status.progress.toFixed(2) + '%';
    3164                 this.progressBar.updateProgress(status.progress, text);
     3235                this.progressBar.updateProgress(status.progress / 100.0, text);
    31653236        }
    31663237});
    3167 Deluge.Details.add(new Ext.deluge.details.StatusTab());
     3238deluge.details.add(new Deluge.details.StatusTab());
    31683239/*
    31693240Script: Deluge.Details.Details.js
     
    32003271*/
    32013272
    3202 Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
     3273Deluge.details.DetailsTab = Ext.extend(Ext.Panel, {
    32033274        title: _('Details'),
    32043275
     
    32103281
    32113282        initComponent: function() {
    3212                 Ext.deluge.details.DetailsTab.superclass.initComponent.call(this);
     3283                Deluge.details.DetailsTab.superclass.initComponent.call(this);
    32133284                this.addItem('torrent_name', _('Name'));
    32143285                this.addItem('hash', _('Hash'));
     
    32223293       
    32233294        onRender: function(ct, position) {
    3224                 Ext.deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
     3295                Deluge.details.DetailsTab.superclass.onRender.call(this, ct, position);
    32253296                this.body.setStyle('padding', '10px');
    32263297                this.dl = Ext.DomHelper.append(this.body, {tag: 'dl'}, true);
     
    32533324       
    32543325        update: function(torrentId) {
    3255                 Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
     3326                deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Details, {
    32563327                        success: this.onRequestComplete,
    32573328                        scope: this,
     
    32803351        }
    32813352});
    3282 Deluge.Details.add(new Ext.deluge.details.DetailsTab());
     3353deluge.details.add(new Deluge.details.DetailsTab());
    32833354/*
    32843355Script: Deluge.Details.Files.js
     
    33243395        }
    33253396       
    3326         Ext.deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
     3397        Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
    33273398               
    33283399                constructor: function(config) {
     
    33623433                        }, config);
    33633434
    3364                         Ext.deluge.details.FilesTab.superclass.constructor.call(this, config);
     3435                        Deluge.details.FilesTab.superclass.constructor.call(this, config);
    33653436                },
    33663437
    33673438                initComponent: function() {
    33683439                       
    3369                         Ext.deluge.details.FilesTab.superclass.initComponent.call(this);
     3440                        Deluge.details.FilesTab.superclass.initComponent.call(this);
    33703441                },
    33713442               
    33723443                onRender: function(ct, position) {
    3373                         Ext.deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
    3374                         Deluge.Menus.FilePriorities.on('itemclick', this.onItemClick, this);
     3444                        Deluge.details.FilesTab.superclass.onRender.call(this, ct, position);
     3445                        deluge.menus.filePriorities.on('itemclick', this.onItemClick, this);
    33753446                        this.on('contextmenu', this.onContextMenu, this);
    33763447                        this.sorter = new Ext.tree.TreeSorter(this, {
     
    33963467                        }
    33973468                       
    3398                         Deluge.Client.web.get_torrent_files(torrentId, {
     3469                        deluge.client.web.get_torrent_files(torrentId, {
    33993470                                success: this.onRequestComplete,
    34003471                                scope: this,
     
    34103481                                node.select();
    34113482                        }
    3412                         Deluge.Menus.FilePriorities.showAt(e.getPoint());
     3483                        deluge.menus.filePriorities.showAt(e.getPoint());
    34133484                },
    34143485               
     
    34453516                                        }
    34463517
    3447                                         Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {
     3518                                        deluge.client.core.set_torrent_file_priorities(this.torrentId, priorities, {
    34483519                                                success: function() {
    34493520                                                        Ext.each(nodes, function(node) {
     
    34993570                }
    35003571        });
    3501         Deluge.Details.add(new Ext.deluge.details.FilesTab());
     3572        deluge.details.add(new Deluge.details.FilesTab());
    35023573})();
    35033574/*
     
    35523623        }
    35533624
    3554         Ext.deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
     3625        Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
    35553626               
    35563627                constructor: function(config) {
     
    36113682                                autoScroll:true
    36123683                        }, config);
    3613                         Ext.deluge.details.PeersTab.superclass.constructor.call(this, config);
     3684                        Deluge.details.PeersTab.superclass.constructor.call(this, config);
    36143685                },
    36153686               
    36163687                onRender: function(ct, position) {
    3617                         Ext.deluge.details.PeersTab.superclass.onRender.call(this, ct, position);
     3688                        Deluge.details.PeersTab.superclass.onRender.call(this, ct, position);
    36183689                },
    36193690               
     
    36233694               
    36243695                update: function(torrentId) {
    3625                         Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Peers, {
     3696                        deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Peers, {
    36263697                                success: this.onRequestComplete,
    36273698                                scope: this
     
    36383709                }
    36393710        });
    3640         Deluge.Details.add(new Ext.deluge.details.PeersTab());
     3711        deluge.details.add(new Deluge.details.PeersTab());
    36413712})();
    36423713/*
     
    36743745
    36753746
    3676 Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
     3747Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {
    36773748
    36783749        constructor: function(config) {
     
    36913762                        title: _('Options')
    36923763                }, config);
    3693                 Ext.deluge.details.OptionsTab.superclass.constructor.call(this, config);
     3764                Deluge.details.OptionsTab.superclass.constructor.call(this, config);
    36943765        },
    36953766
    36963767        initComponent: function() {
    3697                 Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);
     3768                Deluge.details.OptionsTab.superclass.initComponent.call(this);
    36983769               
    36993770                this.fieldsets = {}, this.fields = {};
     
    39844055       
    39854056        onRender: function(ct, position) {
    3986                 Ext.deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
     4057                Deluge.details.OptionsTab.superclass.onRender.call(this, ct, position);
    39874058               
    39884059                // This is another hack I think, so keep an eye out here when upgrading.
     
    40114082                        this.optionsManager.changeId(torrentId);
    40124083                }
    4013                 Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
     4084                deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {
    40144085                        success: this.onRequestComplete,
    40154086                        scope: this
     
    40214092                if (!Ext.isEmpty(changed['prioritize_first_last'])) {
    40224093                        var value = changed['prioritize_first_last'];
    4023                         Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
     4094                        deluge.client.core.set_torrent_prioritize_first_last(this.torrentId, value, {
    40244095                                success: function() {
    40254096                                        this.optionsManager.set('prioritize_first_last', value);
     
    40284099                        });
    40294100                }
    4030                 Deluge.Client.core.set_torrent_options([this.torrentId], changed, {
     4101                deluge.client.core.set_torrent_options([this.torrentId], changed, {
    40314102                        success: function() {
    40324103                                this.optionsManager.commit();
     
    40374108       
    40384109        onEditTrackers: function() {
    4039                 Deluge.EditTrackers.show();
     4110                deluge.editTrackers.show();
    40404111        },
    40414112       
     
    40564127        }
    40574128});
    4058 Deluge.Details.add(new Ext.deluge.details.OptionsTab());
     4129deluge.details.add(new Deluge.details.OptionsTab());
    40594130/*
    40604131Script: Deluge.EditTrackers.js
     
    40924163
    40934164(function() {
    4094         Ext.deluge.AddTracker = Ext.extend(Ext.Window, {
     4165        Deluge.AddTracker = Ext.extend(Ext.Window, {
    40954166                constructor: function(config) {
    40964167                        config = Ext.apply({
     
    41074178                                resizable: false
    41084179                        }, config);
    4109                         Ext.deluge.AddTracker.superclass.constructor.call(this, config);
     4180                        Deluge.AddTracker.superclass.constructor.call(this, config);
    41104181                },
    41114182               
    41124183                initComponent: function() {
    4113                         Ext.deluge.AddTracker.superclass.initComponent.call(this);
     4184                        Deluge.AddTracker.superclass.initComponent.call(this);
    41144185                       
    41154186                        this.addButton(_('Cancel'), this.onCancelClick, this);
     
    41514222        });
    41524223       
    4153         Ext.deluge.EditTracker = Ext.extend(Ext.Window, {
     4224        Deluge.EditTracker = Ext.extend(Ext.Window, {
    41544225                constructor: function(config) {
    41554226                        config = Ext.apply({
     
    41664237                                resizable: false
    41674238                        }, config);
    4168                         Ext.deluge.EditTracker.superclass.constructor.call(this, config);
     4239                        Deluge.EditTracker.superclass.constructor.call(this, config);
    41694240                },
    41704241               
    41714242                initComponent: function() {
    4172                         Ext.deluge.EditTracker.superclass.initComponent.call(this);
     4243                        Deluge.EditTracker.superclass.initComponent.call(this);
    41734244                       
    41744245                        this.addButton(_('Cancel'), this.onCancelClick, this);
     
    41904261               
    41914262                show: function(record) {
    4192                         Ext.deluge.EditTracker.superclass.show.call(this);
     4263                        Deluge.EditTracker.superclass.show.call(this);
    41934264                       
    41944265                        this.record = record;
     
    42124283        });
    42134284       
    4214         Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {
     4285        Deluge.EditTrackers = Ext.extend(Ext.Window, {
    42154286       
    42164287                constructor: function(config) {
     
    42284299                                resizable: true
    42294300                        }, config);
    4230                         Ext.deluge.EditTrackers.superclass.constructor.call(this, config);
     4301                        Deluge.EditTrackers.superclass.constructor.call(this, config);
    42314302                },
    42324303               
    42334304                initComponent: function() {
    4234                         Ext.deluge.EditTrackers.superclass.initComponent.call(this);
     4305                        Deluge.EditTrackers.superclass.initComponent.call(this);
    42354306                       
    42364307                        this.addButton(_('Cancel'), this.onCancelClick, this);
     
    42414312                        this.on('save', this.onSave, this);
    42424313                       
    4243                         this.addWindow = new Ext.deluge.AddTracker();
     4314                        this.addWindow = new Deluge.AddTracker();
    42444315                        this.addWindow.on('add', this.onAddTrackers, this);
    4245                         this.editWindow = new Ext.deluge.EditTracker();
     4316                        this.editWindow = new Deluge.EditTracker();
    42464317                       
    42474318                        this.grid = this.add({
     
    42804351                                        items: [
    42814352                                                {
    4282                                                         cls: 'x-btn-text-icon',
    42834353                                                        text: _('Up'),
    4284                                                         icon: '/icons/up.png',
     4354                                                        iconCls: 'icon-up',
    42854355                                                        handler: this.onUpClick,
    42864356                                                        scope: this
    42874357                                                }, {
    4288                                                         cls: 'x-btn-text-icon',
    42894358                                                        text: _('Down'),
    4290                                                         icon: '/icons/down.png',
     4359                                                        iconCls: 'icon-down',
    42914360                                                        handler: this.onDownClick,
    42924361                                                        scope: this
    42934362                                                }, '->', {
    4294                                                         cls: 'x-btn-text-icon',
    42954363                                                        text: _('Add'),
    4296                                                         icon: '/icons/add.png',
     4364                                                        iconCls: 'icon-add',
    42974365                                                        handler: this.onAddClick,
    42984366                                                        scope: this
    42994367                                                }, {
    4300                                                         cls: 'x-btn-text-icon',
    43014368                                                        text: _('Edit'),
    4302                                                         icon: '/icons/edit_trackers.png',
     4369                                                        iconCls: 'icon-edit-trackers',
    43034370                                                        handler: this.onEditClick,
    43044371                                                        scope: this
    43054372                                                }, {
    4306                                                         cls: 'x-btn-text-icon',
    43074373                                                        text: _('Remove'),
    4308                                                         icon: '/icons/remove.png',
     4374                                                        iconCls: 'icon-remove',
    43094375                                                        handler: this.onRemoveClick,
    43104376                                                        scope: this
     
    43604426                        }, this);
    43614427                       
    4362                         Deluge.Client.core.set_torrent_trackers(this.torrentId, trackers, {
     4428                        deluge.client.core.set_torrent_trackers(this.torrentId, trackers, {
    43634429                                failure: this.onSaveFail,
    43644430                                scope: this
     
    43944460                onShow: function() {
    43954461                        this.grid.getBottomToolbar().items.get(4).disable();
    4396                         var r = Deluge.Torrents.getSelected();
     4462                        var r = deluge.torrents.getSelected();
    43974463                        this.torrentId = r.id;
    4398                         Deluge.Client.core.get_torrent_status(r.id, ['trackers'], {
     4464                        deluge.client.core.get_torrent_status(r.id, ['trackers'], {
    43994465                                success: this.onRequestComplete,
    44004466                                scope: this
     
    44024468                }
    44034469        });
    4404         Deluge.EditTrackers = new Ext.deluge.EditTrackers();
     4470        deluge.editTrackers = new Deluge.EditTrackers();
    44054471})();
    44064472Ext.namespace('Deluge');
    44074473Deluge.FileBrowser = Ext.extend(Ext.Window, {
    44084474
    4409         title: 'Filebrowser',
    4410        
     4475        title: _('File Browser'),
     4476
     4477        width:  500,
     4478        height: 400,
     4479
    44114480        initComponent: function() {
    44124481                Deluge.FileBrowser.superclass.initComponent.call(this);
     4482
     4483                this.add({
     4484                        xtype: 'toolbar',
     4485                        items: [{
     4486                                text: _('Back'),
     4487                                iconCls: 'icon-back'
     4488                        }, {
     4489                                text: _('Forward'),
     4490                                iconCls: 'icon-forward'
     4491                        }, {
     4492                                text: _('Up'),
     4493                                iconCls: 'icon-up'
     4494                        }, {
     4495                                text: _('Home'),
     4496                                iconCls: 'icon-home'
     4497                        }]
     4498                });
    44134499        }
    44144500
     
    44484534*/
    44494535
    4450 Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {
     4536Deluge.LoginWindow = Ext.extend(Ext.Window, {
    44514537       
    44524538        firstShow:   true,
     
    44654551       
    44664552        initComponent: function() {
    4467                 Ext.deluge.LoginWindow.superclass.initComponent.call(this);
     4553                Deluge.LoginWindow.superclass.initComponent.call(this);
    44684554                this.on('show', this.onShow, this);
    44694555               
     
    44944580       
    44954581        logout: function() {
    4496                 Deluge.Events.fire('logout');
    4497                 Deluge.Client.auth.delete_session({
     4582                deluge.events.fire('logout');
     4583                deluge.client.auth.delete_session({
    44984584                        success: function(result) {
    44994585                                this.show(true);
     
    45054591        show: function(skipCheck) {
    45064592                if (this.firstShow) {
    4507                         Deluge.Client.on('error', this.onClientError, this);
     4593                        deluge.client.on('error', this.onClientError, this);
    45084594                        this.firstShow = false;
    45094595                }
    45104596               
    45114597                if (skipCheck) {
    4512                         return Ext.deluge.LoginWindow.superclass.show.call(this);
     4598                        return Deluge.LoginWindow.superclass.show.call(this);
    45134599                }
    45144600               
    4515                 Deluge.Client.auth.check_session({
     4601                deluge.client.auth.check_session({
    45164602                        success: function(result) {
    45174603                                if (result) {
    4518                                         Deluge.Events.fire('login');
     4604                                        deluge.events.fire('login');
    45194605                                } else {
    45204606                                        this.show(true);
     
    45344620        onLogin: function() {
    45354621                var passwordField = this.passwordField;
    4536                 Deluge.Client.auth.login(passwordField.getValue(), {
     4622                deluge.client.auth.login(passwordField.getValue(), {
    45374623                        success: function(result) {
    45384624                                if (result) {
    4539                                         Deluge.Events.fire('login');
     4625                                        deluge.events.fire('login');
    45404626                                        this.hide();
    45414627                                        passwordField.setRawValue('');
     
    45604646        onClientError: function(errorObj, response, requestOptions) {
    45614647                if (errorObj.error.code == 1) {
    4562                         Deluge.Events.fire('logout');
     4648                        deluge.events.fire('logout');
    45634649                        this.show(true);
    45644650                }
     
    45714657});
    45724658
    4573 Deluge.Login = new Ext.deluge.LoginWindow();
     4659deluge.login = new Deluge.LoginWindow();
    45744660/*
    45754661Script: Deluge.MoveStorage.js
     
    46054691*/
    46064692
    4607 Ext.namespace('Ext.deluge');
    4608 Ext.deluge.MoveStorage = Ext.extend(Ext.Window, {
     4693Ext.namespace('Deluge');
     4694Deluge.MoveStorage = Ext.extend(Ext.Window, {
    46094695       
    46104696        constructor: function(config) {
     
    46214707                        resizable: false
    46224708                }, config);
    4623                 Ext.deluge.MoveStorage.superclass.constructor.call(this, config);
     4709                Deluge.MoveStorage.superclass.constructor.call(this, config);
    46244710        },
    46254711
    46264712        initComponent: function() {
    4627                 Ext.deluge.MoveStorage.superclass.initComponent.call(this);
     4713                Deluge.MoveStorage.superclass.initComponent.call(this);
    46284714
    46294715                this.addButton(_('Cancel'), this.onCancel, this);
     
    46434729                        width: 240
    46444730                });
     4731                this.form.add({
     4732                        xtype: 'button',
     4733                        text: _('Browse'),
     4734                        handler: function() {
     4735                                if (!this.fileBrowser) {
     4736                                        this.fileBrowser = new Deluge.FileBrowser();
     4737                                }
     4738                                this.fileBrowser.show();
     4739                        },
     4740                        scope: this
     4741                });
    46454742        },
    46464743
    46474744        hide: function() {
    4648                 Ext.deluge.MoveStorage.superclass.hide.call(this);
     4745                Deluge.MoveStorage.superclass.hide.call(this);
    46494746                this.torrentIds = null;
    46504747        },
    46514748
    46524749        show: function(torrentIds) {
    4653                 Ext.deluge.MoveStorage.superclass.show.call(this);
     4750                Deluge.MoveStorage.superclass.show.call(this);
    46544751                this.torrentIds = torrentIds;
    46554752        },
     
    46614758        onMove: function() {
    46624759                var dest = this.moveLocation.getValue();
    4663                 Deluge.Client.core.move_storage(this.torrentIds, dest);
     4760                deluge.client.core.move_storage(this.torrentIds, dest);
    46644761                this.hide();
    46654762        }
    46664763});
    4667 Deluge.MoveStorage = new Ext.deluge.MoveStorage();
     4764deluge.moveStorage = new Deluge.MoveStorage();
    46684765/*
    46694766Script: Deluge.Plugin.js
     
    47854882*/
    47864883
    4787 Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, {
    4788 
     4884Ext.namespace('Deluge.preferences');
     4885PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]);
     4886
     4887/**
     4888 * @class Deluge.preferences.PreferencesWindow
     4889 * @extends Ext.Window
     4890 */
     4891Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
     4892
     4893        /**
     4894         * @property {String} currentPage The currently selected page.
     4895         */
    47894896        currentPage: null,
    47904897
    4791         constructor: function(config) {
    4792                 config = Ext.apply({
    4793                         layout: 'border',
    4794                         width: 485,
    4795                         height: 500,
    4796                         buttonAlign: 'right',
    4797                         closeAction: 'hide',
    4798                         closable: true,
    4799                         iconCls: 'x-deluge-preferences',
    4800                         plain: true,
    4801                         resizable: false,
    4802                         title: _('Preferences'),
    4803 
    4804                         items: [{
    4805                                 xtype: 'grid',
    4806                                 region: 'west',
    4807                                 title: _('Categories'),
    4808                                 store: new Ext.data.SimpleStore({
    4809                                         fields: [{name: 'name', mapping: 0}]
    4810                                 }),
    4811                                 columns: [{id: 'name', renderer: fplain, dataIndex: 'name'}],
    4812                                 sm: new Ext.grid.RowSelectionModel({
    4813                                         singleSelect: true,
    4814                                         listeners: {'rowselect': {fn: this.onPageSelect, scope: this}}
    4815                                 }),
    4816                                 hideHeaders: true,
    4817                                 autoExpandColumn: 'name',
    4818                                 deferredRender: false,
    4819                                 autoScroll: true,
    4820                                 margins: '5 0 5 5',
    4821                                 cmargins: '5 0 5 5',
    4822                                 width: 120,
    4823                                 collapsible: true
    4824                         }, ]
    4825                 }, config);
    4826                 Ext.deluge.PreferencesWindow.superclass.constructor.call(this, config);
    4827         },
    4828        
     4898        title: _('Preferences'),
     4899        layout: 'border',
     4900        width: 485,
     4901        height: 500,
     4902
     4903        buttonAlign: 'right',
     4904        closeAction: 'hide',
     4905        closable: true,
     4906        iconCls: 'x-deluge-preferences',
     4907        plain: true,
     4908        resizable: false,
     4909
    48294910        initComponent: function() {
    4830                 Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);
    4831                 this.categoriesGrid = this.items.get(0);
     4911                Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this);
     4912
     4913                this.categoriesGrid = this.add({
     4914                        xtype: 'grid',
     4915                        region: 'west',
     4916                        title: _('Categories'),
     4917                        store: new Ext.data.Store(),
     4918                        columns: [{
     4919                                id: 'name',
     4920                                renderer: fplain,
     4921                                dataIndex: 'name'
     4922                        }],
     4923                        sm: new Ext.grid.RowSelectionModel({
     4924                                singleSelect: true,
     4925                                listeners: {
     4926                                        'rowselect': {
     4927                                                fn: this.onPageSelect, scope: this
     4928                                        }
     4929                                }
     4930                        }),
     4931                        hideHeaders: true,
     4932                        autoExpandColumn: 'name',
     4933                        deferredRender: false,
     4934                        autoScroll: true,
     4935                        margins: '5 0 5 5',
     4936                        cmargins: '5 0 5 5',
     4937                        width: 120,
     4938                        collapsible: true
     4939                });
     4940
    48324941                this.configPanel = this.add({
     4942                        type: 'container',
     4943                        autoDestroy: false,
    48334944                        region: 'center',
    4834                         header: false,
    4835                         layout: 'fit',
    4836                         height: 400,
    4837                         autoScroll: true,
     4945                        layout: 'card',
     4946                        //height: 400,
     4947                        //autoScroll: true,
    48384948                        margins: '5 5 5 5',
    48394949                        cmargins: '5 5 5 5'
     
    48464956                this.pages = {};
    48474957                this.optionsManager = new Deluge.OptionsManager();
     4958                this.on('afterrender', this.onAfterRender, this);
    48484959                this.on('show', this.onShow, this);
    48494960        },
     
    48524963                var changed = this.optionsManager.getDirty();
    48534964                if (!Ext.isObjectEmpty(changed)) {
    4854                         Deluge.Client.core.set_config(changed, {
     4965                        deluge.client.core.set_config(changed, {
    48554966                                success: this.onSetConfig,
    48564967                                scope: this
     
    48634974        },
    48644975       
    4865         onClose: function() {
    4866                 this.hide();
    4867         },
    4868 
    4869         onOk: function() {
    4870                 Deluge.Client.core.set_config(this.optionsManager.getDirty());
    4871                 this.hide();
     4976       
     4977        /**
     4978         * Return the options manager for the preferences window.
     4979         * @returns {Deluge.OptionsManager} the options manager
     4980         */
     4981        getOptionsManager: function() {
     4982                return this.optionsManager;
    48724983        },
    48734984       
    48744985        /**
    48754986         * Adds a page to the preferences window.
    4876          * @param {mixed} page
     4987         * @param {Mixed} page
    48774988         */
    48784989        addPage: function(page) {
    48794990                var store = this.categoriesGrid.getStore();
    48804991                var name = page.title;
    4881                 store.loadData([[name]], true);
     4992                store.add([new PreferencesRecord({name: name})]);
    48824993                page['bodyStyle'] = 'margin: 5px';
    48834994                this.pages[name] = this.configPanel.add(page);
     
    48965007            delete this.pages[page.title];
    48975008        },
    4898        
    4899         /**
    4900          * Return the options manager for the preferences window.
    4901          * @returns {Deluge.OptionsManager} the options manager
     5009
     5010        /** 
     5011         * Select which preferences page is displayed.
     5012         * @param {String} page The page name to change to
    49025013         */
    4903         getOptionsManager: function() {
    4904                 return this.optionsManager;
    4905         },
    4906        
     5014        selectPage: function(page) {
     5015                var index = this.configPanel.items.indexOf(this.pages[page]);
     5016                this.configPanel.getLayout().setActiveItem(index);
     5017                this.currentPage = page;
     5018        },
     5019       
     5020        // private
    49075021        onGotConfig: function(config) {
    49085022                this.getOptionsManager().set(config);
    49095023        },
    49105024       
     5025        // private
    49115026        onPageSelect: function(selModel, rowIndex, r) {
    4912                 if (this.currentPage == null) {
    4913                         for (var page in this.pages) {
    4914                                 this.pages[page].hide();
    4915                         }
    4916                 } else {
    4917                         this.currentPage.hide();
    4918                 }
    4919 
    4920                 var name = r.get('name');
    4921                
    4922                 this.pages[name].show();
    4923                 this.currentPage = this.pages[name];
    4924                 this.configPanel.doLayout();
    4925         },
    4926        
     5027                this.selectPage(r.get('name'));
     5028        },
     5029       
     5030        // private
    49275031        onSetConfig: function() {
    49285032                this.getOptionsManager().commit();
    49295033        },
    4930        
    4931         onShow: function() {
     5034
     5035        // private
     5036        onAfterRender: function() {
    49325037                if (!this.categoriesGrid.getSelectionModel().hasSelection()) {
    49335038                        this.categoriesGrid.getSelectionModel().selectFirstRow();
    49345039                }
    4935                
    4936                 Deluge.Client.core.get_config({
     5040                this.configPanel.getLayout().setActiveItem(0);
     5041        },
     5042       
     5043        // private
     5044        onShow: function() {
     5045                if (!deluge.client.core) return;
     5046                deluge.client.core.get_config({
    49375047                        success: this.onGotConfig,
    49385048                        scope: this
    49395049                })
     5050        },
     5051
     5052        // private
     5053        onClose: function() {
     5054                this.hide();
     5055        },
     5056
     5057        // private
     5058        onOk: function() {
     5059                deluge.client.core.set_config(this.optionsManager.getDirty());
     5060                this.hide();
    49405061        }
    49415062});
    4942 
    4943 Deluge.Preferences = new Ext.deluge.PreferencesWindow();
     5063deluge.preferences = new Deluge.preferences.PreferencesWindow();
    49445064/*
    49455065Script: Deluge.Preferences.Downloads.js
     
    49755095*/
    49765096
    4977 Ext.namespace('Ext.deluge.preferences');
    4978 Ext.deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
     5097Ext.namespace('Deluge.preferences');
     5098
     5099/**
     5100 * @class Deluge.preferences.Downloads
     5101 * @extends Ext.form.FormPanel
     5102 */
     5103Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, {
    49795104        constructor: function(config) {
    49805105                config = Ext.apply({
     
    49855110                        width: 320
    49865111                }, config);
    4987                 Ext.deluge.preferences.Downloads.superclass.constructor.call(this, config);
     5112                Deluge.preferences.Downloads.superclass.constructor.call(this, config);
    49885113        },
    49895114
    49905115        initComponent: function() {
    4991                 Ext.deluge.preferences.Downloads.superclass.initComponent.call(this);
    4992 
    4993                 var optMan = Deluge.Preferences.getOptionsManager();
     5116                Deluge.preferences.Downloads.superclass.initComponent.call(this);
     5117
     5118                var optMan = deluge.preferences.getOptionsManager();
    49945119                var fieldset = this.add({
    49955120                        xtype: 'fieldset',
     
    50915216
    50925217        onShow: function() {
    5093                 Ext.deluge.preferences.Downloads.superclass.onShow.call(this);
     5218                Deluge.preferences.Downloads.superclass.onShow.call(this);
    50945219        }
    50955220});
    5096 Deluge.Preferences.addPage(new Ext.deluge.preferences.Downloads());
     5221deluge.preferences.addPage(new Deluge.preferences.Downloads());
    50975222/*
    5098 Script: Deluge.Preferences.Network.js
     5223Script: deluge.preferences.Network.js
    50995224    The network preferences page.
    51005225
     
    51285253*/
    51295254
    5130 Ext.namespace('Ext.deluge.preferences');
    5131 
    5132 Ext.deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
     5255Ext.namespace('Deluge.preferences');
     5256
     5257/**
     5258 * @class Deluge.preferences.Network
     5259 * @extends Ext.form.FormPanel
     5260 */
     5261Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, {
    51335262        constructor: function(config) {
    51345263                config = Ext.apply({
     
    51375266                        layout: 'form'
    51385267                }, config);
    5139                 Ext.deluge.preferences.Network.superclass.constructor.call(this, config);
     5268                Deluge.preferences.Network.superclass.constructor.call(this, config);
    51405269        },
    51415270       
    51425271        initComponent: function() {
    5143                 Ext.deluge.preferences.Network.superclass.initComponent.call(this);
    5144                 var optMan = Deluge.Preferences.getOptionsManager();
     5272                Deluge.preferences.Network.superclass.initComponent.call(this);
     5273                var optMan = deluge.preferences.getOptionsManager();
    51455274               
    51465275                var fieldset = this.add({
     
    53295458        }
    53305459});
    5331 Deluge.Preferences.addPage(new Ext.deluge.preferences.Network());
     5460deluge.preferences.addPage(new Deluge.preferences.Network());
    53325461/*
    5333 Script: Deluge.Preferences.Encryption.js
     5462Script: deluge.preferences.Encryption.js
    53345463    The encryption preferences page.
    53355464
     
    53635492*/
    53645493
    5365 Ext.namespace('Ext.deluge.preferences');
    5366 Ext.deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
     5494Ext.namespace('Deluge.preferences');
     5495
     5496/**
     5497 * @class Deluge.preferences.Encryption
     5498 * @extends Ext.form.FormPanel
     5499 */
     5500Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, {
    53675501        constructor: function(config) {
    53685502                config = Ext.apply({
     
    53715505                        layout: 'form'
    53725506                }, config);
    5373                 Ext.deluge.preferences.Encryption.superclass.constructor.call(this, config);
     5507                Deluge.preferences.Encryption.superclass.constructor.call(this, config);
    53745508        },
    53755509       
    53765510        initComponent: function() {
    5377                 Ext.deluge.preferences.Encryption.superclass.initComponent.call(this);
    5378 
    5379                 var optMan = Deluge.Preferences.getOptionsManager();
     5511                Deluge.preferences.Encryption.superclass.initComponent.call(this);
     5512
     5513                var optMan = deluge.preferences.getOptionsManager();
    53805514               
    53815515                var fieldset = this.add({
     
    54435577        }
    54445578});
    5445 Deluge.Preferences.addPage(new Ext.deluge.preferences.Encryption());/*
    5446 Script: Deluge.Preferences.Bandwidth.js
     5579deluge.preferences.addPage(new Deluge.preferences.Encryption());
     5580/*
     5581Script: deluge.preferences.Bandwidth.js
    54475582    The bandwidth preferences page.
    54485583
     
    54765611*/
    54775612
    5478 Ext.namespace('Ext.deluge.preferences');
    5479 Ext.deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
     5613Ext.namespace('Deluge.preferences');
     5614
     5615/**
     5616 * @class Deluge.preferences.Bandwidth
     5617 * @extends Ext.form.FormPanel
     5618 */
     5619Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, {
    54805620        constructor: function(config) {
    54815621                config = Ext.apply({
     
    54855625                        labelWidth: 10
    54865626                }, config);
    5487                 Ext.deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
     5627                Deluge.preferences.Bandwidth.superclass.constructor.call(this, config);
    54885628        },
    54895629       
    54905630        initComponent: function() {
    5491                 Ext.deluge.preferences.Bandwidth.superclass.initComponent.call(this);
    5492                
    5493                 var optMan = Deluge.Preferences.getOptionsManager();
     5631                Deluge.preferences.Bandwidth.superclass.initComponent.call(this);
     5632               
     5633                var optMan = deluge.preferences.getOptionsManager();
    54945634                var fieldset = this.add({
    54955635                        xtype: 'fieldset',
     
    56565796        }
    56575797});
    5658 Deluge.Preferences.addPage(new Ext.deluge.preferences.Bandwidth());
     5798deluge.preferences.addPage(new Deluge.preferences.Bandwidth());
    56595799/*
    56605800Script: Deluge.Preferences.Interface.js
     
    56905830*/
    56915831
    5692 Ext.namespace('Ext.deluge.preferences');
    5693 Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
     5832Ext.namespace('Deluge.preferences');
     5833
     5834/**
     5835 * @class Deluge.preferences.Interface
     5836 * @extends Ext.form.FormPanel
     5837 */
     5838Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, {
    56945839        constructor: function(config) {
    56955840                config = Ext.apply({
     
    56985843                        layout: 'form'
    56995844                }, config);
    5700                 Ext.deluge.preferences.Interface.superclass.constructor.call(this, config);
     5845                Deluge.preferences.Interface.superclass.constructor.call(this, config);
    57015846        },
    57025847       
    57035848        initComponent: function() {
    5704                 Ext.deluge.preferences.Interface.superclass.initComponent.call(this);
     5849                Deluge.preferences.Interface.superclass.initComponent.call(this);
    57055850               
    57065851                var optMan = this.optionsManager = new Deluge.OptionsManager();
     
    58435988                var changed = this.optionsManager.getDirty();
    58445989                if (!Ext.isObjectEmpty(changed)) {
    5845                         Deluge.Client.web.set_config(changed, {
     5990                        deluge.client.web.set_config(changed, {
    58465991                                success: this.onSetConfig,
    58475992                                scope: this
     
    58696014               
    58706015                var oldPassword = this.oldPassword.getValue();
    5871                 Deluge.Client.auth.change_password(oldPassword, newPassword, {
     6016                deluge.client.auth.change_password(oldPassword, newPassword, {
    58726017                        success: function(result) {
    58736018                                if (!result) {
     
    59046049       
    59056050        onShow: function() {
    5906                 Ext.deluge.preferences.Interface.superclass.onShow.call(this);
    5907                 Deluge.Client.web.get_config({
     6051                Deluge.preferences.Interface.superclass.onShow.call(this);
     6052                deluge.client.web.get_config({
    59086053                        success: this.onGotConfig,
    59096054                        scope: this
     
    59166061        }
    59176062});
    5918 Deluge.Preferences.addPage(new Ext.deluge.preferences.Interface());
     6063deluge.preferences.addPage(new Deluge.preferences.Interface());
    59196064/*
    59206065Script: Deluge.Preferences.Other.js
     
    59506095*/
    59516096
    5952 Ext.namespace('Ext.deluge.preferences');
    5953 Ext.deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
     6097Ext.namespace('Deluge.preferences');
     6098
     6099/**
     6100 * @class Deluge.preferences.Other
     6101 * @extends Ext.form.FormPanel
     6102 */
     6103Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, {
    59546104        constructor: function(config) {
    59556105                config = Ext.apply({
     
    59586108                        layout: 'form'
    59596109                }, config);
    5960                 Ext.deluge.preferences.Other.superclass.constructor.call(this, config);
     6110                Deluge.preferences.Other.superclass.constructor.call(this, config);
    59616111        },
    59626112       
    59636113        initComponent: function() {
    5964                 Ext.deluge.preferences.Other.superclass.initComponent.call(this);
    5965                
    5966                 var optMan = Deluge.Preferences.getOptionsManager();
     6114                Deluge.preferences.Other.superclass.initComponent.call(this);
     6115               
     6116                var optMan = deluge.preferences.getOptionsManager();
    59676117               
    59686118                var fieldset = this.add({
     
    60226172        }
    60236173});
    6024 Deluge.Preferences.addPage(new Ext.deluge.preferences.Other());
     6174deluge.preferences.addPage(new Deluge.preferences.Other());
    60256175/*
    60266176Script: Deluge.Preferences.Daemon.js
     
    60566206*/
    60576207
    6058 Ext.namespace('Ext.deluge.preferences');
    6059 Ext.deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
     6208Ext.namespace('Deluge.preferences');
     6209
     6210/**
     6211 * @class Deluge.preferences.Daemon
     6212 * @extends Ext.form.FormPanel
     6213 */
     6214Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, {
    60606215        constructor: function(config) {
    60616216                config = Ext.apply({
     
    60646219                        layout: 'form'
    60656220                }, config);
    6066                 Ext.deluge.preferences.Daemon.superclass.constructor.call(this, config);
     6221                Deluge.preferences.Daemon.superclass.constructor.call(this, config);
    60676222        },
    60686223       
    60696224        initComponent: function() {
    6070                 Ext.deluge.preferences.Daemon.superclass.initComponent.call(this);
    6071 
    6072                 var optMan = Deluge.Preferences.getOptionsManager();
     6225                Deluge.preferences.Daemon.superclass.initComponent.call(this);
     6226
     6227                var optMan = deluge.preferences.getOptionsManager();
    60736228               
    60746229                var fieldset = this.add({
     
    61246279        }
    61256280});
    6126 Deluge.Preferences.addPage(new Ext.deluge.preferences.Daemon());
     6281deluge.preferences.addPage(new Deluge.preferences.Daemon());
    61276282/*
    61286283Script: Deluge.Preferences.Queue.js
     
    61586313*/
    61596314
    6160 Ext.namespace('Ext.deluge.preferences');
    6161 Ext.deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
     6315Ext.namespace('Deluge.preferences');
     6316
     6317/**
     6318 * @class Deluge.preferences.Queue
     6319 * @extends Ext.form.FormPanel
     6320 */
     6321Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, {
    61626322        constructor: function(config) {
    61636323                config = Ext.apply({
     
    61666326                        layout: 'form'
    61676327                }, config);
    6168                 Ext.deluge.preferences.Queue.superclass.constructor.call(this, config);
     6328                Deluge.preferences.Queue.superclass.constructor.call(this, config);
    61696329        },
    61706330       
    61716331        initComponent: function() {
    6172                 Ext.deluge.preferences.Queue.superclass.initComponent.call(this);
    6173                
    6174                 var optMan = Deluge.Preferences.getOptionsManager();
     6332                Deluge.preferences.Queue.superclass.initComponent.call(this);
     6333               
     6334                var optMan = deluge.preferences.getOptionsManager();
    61756335               
    61766336                var fieldset = this.add({
     
    63456505        }
    63466506});
    6347 Deluge.Preferences.addPage(new Ext.deluge.preferences.Queue());
     6507deluge.preferences.addPage(new Deluge.preferences.Queue());
    63486508/*
    63496509Script: Deluge.Preferences.Proxy.js
     
    63796539*/
    63806540
    6381 Ext.namespace('Ext.deluge.preferences');
    6382 Ext.deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
     6541Ext.namespace('Deluge.preferences');
     6542
     6543/**
     6544 * @class Deluge.preferences.ProxyField
     6545 * @extends Ext.form.FormSet
     6546 */
     6547Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, {
    63836548
    63846549        constructor: function(config) {
     
    63886553                        labelWidth: 70
    63896554                }, config);
    6390                 Ext.deluge.preferences.ProxyField.superclass.constructor.call(this, config);
     6555                Deluge.preferences.ProxyField.superclass.constructor.call(this, config);
    63916556        },
    63926557
    63936558        initComponent: function() {
    6394                 Ext.deluge.preferences.ProxyField.superclass.initComponent.call(this);
     6559                Deluge.preferences.ProxyField.superclass.initComponent.call(this);
    63956560                this.type = this.add({
    63966561                        xtype: 'combo',
     
    65136678});
    65146679
    6515 
    6516 Ext.deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
     6680/**
     6681 * @class Deluge.preferences.Proxy
     6682 * @extends Ext.form.FormPanel
     6683 */
     6684Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, {
    65176685        constructor: function(config) {
    65186686                config = Ext.apply({
     
    65216689                        layout: 'form'
    65226690                }, config);
    6523                 Ext.deluge.preferences.Proxy.superclass.constructor.call(this, config);
     6691                Deluge.preferences.Proxy.superclass.constructor.call(this, config);
    65246692        },
    65256693       
    65266694        initComponent: function() {
    6527                 Ext.deluge.preferences.Proxy.superclass.initComponent.call(this);
    6528                 this.peer = this.add(new Ext.deluge.preferences.ProxyField({
     6695                Deluge.preferences.Proxy.superclass.initComponent.call(this);
     6696                this.peer = this.add(new Deluge.preferences.ProxyField({
    65296697                        title: _('Peer'),
    65306698                        name: 'peer'
     
    65326700                this.peer.on('change', this.onProxyChange, this);
    65336701               
    6534                 this.web_seed = this.add(new Ext.deluge.preferences.ProxyField({
     6702                this.web_seed = this.add(new Deluge.preferences.ProxyField({
    65356703                        title: _('Web Seed'),
    65366704                        name: 'web_seed'
     
    65386706                this.web_seed.on('change', this.onProxyChange, this);
    65396707               
    6540                 this.tracker = this.add(new Ext.deluge.preferences.ProxyField({
     6708                this.tracker = this.add(new Deluge.preferences.ProxyField({
    65416709                        title: _('Tracker'),
    65426710                        name: 'tracker'
     
    65446712                this.tracker.on('change', this.onProxyChange, this);
    65456713               
    6546                 this.dht = this.add(new Ext.deluge.preferences.ProxyField({
     6714                this.dht = this.add(new Deluge.preferences.ProxyField({
    65476715                        title: _('DHT'),
    65486716                        name: 'dht'
     
    65506718                this.dht.on('change', this.onProxyChange, this);
    65516719               
    6552                 Deluge.Preferences.getOptionsManager().bind('proxies', this);
     6720                deluge.preferences.getOptionsManager().bind('proxies', this);
    65536721        },
    65546722       
     
    65766744        }
    65776745});
    6578 Deluge.Preferences.addPage(new Ext.deluge.preferences.Proxy());
     6746deluge.preferences.addPage(new Deluge.preferences.Proxy());
    65796747/*
    6580 Script: Deluge.Preferences.Cache.js
     6748Script: deluge.preferences.Cache.js
    65816749    The cache preferences page.
    65826750
     
    66106778*/
    66116779
    6612 Ext.namespace('Ext.deluge.preferences');
    6613 Ext.deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
     6780Ext.namespace('Deluge.preferences');
     6781
     6782/**
     6783 * @class Deluge.preferences.Cache
     6784 * @extends Ext.form.FormPanel
     6785 */
     6786Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, {
    66146787        constructor: function(config) {
    66156788                config = Ext.apply({
     
    66186791                        layout: 'form'
    66196792                }, config);
    6620                 Ext.deluge.preferences.Cache.superclass.constructor.call(this, config);
     6793                Deluge.preferences.Cache.superclass.constructor.call(this, config);
    66216794        },
    66226795       
    66236796        initComponent: function() {
    6624                 Ext.deluge.preferences.Cache.superclass.initComponent.call(this);
    6625 
    6626                 var optMan = Deluge.Preferences.getOptionsManager();
     6797                Deluge.preferences.Cache.superclass.initComponent.call(this);
     6798
     6799                var optMan = deluge.preferences.getOptionsManager();
    66276800               
    66286801                var fieldset = this.add({
     
    66606833        }
    66616834});
    6662 Deluge.Preferences.addPage(new Ext.deluge.preferences.Cache());
     6835deluge.preferences.addPage(new Deluge.preferences.Cache());
    66636836/*
    66646837Script: Deluge.Preferences.Plugins.js
     
    66946867*/
    66956868
    6696 Ext.namespace('Ext.deluge.preferences');
    6697 
    6698 Ext.deluge.preferences.InstallPlugin = Ext.extend(Ext.Window, {
     6869Ext.namespace('Deluge.preferences');
     6870
     6871/**
     6872 * @class Deluge.preferences.InstallPluginWindow
     6873 * @extends Ext.Window
     6874 */
     6875Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, {
    66996876
    67006877        height: 115,
     
    67186895
    67196896        initComponent: function() {
    6720                 Ext.deluge.add.FileWindow.superclass.initComponent.call(this);
     6897                Deluge.add.FileWindow.superclass.initComponent.call(this);
    67216898                this.addButton(_('Install'), this.onInstall, this);
    67226899               
     
    67596936                        var path = upload.result.files[0]
    67606937                        this.form.getForm().findField('pluginEgg').setValue('');
    6761                         Deluge.Client.web.upload_plugin(filename, path, {
     6938                        deluge.client.web.upload_plugin(filename, path, {
    67626939                                success: this.onUploadPlugin,
    67636940                                scope: this,
     
    67676944        }
    67686945});
    6769        
    6770 
    6771 Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
     6946
     6947/**
     6948 * @class Deluge.preferences.Plugins
     6949 * @extends Ext.Panel
     6950 */
     6951Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
    67726952        constructor: function(config) {
    67736953                config = Ext.apply({
     
    67786958                        cls: 'x-deluge-plugins'
    67796959                }, config);
    6780                 Ext.deluge.preferences.Plugins.superclass.constructor.call(this, config);
     6960                Deluge.preferences.Plugins.superclass.constructor.call(this, config);
    67816961        },
    67826962
     
    67926972
    67936973        initComponent: function() {
    6794                 Ext.deluge.preferences.Plugins.superclass.initComponent.call(this);
     6974                Deluge.preferences.Plugins.superclass.initComponent.call(this);
    67956975                this.defaultValues = {
    67966976                        'version': '',
     
    68477027                                        iconCls: 'x-deluge-install-plugin',
    68487028                                        text: _('Install'),
    6849                                         handler: this.onInstallPlugin,
     7029                                        handler: this.onInstallPluginWindow,
    68507030                                        scope: this
    68517031                                }, '->', {
     
    68787058                this.pluginInfo.on('render', this.onPluginInfoRender, this);
    68797059                this.grid.on('cellclick', this.onCellClick, this);
    6880                 Deluge.Preferences.on('show', this.onPreferencesShow, this);
    6881                 Deluge.Events.on('PluginDisabledEvent', this.onPluginDisabled, this);
    6882                 Deluge.Events.on('PluginEnabledEvent', this.onPluginEnabled, this);
     7060                deluge.preferences.on('show', this.onPreferencesShow, this);
     7061                deluge.events.on('PluginDisabledEvent', this.onPluginDisabled, this);
     7062                deluge.events.on('PluginEnabledEvent', this.onPluginEnabled, this);
    68837063        },
    68847064
    68857065        disablePlugin: function(plugin) {
    6886                 Deluge.Client.core.disable_plugin(plugin);
     7066                deluge.client.core.disable_plugin(plugin);
    68877067        },
    68887068
    68897069        enablePlugin: function(plugin) {
    6890                 Deluge.Client.core.enable_plugin(plugin);
     7070                deluge.client.core.enable_plugin(plugin);
    68917071        },
    68927072
     
    68987078       
    68997079        updatePlugins: function() {
    6900                 Deluge.Client.web.get_plugins({
     7080                deluge.client.web.get_plugins({
    69017081                        success: this.onGotPlugins,
    69027082                        scope: this
     
    69517131        },
    69527132
    6953         onInstallPlugin: function() {
     7133        onInstallPluginWindow: function() {
    69547134                if (!this.installWindow) {
    6955                         this.installWindow = new Ext.deluge.preferences.InstallPlugin();
     7135                        this.installWindow = new Deluge.preferences.InstallPluginWindow();
    69567136                        this.installWindow.on('pluginadded', this.onPluginInstall, this);
    69577137                }
     
    69787158
    69797159        onPluginSelect: function(selmodel, rowIndex, r) {
    6980                 Deluge.Client.web.get_plugin_info(r.get('plugin'), {
     7160                deluge.client.web.get_plugin_info(r.get('plugin'), {
    69817161                        success: this.onGotPluginInfo,
    69827162                        scope: this
     
    69927172        }
    69937173});
    6994 Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());
     7174deluge.preferences.addPage(new Deluge.preferences.Plugins());
    69957175/*
    69967176Script:
     
    70277207
    70287208/**
    7029  * @class Ext.deluge.RemoveWindow
     7209 * @class Deluge.RemoveWindow
    70307210 */
    7031 Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {
     7211Deluge.RemoveWindow = Ext.extend(Ext.Window, {
    70327212
    70337213        constructor: function(config) {
     
    70437223                        iconCls: 'x-deluge-remove-window-icon'
    70447224                }, config);
    7045                 Ext.deluge.RemoveWindow.superclass.constructor.call(this, config);
     7225                Deluge.RemoveWindow.superclass.constructor.call(this, config);
    70467226        },
    70477227       
    70487228        initComponent: function() {
    7049                 Ext.deluge.RemoveWindow.superclass.initComponent.call(this);
     7229                Deluge.RemoveWindow.superclass.initComponent.call(this);
    70507230                this.addButton(_('Cancel'), this.onCancel, this);
    70517231                this.addButton(_('Remove With Data'), this.onRemoveData, this);
     
    70617241        remove: function(removeData) {
    70627242                Ext.each(this.torrentIds, function(torrentId) {
    7063                         Deluge.Client.core.remove_torrent(torrentId, removeData, {
     7243                        deluge.client.core.remove_torrent(torrentId, removeData, {
    70647244                                success: function() {
    70657245                                        this.onRemoved(torrentId);
     
    70737253       
    70747254        show: function(ids) {
    7075                 Ext.deluge.RemoveWindow.superclass.show.call(this);
     7255                Deluge.RemoveWindow.superclass.show.call(this);
    70767256                this.torrentIds = ids;
    70777257        },
     
    70917271       
    70927272        onRemoved: function(torrentId) {
    7093                 Deluge.Events.fire('torrentRemoved', torrentId);
     7273                deluge.events.fire('torrentRemoved', torrentId);
    70947274                this.hide();
    7095                 Deluge.UI.update();
     7275                deluge.ui.update();
    70967276        }
    70977277});
    70987278
    7099 Deluge.RemoveWindow = new Ext.deluge.RemoveWindow();
     7279deluge.removeWindow = new Deluge.RemoveWindow();
    71007280/*
    7101 Script: deluge-bars.js
     7281Script: Deluge.Sidebar.js
    71027282    Contains all objects and functions related to the statusbar, toolbar and
    71037283        sidebar.
     
    71457325        if (r.store.id == 'tracker_host') {
    71467326            if (value != 'Error') {
    7147                 image = String.format('url(/tracker/{0})', value);
     7327                image = String.format('url(' + deluge.config.base + 'tracker/{0})', value);
    71487328            } else {
    71497329                lname = null;
     
    71607340
    71617341        /**
    7162          * @class Ext.deluge.Sidebar
     7342         * @class Deluge.Sidebar
    71637343         * @author Damien Churchill <damoxc@gmail.com>
    71647344         * @version 1.3
    71657345         */
    7166     Ext.deluge.Sidebar = Ext.extend(Ext.Panel, {
     7346    Deluge.Sidebar = Ext.extend(Ext.Panel, {
    71677347
    71687348        // private
     
    71867366                cmargins: '5 0 0 5'
    71877367            }, config);
    7188             Ext.deluge.Sidebar.superclass.constructor.call(this, config);
     7368            Deluge.Sidebar.superclass.constructor.call(this, config);
    71897369        },
    71907370   
    71917371        // private
    71927372        initComponent: function() {
    7193             Ext.deluge.Sidebar.superclass.initComponent.call(this);
    7194             Deluge.Events.on("disconnect", this.onDisconnect, this);
     7373            Deluge.Sidebar.superclass.initComponent.call(this);
     7374            deluge.events.on("disconnect", this.onDisconnect, this);
    71957375        },
    71967376   
    71977377        createFilter: function(filter, states) {
    7198             var store = new Ext.data.SimpleStore({
    7199                 id: filter,
     7378            var store = new Ext.data.ArrayStore({
     7379                idIndex: 0,
    72007380                fields: [
    72017381                    {name: 'filter'},
     
    72037383                ]
    72047384            });
     7385                        store.id = filter;
    72057386   
    72067387            var title = filter.replace('_', ' ');
     
    72357416            });
    72367417       
    7237             if (Deluge.config['sidebar_show_zero'] == false) {
     7418            if (deluge.config['sidebar_show_zero'] == false) {
    72387419                states = this.removeZero(states);
    72397420            }
     
    72457426            this.panels[filter] = panel;
    72467427       
    7247             if (!this.selected) {
    7248                 panel.getSelectionModel().selectFirstRow();
    7249                 this.selected = {
    7250                     row: 0,
    7251                     filter: states[0][0],
    7252                     panel: panel
    7253                 }
    7254             }
     7428                        panel.getSelectionModel().selectFirstRow();
    72557429        },
    72567430   
    72577431        getFilters: function() {
    72587432            var filters = {}
    7259             if (!this.selected) {
    7260                 return filters;
    7261             }
    7262             if (!this.selected.filter || !this.selected.panel) {
    7263                 return filters;
    7264             }
    7265             var filterType = this.selected.panel.store.id;
    7266             if (filterType == "state" && this.selected.filter == "All") {
    7267                 return filters;
    7268             }
    7269    
    7270             filters[filterType] = this.selected.filter;
     7433
     7434                        // Grab the filters from each of the filter panels
     7435                        this.items.each(function(panel) {
     7436                                var sm = panel.getSelectionModel();
     7437
     7438                                if (!sm.hasSelection()) return;
     7439                               
     7440                                var filter = sm.getSelected();
     7441                                var filterType = panel.getStore().id;
     7442
     7443                                if (filter.id == "All") return;
     7444
     7445                                filters[filterType] = filter.id;
     7446                        }, this);
     7447
    72717448            return filters;
    72727449        },
     
    72827459   
    72837460        onFilterSelect: function(selModel, rowIndex, record) {
    7284             if (!this.selected) needsUpdate = true;
    7285             else if (this.selected.row != rowIndex) needsUpdate = true;
    7286             else needsUpdate = false;
    7287             this.selected = {
    7288                 row: rowIndex,
    7289                 filter: record.get('filter'),
    7290                 panel: this.panels[record.store.id]
    7291             }
    7292    
    7293             if (needsUpdate) Deluge.UI.update();
     7461            deluge.ui.update();
    72947462        },
    72957463   
     
    73277495   
    73287496        updateFilter: function(filter, states) {
    7329             if (Deluge.config['sidebar_show_zero'] == false) {
     7497            if (deluge.config.sidebar_show_zero == false) {
    73307498                states = this.removeZero(states);
    73317499            }
    7332    
    7333             this.panels[filter].store.loadData(states);
    7334             if (this.selected && this.selected.panel == this.panels[filter]) {
    7335                 this.panels[filter].getSelectionModel().selectRow(this.selected.row);
    7336             }
     7500
     7501                        var store = this.panels[filter].getStore();
     7502                        var filters = [];
     7503                        Ext.each(states, function(s, i) {
     7504                                var record = store.getById(s[0]);
     7505                                if (!record) {
     7506                                        record = new store.recordType({
     7507                                                filter: s[0],
     7508                                                count: s[1]
     7509                                        });
     7510                                        record.id = s[0];
     7511                                        store.insert(i, [record]);
     7512                                }
     7513                                record.beginEdit();
     7514                                record.set('filter', s[0]);
     7515                                record.set('count', s[1]);
     7516                                record.endEdit();
     7517                                filters[s[0]] = true;
     7518                        }, this);
     7519
     7520                        store.each(function(record) {
     7521                                if (filters[record.id]) return;
     7522
     7523                                store.remove(record);
     7524                        }, this);
     7525
     7526                        store.commitChanges();
    73377527        }
    73387528    });
    7339     Deluge.Sidebar = new Ext.deluge.Sidebar();
     7529    deluge.sidebar = new Deluge.Sidebar();
    73407530})();
    7341 Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
     7531Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {
    73427532        constructor: function(config) {
    73437533                config = Ext.apply({
     
    73467536                        defaultText: _('Not Connected')
    73477537                }, config);
    7348                 Ext.deluge.Statusbar.superclass.constructor.call(this, config);
     7538                Deluge.Statusbar.superclass.constructor.call(this, config);
    73497539        },
    73507540       
    73517541        initComponent: function() {
    7352                 Ext.deluge.Statusbar.superclass.initComponent.call(this);
    7353                
    7354                 Deluge.Events.on('connect', this.onConnect, this);
    7355                 Deluge.Events.on('disconnect', this.onDisconnect, this);
     7542                Deluge.Statusbar.superclass.initComponent.call(this);
     7543               
     7544                deluge.events.on('connect', this.onConnect, this);
     7545                deluge.events.on('disconnect', this.onDisconnect, this);
    73567546        },
    73577547       
    73587548        createButtons: function() {
    7359                 this.add({
     7549                this.buttons = this.add({
    73607550                        id: 'statusbar-connections',
    73617551                        text: ' ',
     
    73637553                        iconCls: 'x-deluge-connections',
    73647554                        tooltip: _('Connections'),
    7365                         menu: Deluge.Menus.Connections
     7555                        menu: deluge.menus.connections
    73667556                }, '-', {
    73677557                        id: 'statusbar-downspeed',
     
    73707560                        iconCls: 'x-deluge-downloading',
    73717561                        tooltip: _('Download Speed'),
    7372                         menu: Deluge.Menus.Download
     7562                        menu: deluge.menus.download
    73737563                }, '-', {
    73747564                        id: 'statusbar-upspeed',
     
    73777567                        iconCls: 'x-deluge-seeding',
    73787568                        tooltip: _('Upload Speed'),
    7379                         menu: Deluge.Menus.Upload
     7569                        menu: deluge.menus.upload
    73807570                }, '-', {
    73817571                        id: 'statusbar-traffic',
     
    74017591       
    74027592        onConnect: function() {
    7403                 //this.setStatus({
    7404                 //      iconCls: 'x-connected',
    7405                 //      text: ''
    7406                 //});
    7407                 if (!this.created) this.createButtons();
    7408                 else {
    7409                         this.items.each(function(item) {
     7593                this.setStatus({
     7594                        iconCls: 'x-connected',
     7595                        text: ''
     7596                });
     7597                if (!this.created) {
     7598                        this.createButtons();
     7599                } else {
     7600                        Ext.each(this.buttons, function(item) {
    74107601                                item.show();
    74117602                                item.enable();
    74127603                        });
    74137604                }
     7605                this.doLayout();
    74147606        },
    74157607
    74167608        onDisconnect: function() {
    7417                 //this.clearStatus({useDefaults:true});
    7418                 this.items.each(function(item) {
     7609                this.clearStatus({useDefaults:true});
     7610                Ext.each(this.buttons, function(item) {
    74197611                        item.hide();
    74207612                        item.disable();
    74217613                });
     7614                this.doLayout();
    74227615        },
    74237616       
     
    74307623                        var item = this.items.get('statusbar-' + name);
    74317624                        if (config.limit.value > 0) {
    7432                                 var value = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
    7433                                 var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value) : config.limit.value;
     7625                                var value = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
     7626                                var limit = (config.limit.formatter) ? config.limit.formatter(config.limit.value, true) : config.limit.value;
    74347627                                var str = String.format(config.format, value, limit);
    74357628                        } else {
    7436                                 var str = (config.value.formatter) ? config.value.formatter(config.value.value) : config.value.value;
     7629                                var str = (config.value.formatter) ? config.value.formatter(config.value.value, true) : config.value.value;
    74377630                        }
    74387631                        item.setText(str);
     
    74847677                this.items.get('statusbar-freespace').setText(fsize(stats.free_space));
    74857678               
    7486                 Deluge.Menus.Connections.setValue(stats.max_num_connections);
    7487                 Deluge.Menus.Download.setValue(stats.max_download);
    7488                 Deluge.Menus.Upload.setValue(stats.max_upload);
     7679                deluge.menus.connections.setValue(stats.max_num_connections);
     7680                deluge.menus.download.setValue(stats.max_download);
     7681                deluge.menus.upload.setValue(stats.max_upload);
    74897682        }
    74907683});
    7491 Deluge.Statusbar = new Ext.deluge.Statusbar();
     7684deluge.statusbar = new Deluge.Statusbar();
    74927685/*
    74937686Script: Deluge.Toolbar.js
     
    75267719/**
    75277720 * An extension of the <tt>Ext.Toolbar</tt> class that provides an extensible toolbar for Deluge.
    7528  * @class Ext.deluge.Toolbar
     7721 * @class Deluge.Toolbar
    75297722 * @extends Ext.Toolbar
    75307723 */
    7531 Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {
     7724Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
    75327725        constructor: function(config) {
    75337726                config = Ext.apply({
     
    75357728                                {
    75367729                                        id: 'create',
    7537                                         cls: 'x-btn-text-icon',
    75387730                                        disabled: true,
    75397731                                        text: _('Create'),
    7540                                         icon: '/icons/create.png',
     7732                                        iconCls: 'icon-create',
    75417733                                        handler: this.onTorrentAction
    75427734                                },{
    75437735                                        id: 'add',
    7544                                         cls: 'x-btn-text-icon',
    75457736                                        disabled: true,
    75467737                                        text: _('Add'),
    7547                                         icon: '/icons/add.png',
     7738                                        iconCls: 'icon-add',
    75487739                                        handler: this.onTorrentAdd
    75497740                                },{
    75507741                                        id: 'remove',
    7551                                         cls: 'x-btn-text-icon',
    75527742                                        disabled: true,
    75537743                                        text: _('Remove'),
    7554                                         icon: '/icons/remove.png',
     7744                                        iconCls: 'icon-remove',
    75557745                                        handler: this.onTorrentAction
    75567746                                },'|',{
    75577747                                        id: 'pause',
    7558                                         cls: 'x-btn-text-icon',
    75597748                                        disabled: true,
    75607749                                        text: _('Pause'),
    7561                                         icon: '/icons/pause.png',
     7750                                        iconCls: 'icon-pause',
    75627751                                        handler: this.onTorrentAction
    75637752                                },{
    75647753                                        id: 'resume',
    7565                                         cls: 'x-btn-text-icon',
    75667754                                        disabled: true,
    75677755                                        text: _('Resume'),
    7568                                         icon: '/icons/start.png',
     7756                                        iconCls: 'icon-resume',
    75697757                                        handler: this.onTorrentAction
    75707758                                },'|',{
     
    75737761                                        disabled: true,
    75747762                                        text: _('Up'),
    7575                                         icon: '/icons/up.png',
     7763                                        iconCls: 'icon-up',
    75767764                                        handler: this.onTorrentAction
    75777765                                },{
    75787766                                        id: 'down',
    7579                                         cls: 'x-btn-text-icon',
    75807767                                        disabled: true,
    75817768                                        text: _('Down'),
    7582                                         icon: '/icons/down.png',
     7769                                        iconCls: 'icon-down',
    75837770                                        handler: this.onTorrentAction
    75847771                                },'|',{
    75857772                                        id: 'preferences',
    7586                                         cls: 'x-btn-text-icon',
    75877773                                        text: _('Preferences'),
    75887774                                        iconCls: 'x-deluge-preferences',
     
    75917777                                },{
    75927778                                        id: 'connectionman',
    7593                                         cls: 'x-btn-text-icon',
    75947779                                        text: _('Connection Manager'),
    75957780                                        iconCls: 'x-deluge-connection-manager',
     
    75987783                                },'->',{
    75997784                                        id: 'help',
    7600                                         cls: 'x-btn-text-icon',
    7601                                         icon: '/icons/help.png',
     7785                                        iconCls: 'icon-help',
    76027786                                        text: _('Help'),
    76037787                                        handler: this.onHelpClick,
     
    76057789                                },{
    76067790                                        id: 'logout',
    7607                                         cls: 'x-btn-text-icon',
    7608                                         icon: '/icons/logout.png',
     7791                                        iconCls: 'icon-logout',
    76097792                                        disabled: true,
    76107793                                        text: _('Logout'),
     
    76147797                        ]
    76157798                }, config);
    7616                 Ext.deluge.Toolbar.superclass.constructor.call(this, config);
     7799                Deluge.Toolbar.superclass.constructor.call(this, config);
    76177800        },
    76187801
     
    76227805       
    76237806        initComponent: function() {
    7624                 Ext.deluge.Toolbar.superclass.initComponent.call(this);
    7625                 Deluge.Events.on('connect', this.onConnect, this);
    7626                 Deluge.Events.on('login', this.onLogin, this);
     7807                Deluge.Toolbar.superclass.initComponent.call(this);
     7808                deluge.events.on('connect', this.onConnect, this);
     7809                deluge.events.on('login', this.onLogin, this);
    76277810        },
    76287811       
     
    76457828        onLogout: function() {
    76467829                this.items.get('logout').disable();
    7647                 Deluge.Login.logout();
     7830                deluge.login.logout();
    76487831        },
    76497832       
    76507833        onConnectionManagerClick: function() {
    7651                 Deluge.ConnectionManager.show();
     7834                deluge.connectionManager.show();
    76527835        },
    76537836       
     
    76577840       
    76587841        onPreferencesClick: function() {
    7659                 Deluge.Preferences.show();
     7842                deluge.preferences.show();
    76607843        },
    76617844       
    76627845        onTorrentAction: function(item) {
    7663                 var selection = Deluge.Torrents.getSelections();
     7846                var selection = deluge.torrents.getSelections();
    76647847                var ids = [];
    76657848                Ext.each(selection, function(record) {
     
    76697852                switch (item.id) {
    76707853                        case 'remove':
    7671                                 Deluge.RemoveWindow.show(ids);
     7854                                deluge.removeWindow.show(ids);
    76727855                                break;
    76737856                        case 'pause':
    76747857                        case 'resume':
    7675                                 Deluge.Client.core[item.id + '_torrent'](ids, {
     7858                                deluge.client.core[item.id + '_torrent'](ids, {
    76767859                                        success: function() {
    7677                                                 Deluge.UI.update();
     7860                                                deluge.ui.update();
    76787861                                        }
    76797862                                });
     
    76817864                        case 'up':
    76827865                        case 'down':
    7683                                 Deluge.Client.core['queue_' + item.id](ids, {
     7866                                deluge.client.core['queue_' + item.id](ids, {
    76847867                                        success: function() {
    7685                                                 Deluge.UI.update();
     7868                                                deluge.ui.update();
    76867869                                        }
    76877870                                });
     
    76917874       
    76927875        onTorrentAdd: function() {
    7693                 Deluge.Add.show();
     7876                deluge.add.show();
    76947877        }
    76957878});
    76967879
    7697 Deluge.Toolbar = new Ext.deluge.Toolbar();
     7880deluge.toolbar = new Deluge.Toolbar();
    76987881/*
    76997882Script: Deluge.Torrent.js
     
    78628045        }
    78638046        function trackerRenderer(value, p, r) {
    7864                 return String.format('<div style="background: url(/tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
     8047                return String.format('<div style="background: url(' + deluge.config.base + 'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
    78658048        }
    78668049       
     
    78708053
    78718054        /**
    7872          * Ext.deluge.TorrentGrid Class
     8055         * Deluge.TorrentGrid Class
    78738056         *
    78748057         * @author Damien Churchill <damoxc@gmail.com>
    78758058         * @version 1.3
    78768059         *
    7877          * @class Ext.deluge.TorrentGrid
     8060         * @class Deluge.TorrentGrid
    78788061         * @extends Ext.grid.GridPanel
    78798062         * @constructor
    78808063         * @param {Object} config Configuration options
    78818064         */
    7882         Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
     8065        Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
    78838066
    78848067                // object to store contained torrent ids
     
    80048187                                })
    80058188                        }, config);
    8006                         Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
     8189                        Deluge.TorrentGrid.superclass.constructor.call(this, config);
    80078190                },
    80088191
    80098192        initComponent: function() {
    8010                 Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
    8011                 Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
    8012                 Deluge.Events.on('logout', this.onDisconnect, this);
     8193                Deluge.TorrentGrid.superclass.initComponent.call(this);
     8194                deluge.events.on('torrentRemoved', this.onTorrentRemoved, this);
     8195                deluge.events.on('logout', this.onDisconnect, this);
    80138196
    80148197                this.on('rowcontextmenu', function(grid, rowIndex, e) {
     
    80188201                                selection.selectRow(rowIndex);
    80198202                        }
    8020                         Deluge.Menus.Torrent.showAt(e.getPoint());
     8203                        deluge.menus.torrent.showAt(e.getPoint());
    80218204                });
    80228205        },
     
    80408223        },
    80418224
     8225        /**
     8226         * Returns the currently selected records.
     8227         */
    80428228        getSelections: function() {
    80438229                return this.getSelectionModel().getSelections();
     
    80748260                        if (!torrents[record.id]) {
    80758261                                store.remove(record);
     8262                                delete this.torrents[record.id];
    80768263                        }
    8077                 });
     8264                }, this);
    80788265                store.commitChanges();
     8266
     8267                var sortState = store.getSortState()
     8268                if (!sortState) return;
     8269                store.sort(sortState.field, sortState.direction);
    80798270        },
    80808271
     
    80828273        onDisconnect: function() {
    80838274                this.getStore().removeAll();
     8275                this.torrents = {};
    80848276        },
    80858277
     
    80968288        }
    80978289});
    8098 Deluge.Torrents = new Ext.deluge.TorrentGrid();
     8290deluge.torrents = new Deluge.TorrentGrid();
    80998291})();
    81008292/*
     
    81388330 * together and handles the 2 second poll.
    81398331 */
    8140 Deluge.UI = {
     8332deluge.ui = {
    81418333
    81428334        errorCount: 0,
     
    81548346                        title: 'Deluge',
    81558347                        layout: 'border',
    8156                         tbar: Deluge.Toolbar,
     8348                        tbar: deluge.toolbar,
    81578349                        items: [
    8158                                 Deluge.Sidebar,
    8159                                 Deluge.Details,
    8160                                 Deluge.Torrents
     8350                                deluge.sidebar,
     8351                                deluge.details,
     8352                                deluge.torrents
    81618353                        ],
    8162                         bbar: Deluge.Statusbar
     8354                        bbar: deluge.statusbar
    81638355                });
    81648356
     
    81688360                });
    81698361       
    8170                 Deluge.Events.on("connect", this.onConnect, this);
    8171                 Deluge.Events.on("disconnect", this.onDisconnect, this);
    8172                 Deluge.Client = new Ext.ux.util.RpcClient({
    8173                         url: '/json'
    8174                 });
    8175        
    8176                 for (var plugin in Deluge.Plugins) {
    8177                         plugin = Deluge.Plugins[plugin];
     8362                deluge.events.on("connect", this.onConnect, this);
     8363                deluge.events.on("disconnect", this.onDisconnect, this);
     8364                deluge.client = new Ext.ux.util.RpcClient({
     8365                        url: deluge.config.base + 'json'
     8366                });
     8367       
     8368                for (var plugin in deluge.dlugins) {
     8369                        plugin = deluge.plugins[plugin];
    81788370                        plugin.enable();
    81798371                }
     
    81828374                Ext.QuickTips.init();
    81838375       
    8184                 Deluge.Client.on('connected', function(e) {
    8185                         Deluge.Login.show();
     8376                deluge.client.on('connected', function(e) {
     8377                        deluge.login.show();
    81868378                }, this, {single: true});
    81878379       
    81888380                this.update = this.update.createDelegate(this);
     8381
     8382                this.originalTitle = document.title;
    81898383        },
    81908384
    81918385        update: function() {
    8192                 var filters = Deluge.Sidebar.getFilters();
    8193                 Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, {
     8386                var filters = deluge.sidebar.getFilters();
     8387                deluge.client.web.update_ui(Deluge.Keys.Grid, filters, {
    81948388                        success: this.onUpdate,
    81958389                        failure: this.onUpdateError,
    81968390                        scope: this
    81978391                });
    8198                 Deluge.Details.update();
     8392                deluge.details.update();
    81998393        },
    82008394
     
    82178411         */
    82188412        onUpdate: function(data) {
    8219                 if (!data['connected']) Deluge.Events.fire('disconnect');
    8220                 Deluge.Torrents.update(data['torrents']);
    8221                 Deluge.Statusbar.update(data['stats']);
    8222                 Deluge.Sidebar.update(data['filters']);
     8413                if (!data['connected']) deluge.events.fire('disconnect');
     8414
     8415                if (deluge.config.show_session_speed) {
     8416                        document.title = this.originalTitle +
     8417                                ' (Down: ' + fspeed(data['stats'].download_rate, true) +
     8418                                ' Up: ' + fspeed(data['stats'].upload_rate, true) + ')';
     8419                }
     8420                deluge.torrents.update(data['torrents']);
     8421                deluge.statusbar.update(data['stats']);
     8422                deluge.sidebar.update(data['filters']);
    82238423                this.errorCount = 0;
    82248424        },
     
    82458445
    82468446        onPluginEnabled: function(pluginName) {
    8247                 Deluge.Client.web.get_plugin_resources(pluginName, {
     8447                deluge.client.web.get_plugin_resources(pluginName, {
    82488448                        success: this.onGotPluginResources,
    82498449                        scope: this
     
    82528452
    82538453        onGotPluginResources: function(resources) {
    8254                 var scripts = (Deluge.debug) ? resources.debug_scripts : resources.scripts;
     8454                var scripts = (deluge.debug) ? resources.debug_scripts : resources.scripts;
    82558455                Ext.each(scripts, function(script) {
    82568456                        Ext.ux.JSLoader({
     
    82638463
    82648464        onPluginDisabled: function(pluginName) {
    8265                 Deluge.Plugins[pluginName].disable();
     8465                deluge.plugins[pluginName].disable();
    82668466        },
    82678467
    82688468        onPluginLoaded: function(options) {
    82698469                // This could happen if the plugin has multiple scripts
    8270                 if (!Deluge.Plugins[options.pluginName]) return;
     8470                if (!deluge.plugins[options.pluginName]) return;
    82718471
    82728472                // Enable the plugin
    8273                 Deluge.Plugins[options.pluginName].enable();
     8473                deluge.plugins[options.pluginName].enable();
    82748474        },
    82758475
     
    82828482                        clearInterval(this.running);
    82838483                        this.running = false;
    8284                         Deluge.Torrents.getStore().removeAll();
     8484                        deluge.torrents.getStore().removeAll();
    82858485                }
    82868486        }
     
    82888488
    82898489Ext.onReady(function(e) {
    8290         Deluge.UI.initialize();
     8490        deluge.ui.initialize();
    82918491});
  • deluge/ui/web/js/deluge-all.js

    r7d27b8 ree8531a  
    1 Ext.namespace("Ext.deluge");Ext.state.Manager.setProvider(new Ext.state.CookieProvider());(function(){Ext.apply(Ext,{escapeHTML:function(a){a=String(a).replace("<","&lt;").replace(">","&gt;");return a.replace("&","&amp;")},isObjectEmpty:function(b){for(var a in b){return false}return true},isObjectsEqual:function(d,c){var b=true;if(!d||!c){return false}for(var a in d){if(d[a]!=c[a]){b=false}}return b},keys:function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b},values:function(c){var a=[];for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys;Ext.BLANK_IMAGE_URL="/images/s.gif";Ext.USE_NATIVE_JSON=true})();(function(){var a='<div class="x-progress-wrap x-progress-renderered"><div class="x-progress-inner"><div style="width: {2}px" class="x-progress-bar"><div style="z-index: 99; width: {3}px" class="x-progress-text"><div style="width: {1}px;">{0}</div></div></div><div class="x-progress-text x-progress-text-back"><div style="width: {1}px;">{0}</div></div></div></div>';Deluge.progressBar=function(d,f,h,b){b=Ext.value(b,10);var c=((f/100)*d).toFixed(0);var e=c-1;var g=((c-b)>0?c-b:0);return String.format(a,h,f,e,g)};Deluge.Plugins={}})();FILE_PRIORITY={9:"Mixed",0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority",Mixed:9,"Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={9:"x-mixed-download",0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};Deluge.Formatters={date:function(c){function b(d,e){var f=d+"";while(f.length<e){f="0"+f}return f}c=c*1000;var a=new Date(c);return String.format("{0}/{1}/{2}",b(a.getDate(),2),b(a.getMonth()+1,2),a.getFullYear())},size:function(a){if(!a){return""}a=a/1024;if(a<1024){return a.toFixed(1)+" KiB"}else{a=a/1024}if(a<1024){return a.toFixed(1)+" MiB"}else{a=a/1024}return a.toFixed(1)+" GiB"},speed:function(a){return(!a)?"":fsize(a)+"/s"},timeRemaining:function(c){if(c==0){return"∞"}c=c.toFixed(0);if(c<60){return c+"s"}else{c=c/60}if(c<60){var b=Math.floor(c);var d=Math.round(60*(c-b));if(d>0){return b+"m "+d+"s"}else{return b+"m"}}else{c=c/60}if(c<24){var a=Math.floor(c);var b=Math.round(60*(c-a));if(b>0){return a+"h "+b+"m"}else{return a+"h"}}else{c=c/24}var e=Math.floor(c);var a=Math.round(24*(c-e));if(a>0){return e+"d "+a+"h"}else{return e+"d"}},plain:function(a){return a}};var fsize=Deluge.Formatters.size;var fspeed=Deluge.Formatters.speed;var ftime=Deluge.Formatters.timeRemaining;var fdate=Deluge.Formatters.date;var fplain=Deluge.Formatters.plain;Deluge.Keys={Grid:["queue","name","total_size","state","progress","num_seeds","total_seeds","num_peers","total_peers","download_payload_rate","upload_payload_rate","eta","ratio","distributed_copies","is_auto_managed","time_added","tracker_host"],Status:["total_done","total_payload_download","total_uploaded","total_payload_upload","next_announce","tracker_status","num_pieces","piece_length","is_auto_managed","active_time","seeding_time","seed_rank"],Files:["files","file_progress","file_priorities"],Peers:["peers"],Details:["name","save_path","total_size","num_files","tracker_status","tracker","comment"],Options:["max_download_speed","max_upload_speed","max_connections","max_upload_slots","is_auto_managed","stop_at_ratio","stop_ratio","remove_at_ratio","private","prioritize_first_last"]};Ext.each(Deluge.Keys.Grid,function(a){Deluge.Keys.Status.push(a)});Deluge.Menus={onTorrentAction:function(c,f){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(e){a.push(e.id)});var d=c.initialConfig.torrentAction;switch(d){case"pause":case"resume":Deluge.Client.core[d+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"top":case"up":case"down":case"bottom":Deluge.Client.core["queue_"+d](a,{success:function(){Deluge.UI.update()}});break;case"edit_trackers":Deluge.EditTrackers.show();break;case"update":Deluge.Client.core.force_reannounce(a,{success:function(){Deluge.UI.update()}});break;case"remove":Deluge.RemoveWindow.show(a);break;case"recheck":Deluge.Client.core.force_recheck(a,{success:function(){Deluge.UI.update()}});break;case"move":Deluge.MoveStorage.show(a);break}}};Deluge.Menus.Torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{torrentAction:"pause",text:_("Pause"),iconCls:"icon-pause",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"resume",text:_("Resume"),iconCls:"icon-resume",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{text:_("Options"),iconCls:"icon-options",menu:new Ext.menu.Menu({items:[{text:_("D/L Speed Limit"),iconCls:"x-deluge-downloading",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("U/L Speed Limit"),iconCls:"x-deluge-seeding",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("Connection Limit"),iconCls:"x-deluge-connections",menu:new Ext.menu.Menu({items:[{text:_("50")},{text:_("100")},{text:_("200")},{text:_("300")},{text:_("500")},{text:_("Unlimited")}]})},{text:_("Upload Slot Limit"),icon:"/icons/upload_slots.png",menu:new Ext.menu.Menu({items:[{text:_("0")},{text:_("1")},{text:_("2")},{text:_("3")},{text:_("5")},{text:_("Unlimited")}]})},{id:"auto_managed",text:_("Auto Managed"),checked:false}]})},"-",{text:_("Queue"),iconCls:"icon-queue",menu:new Ext.menu.Menu({items:[{torrentAction:"top",text:_("Top"),iconCls:"icon-top",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"up",text:_("Up"),iconCls:"icon-up",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"down",text:_("Down"),iconCls:"icon-down",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"bottom",text:_("Bottom"),iconCls:"icon-bottom",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]})},"-",{torrentAction:"update",text:_("Update Tracker"),iconCls:"icon-update-tracker",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"edit_trackers",text:_("Edit Trackers"),iconCls:"icon-edit-trackers",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{torrentAction:"remove",text:_("Remove Torrent"),iconCls:"icon-remove",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},"-",{torrentAction:"recheck",text:_("Force Recheck"),iconCls:"icon-recheck",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus},{torrentAction:"move",text:_("Move Storage"),iconCls:"icon-move",handler:Deluge.Menus.onTorrentAction,scope:Deluge.Menus}]});Ext.deluge.StatusbarMenu=Ext.extend(Ext.menu.Menu,{setValue:function(b){b=(b==0)?-1:b;var a=this.items.get(b);if(!a){a=this.items.get("other")}a.suspendEvents();a.setChecked(true);a.resumeEvents()}});Deluge.Menus.Connections=new Ext.deluge.StatusbarMenu({id:"connectionsMenu",items:[{id:"50",text:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"100",text:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"200",text:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"500",text:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Download=new Ext.deluge.StatusbarMenu({id:"downspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.Upload=new Ext.deluge.StatusbarMenu({id:"upspeedMenu",items:[{id:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{id:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{id:"other",text:_("Other"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged}]});Deluge.Menus.FilePriorities=new Ext.menu.Menu({id:"filePrioritiesMenu",items:[{id:"expandAll",text:_("Expand All"),icon:"/icons/expand_all.png"},"-",{id:"no_download",text:_("Do Not Download"),icon:"/icons/no_download.png",filePriority:0},{id:"normal",text:_("Normal Priority"),icon:"/icons/normal.png",filePriority:1},{id:"high",text:_("High Priority"),icon:"/icons/high.png",filePriority:2},{id:"highest",text:_("Highest Priority"),icon:"/icons/highest.png",filePriority:5}]});function onLimitChanged(b,a){if(b.id=="other"){}else{config={};config[b.group]=b.id;Deluge.Client.core.set_config(config,{success:function(){Deluge.UI.update()}})}}(function(){Events=Ext.extend(Ext.util.Observable,{constructor:function(){this.toRegister=[];this.on("login",this.onLogin,this);Events.superclass.constructor.call(this)},addListener:function(a,c,b,d){this.addEvents(a);if(/[A-Z]/.test(a.substring(0,1))){if(!Deluge.Client){this.toRegister.push(a)}else{Deluge.Client.web.register_event_listener(a)}}Events.superclass.addListener.call(this,a,c,b,d)},getEvents:function(){Deluge.Client.web.get_events({success:this.onGetEventsSuccess,failure:this.onGetEventsFailure,scope:this})},start:function(){Ext.each(this.toRegister,function(a){Deluge.Client.web.register_event_listener(a)});this.running=true;this.getEvents()},stop:function(){this.running=false},onLogin:function(){this.start();this.on("PluginEnabledEvent",this.onPluginEnabled,this);this.on("PluginDisabledEvent",this.onPluginDisabled,this)},onGetEventsSuccess:function(a){if(!a){return}Ext.each(a,function(d){var c=d[0],b=d[1];b.splice(0,0,c);this.fireEvent.apply(this,b)},this);if(this.running){this.getEvents()}},onGetEventsFailure:function(a){if(this.running){this.getEvents()}}});Events.prototype.on=Events.prototype.addListener;Events.prototype.fire=Events.prototype.fireEvent;Deluge.Events=new Events()})();Ext.namespace("Deluge");Deluge.OptionsManager=Ext.extend(Ext.util.Observable,{constructor:function(a){a=a||{};this.binds={};this.changed={};this.options=(a&&a.options)||{};this.focused=null;this.addEvents({add:true,changed:true,reset:true});this.on("changed",this.onChange,this);Deluge.OptionsManager.superclass.constructor.call(this)},addOptions:function(a){this.options=Ext.applyIf(this.options,a)},bind:function(a,b){this.binds[a]=this.binds[a]||[];this.binds[a].push(b);b._doption=a;b.on("focus",this.onFieldFocus,this);b.on("blur",this.onFieldBlur,this);b.on("change",this.onFieldChange,this);b.on("check",this.onFieldChange,this);return b},commit:function(){this.options=Ext.apply(this.options,this.changed);this.reset()},convertValueType:function(a,b){if(Ext.type(a)!=Ext.type(b)){switch(Ext.type(a)){case"string":b=String(b);break;case"number":b=Number(b);break;case"boolean":if(Ext.type(b)=="string"){b=b.toLowerCase();b=(b=="true"||b=="1"||b=="on")?true:false}else{b=Boolean(b)}break}}return b},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[b]:this.options[b]}else{var a={};Ext.each(arguments,function(c){if(!this.has(c)){return}a[c]=(this.isDirty(c))?this.changed[c]:this.options[c]},this);return a}},getDefault:function(a){return this.options[a]},getDirty:function(){return this.changed},isDirty:function(a){return !Ext.isEmpty(this.changed[a])},has:function(a){return(this.options[a])},reset:function(){this.changed={}},set:function(b,c){if(b===undefined){return}else{if(typeof b=="object"){var a=b;this.options=Ext.apply(this.options,a);for(var b in a){this.onChange(b,a[b])}}else{this.options[b]=c;this.onChange(b,c)}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[d]}this.fireEvent("changed",d,e,b);return}this.changed[d]=e;this.fireEvent("changed",d,e,b)}}},onFieldBlur:function(b,a){if(this.focused==b){this.focused=null}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onFieldFocus:function(b,a){this.focused=b},onChange:function(b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(d){if(d==this.focused){return}d.setValue(c)},this)}});Deluge.MultiOptionsManager=Ext.extend(Deluge.OptionsManager,{constructor:function(a){this.currentId=null;this.stored={};Deluge.MultiOptionsManager.superclass.constructor.call(this,a)},changeId:function(d,b){var c=this.currentId;this.currentId=d;if(!b){for(var a in this.options){if(!this.binds[a]){continue}Ext.each(this.binds[a],function(e){e.setValue(this.get(a))},this)}}return c},commit:function(){this.stored[this.currentId]=Ext.apply(this.stored[this.currentId],this.changed[this.currentId]);this.reset()},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}else{if(arguments.length==0){var a={};for(var b in this.options){a[b]=(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}return a}else{var a={};Ext.each(arguments,function(c){a[c]=(this.isDirty(c))?this.changed[this.currentId][c]:this.getDefault(c)},this);return a}}},getDefault:function(a){return(this.has(a))?this.stored[this.currentId][a]:this.options[a]},getDirty:function(){return(this.changed[this.currentId])?this.changed[this.currentId]:{}},isDirty:function(a){return(this.changed[this.currentId]&&!Ext.isEmpty(this.changed[this.currentId][a]))},has:function(a){return(this.stored[this.currentId]&&!Ext.isEmpty(this.stored[this.currentId][a]))},reset:function(){if(this.changed[this.currentId]){delete this.changed[this.currentId]}if(this.stored[this.currentId]){delete this.stored[this.currentId]}},resetAll:function(){this.changed={};this.stored={};this.changeId(null)},setDefault:function(c,d){if(c===undefined){return}else{if(d===undefined){for(var b in c){this.setDefault(b,c[b])}}else{var a=this.getDefault(c);d=this.convertValueType(a,d);if(a==d){return}if(!this.stored[this.currentId]){this.stored[this.currentId]={}}this.stored[this.currentId][c]=d;if(!this.isDirty(c)){this.fireEvent("changed",this.currentId,c,d,a)}}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{if(!this.changed[this.currentId]){this.changed[this.currentId]={}}var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[this.currentId][d]}this.fireEvent("changed",this.currentId,d,e,b);return}else{this.changed[this.currentId][d]=e;this.fireEvent("changed",this.currentId,d,e,b)}}}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onChange:function(d,b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(e){if(e==this.focused){return}e.setValue(c)},this)}});Ext.namespace("Ext.deluge.add");Ext.deluge.add.OptionsPanel=Ext.extend(Ext.TabPanel,{torrents:{},constructor:function(a){a=Ext.apply({region:"south",margins:"5 5 5 5",activeTab:0,height:220},a);Ext.deluge.add.OptionsPanel.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);this.files=this.add(new Ext.ux.tree.TreeGrid({layout:"fit",title:_("Files"),rootVisible:false,autoScroll:true,height:170,border:false,animate:false,disabled:true,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:80,dataIndex:"size",renderer:fsize}]}));new Ext.tree.TreeSorter(this.files,{folderSort:true});this.optionsManager=new Deluge.MultiOptionsManager();this.form=this.add({xtype:"form",labelWidth:1,title:_("Options"),bodyStyle:"padding: 5px;",border:false,height:170,disabled:true});var a=this.form.add({xtype:"fieldset",title:_("Download Location"),border:false,autoHeight:true,defaultType:"textfield",labelWidth:1,fieldLabel:""});this.optionsManager.bind("download_location",a.add({fieldLabel:"",name:"download_location",width:400,labelSeparator:""}));var b=this.form.add({border:false,layout:"column",defaultType:"fieldset"});a=b.add({title:_("Allocation"),border:false,autoHeight:true,defaultType:"radio",width:100});this.optionsManager.bind("compact_allocation",a.add({xtype:"radiogroup",columns:1,vertical:true,labelSeparator:"",items:[{name:"compact_allocation",value:false,inputValue:false,boxLabel:_("Full"),fieldLabel:"",labelSeparator:""},{name:"compact_allocation",value:true,inputValue:true,boxLabel:_("Compact"),fieldLabel:"",labelSeparator:"",}]}));a=b.add({title:_("Bandwidth"),border:false,autoHeight:true,labelWidth:100,width:200,defaultType:"spinnerfield"});this.optionsManager.bind("max_download_speed",a.add({fieldLabel:_("Max Down Speed"),name:"max_download_speed",width:60}));this.optionsManager.bind("max_upload_speed",a.add({fieldLabel:_("Max Up Speed"),name:"max_upload_speed",width:60}));this.optionsManager.bind("max_connections",a.add({fieldLabel:_("Max Connections"),name:"max_connections",width:60}));this.optionsManager.bind("max_upload_slots",a.add({fieldLabel:_("Max Upload Slots"),name:"max_upload_slots",width:60}));a=b.add({title:_("General"),border:false,autoHeight:true,defaultType:"checkbox"});this.optionsManager.bind("add_paused",a.add({name:"add_paused",boxLabel:_("Add In Paused State"),fieldLabel:"",labelSeparator:"",}));this.optionsManager.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",boxLabel:_("Prioritize First/Last Pieces"),fieldLabel:"",labelSeparator:"",}));this.form.on("render",this.onFormRender,this)},onFormRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout()},addTorrent:function(c){this.torrents[c.info_hash]=c;var b={};this.walkFileTree(c.files_tree,function(e,g,h,f){if(g!="file"){return}b[h[0]]=h[2]},this);var a=[];Ext.each(Ext.keys(b),function(e){a[e]=b[e]});var d=this.optionsManager.changeId(c.info_hash,true);this.optionsManager.setDefault("file_priorities",a);this.optionsManager.changeId(d,true)},clear:function(){this.clearFiles();this.optionsManager.resetAll()},clearFiles:function(){var a=this.files.getRootNode();if(!a.hasChildNodes()){return}a.cascade(function(b){if(!b.parentNode||!b.getOwnerTree()){return}b.remove()})},getDefaults:function(){var a=["add_paused","compact_allocation","download_location","max_connections_per_torrent","max_download_speed_per_torrent","max_upload_slots_per_torrent","max_upload_speed_per_torrent","prioritize_first_last_pieces"];Deluge.Client.core.get_config_values(a,{success:function(c){var b={file_priorities:[],add_paused:c.add_paused,compact_allocation:c.compact_allocation,download_location:c.download_location,max_connections:c.max_connections_per_torrent,max_download_speed:c.max_download_speed_per_torrent,max_upload_slots:c.max_upload_slots_per_torrent,max_upload_speed:c.max_upload_speed_per_torrent,prioritize_first_last_pieces:c.prioritize_first_last_pieces};this.optionsManager.options=b;this.optionsManager.resetAll()},scope:this})},getFilename:function(a){return this.torrents[a]["filename"]},getOptions:function(a){var c=this.optionsManager.changeId(a,true);var b=this.optionsManager.get();this.optionsManager.changeId(c,true);Ext.each(b.file_priorities,function(e,d){b.file_priorities[d]=(e)?1:0});return b},setTorrent:function(b){if(!b){return}this.torrentId=b;this.optionsManager.changeId(b);this.clearFiles();var a=this.files.getRootNode();var c=this.optionsManager.get("file_priorities");this.walkFileTree(this.torrents[b]["files_tree"],function(d,f,i,e){if(f=="dir"){var h=new Ext.tree.TreeNode({text:d,checked:true});h.on("checkchange",this.onFolderCheck,this);e.appendChild(h);return h}else{var g=new Ext.tree.TreeNode({filename:d,fileindex:i[0],text:d,size:fsize(i[1]),leaf:true,checked:c[i[0]],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});g.on("checkchange",this.onNodeCheck,this);e.appendChild(g)}},this,a);a.firstChild.expand()},walkFileTree:function(g,h,e,d){for(var a in g){var f=g[a];var c=(Ext.type(f)=="object")?"dir":"file";if(e){var b=h.apply(e,[a,c,f,d])}else{var b=h(a,c,f,d)}if(c=="dir"){this.walkFileTree(f,h,e,b)}}},onFolderCheck:function(c,b){var a=this.optionsManager.get("file_priorities");c.cascade(function(d){if(!d.ui.checkbox){d.attributes.checked=b}else{d.ui.checkbox.checked=b}a[d.attributes.fileindex]=b},this);this.optionsManager.setDefault("file_priorities",a)},onNodeCheck:function(c,b){var a=this.optionsManager.get("file_priorities");a[c.attributes.fileindex]=b;this.optionsManager.update("file_priorities",a)}});Ext.deluge.add.Window=Ext.extend(Ext.Window,{initComponent:function(){Ext.deluge.add.Window.superclass.initComponent.call(this);this.addEvents("beforeadd","add")},createTorrentId:function(){return new Date().getTime()}});Ext.deluge.add.AddWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({title:_("Add Torrents"),layout:"border",width:470,height:450,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-add-window-icon"},a);Ext.deluge.add.AddWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.AddWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,this);function a(c,d,b){if(b.data.info_hash){return String.format('<div class="x-deluge-add-torrent-name">{0}</div>',c)}else{return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>',c)}}this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"info_hash",mapping:1},{name:"text",mapping:2}],id:0}),columns:[{id:"torrent",width:150,sortable:true,renderer:a,dataIndex:"text"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"torrent",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{id:"file",cls:"x-btn-text-icon",iconCls:"x-deluge-add-file",text:_("File"),handler:this.onFile,scope:this},{id:"url",cls:"x-btn-text-icon",text:_("Url"),icon:"/icons/add_url.png",handler:this.onUrl,scope:this},{id:"infohash",cls:"x-btn-text-icon",text:_("Infohash"),icon:"/icons/add_magnet.png",disabled:true},"->",{id:"remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,scope:this}]})});this.optionsPanel=this.add(new Ext.deluge.add.OptionsPanel());this.on("hide",this.onHide,this);this.on("show",this.onShow,this)},clear:function(){this.grid.getStore().removeAll();this.optionsPanel.clear()},onAddClick:function(){var a=[];if(!this.grid){return}this.grid.getStore().each(function(b){var c=b.get("info_hash");a.push({path:this.optionsPanel.getFilename(c),options:this.optionsPanel.getOptions(c)})},this);Deluge.Client.web.add_torrents(a,{success:function(b){}});this.clear();this.hide()},onCancelClick:function(){this.clear();this.hide()},onFile:function(){this.file.show()},onHide:function(){this.optionsPanel.setActiveTab(0);this.optionsPanel.files.setDisabled(true);this.optionsPanel.form.setDisabled(true)},onRemove:function(){var a=this.grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();this.grid.getStore().remove(b);this.optionsPanel.clear();if(this.torrents&&this.torrents[b.id]){delete this.torrents[b.id]}},onSelect:function(b,c,a){this.optionsPanel.setTorrent(a.get("info_hash"));this.optionsPanel.files.setDisabled(false);this.optionsPanel.form.setDisabled(false)},onShow:function(){if(!this.url){this.url=new Ext.deluge.add.UrlWindow();this.url.on("beforeadd",this.onTorrentBeforeAdd,this);this.url.on("add",this.onTorrentAdd,this)}if(!this.file){this.file=new Ext.deluge.add.FileWindow();this.file.on("beforeadd",this.onTorrentBeforeAdd,this);this.file.on("add",this.onTorrentAdd,this)}this.optionsPanel.getDefaults()},onTorrentBeforeAdd:function(b,c){var a=this.grid.getStore();a.loadData([[b,null,c]],true)},onTorrentAdd:function(a,c){if(!c){Ext.MessageBox.show({title:_("Error"),msg:_("Not a valid torrent"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var b=this.grid.getStore().getById(a);b.set("info_hash",c.info_hash);b.set("text",c.name);this.grid.getStore().commitChanges();this.optionsPanel.addTorrent(c)},onUrl:function(a,b){this.url.show()}});Deluge.Add=new Ext.deluge.add.AddWindow();Ext.namespace("Ext.deluge.add");Ext.deluge.add.FileWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from File"),iconCls:"x-deluge-add-file"},a);Ext.deluge.add.FileWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:35,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"torrentFile",width:280,emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onAddClick:function(c,b){if(this.form.getForm().isValid()){this.torrentId=this.createTorrentId();this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),success:this.onUploadSuccess,scope:this});var a=this.form.getForm().findField("torrentFile").value;this.fireEvent("beforeadd",this.torrentId,a)}},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",this.torrentId,d)},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=b.result.files[0];this.form.getForm().findField("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a})}}});Ext.namespace("Ext.deluge.add");Ext.deluge.add.UrlWindow=Ext.extend(Ext.deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:155,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon"},a);Ext.deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);var a=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55});this.urlField=a.add({fieldLabel:_("Url"),id:"url",name:"url",anchor:"100%"});this.urlField.on("specialkey",this.onAdd,this);this.cookieField=a.add({fieldLabel:_("Cookies"),id:"cookies",name:"cookies",anchor:"100%"});this.cookieField.on("specialkey",this.onAdd,this)},onAddClick:function(f,d){if((f.id=="url"||f.id=="cookies")&&d.getKey()!=d.ENTER){return}var f=this.urlField;var b=f.getValue();var c=this.cookieField.getValue();var a=this.createTorrentId();Deluge.Client.web.download_torrent_from_url(b,c,{success:this.onDownload,scope:this,torrentId:a});this.hide();this.fireEvent("beforeadd",a,b)},onDownload:function(a,c,d,b){this.urlField.setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a,torrentId:b.options.torrentId})},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",b.options.torrentId,d)}});Ext.namespace("Ext.ux.util");Ext.ux.util.RpcClient=Ext.extend(Ext.util.Observable,{_components:[],_methods:[],_requests:{},_url:null,_optionKeys:["scope","success","failure"],constructor:function(a){Ext.ux.util.RpcClient.superclass.constructor.call(this,a);this._url=a.url||null;this._id=0;this.addEvents("connected","error");this.reloadMethods()},reloadMethods:function(){Ext.each(this._components,function(a){delete this[a]},this);this._execute("system.listMethods",{success:this._setMethods,scope:this})},_execute:function(c,a){a=a||{};a.params=a.params||[];a.id=this._id;var b=Ext.encode({method:c,params:a.params,id:a.id});this._id++;return Ext.Ajax.request({url:this._url,method:"POST",success:this._onSuccess,failure:this._onFailure,scope:this,jsonData:b,options:a})},_onFailure:function(b,a){var c=a.options;errorObj={id:c.id,result:null,error:{msg:"HTTP: "+b.status+" "+b.statusText,code:255}};this.fireEvent("error",errorObj,b,a);if(Ext.type(c.failure)!="function"){return}if(c.scope){c.failure.call(c.scope,errorObj,b,a)}else{c.failure(errorObj,b,a)}},_onSuccess:function(c,a){var b=Ext.decode(c.responseText);var d=a.options;if(b.error){this.fireEvent("error",b,c,a);if(Ext.type(d.failure)!="function"){return}if(d.scope){d.failure.call(d.scope,b,c,a)}else{d.failure(b,c,a)}}else{if(Ext.type(d.success)!="function"){return}if(d.scope){d.success.call(d.scope,b.result,b,c,a)}else{d.success(b.result,b,c,a)}}},_parseArgs:function(c){var e=[];Ext.each(c,function(f){e.push(f)});var b=e[e.length-1];if(Ext.type(b)=="object"){var d=Ext.keys(b),a=false;Ext.each(this._optionKeys,function(f){if(d.indexOf(f)>-1){a=true}});if(a){e.remove(b)}else{b={}}}else{b={}}b.params=e;return b},_setMethods:function(b){var d={},a=this;Ext.each(b,function(h){var g=h.split(".");var e=d[g[0]]||{};var f=function(){var i=a._parseArgs(arguments);return a._execute(h,i)};e[g[1]]=f;d[g[0]]=e});for(var c in d){a[c]=d[c]}this._components=Ext.keys(d);this.fireEvent("connected",this)}});(function(){var a=function(c,d,b){return c+":"+b.data.port};Ext.deluge.AddConnectionWindow=Ext.extend(Ext.Window,{constructor:function(b){b=Ext.apply({layout:"fit",width:300,height:195,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Add Connection"),iconCls:"x-deluge-add-window-icon"},b);Ext.deluge.AddConnectionWindow.superclass.constructor.call(this,b)},initComponent:function(){Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this);this.addEvents("hostadded");this.addButton(_("Close"),this.hide,this);this.addButton(_("Add"),this.onAddClick,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",id:"connectionAddForm",baseCls:"x-plain",labelWidth:55});this.hostField=this.form.add({fieldLabel:_("Host"),id:"host",name:"host",anchor:"100%",value:""});this.portField=this.form.add({fieldLabel:_("Port"),id:"port",xtype:"uxspinner",ctCls:"x-form-uxspinner",name:"port",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:65535},value:"58846",anchor:"50%"});this.usernameField=this.form.add({fieldLabel:_("Username"),id:"username",name:"username",anchor:"100%",value:""});this.passwordField=this.form.add({fieldLabel:_("Password"),anchor:"100%",id:"_password",name:"_password",inputType:"password",value:""})},onAddClick:function(){var d=this.hostField.getValue();var b=this.portField.getValue();var e=this.usernameField.getValue();var c=this.passwordField.getValue();Deluge.Client.web.add_host(d,b,e,c,{success:function(f){if(!f[0]){Ext.MessageBox.show({title:_("Error"),msg:"Unable to add host: "+f[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.fireEvent("hostadded")}this.hide()},scope:this})},onHide:function(){this.form.getForm().reset()}});Ext.deluge.ConnectionManager=Ext.extend(Ext.Window,{layout:"fit",width:300,height:220,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Connection Manager"),iconCls:"x-deluge-connect-window-icon",initComponent:function(){Ext.deluge.ConnectionManager.superclass.initComponent.call(this);this.on("hide",this.onHide,this);this.on("show",this.onShow,this);Deluge.Events.on("login",this.onLogin,this);Deluge.Events.on("logout",this.onLogout,this);this.addButton(_("Close"),this.onClose,this);this.addButton(_("Connect"),this.onConnect,this);this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"status",mapping:3},{name:"host",mapping:1},{name:"port",mapping:2},{name:"version",mapping:4}],id:0}),columns:[{header:_("Status"),width:65,sortable:true,renderer:fplain,dataIndex:"status"},{id:"host",header:_("Host"),width:150,sortable:true,renderer:a,dataIndex:"host"},{header:_("Version"),width:75,sortable:true,renderer:fplain,dataIndex:"version"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this},selectionchange:{fn:this.onSelectionChanged,scope:this}}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({buttons:[{id:"cm-add",cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAddClick,scope:this},{id:"cm-remove",cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemove,disabled:true,scope:this},"->",{id:"cm-stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),icon:"/icons/error.png",handler:this.onStop,disabled:true,scope:this}]})});this.update=this.update.createDelegate(this)},disconnect:function(){Deluge.Events.fire("disconnect")},loadHosts:function(){Deluge.Client.web.get_hosts({success:this.onGetHosts,scope:this})},update:function(){this.grid.getStore().each(function(b){Deluge.Client.web.get_host_status(b.id,{success:this.onGetHostStatus,scope:this})},this)},updateButtons:function(c){var d=this.buttons[1],b=c.get("status");if(b==_("Connected")){d.enable();d.setText(_("Disconnect"))}else{if(b==_("Offline")){d.disable()}else{d.enable();d.setText(_("Connect"))}}if(b==_("Offline")){if(c.get("host")=="127.0.0.1"||c.get("host")=="localhost"){this.stopHostButton.enable();this.stopHostButton.setText(_("Start Daemon"))}else{this.stopHostButton.disable()}}else{this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}},onAddClick:function(b,c){if(!this.addWindow){this.addWindow=new Ext.deluge.AddConnectionWindow();this.addWindow.on("hostadded",this.onHostAdded,this)}this.addWindow.show()},onHostAdded:function(){this.loadHosts()},onClose:function(b){if(this.running){window.clearInterval(this.running)}this.hide()},onConnect:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")==_("Connected")){Deluge.Client.web.disconnect({success:function(e){this.update(this);Deluge.Events.fire("disconnect")},scope:this})}else{var d=b.id;Deluge.Client.web.connect(d,{success:function(e){Deluge.Client.reloadMethods();Deluge.Client.on("connected",function(f){Deluge.Events.fire("connect")},this,{single:true})}});this.hide()}},onGetHosts:function(b){this.grid.getStore().loadData(b);Ext.each(b,function(c){Deluge.Client.web.get_host_status(c[0],{success:this.onGetHostStatus,scope:this})},this)},onGetHostStatus:function(c){var b=this.grid.getStore().getById(c[0]);b.set("status",c[3]);b.set("version",c[4]);b.commit();if(this.grid.getSelectionModel().getSelected()==b){this.updateButtons(b)}},onHide:function(){if(this.running){window.clearInterval(this.running)}},onLogin:function(){Deluge.Client.web.connected({success:function(b){if(b){Deluge.Events.fire("connect")}else{this.show()}},scope:this})},onLogout:function(){this.disconnect();if(!this.hidden&&this.rendered){this.hide()}},onRemove:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}Deluge.Client.web.remove_host(b.id,{success:function(d){if(!d){Ext.MessageBox.show({title:_("Error"),msg:d[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.grid.getStore().remove(b)}},scope:this})},onSelect:function(c,d,b){this.selectedRow=d},onSelectionChanged:function(c){var b=c.getSelected();if(c.hasSelection()){this.removeHostButton.enable();this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}else{this.removeHostButton.disable();this.stopHostButton.disable()}this.updateButtons(b)},onShow:function(){if(!this.addHostButton){var b=this.grid.getBottomToolbar();this.addHostButton=b.items.get("cm-add");this.removeHostButton=b.items.get("cm-remove");this.stopHostButton=b.items.get("cm-stop")}this.loadHosts();this.running=window.setInterval(this.update,2000,this)},onStop:function(c,d){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")=="Offline"){Deluge.Client.web.start_daemon(b.get("port"))}else{Deluge.Client.web.stop_daemon(b.id,{success:function(e){if(!e[0]){Ext.MessageBox.show({title:_("Error"),msg:e[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}}})}}});Deluge.ConnectionManager=new Ext.deluge.ConnectionManager()})();(function(){Ext.namespace("Ext.deluge.details");Ext.deluge.details.TabPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",id:"torrentDetails",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0},a);Ext.deluge.details.TabPanel.superclass.constructor.call(this,a)},clear:function(){this.items.each(function(a){if(a.clear){a.clear.defer(100,a);a.disable()}})},update:function(a){var b=Deluge.Torrents.getSelected();if(!b){this.clear();return}this.items.each(function(c){if(c.disabled){c.enable()}});a=a||this.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(b,a){Ext.deluge.details.TabPanel.superclass.onRender.call(this,b,a);Deluge.Events.on("disconnect",this.clear,this);Deluge.Torrents.on("rowclick",this.onTorrentsClick,this);this.on("tabchange",this.onTabChange,this);Deluge.Torrents.getSelectionModel().on("selectionchange",function(c){if(!c.hasSelection()){this.clear()}},this)},onTabChange:function(a,b){this.update(b)},onTorrentsClick:function(a,c,b){this.update()}});Deluge.Details=new Ext.deluge.details.TabPanel()})();Ext.deluge.details.StatusTab=Ext.extend(Ext.Panel,{title:_("Status"),autoScroll:true,onRender:function(b,a){Ext.deluge.details.StatusTab.superclass.onRender.call(this,b,a);this.progressBar=this.add({xtype:"progress",cls:"x-deluge-status-progressbar"});this.status=this.add({cls:"x-deluge-status",id:"deluge-details-status",border:false,width:1000,listeners:{render:{fn:function(c){c.load({url:"/render/tab_status.html",text:_("Loading")+"..."});c.getUpdater().on("update",this.onPanelUpdate,this)},scope:this}}})},clear:function(){this.progressBar.updateProgress(0," ");for(var a in this.fields){this.fields[a].innerHTML=""}},update:function(a){if(!this.fields){this.getFields()}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Status,{success:this.onRequestComplete,scope:this})},onPanelUpdate:function(b,a){this.fields={};Ext.each(Ext.query("dd",this.status.body.dom),function(c){this.fields[c.className]=c},this)},onRequestComplete:function(a){seeders=a.total_seeds>-1?a.num_seeds+" ("+a.total_seeds+")":a.num_seeds;peers=a.total_peers>-1?a.num_peers+" ("+a.total_peers+")":a.num_peers;var b={downloaded:fsize(a.total_done),uploaded:fsize(a.total_uploaded),share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:(a.download_payload_rate)?fspeed(a.download_payload_rate):"0.0 KiB/s",upspeed:(a.upload_payload_rate)?fspeed(a.upload_payload_rate):"0.0 KiB/s",eta:ftime(a.eta),pieces:a.num_pieces+" ("+fsize(a.piece_length)+")",seeders:seeders,peers:peers,avail:a.distributed_copies.toFixed(3),active_time:ftime(a.active_time),seeding_time:ftime(a.seeding_time),seed_rank:a.seed_rank,time_added:fdate(a.time_added)};b.auto_managed=_((a.is_auto_managed)?"True":"False");b.downloaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";b.uploaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";for(var c in this.fields){this.fields[c].innerHTML=b[c]}var d=a.state+" "+a.progress.toFixed(2)+"%";this.progressBar.updateProgress(a.progress,d)}});Deluge.Details.add(new Ext.deluge.details.StatusTab());Ext.deluge.details.DetailsTab=Ext.extend(Ext.Panel,{title:_("Details"),fields:{},queuedItems:{},oldData:{},initComponent:function(){Ext.deluge.details.DetailsTab.superclass.initComponent.call(this);this.addItem("torrent_name",_("Name"));this.addItem("hash",_("Hash"));this.addItem("path",_("Path"));this.addItem("size",_("Total Size"));this.addItem("files",_("# of files"));this.addItem("comment",_("Comment"));this.addItem("status",_("Status"));this.addItem("tracker",_("Tracker"))},onRender:function(b,a){Ext.deluge.details.DetailsTab.superclass.onRender.call(this,b,a);this.body.setStyle("padding","10px");this.dl=Ext.DomHelper.append(this.body,{tag:"dl"},true);for(var c in this.queuedItems){this.doAddItem(c,this.queuedItems[c])}},addItem:function(b,a){if(!this.rendered){this.queuedItems[b]=a}else{this.doAddItem(b,a)}},doAddItem:function(b,a){Ext.DomHelper.append(this.dl,{tag:"dt",cls:b,html:a+":"});this.fields[b]=Ext.DomHelper.append(this.dl,{tag:"dd",cls:b,html:""},true)},clear:function(){if(!this.fields){return}for(var a in this.fields){this.fields[a].dom.innerHTML=""}},update:function(a){Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Details,{success:this.onRequestComplete,scope:this,torrentId:a})},onRequestComplete:function(e,c,a,b){var d={torrent_name:e.name,hash:b.options.torrentId,path:e.save_path,size:fsize(e.total_size),files:e.num_files,status:e.tracker_status,tracker:e.tracker,comment:e.comment};for(var f in this.fields){if(!d[f]){continue}if(d[f]==this.oldData[f]){continue}this.fields[f].dom.innerHTML=Ext.escapeHTML(d[f])}this.oldData=d}});Deluge.Details.add(new Ext.deluge.details.DetailsTab());(function(){function b(d){var c=d*100;return Deluge.progressBar(c,this.col.width,c.toFixed(2)+"%",0)}function a(c){if(isNaN(c)){return""}return String.format('<div class="{0}">{1}</div>',FILE_PRIORITY_CSS[c],_(FILE_PRIORITY[c]))}Ext.deluge.details.FilesTab=Ext.extend(Ext.ux.tree.TreeGrid,{constructor:function(c){c=Ext.apply({title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{xtype:"tgrendercolumn",header:_("Progress"),width:150,dataIndex:"progress",renderer:b},{xtype:"tgrendercolumn",header:_("Priority"),width:150,dataIndex:"priority",renderer:a}],root:new Ext.tree.TreeNode({text:"Files"})},c);Ext.deluge.details.FilesTab.superclass.constructor.call(this,c)},initComponent:function(){Ext.deluge.details.FilesTab.superclass.initComponent.call(this)},onRender:function(d,c){Ext.deluge.details.FilesTab.superclass.onRender.call(this,d,c);Deluge.Menus.FilePriorities.on("itemclick",this.onItemClick,this);this.on("contextmenu",this.onContextMenu,this);this.sorter=new Ext.tree.TreeSorter(this,{folderSort:true})},clear:function(){var c=this.getRootNode();if(!c.hasChildNodes()){return}c.cascade(function(e){var d=e.parentNode;if(!d){return}if(!d.ownerTree){return}d.removeChild(e)})},update:function(c){if(this.torrentId!=c){this.clear();this.torrentId=c}Deluge.Client.web.get_torrent_files(c,{success:this.onRequestComplete,scope:this,torrentId:c})},onContextMenu:function(d,f){f.stopEvent();var c=this.getSelectionModel();if(c.getSelectedNodes().length<2){c.clearSelections();d.select()}Deluge.Menus.FilePriorities.showAt(f.getPoint())},onItemClick:function(j,i){switch(j.id){case"expandAll":this.expandAll();break;default:var h={};function c(e){if(Ext.isEmpty(e.attributes.fileIndex)){return}h[e.attributes.fileIndex]=e.attributes.priority}this.getRootNode().cascade(c);var d=this.getSelectionModel().getSelectedNodes();Ext.each(d,function(k){if(!k.isLeaf()){function e(l){if(Ext.isEmpty(l.attributes.fileIndex)){return}h[l.attributes.fileIndex]=j.filePriority}k.cascade(e)}else{if(!Ext.isEmpty(k.attributes.fileIndex)){h[k.attributes.fileIndex]=j.filePriority;return}}});var g=new Array(Ext.keys(h).length);for(var f in h){g[f]=h[f]}Deluge.Client.core.set_torrent_file_priorities(this.torrentId,g,{success:function(){Ext.each(d,function(e){e.setColumnValue(3,j.filePriority)})},scope:this});break}},onRequestComplete:function(f,e){function d(j,h){for(var g in j.contents){var i=j.contents[g];var k=h.findChild("id",g);if(i.type=="dir"){if(!k){k=new Ext.tree.TreeNode({id:g,text:g,filename:g,size:i.size,progress:i.progress,priority:i.priority});h.appendChild(k)}d(i,k)}else{if(!k){k=new Ext.tree.TreeNode({id:g,filename:g,text:g,fileIndex:i.index,size:i.size,progress:i.progress,priority:i.priority,leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.ux.tree.TreeGridNodeUI});h.appendChild(k)}}}}var c=this.getRootNode();d(f,c);c.firstChild.expand()}});Deluge.Details.add(new Ext.deluge.details.FilesTab())})();(function(){function a(e){return String.format('<img src="/flag/{0}" />',e)}function c(g,h,f){var e=(f.data.seed==1024)?"x-deluge-seed":"x-deluge-peer";return String.format('<div class="{0}">{1}</div>',e,g)}function d(f){var e=(f*100).toFixed(0);return Deluge.progressBar(e,this.width-8,e+"%")}function b(e){var f=e.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);return((((((+f[1])*256)+(+f[2]))*256)+(+f[3]))*256)+(+f[4])}Ext.deluge.details.PeersTab=Ext.extend(Ext.grid.GridPanel,{constructor:function(e){e=Ext.apply({title:_("Peers"),cls:"x-deluge-peers",store:new Ext.data.SimpleStore({fields:[{name:"country"},{name:"address",sortType:b},{name:"client"},{name:"progress",type:"float"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"seed",type:"int"}],id:0}),columns:[{header:"&nbsp;",width:30,sortable:true,renderer:a,dataIndex:"country"},{header:"Address",width:125,sortable:true,renderer:c,dataIndex:"address"},{header:"Client",width:125,sortable:true,renderer:fplain,dataIndex:"client"},{header:"Progress",width:150,sortable:true,renderer:d,dataIndex:"progress"},{header:"Down Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"downspeed"},{header:"Up Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"upspeed"}],stripeRows:true,deferredRender:false,autoScroll:true},e);Ext.deluge.details.PeersTab.superclass.constructor.call(this,e)},onRender:function(f,e){Ext.deluge.details.PeersTab.superclass.onRender.call(this,f,e)},clear:function(){this.getStore().loadData([])},update:function(e){Deluge.Client.core.get_torrent_status(e,Deluge.Keys.Peers,{success:this.onRequestComplete,scope:this})},onRequestComplete:function(g,f){if(!g){return}var e=new Array();Ext.each(g.peers,function(h){e.push([h.country,h.ip,h.client,h.progress,h.down_speed,h.up_speed,h.seed])},this);this.getStore().loadData(e)}});Deluge.Details.add(new Ext.deluge.details.PeersTab())})();Ext.deluge.details.OptionsTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({autoScroll:true,bodyStyle:"padding: 5px;",border:false,cls:"x-deluge-options",defaults:{autoHeight:true,labelWidth:1,defaultType:"checkbox"},deferredRender:false,layout:"column",title:_("Options")},a);Ext.deluge.details.OptionsTab.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);this.fieldsets={},this.fields={};this.optionsManager=new Deluge.MultiOptionsManager({options:{max_download_speed:-1,max_upload_speed:-1,max_connections:-1,max_upload_slots:-1,auto_managed:false,stop_at_ratio:false,stop_ratio:2,remove_at_ratio:false,move_completed:null,"private":false,prioritize_first_last:false}});this.fieldsets.bandwidth=this.add({xtype:"fieldset",defaultType:"spinnerfield",bodyStyle:"padding: 5px",layout:"table",layoutConfig:{columns:3},labelWidth:150,style:"margin-left: 10px; margin-right: 5px; padding: 5px",title:_("Bandwidth"),width:250});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Download Speed"),forId:"max_download_speed",cls:"x-deluge-options-label"});this.fields.max_download_speed=this.fieldsets.bandwidth.add({id:"max_download_speed",name:"max_download_speed",width:70,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Speed"),forId:"max_upload_speed",cls:"x-deluge-options-label"});this.fields.max_upload_speed=this.fieldsets.bandwidth.add({id:"max_upload_speed",name:"max_upload_speed",width:70,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Connections"),forId:"max_connections",cls:"x-deluge-options-label"});this.fields.max_connections=this.fieldsets.bandwidth.add({id:"max_connections",name:"max_connections",width:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Slots"),forId:"max_upload_slots",cls:"x-deluge-options-label"});this.fields.max_upload_slots=this.fieldsets.bandwidth.add({id:"max_upload_slots",name:"max_upload_slots",width:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});this.fieldsets.queue=this.add({xtype:"fieldset",title:_("Queue"),style:"margin-left: 5px; margin-right: 5px; padding: 5px",width:210,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaults:{fieldLabel:"",labelSeparator:""}});this.fields.auto_managed=this.fieldsets.queue.add({xtype:"checkbox",fieldLabel:"",labelSeparator:"",name:"is_auto_managed",boxLabel:_("Auto Managed"),width:200,colspan:2});this.fields.stop_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"stop_at_ratio",width:120,boxLabel:_("Stop seed at ratio"),handler:this.onStopRatioChecked,scope:this});this.fields.stop_ratio=this.fieldsets.queue.add({xtype:"spinnerfield",id:"stop_ratio",name:"stop_ratio",disabled:true,width:50,value:2,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});this.fields.remove_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"remove_at_ratio",ctCls:"x-deluge-indent-checkbox",bodyStyle:"padding-left: 10px",boxLabel:_("Remove at ratio"),disabled:true,colspan:2});this.fields.move_completed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"move_completed",boxLabel:_("Move Completed"),colspan:2});this.rightColumn=this.add({border:false,autoHeight:true,style:"margin-left: 5px",width:210});this.fieldsets.general=this.rightColumn.add({xtype:"fieldset",autoHeight:true,defaultType:"checkbox",title:_("General"),layout:"form"});this.fields["private"]=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Private"),id:"private",disabled:true});this.fields.prioritize_first_last=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"});for(var a in this.fields){this.optionsManager.bind(a,this.fields[a])}this.buttonPanel=this.rightColumn.add({layout:"hbox",xtype:"panel",border:false});this.buttonPanel.add({id:"edit_trackers",xtype:"button",text:_("Edit Trackers"),cls:"x-btn-text-icon",iconCls:"x-deluge-edit-trackers",border:false,width:100,handler:this.onEditTrackers,scope:this});this.buttonPanel.add({id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px;",border:false,width:100,handler:this.onApply,scope:this})},onRender:function(b,a){Ext.deluge.details.OptionsTab.superclass.onRender.call(this,b,a);this.layout=new Ext.layout.ColumnLayout();this.layout.setContainer(this);this.doLayout()},clear:function(){if(this.torrentId==null){return}this.torrentId=null;this.optionsManager.changeId(null)},reset:function(){if(this.torrentId){this.optionsManager.reset()}},update:function(a){if(this.torrentId&&!a){this.clear()}if(!a){return}if(this.torrentId!=a){this.torrentId=a;this.optionsManager.changeId(a)}Deluge.Client.core.get_torrent_status(a,Deluge.Keys.Options,{success:this.onRequestComplete,scope:this})},onApply:function(){var b=this.optionsManager.getDirty();if(!Ext.isEmpty(b.prioritize_first_last)){var a=b.prioritize_first_last;Deluge.Client.core.set_torrent_prioritize_first_last(this.torrentId,a,{success:function(){this.optionsManager.set("prioritize_first_last",a)},scope:this})}Deluge.Client.core.set_torrent_options([this.torrentId],b,{success:function(){this.optionsManager.commit()},scope:this})},onEditTrackers:function(){Deluge.EditTrackers.show()},onStopRatioChecked:function(b,a){this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)},onRequestComplete:function(c,b){this.fields["private"].setValue(c["private"]);this.fields["private"].setDisabled(true);delete c["private"];c.auto_managed=c.is_auto_managed;this.optionsManager.setDefault(c);var a=this.optionsManager.get("stop_at_ratio");this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)}});Deluge.Details.add(new Ext.deluge.details.OptionsTab());(function(){Ext.deluge.AddTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Add Tracker"),width:375,height:150,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Ext.deluge.AddTracker.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.AddTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,this);this.addEvents("add");this.form=this.add({xtype:"form",defaultType:"textarea",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Trackers"),name:"trackers",anchor:"100%"}]})},onAddClick:function(){var b=this.form.getForm().findField("trackers").getValue();b=b.split("\n");var a=[];Ext.each(b,function(c){if(Ext.form.VTypes.url(c)){a.push(c)}},this);this.fireEvent("add",a);this.hide();this.form.getForm().findField("trackers").setValue("")},onCancelClick:function(){this.form.getForm().findField("trackers").setValue("");this.hide()}});Ext.deluge.EditTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Tracker"),width:375,height:110,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Ext.deluge.EditTracker.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.EditTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Save"),this.onSaveClick,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Tracker"),name:"tracker",anchor:"100%"}]})},show:function(a){Ext.deluge.EditTracker.superclass.show.call(this);this.record=a;this.form.getForm().findField("tracker").setValue(a.data.url)},onCancelClick:function(){this.hide()},onHide:function(){this.form.getForm().findField("tracker").setValue("")},onSaveClick:function(){var a=this.form.getForm().findField("tracker").getValue();this.record.set("url",a);this.record.commit();this.hide()}});Ext.deluge.EditTrackers=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Trackers"),width:350,height:220,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:true},a);Ext.deluge.EditTrackers.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.EditTrackers.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Ok"),this.onOkClick,this);this.addEvents("save");this.on("show",this.onShow,this);this.on("save",this.onSave,this);this.addWindow=new Ext.deluge.AddTracker();this.addWindow.on("add",this.onAddTrackers,this);this.editWindow=new Ext.deluge.EditTracker();this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"tier",mapping:0},{name:"url",mapping:1}]}),columns:[{header:_("Tier"),width:50,sortable:true,renderer:fplain,dataIndex:"tier"},{id:"tracker",header:_("Tracker"),sortable:true,renderer:fplain,dataIndex:"url"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:{fn:this.onSelect,scope:this}}}),autoExpandColumn:"tracker",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",text:_("Up"),icon:"/icons/up.png",handler:this.onUpClick,scope:this},{cls:"x-btn-text-icon",text:_("Down"),icon:"/icons/down.png",handler:this.onDownClick,scope:this},"->",{cls:"x-btn-text-icon",text:_("Add"),icon:"/icons/add.png",handler:this.onAddClick,scope:this},{cls:"x-btn-text-icon",text:_("Edit"),icon:"/icons/edit_trackers.png",handler:this.onEditClick,scope:this},{cls:"x-btn-text-icon",text:_("Remove"),icon:"/icons/remove.png",handler:this.onRemoveClick,scope:this}]})})},onAddClick:function(){this.addWindow.show()},onAddTrackers:function(b){var a=this.grid.getStore();Ext.each(b,function(d){var e=false,c=-1;a.each(function(f){if(f.get("tier")>c){c=f.get("tier")}if(d==f.get("tracker")){e=true;return false}},this);if(!e){a.loadData([[c+1,d]],true)}},this)},onCancelClick:function(){this.hide()},onEditClick:function(){var a=this.grid.getSelectionModel().getSelected();this.editWindow.show(a)},onHide:function(){this.grid.getStore().removeAll()},onOkClick:function(){var a=[];this.grid.getStore().each(function(b){a.push({tier:b.get("tier"),url:b.get("url")})},this);Deluge.Client.core.set_torrent_trackers(this.torrentId,a,{failure:this.onSaveFail,scope:this});this.hide()},onRemove:function(){var a=this.grid.getSelectionModel().getSelected();this.grid.getStore().remove(a)},onRequestComplete:function(a){var b=[];Ext.each(a.trackers,function(c){b.push([c.tier,c.url])});this.grid.getStore().loadData(b)},onSaveFail:function(){},onSelect:function(a){if(a.hasSelection()){this.grid.getBottomToolbar().items.get(4).enable()}},onShow:function(){this.grid.getBottomToolbar().items.get(4).disable();var a=Deluge.Torrents.getSelected();this.torrentId=a.id;Deluge.Client.core.get_torrent_status(a.id,["trackers"],{success:this.onRequestComplete,scope:this})}});Deluge.EditTrackers=new Ext.deluge.EditTrackers()})();Ext.namespace("Deluge");Deluge.FileBrowser=Ext.extend(Ext.Window,{title:"Filebrowser",initComponent:function(){Deluge.FileBrowser.superclass.initComponent.call(this)}});Ext.deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closable:false,closeAction:"hide",iconCls:"x-deluge-login-window-icon",layout:"fit",modal:true,plain:true,resizable:false,title:_("Login"),width:300,height:120,initComponent:function(){Ext.deluge.LoginWindow.superclass.initComponent.call(this);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:55,width:300,defaults:{width:200},defaultType:"textfield",});this.passwordField=this.form.add({xtype:"textfield",fieldLabel:_("Password"),id:"_password",name:"password",inputType:"password"});this.passwordField.on("specialkey",this.onSpecialKey,this)},logout:function(){Deluge.Events.fire("logout");Deluge.Client.auth.delete_session({success:function(a){this.show(true)},scope:this})},show:function(a){if(this.firstShow){Deluge.Client.on("error",this.onClientError,this);this.firstShow=false}if(a){return Ext.deluge.LoginWindow.superclass.show.call(this)}Deluge.Client.auth.check_session({success:function(b){if(b){Deluge.Events.fire("login")}else{this.show(true)}},failure:function(b){this.show(true)},scope:this})},onSpecialKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.passwordField;Deluge.Client.auth.login(a.getValue(),{success:function(b){if(b){Deluge.Events.fire("login");this.hide();a.setRawValue("")}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){a.focus()},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}},scope:this})},onClientError:function(c,b,a){if(c.error.code==1){Deluge.Events.fire("logout");this.show(true)}},onShow:function(){this.passwordField.focus(false,150);this.passwordField.setRawValue("")}});Deluge.Login=new Ext.deluge.LoginWindow();Ext.namespace("Ext.deluge");Ext.deluge.MoveStorage=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Move Storage"),width:375,height:110,layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-move-storage",plain:true,resizable:false},a);Ext.deluge.MoveStorage.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.MoveStorage.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Move"),this.onMove,this);this.form=this.add({xtype:"form",border:false,defaultType:"textfield",width:300,bodyStyle:"padding: 5px"});this.moveLocation=this.form.add({fieldLabel:_("Location"),name:"location",width:240})},hide:function(){Ext.deluge.MoveStorage.superclass.hide.call(this);this.torrentIds=null},show:function(a){Ext.deluge.MoveStorage.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide()},onMove:function(){var a=this.moveLocation.getValue();Deluge.Client.core.move_storage(this.torrentIds,a);this.hide()}});Deluge.MoveStorage=new Ext.deluge.MoveStorage();Deluge.Plugin=Ext.extend(Ext.util.Observable,{name:null,constructor:function(a){this.name=a.name;this.addEvents({enabled:true,disabled:true});this.isDelugePlugin=true;Deluge.Plugins[this.name]=this;Deluge.Plugin.superclass.constructor.call(this,a)},disable:function(){this.fireEvent("disabled",this);if(this.onDisable){this.onDisable()}},enable:function(){this.fireEvent("enable",this);if(this.onEnable){this.onEnable()}}});Ext.deluge.PreferencesWindow=Ext.extend(Ext.Window,{currentPage:null,constructor:function(a){a=Ext.apply({layout:"border",width:485,height:500,buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-preferences",plain:true,resizable:false,title:_("Preferences"),items:[{xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.SimpleStore({fields:[{name:"name",mapping:0}]}),columns:[{id:"name",renderer:fplain,dataIndex:"name"}],sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPageSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 0 5 5",cmargins:"5 0 5 5",width:120,collapsible:true},]},a);Ext.deluge.PreferencesWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.items.get(0);this.configPanel=this.add({region:"center",header:false,layout:"fit",height:400,autoScroll:true,margins:"5 5 5 5",cmargins:"5 5 5 5"});this.addButton(_("Close"),this.onClose,this);this.addButton(_("Apply"),this.onApply,this);this.addButton(_("Ok"),this.onOk,this);this.pages={};this.optionsManager=new Deluge.OptionsManager();this.on("show",this.onShow,this)},onApply:function(b){var c=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(c)){Deluge.Client.core.set_config(c,{success:this.onSetConfig,scope:this})}for(var a in this.pages){if(this.pages[a].onApply){this.pages[a].onApply()}}},onClose:function(){this.hide()},onOk:function(){Deluge.Client.core.set_config(this.optionsManager.getDirty());this.hide()},addPage:function(c){var a=this.categoriesGrid.getStore();var b=c.title;a.loadData([[b]],true);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);return this.pages[b]},removePage:function(c){var b=c.title;var a=this.categoriesGrid.getStore();a.removeAt(a.find("name",b));this.configPanel.remove(c);delete this.pages[c.title]},getOptionsManager:function(){return this.optionsManager},onGotConfig:function(a){this.getOptionsManager().set(a)},onPageSelect:function(a,e,c){if(this.currentPage==null){for(var d in this.pages){this.pages[d].hide()}}else{this.currentPage.hide()}var b=c.get("name");this.pages[b].show();this.currentPage=this.pages[b];this.configPanel.doLayout()},onSetConfig:function(){this.getOptionsManager().commit()},onShow:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}Deluge.Client.core.get_config({success:this.onGotConfig,scope:this})}});Deluge.Preferences=new Ext.deluge.PreferencesWindow();Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Downloads=Ext.extend(Ext.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Downloads"),layout:"form",autoHeight:true,width:320},a);Ext.deluge.preferences.Downloads.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Downloads.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Folders"),labelWidth:150,defaultType:"togglefield",autoHeight:true,labelAlign:"top",width:300,style:"margin-bottom: 5px; padding-bottom: 5px;"});b.bind("download_location",a.add({xtype:"textfield",name:"download_location",fieldLabel:_("Download to"),width:280}));var c=a.add({name:"move_completed_path",fieldLabel:_("Move completed to"),width:280});b.bind("move_completed",c.toggle);b.bind("move_completed_path",c.input);c=a.add({name:"torrentfiles_location",fieldLabel:_("Copy of .torrent files to"),width:280});b.bind("copy_torrent_file",c.toggle);b.bind("torrentfiles_location",c.input);c=a.add({name:"autoadd_location",fieldLabel:_("Autoadd .torrent files from"),width:280});b.bind("autoadd_enable",c.toggle);b.bind("autoadd_location",c.input);a=this.add({xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radiogroup",style:"margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;",width:240,});b.bind("compact_allocation",a.add({name:"compact_allocation",width:200,labelSeparator:"",disabled:true,defaults:{width:80,height:22,name:"compact_allocation"},items:[{boxLabel:_("Use Full"),inputValue:false},{boxLabel:_("Use Compact"),inputValue:true}]}));a=this.add({xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",style:"margin-bottom: 0; padding-bottom: 0;",width:280});b.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",labelSeparator:"",height:22,boxLabel:_("Prioritize first and last pieces of torrent")}));b.bind("add_paused",a.add({name:"add_paused",labelSeparator:"",height:22,boxLabel:_("Add torrents in Paused state")}));this.on("show",this.onShow,this)},onShow:function(){Ext.deluge.preferences.Downloads.superclass.onShow.call(this)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Downloads());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Network=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Network"),layout:"form"},a);Ext.deluge.preferences.Network.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Network.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Incoming Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_port",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_port",height:22,listeners:{check:{fn:function(d,c){this.listenPorts.setDisabled(c)},scope:this}}}));this.listenPorts=a.add({xtype:"uxspinnergroup",name:"listen_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("listen_ports",this.listenPorts);a=this.add({xtype:"fieldset",border:false,title:_("Outgoing Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_outgoing_ports",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_outgoing_ports",height:22,listeners:{check:{fn:function(d,c){this.outgoingPorts.setDisabled(c)},scope:this}}}));this.outgoingPorts=a.add({xtype:"uxspinnergroup",name:"outgoing_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("outgoing_ports",this.outgoingPorts);a=this.add({xtype:"fieldset",border:false,title:_("Network Interface"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"textfield"});b.bind("listen_interface",a.add({name:"listen_interface",fieldLabel:"",labelSeparator:"",width:200}));a=this.add({xtype:"fieldset",border:false,title:_("TOS"),style:"margin-bottom: 5px; padding-bottom: 0px;",bodyStyle:"margin: 0px; padding: 0px",autoHeight:true,defaultType:"textfield"});b.bind("peer_tos",a.add({name:"peer_tos",fieldLabel:_("Peer TOS Byte"),width:80}));a=this.add({xtype:"fieldset",border:false,title:_("Network Extras"),autoHeight:true,layout:"table",layoutConfig:{columns:3},defaultType:"checkbox"});b.bind("upnp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("UPnP"),name:"upnp"}));b.bind("natpmp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("NAT-PMP"),ctCls:"x-deluge-indent-checkbox",name:"natpmp"}));b.bind("utpex",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Peer Exchange"),ctCls:"x-deluge-indent-checkbox",name:"utpex"}));b.bind("lsd",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("LSD"),name:"lsd"}));b.bind("dht",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("DHT"),ctCls:"x-deluge-indent-checkbox",name:"dht"}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Network());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Encryption=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Encryption"),layout:"form"},a);Ext.deluge.preferences.Encryption.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Encryption.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,defaultType:"combo"});b.bind("enc_in_policy",a.add({fieldLabel:_("Inbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_out_policy",a.add({fieldLabel:_("Outbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_level",a.add({fieldLabel:_("Level"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Handshake")],[1,_("Full Stream")],[2,_("Either")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_prefer_rc4",a.add({xtype:"checkbox",name:"enc_prefer_rc4",height:40,hideLabel:true,boxLabel:_("Encrypt entire stream")}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Encryption());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Bandwidth=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Bandwidth"),layout:"form",labelWidth:10},a);Ext.deluge.preferences.Bandwidth.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Bandwidth.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),labelWidth:200,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",autoHeight:true});b.bind("max_connections_global",a.add({name:"max_connections_global",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_global",a.add({name:"max_upload_slots_global",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed",a.add({name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed",a.add({name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_half_open_connections",a.add({name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_connections_per_second",a.add({name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));a=this.add({xtype:"fieldset",border:false,title:"",defaultType:"checkbox",style:"padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;",autoHeight:true});b.bind("ignore_limits_on_local_network",a.add({name:"ignore_limits_on_local_network",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),}));b.bind("rate_limit_ip_overhead",a.add({name:"rate_limit_ip_overhead",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),}));a=this.add({xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"spinnerfield",labelWidth:200,autoHeight:true});b.bind("max_connections_per_torrent",a.add({name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_per_torrent",a.add({name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed_per_torrent",a.add({name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed_per_torrent",a.add({name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Bandwidth());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Interface=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Interface"),layout:"form"},a);Ext.deluge.preferences.Interface.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Interface.superclass.initComponent.call(this);var c=this.optionsManager=new Deluge.OptionsManager();this.on("show",this.onShow,this);var a=this.add({xtype:"fieldset",border:false,title:_("Interface"),style:"margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px",autoHeight:true,labelWidth:1,defaultType:"checkbox"});c.bind("show_session_speed",a.add({name:"show_session_speed",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar")}));c.bind("sidebar_show_zero",a.add({name:"sidebar_show_zero",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show filters with zero torrents")}));c.bind("sidebar_show_trackers",a.add({name:"sidebar_show_trackers",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show trackers with zero torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Password"),style:"margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px",autoHeight:true,labelWidth:110,defaultType:"textfield",defaults:{width:180,inputType:"password"}});this.oldPassword=a.add({name:"old_password",fieldLabel:_("Old Password")});this.newPassword=a.add({name:"new_password",fieldLabel:_("New Password")});this.confirmPassword=a.add({name:"confirm_password",fieldLabel:_("Confirm Password")});var b=a.add({xtype:"panel",autoHeight:true,border:false,width:320,bodyStyle:"padding-left: 230px"});b.add({xtype:"button",text:_("Change"),listeners:{click:{fn:this.onPasswordChange,scope:this}}});a=this.add({xtype:"fieldset",border:false,title:_("Server"),style:"margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px",autoHeight:true,labelWidth:110,defaultType:"spinnerfield",defaults:{width:80,}});c.bind("session_timeout",a.add({name:"session_timeout",fieldLabel:_("Session Timeout"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));c.bind("port",a.add({name:"port",fieldLabel:_("Port"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));this.httpsField=c.bind("https",a.add({xtype:"checkbox",name:"https",hideLabel:true,width:280,height:22,boxLabel:_("Use SSL (paths relative to Deluge config folder)")}));this.httpsField.on("check",this.onSSLCheck,this);this.pkeyField=c.bind("pkey",a.add({xtype:"textfield",disabled:true,name:"pkey",width:180,fieldLabel:_("Private Key")}));this.certField=c.bind("cert",a.add({xtype:"textfield",disabled:true,name:"cert",width:180,fieldLabel:_("Certificate")}))},onApply:function(){var a=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(a)){Deluge.Client.web.set_config(a,{success:this.onSetConfig,scope:this})}},onGotConfig:function(a){this.optionsManager.set(a)},onPasswordChange:function(){var b=this.newPassword.getValue();if(b!=this.confirmPassword.getValue()){Ext.MessageBox.show({title:_("Invalid Password"),msg:_("Your passwords don't match!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var a=this.oldPassword.getValue();Deluge.Client.auth.change_password(a,b,{success:function(c){if(!c){Ext.MessageBox.show({title:_("Password"),msg:_("Your old password was incorrect!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});this.oldPassword.setValue("")}else{Ext.MessageBox.show({title:_("Change Successful"),msg:_("Your password was successfully changed!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.INFO,iconCls:"x-deluge-icon-info"});this.oldPassword.setValue("");this.newPassword.setValue("");this.confirmPassword.setValue("")}},scope:this})},onSetConfig:function(){this.optionsManager.commit()},onShow:function(){Ext.deluge.preferences.Interface.superclass.onShow.call(this);Deluge.Client.web.get_config({success:this.onGotConfig,scope:this})},onSSLCheck:function(b,a){this.pkeyField.setDisabled(!a);this.certField.setDisabled(!a)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Interface());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Other=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Other"),layout:"form"},a);Ext.deluge.preferences.Other.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Other.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Updates"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:22,name:"new_release_check",boxLabel:_("Be alerted about new releases")}));a=this.add({xtype:"fieldset",border:false,title:_("System Information"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});a.add({xtype:"panel",border:false,bodyCfg:{html:_("Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.")}});b.bind("send_info",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Yes, please send anonymous statistics"),name:"send_info"}));a=this.add({xtype:"fieldset",border:false,title:_("GeoIP Database"),autoHeight:true,labelWidth:80,defaultType:"textfield"});b.bind("geoip_db_location",a.add({name:"geoip_db_location",fieldLabel:_("Location"),width:200}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Other());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Daemon=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Daemon"),layout:"form"},a);Ext.deluge.preferences.Daemon.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Daemon.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"spinnerfield"});b.bind("daemon_port",a.add({fieldLabel:_("Daemon port"),name:"daemon_port",value:58846,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("allow_remote",a.add({fieldLabel:"",height:22,labelSeparator:"",boxLabel:_("Allow Remote Connections"),name:"allow_remote"}));a=this.add({xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_release_check"}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Daemon());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Queue=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Queue"),layout:"form"},a);Ext.deluge.preferences.Queue.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Queue.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("General"),style:"padding-top: 5px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("queue_new_to_top",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Queue new torrents to top"),name:"queue_new_to_top"}));a=this.add({xtype:"fieldset",border:false,title:_("Active Torrents"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",});b.bind("max_active_limit",a.add({fieldLabel:_("Total Active"),name:"max_active_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_downloading",a.add({fieldLabel:_("Total Active Downloading"),name:"max_active_downloading",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_seeding",a.add({fieldLabel:_("Total Active Seeding"),name:"max_active_seeding",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("dont_count_slow_torrents",a.add({xtype:"checkbox",name:"dont_count_slow_torrents",height:40,hideLabel:true,boxLabel:_("Do not count slow torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Seeding"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;",});b.bind("share_ratio_limit",a.add({fieldLabel:_("Share Ratio Limit"),name:"share_ratio_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_ratio_limit",a.add({fieldLabel:_("Share Time Ratio"),name:"seed_time_ratio_limit",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_limit",a.add({fieldLabel:_("Seed Time (m)"),name:"seed_time_limit",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,autoHeight:true,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaultType:"checkbox",defaults:{fieldLabel:"",labelSeparator:""}});this.stopAtRatio=a.add({name:"stop_seed_at_ratio",boxLabel:_("Stop seeding when share ratio reaches:")});this.stopAtRatio.on("check",this.onStopRatioCheck,this);b.bind("stop_seed_at_ratio",this.stopAtRatio);this.stopRatio=a.add({xtype:"spinnerfield",name:"stop_seed_ratio",ctCls:"x-deluge-indent-checkbox",disabled:true,value:2,width:60,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});b.bind("stop_seed_ratio",this.stopRatio);this.removeAtRatio=a.add({name:"remove_seed_at_ratio",ctCls:"x-deluge-indent-checkbox",boxLabel:_("Remove torrent when share ratio is reached"),disabled:true,colspan:2});b.bind("remove_seed_at_ratio",this.removeAtRatio)},onStopRatioCheck:function(b,a){this.stopRatio.setDisabled(!a);this.removeAtRatio.setDisabled(!a)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Queue());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.ProxyField=Ext.extend(Ext.form.FieldSet,{constructor:function(a){a=Ext.apply({border:false,autoHeight:true,labelWidth:70},a);Ext.deluge.preferences.ProxyField.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.ProxyField.superclass.initComponent.call(this);this.type=this.add({xtype:"combo",fieldLabel:_("Type"),name:"type",mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("None")],[1,_("Socksv4")],[2,_("Socksv5")],[3,_("Socksv5 with Auth")],[4,_("HTTP")],[5,_("HTTP with Auth")],]}),value:0,triggerAction:"all",valueField:"id",displayField:"text"});this.hostname=this.add({xtype:"textfield",name:"hostname",fieldLabel:_("Host"),width:220});this.port=this.add({xtype:"spinnerfield",name:"port",fieldLabel:_("Port"),width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}});this.username=this.add({xtype:"textfield",name:"username",fieldLabel:_("Username"),width:220});this.password=this.add({xtype:"textfield",name:"password",fieldLabel:_("Password"),inputType:"password",width:220});this.type.on("change",this.onFieldChange,this);this.type.on("select",this.onTypeSelect,this);this.setting=false},getName:function(){return this.initialConfig.name},getValue:function(){return{type:this.type.getValue(),hostname:this.hostname.getValue(),port:Number(this.port.getValue()),username:this.username.getValue(),password:this.password.getValue()}},setValue:function(c){this.setting=true;this.type.setValue(c.type);var b=this.type.getStore().find("id",c.type);var a=this.type.getStore().getAt(b);this.hostname.setValue(c.hostname);this.port.setValue(c.port);this.username.setValue(c.username);this.password.setValue(c.password);this.onTypeSelect(this.type,a,b);this.setting=false},onFieldChange:function(e,d,c){if(this.setting){return}var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)},onTypeSelect:function(d,a,b){var c=a.get("id");if(c>0){this.hostname.show();this.port.show()}else{this.hostname.hide();this.port.hide()}if(c==3||c==5){this.username.show();this.password.show()}else{this.username.hide();this.password.hide()}}});Ext.deluge.preferences.Proxy=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Proxy"),layout:"form"},a);Ext.deluge.preferences.Proxy.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Proxy.superclass.initComponent.call(this);this.peer=this.add(new Ext.deluge.preferences.ProxyField({title:_("Peer"),name:"peer"}));this.peer.on("change",this.onProxyChange,this);this.web_seed=this.add(new Ext.deluge.preferences.ProxyField({title:_("Web Seed"),name:"web_seed"}));this.web_seed.on("change",this.onProxyChange,this);this.tracker=this.add(new Ext.deluge.preferences.ProxyField({title:_("Tracker"),name:"tracker"}));this.tracker.on("change",this.onProxyChange,this);this.dht=this.add(new Ext.deluge.preferences.ProxyField({title:_("DHT"),name:"dht"}));this.dht.on("change",this.onProxyChange,this);Deluge.Preferences.getOptionsManager().bind("proxies",this)},getValue:function(){return{dht:this.dht.getValue(),peer:this.peer.getValue(),tracker:this.tracker.getValue(),web_seed:this.web_seed.getValue()}},setValue:function(b){for(var a in b){this[a].setValue(b[a])}},onProxyChange:function(e,d,c){var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Proxy());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.Cache=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Cache"),layout:"form"},a);Ext.deluge.preferences.Cache.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.preferences.Cache.superclass.initComponent.call(this);var b=Deluge.Preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,labelWidth:180,defaultType:"spinnerfield"});b.bind("cache_size",a.add({fieldLabel:_("Cache Size (16 KiB Blocks)"),name:"cache_size",width:60,value:512,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("cache_expiry",a.add({fieldLabel:_("Cache Expiry (seconds)"),name:"cache_expiry",width:60,value:60,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}))}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Cache());Ext.namespace("Ext.deluge.preferences");Ext.deluge.preferences.InstallPlugin=Ext.extend(Ext.Window,{height:115,width:350,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",iconCls:"x-deluge-install-plugin",layout:"fit",modal:true,plain:true,title:_("Install Plugin"),initComponent:function(){Ext.deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Install"),this.onInstall,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:70,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"pluginEgg",emptyText:_("Select an egg"),fieldLabel:_("Plugin Egg"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onInstall:function(b,a){this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your plugin..."),success:this.onUploadSuccess,scope:this})},onUploadPlugin:function(d,c,a,b){this.fireEvent("pluginadded")},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=this.form.getForm().findField("pluginEgg").value;var d=b.result.files[0];this.form.getForm().findField("pluginEgg").setValue("");Deluge.Client.web.upload_plugin(a,d,{success:this.onUploadPlugin,scope:this,filename:a})}}});Ext.deluge.preferences.Plugins=Ext.extend(Ext.Panel,{constructor:function(a){a=Ext.apply({border:false,title:_("Plugins"),layout:"border",height:400,cls:"x-deluge-plugins"},a);Ext.deluge.preferences.Plugins.superclass.constructor.call(this,a)},pluginTemplate:new Ext.Template('<dl class="singleline"><dt>Author:</dt><dd>{author}</dd><dt>Version:</dt><dd>{version}</dd><dt>Author Email:</dt><dd>{email}</dd><dt>Homepage:</dt><dd>{homepage}</dd><dt>Details:</dt><dd>{details}</dd></dl>'),initComponent:function(){Ext.deluge.preferences.Plugins.superclass.initComponent.call(this);this.defaultValues={version:"",email:"",homepage:"",details:""};this.pluginTemplate.compile();var b=function(d,e,c){e.css+=" x-grid3-check-col-td";return'<div class="x-grid3-check-col'+(d?"-on":"")+'"> </div>'};this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"enabled",mapping:0},{name:"plugin",mapping:1}]}),columns:[{id:"enabled",header:_("Enabled"),width:50,sortable:true,renderer:b,dataIndex:"enabled"},{id:"plugin",header:_("Plugin"),sortable:true,dataIndex:"plugin"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPluginSelect,scope:this}}}),autoExpandColumn:"plugin",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",iconCls:"x-deluge-install-plugin",text:_("Install"),handler:this.onInstallPlugin,scope:this},"->",{cls:"x-btn-text-icon",text:_("Find More"),iconCls:"x-deluge-find-more",handler:this.onFindMorePlugins,scope:this}]})});var a=this.add({xtype:"fieldset",border:false,region:"south",title:_("Info"),autoHeight:true,labelWidth:1});this.pluginInfo=a.add({xtype:"panel",border:false,bodyCfg:{style:"margin-left: 10px"}});this.on("show",this.onShow,this);this.pluginInfo.on("render",this.onPluginInfoRender,this);this.grid.on("cellclick",this.onCellClick,this);Deluge.Preferences.on("show",this.onPreferencesShow,this);Deluge.Events.on("PluginDisabledEvent",this.onPluginDisabled,this);Deluge.Events.on("PluginEnabledEvent",this.onPluginEnabled,this)},disablePlugin:function(a){Deluge.Client.core.disable_plugin(a)},enablePlugin:function(a){Deluge.Client.core.enable_plugin(a)},setInfo:function(b){if(!this.pluginInfo.rendered){return}var a=b||this.defaultValues;this.pluginInfo.body.dom.innerHTML=this.pluginTemplate.apply(a)},updatePlugins:function(){Deluge.Client.web.get_plugins({success:this.onGotPlugins,scope:this})},updatePluginsGrid:function(){var a=[];Ext.each(this.availablePlugins,function(b){if(this.enabledPlugins.indexOf(b)>-1){a.push([true,b])}else{a.push([false,b])}},this);this.grid.getStore().loadData(a)},onCellClick:function(b,f,a,d){if(a!=0){return}var c=b.getStore().getAt(f);c.set("enabled",!c.get("enabled"));c.commit();if(c.get("enabled")){this.enablePlugin(c.get("plugin"))}else{this.disablePlugin(c.get("plugin"))}},onFindMorePlugins:function(){window.open("http://dev.deluge-torrent.org/wiki/Plugins")},onGotPlugins:function(a){this.enabledPlugins=a.enabled_plugins;this.availablePlugins=a.available_plugins;this.setInfo();this.updatePluginsGrid()},onGotPluginInfo:function(b){var a={author:b.Author,version:b.Version,email:b["Author-email"],homepage:b["Home-page"],details:b.Description};this.setInfo(a);delete b},onInstallPlugin:function(){if(!this.installWindow){this.installWindow=new Ext.deluge.preferences.InstallPlugin();this.installWindow.on("pluginadded",this.onPluginInstall,this)}this.installWindow.show()},onPluginEnabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",true);b.commit()},onPluginDisabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",false);b.commit()},onPluginInstall:function(){this.updatePlugins()},onPluginSelect:function(b,c,a){Deluge.Client.web.get_plugin_info(a.get("plugin"),{success:this.onGotPluginInfo,scope:this})},onPreferencesShow:function(){this.updatePlugins()},onPluginInfoRender:function(b,a){this.setInfo()}});Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());Ext.deluge.RemoveWindow=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Remove Torrent"),layout:"fit",width:350,height:100,buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-remove-window-icon"},a);Ext.deluge.RemoveWindow.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.RemoveWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Remove With Data"),this.onRemoveData,this);this.addButton(_("Remove Torrent"),this.onRemove,this);this.add({border:false,bodyStyle:"padding: 5px; padding-left: 10px;",html:"Are you sure you wish to remove the torrent(s)?"})},remove:function(a){Ext.each(this.torrentIds,function(b){Deluge.Client.core.remove_torrent(b,a,{success:function(){this.onRemoved(b)},scope:this,torrentId:b})},this)},show:function(a){Ext.deluge.RemoveWindow.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide();this.torrentIds=null},onRemove:function(){this.remove(false)},onRemoveData:function(){this.remove(true)},onRemoved:function(a){Deluge.Events.fire("torrentRemoved",a);this.hide();Deluge.UI.update()}});Deluge.RemoveWindow=new Ext.deluge.RemoveWindow();(function(){function a(d,f,c){var b=d.toLowerCase().replace(".","_");var e="";if(c.store.id=="tracker_host"){if(d!="Error"){e=String.format("url(/tracker/{0})",d)}else{b=null}}if(e){return String.format('<div class="x-deluge-filter" style="background-image: {2};">{0} ({1})</div>',d,c.data.count,e)}else{if(b){return String.format('<div class="x-deluge-filter x-deluge-{2}">{0} ({1})</div>',d,c.data.count,b)}else{return String.format('<div class="x-deluge-filter">{0} ({1})</div>',d,c.data.count)}}}Ext.deluge.Sidebar=Ext.extend(Ext.Panel,{panels:{},selected:null,constructor:function(b){b=Ext.apply({id:"sidebar",region:"west",cls:"deluge-sidebar",title:_("Filters"),layout:"accordion",split:true,width:200,minSize:175,collapsible:true,margins:"5 0 0 5",cmargins:"5 0 0 5"},b);Ext.deluge.Sidebar.superclass.constructor.call(this,b)},initComponent:function(){Ext.deluge.Sidebar.superclass.initComponent.call(this);Deluge.Events.on("disconnect",this.onDisconnect,this)},createFilter:function(e,d){var c=new Ext.data.SimpleStore({id:e,fields:[{name:"filter"},{name:"count"}]});var g=e.replace("_"," ");var f=g.split(" ");g="";Ext.each(f,function(h){firstLetter=h.substring(0,1);firstLetter=firstLetter.toUpperCase();h=firstLetter+h.substring(1);g+=h+" "});var b=new Ext.grid.GridPanel({id:e+"-panel",border:false,store:c,title:_(g),columns:[{id:"filter",sortable:false,renderer:a,dataIndex:"filter"}],stripeRows:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onFilterSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"filter",deferredRender:false,autoScroll:true});if(Deluge.config.sidebar_show_zero==false){d=this.removeZero(d)}c.loadData(d);this.add(b);this.doLayout();this.panels[e]=b;if(!this.selected){b.getSelectionModel().selectFirstRow();this.selected={row:0,filter:d[0][0],panel:b}}},getFilters:function(){var c={};if(!this.selected){return c}if(!this.selected.filter||!this.selected.panel){return c}var b=this.selected.panel.store.id;if(b=="state"&&this.selected.filter=="All"){return c}c[b]=this.selected.filter;return c},onDisconnect:function(){Ext.each(Ext.getKeys(this.panels),function(b){this.remove(b+"-panel")},this);this.panels={};this.selected=null},onFilterSelect:function(c,d,b){if(!this.selected){needsUpdate=true}else{if(this.selected.row!=d){needsUpdate=true}else{needsUpdate=false}}this.selected={row:d,filter:b.get("filter"),panel:this.panels[b.store.id]};if(needsUpdate){Deluge.UI.update()}},removeZero:function(b){var c=[];Ext.each(b,function(d){if(d[1]>0||d[0]==_("All")){c.push(d)}});return c},update:function(d){for(var c in d){var b=d[c];if(Ext.getKeys(this.panels).indexOf(c)>-1){this.updateFilter(c,b)}else{this.createFilter(c,b)}}Ext.each(Ext.keys(this.panels),function(e){if(Ext.keys(d).indexOf(e)==-1){this.panels[e]}},this)},updateFilter:function(c,b){if(Deluge.config.sidebar_show_zero==false){b=this.removeZero(b)}this.panels[c].store.loadData(b);if(this.selected&&this.selected.panel==this.panels[c]){this.panels[c].getSelectionModel().selectRow(this.selected.row)}}});Deluge.Sidebar=new Ext.deluge.Sidebar()})();Ext.deluge.Statusbar=Ext.extend(Ext.ux.StatusBar,{constructor:function(a){a=Ext.apply({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected")},a);Ext.deluge.Statusbar.superclass.constructor.call(this,a)},initComponent:function(){Ext.deluge.Statusbar.superclass.initComponent.call(this);Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("disconnect",this.onDisconnect,this)},createButtons:function(){this.add({id:"statusbar-connections",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",tooltip:_("Connections"),menu:Deluge.Menus.Connections},"-",{id:"statusbar-downspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",tooltip:_("Download Speed"),menu:Deluge.Menus.Download},"-",{id:"statusbar-upspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",tooltip:_("Upload Speed"),menu:Deluge.Menus.Upload},"-",{id:"statusbar-traffic",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic",tooltip:_("Protocol Traffic Download/Upload")},"-",{id:"statusbar-dht",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-dht",tooltip:_("DHT Nodes")},"-",{id:"statusbar-freespace",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-freespace",tooltip:_("Freespace in download location")});this.created=true},onConnect:function(){if(!this.created){this.createButtons()}else{this.items.each(function(a){a.show();a.enable()})}},onDisconnect:function(){this.items.each(function(a){a.hide();a.disable()})},update:function(b){if(!b){return}function c(d){return d+" KiB/s"}var a=function(f,e){var g=this.items.get("statusbar-"+f);if(e.limit.value>0){var h=(e.value.formatter)?e.value.formatter(e.value.value):e.value.value;var d=(e.limit.formatter)?e.limit.formatter(e.limit.value):e.limit.value;var i=String.format(e.format,h,d)}else{var i=(e.value.formatter)?e.value.formatter(e.value.value):e.value.value}g.setText(i)}.createDelegate(this);a("connections",{value:{value:b.num_connections},limit:{value:b.max_num_connections},format:"{0} ({1})"});a("downspeed",{value:{value:b.download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_download,formatter:c},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:c},format:"{0} ({1})"});a("traffic",{value:{value:b.download_protocol_rate,formatter:Deluge.Formatters.speed},limit:{value:b.upload_protocol_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.items.get("statusbar-dht").setText(b.dht_nodes);this.items.get("statusbar-freespace").setText(fsize(b.free_space));Deluge.Menus.Connections.setValue(b.max_num_connections);Deluge.Menus.Download.setValue(b.max_download);Deluge.Menus.Upload.setValue(b.max_upload)}});Deluge.Statusbar=new Ext.deluge.Statusbar();Ext.deluge.Toolbar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=Ext.apply({items:[{id:"create",cls:"x-btn-text-icon",disabled:true,text:_("Create"),icon:"/icons/create.png",handler:this.onTorrentAction},{id:"add",cls:"x-btn-text-icon",disabled:true,text:_("Add"),icon:"/icons/add.png",handler:this.onTorrentAdd},{id:"remove",cls:"x-btn-text-icon",disabled:true,text:_("Remove"),icon:"/icons/remove.png",handler:this.onTorrentAction},"|",{id:"pause",cls:"x-btn-text-icon",disabled:true,text:_("Pause"),icon:"/icons/pause.png",handler:this.onTorrentAction},{id:"resume",cls:"x-btn-text-icon",disabled:true,text:_("Resume"),icon:"/icons/start.png",handler:this.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),icon:"/icons/up.png",handler:this.onTorrentAction},{id:"down",cls:"x-btn-text-icon",disabled:true,text:_("Down"),icon:"/icons/down.png",handler:this.onTorrentAction},"|",{id:"preferences",cls:"x-btn-text-icon",text:_("Preferences"),iconCls:"x-deluge-preferences",handler:this.onPreferencesClick,scope:this},{id:"connectionman",cls:"x-btn-text-icon",text:_("Connection Manager"),iconCls:"x-deluge-connection-manager",handler:this.onConnectionManagerClick,scope:this},"->",{id:"help",cls:"x-btn-text-icon",icon:"/icons/help.png",text:_("Help"),handler:this.onHelpClick,scope:this},{id:"logout",cls:"x-btn-text-icon",icon:"/icons/logout.png",disabled:true,text:_("Logout"),handler:this.onLogout,scope:this}]},a);Ext.deluge.Toolbar.superclass.constructor.call(this,a)},connectedButtons:["add","remove","pause","resume","up","down"],initComponent:function(){Ext.deluge.Toolbar.superclass.initComponent.call(this);Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("login",this.onLogin,this)},onConnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).enable()},this)},onDisconnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).disable()},this)},onLogin:function(){this.items.get("logout").enable()},onLogout:function(){this.items.get("logout").disable();Deluge.Login.logout()},onConnectionManagerClick:function(){Deluge.ConnectionManager.show()},onHelpClick:function(){window.open("http://dev.deluge-torrent.org/wiki/UserGuide")},onPreferencesClick:function(){Deluge.Preferences.show()},onTorrentAction:function(c){var b=Deluge.Torrents.getSelections();var a=[];Ext.each(b,function(d){a.push(d.id)});switch(c.id){case"remove":Deluge.RemoveWindow.show(a);break;case"pause":case"resume":Deluge.Client.core[c.id+"_torrent"](a,{success:function(){Deluge.UI.update()}});break;case"up":case"down":Deluge.Client.core["queue_"+c.id](a,{success:function(){Deluge.UI.update()}});break}},onTorrentAdd:function(){Deluge.Add.show()}});Deluge.Toolbar=new Ext.deluge.Toolbar();Deluge.Torrent=Ext.data.Record.create([{name:"queue",type:"int"},{name:"name",type:"string"},{name:"total_size",type:"int"},{name:"state",type:"string"},{name:"progress",type:"int"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_rate",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host",type:"string"}]);(function(){function c(j){return(j==99999)?"":j+1}function e(k,l,j){return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>',j.data.state.toLowerCase(),k)}function g(j){if(!j){return}return fspeed(j)}function i(m,n,l){m=new Number(m);var j=m;var o=l.data.state+" "+m.toFixed(2)+"%";var k=new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]);return Deluge.progressBar(m,k-8,o)}function a(k,l,j){if(j.data.total_seeds>-1){return String.format("{0} ({1})",k,j.data.total_seeds)}else{return k}}function d(k,l,j){if(j.data.total_peers>-1){return String.format("{0} ({1})",k,j.data.total_peers)}else{return k}}function b(k,l,j){return(k<0)?"∞":new Number(k).toFixed(3)}function f(k,l,j){return String.format('<div style="background: url(/tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>',k)}function h(j){return j*-1}Ext.deluge.TorrentGrid=Ext.extend(Ext.grid.GridPanel,{torrents:{},constructor:function(j){j=Ext.apply({id:"torrentGrid",store:new Ext.data.JsonStore({root:"torrents",idProperty:"id",fields:[{name:"queue"},{name:"name"},{name:"total_size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_speed",type:"int"},{name:"eta",type:"int",sortType:h},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host"}]}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:c,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:e,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"total_size"},{header:_("Progress"),width:150,sortable:true,renderer:i,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:a,dataIndex:"num_seeds"},{header:_("Peers"),width:60,sortable:true,renderer:d,dataIndex:"num_peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:g,dataIndex:"download_payload_rate"},{header:_("Up Speed"),width:80,sortable:true,renderer:g,dataIndex:"upload_payload_rate"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:b,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:b,dataIndex:"distributed_copies"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"time_added"},{header:_("Tracker"),width:120,sortable:true,renderer:f,dataIndex:"tracker_host"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0",stateful:true,view:new Ext.ux.grid.BufferView({rowHeight:26,scrollDelay:false})},j);Ext.deluge.TorrentGrid.superclass.constructor.call(this,j)},initComponent:function(){Ext.deluge.TorrentGrid.superclass.initComponent.call(this);Deluge.Events.on("torrentRemoved",this.onTorrentRemoved,this);Deluge.Events.on("logout",this.onDisconnect,this);this.on("rowcontextmenu",function(j,m,l){l.stopEvent();var k=j.getSelectionModel();if(!k.hasSelection()){k.selectRow(m)}Deluge.Menus.Torrent.showAt(l.getPoint())})},getTorrent:function(j){return this.getStore().getAt(j)},getSelected:function(){return this.getSelectionModel().getSelected()},getSelections:function(){return this.getSelectionModel().getSelections()},update:function(p){var n=this.getStore();var l=[];for(var o in p){var q=p[o];if(this.torrents[o]){var j=n.getById(o);j.beginEdit();for(var m in q){if(j.get(m)!=q[m]){j.set(m,q[m])}}j.endEdit()}else{var j=new Deluge.Torrent(q);j.id=o;this.torrents[o]=1;l.push(j)}}n.add(l);n.each(function(k){if(!p[k.id]){n.remove(k)}});n.commitChanges()},onDisconnect:function(){this.getStore().removeAll()},onTorrentRemoved:function(k){var j=this.getSelectionModel();Ext.each(k,function(m){var l=this.getStore().getById(m);if(j.isSelected(l)){j.deselectRow(this.getStore().indexOf(l))}this.getStore().remove(l)},this)}});Deluge.Torrents=new Ext.deluge.TorrentGrid()})();Deluge.UI={errorCount:0,filters:null,initialize:function(){this.MainPanel=new Ext.Panel({id:"mainPanel",iconCls:"x-deluge-main-panel",title:"Deluge",layout:"border",tbar:Deluge.Toolbar,items:[Deluge.Sidebar,Deluge.Details,Deluge.Torrents],bbar:Deluge.Statusbar});this.Viewport=new Ext.Viewport({layout:"fit",items:[this.MainPanel]});Deluge.Events.on("connect",this.onConnect,this);Deluge.Events.on("disconnect",this.onDisconnect,this);Deluge.Client=new Ext.ux.util.RpcClient({url:"/json"});for(var a in Deluge.Plugins){a=Deluge.Plugins[a];a.enable()}Ext.QuickTips.init();Deluge.Client.on("connected",function(b){Deluge.Login.show()},this,{single:true});this.update=this.update.createDelegate(this)},update:function(){var a=Deluge.Sidebar.getFilters();Deluge.Client.web.update_ui(Deluge.Keys.Grid,a,{success:this.onUpdate,failure:this.onUpdateError,scope:this});Deluge.Details.update()},onUpdateError:function(a){if(this.errorCount==2){Ext.MessageBox.show({title:"Lost Connection",msg:"The connection to the webserver has been lost!",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}this.errorCount++},onUpdate:function(a){if(!a.connected){Deluge.Events.fire("disconnect")}Deluge.Torrents.update(a.torrents);Deluge.Statusbar.update(a.stats);Deluge.Sidebar.update(a.filters);this.errorCount=0},onConnect:function(){if(!this.running){this.running=setInterval(this.update,2000);this.update()}},onDisconnect:function(){this.stop()},onPluginEnabled:function(a){Deluge.Client.web.get_plugin_resources(a,{success:this.onGotPluginResources,scope:this})},onGotPluginResources:function(b){var a=(Deluge.debug)?b.debug_scripts:b.scripts;Ext.each(a,function(c){Ext.ux.JSLoader({url:c,onLoad:this.onPluginLoaded,pluginName:b.name})},this)},onPluginDisabled:function(a){Deluge.Plugins[a].disable()},onPluginLoaded:function(a){if(!Deluge.Plugins[a.pluginName]){return}Deluge.Plugins[a.pluginName].enable()},stop:function(){if(this.running){clearInterval(this.running);this.running=false;Deluge.Torrents.getStore().removeAll()}}};Ext.onReady(function(a){Deluge.UI.initialize()});
     1Ext.state.Manager.setProvider(new Ext.state.CookieProvider());(function(){Ext.apply(Ext,{escapeHTML:function(a){a=String(a).replace("<","&lt;").replace(">","&gt;");return a.replace("&","&amp;")},isObjectEmpty:function(b){for(var a in b){return false}return true},isObjectsEqual:function(d,c){var b=true;if(!d||!c){return false}for(var a in d){if(d[a]!=c[a]){b=false}}return b},keys:function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b},values:function(c){var a=[];for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys;Ext.BLANK_IMAGE_URL=deluge.config.base+"images/s.gif";Ext.USE_NATIVE_JSON=true})();Deluge={progressTpl:'<div class="x-progress-wrap x-progress-renderered"><div class="x-progress-inner"><div style="width: {2}px" class="x-progress-bar"><div style="z-index: 99; width: {3}px" class="x-progress-text"><div style="width: {1}px;">{0}</div></div></div><div class="x-progress-text x-progress-text-back"><div style="width: {1}px;">{0}</div></div></div></div>',progressBar:function(c,e,g,a){a=Ext.value(a,10);var b=((e/100)*c).toFixed(0);var d=b-1;var f=((b-a)>0?b-a:0);return String.format(Deluge.progressTpl,g,e,d,f)}};deluge.plugins={};FILE_PRIORITY={9:"Mixed",0:"Do Not Download",1:"Normal Priority",2:"High Priority",5:"Highest Priority",Mixed:9,"Do Not Download":0,"Normal Priority":1,"High Priority":2,"Highest Priority":5};FILE_PRIORITY_CSS={9:"x-mixed-download",0:"x-no-download",1:"x-normal-download",2:"x-high-download",5:"x-highest-download"};Deluge.Formatters={date:function(c){function b(d,e){var f=d+"";while(f.length<e){f="0"+f}return f}c=c*1000;var a=new Date(c);return String.format("{0}/{1}/{2}",b(a.getDate(),2),b(a.getMonth()+1,2),a.getFullYear())},size:function(b,a){if(!b&&!a){return""}b=b/1024;if(b<1024){return b.toFixed(1)+" KiB"}else{b=b/1024}if(b<1024){return b.toFixed(1)+" MiB"}else{b=b/1024}return b.toFixed(1)+" GiB"},speed:function(b,a){return(!b&&!a)?"":fsize(b,a)+"/s"},timeRemaining:function(c){if(c==0){return"∞"}c=c.toFixed(0);if(c<60){return c+"s"}else{c=c/60}if(c<60){var b=Math.floor(c);var d=Math.round(60*(c-b));if(d>0){return b+"m "+d+"s"}else{return b+"m"}}else{c=c/60}if(c<24){var a=Math.floor(c);var b=Math.round(60*(c-a));if(b>0){return a+"h "+b+"m"}else{return a+"h"}}else{c=c/24}var e=Math.floor(c);var a=Math.round(24*(c-e));if(a>0){return e+"d "+a+"h"}else{return e+"d"}},plain:function(a){return a}};var fsize=Deluge.Formatters.size;var fspeed=Deluge.Formatters.speed;var ftime=Deluge.Formatters.timeRemaining;var fdate=Deluge.Formatters.date;var fplain=Deluge.Formatters.plain;Deluge.Keys={Grid:["queue","name","total_size","state","progress","num_seeds","total_seeds","num_peers","total_peers","download_payload_rate","upload_payload_rate","eta","ratio","distributed_copies","is_auto_managed","time_added","tracker_host"],Status:["total_done","total_payload_download","total_uploaded","total_payload_upload","next_announce","tracker_status","num_pieces","piece_length","is_auto_managed","active_time","seeding_time","seed_rank"],Files:["files","file_progress","file_priorities"],Peers:["peers"],Details:["name","save_path","total_size","num_files","tracker_status","tracker","comment"],Options:["max_download_speed","max_upload_speed","max_connections","max_upload_slots","is_auto_managed","stop_at_ratio","stop_ratio","remove_at_ratio","private","prioritize_first_last"]};Ext.each(Deluge.Keys.Grid,function(a){Deluge.Keys.Status.push(a)});deluge.menus={onTorrentAction:function(c,f){var b=deluge.torrents.getSelections();var a=[];Ext.each(b,function(e){a.push(e.id)});var d=c.initialConfig.torrentAction;switch(d){case"pause":case"resume":deluge.client.core[d+"_torrent"](a,{success:function(){deluge.ui.update()}});break;case"top":case"up":case"down":case"bottom":deluge.client.core["queue_"+d](a,{success:function(){deluge.ui.update()}});break;case"edit_trackers":deluge.editTrackers.show();break;case"update":deluge.client.core.force_reannounce(a,{success:function(){deluge.ui.update()}});break;case"remove":deluge.removeWindow.show(a);break;case"recheck":deluge.client.core.force_recheck(a,{success:function(){deluge.ui.update()}});break;case"move":deluge.moveStorage.show(a);break}}};deluge.menus.torrent=new Ext.menu.Menu({id:"torrentMenu",items:[{torrentAction:"pause",text:_("Pause"),iconCls:"icon-pause",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"resume",text:_("Resume"),iconCls:"icon-resume",handler:deluge.menus.onTorrentAction,scope:deluge.menus},"-",{text:_("Options"),iconCls:"icon-options",menu:new Ext.menu.Menu({items:[{text:_("D/L Speed Limit"),iconCls:"x-deluge-downloading",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("U/L Speed Limit"),iconCls:"x-deluge-seeding",menu:new Ext.menu.Menu({items:[{text:_("5 KiB/s")},{text:_("10 KiB/s")},{text:_("30 KiB/s")},{text:_("80 KiB/s")},{text:_("300 KiB/s")},{text:_("Unlimited")}]})},{text:_("Connection Limit"),iconCls:"x-deluge-connections",menu:new Ext.menu.Menu({items:[{text:_("50")},{text:_("100")},{text:_("200")},{text:_("300")},{text:_("500")},{text:_("Unlimited")}]})},{text:_("Upload Slot Limit"),iconCls:"icon-upload-slots",menu:new Ext.menu.Menu({items:[{text:_("0")},{text:_("1")},{text:_("2")},{text:_("3")},{text:_("5")},{text:_("Unlimited")}]})},{id:"auto_managed",text:_("Auto Managed"),checked:false}]})},"-",{text:_("Queue"),iconCls:"icon-queue",menu:new Ext.menu.Menu({items:[{torrentAction:"top",text:_("Top"),iconCls:"icon-top",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"up",text:_("Up"),iconCls:"icon-up",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"down",text:_("Down"),iconCls:"icon-down",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"bottom",text:_("Bottom"),iconCls:"icon-bottom",handler:deluge.menus.onTorrentAction,scope:deluge.menus}]})},"-",{torrentAction:"update",text:_("Update Tracker"),iconCls:"icon-update-tracker",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"edit_trackers",text:_("Edit Trackers"),iconCls:"icon-edit-trackers",handler:deluge.menus.onTorrentAction,scope:deluge.menus},"-",{torrentAction:"remove",text:_("Remove Torrent"),iconCls:"icon-remove",handler:deluge.menus.onTorrentAction,scope:deluge.menus},"-",{torrentAction:"recheck",text:_("Force Recheck"),iconCls:"icon-recheck",handler:deluge.menus.onTorrentAction,scope:deluge.menus},{torrentAction:"move",text:_("Move Storage"),iconCls:"icon-move",handler:deluge.menus.onTorrentAction,scope:deluge.menus}]});Deluge.StatusbarMenu=Ext.extend(Ext.menu.Menu,{setValue:function(b){var c=false;b=(b==0)?-1:b;this.items.each(function(d){if(d.setChecked){d.suspendEvents();if(d.value==b){d.setChecked(true);c=true}else{d.setChecked(false)}d.resumeEvents()}});if(c){return}var a=this.items.get("other");a.suspendEvents();a.setChecked(true);a.resumeEvents()}});deluge.menus.connections=new Deluge.StatusbarMenu({id:"connectionsMenu",items:[{text:"50",value:"50",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"100",value:"100",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"200",value:"200",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"300",value:"300",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:"500",value:"500",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},{text:_("Unlimited"),value:"-1",group:"max_connections_global",checked:false,checkHandler:onLimitChanged},"-",{text:_("Other"),value:"other",group:"max_connections_global",checked:false,checkHandler:onLimitChanged}]});deluge.menus.download=new Deluge.StatusbarMenu({id:"downspeedMenu",items:[{value:"5",text:"5 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"10",text:"10 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"30",text:"30 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"80",text:"80 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"300",text:"300 KiB/s",group:"max_download_speed",checked:false,checkHandler:onLimitChanged},{value:"-1",text:_("Unlimited"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged},"-",{value:"other",text:_("Other"),group:"max_download_speed",checked:false,checkHandler:onLimitChanged}]});deluge.menus.upload=new Deluge.StatusbarMenu({id:"upspeedMenu",items:[{value:"5",text:"5 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"10",text:"10 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"30",text:"30 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"80",text:"80 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"300",text:"300 KiB/s",group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},{value:"-1",text:_("Unlimited"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged},"-",{value:"other",text:_("Other"),group:"max_upload_speed",checked:false,checkHandler:onLimitChanged}]});deluge.menus.filePriorities=new Ext.menu.Menu({id:"filePrioritiesMenu",items:[{id:"expandAll",text:_("Expand All"),iconCls:"icon-expand-all"},"-",{id:"no_download",text:_("Do Not Download"),iconCls:"icon-do-not-download",filePriority:0},{id:"normal",text:_("Normal Priority"),iconCls:"icon-normal",filePriority:1},{id:"high",text:_("High Priority"),iconCls:"icon-high",filePriority:2},{id:"highest",text:_("Highest Priority"),iconCls:"icon-highest",filePriority:5}]});function onLimitChanged(b,a){if(b.value=="other"){}else{config={};config[b.group]=b.value;deluge.client.core.set_config(config,{success:function(){deluge.ui.update()}})}}Deluge.EventsManager=Ext.extend(Ext.util.Observable,{constructor:function(){this.toRegister=[];this.on("login",this.onLogin,this);Deluge.EventsManager.superclass.constructor.call(this)},addListener:function(a,c,b,d){this.addEvents(a);if(/[A-Z]/.test(a.substring(0,1))){if(!deluge.client){this.toRegister.push(a)}else{deluge.client.web.register_event_listener(a)}}Deluge.EventsManager.superclass.addListener.call(this,a,c,b,d)},getEvents:function(){deluge.client.web.get_events({success:this.onGetEventsSuccess,failure:this.onGetEventsFailure,scope:this})},start:function(){Ext.each(this.toRegister,function(a){deluge.client.web.register_event_listener(a)});this.running=true;this.getEvents()},stop:function(){this.running=false},onLogin:function(){this.start();this.on("PluginEnabledEvent",this.onPluginEnabled,this);this.on("PluginDisabledEvent",this.onPluginDisabled,this)},onGetEventsSuccess:function(a){if(!a){return}Ext.each(a,function(d){var c=d[0],b=d[1];b.splice(0,0,c);this.fireEvent.apply(this,b)},this);if(this.running){this.getEvents()}},onGetEventsFailure:function(a){if(this.running){this.getEvents()}}});Deluge.EventsManager.prototype.on=Deluge.EventsManager.prototype.addListener;Deluge.EventsManager.prototype.fire=Deluge.EventsManager.prototype.fireEvent;deluge.events=new Deluge.EventsManager();Ext.namespace("Deluge");Deluge.OptionsManager=Ext.extend(Ext.util.Observable,{constructor:function(a){a=a||{};this.binds={};this.changed={};this.options=(a&&a.options)||{};this.focused=null;this.addEvents({add:true,changed:true,reset:true});this.on("changed",this.onChange,this);Deluge.OptionsManager.superclass.constructor.call(this)},addOptions:function(a){this.options=Ext.applyIf(this.options,a)},bind:function(a,b){this.binds[a]=this.binds[a]||[];this.binds[a].push(b);b._doption=a;b.on("focus",this.onFieldFocus,this);b.on("blur",this.onFieldBlur,this);b.on("change",this.onFieldChange,this);b.on("check",this.onFieldChange,this);return b},commit:function(){this.options=Ext.apply(this.options,this.changed);this.reset()},convertValueType:function(a,b){if(Ext.type(a)!=Ext.type(b)){switch(Ext.type(a)){case"string":b=String(b);break;case"number":b=Number(b);break;case"boolean":if(Ext.type(b)=="string"){b=b.toLowerCase();b=(b=="true"||b=="1"||b=="on")?true:false}else{b=Boolean(b)}break}}return b},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[b]:this.options[b]}else{var a={};Ext.each(arguments,function(c){if(!this.has(c)){return}a[c]=(this.isDirty(c))?this.changed[c]:this.options[c]},this);return a}},getDefault:function(a){return this.options[a]},getDirty:function(){return this.changed},isDirty:function(a){return !Ext.isEmpty(this.changed[a])},has:function(a){return(this.options[a])},reset:function(){this.changed={}},set:function(b,c){if(b===undefined){return}else{if(typeof b=="object"){var a=b;this.options=Ext.apply(this.options,a);for(var b in a){this.onChange(b,a[b])}}else{this.options[b]=c;this.onChange(b,c)}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[d]}this.fireEvent("changed",d,e,b);return}this.changed[d]=e;this.fireEvent("changed",d,e,b)}}},onFieldBlur:function(b,a){if(this.focused==b){this.focused=null}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onFieldFocus:function(b,a){this.focused=b},onChange:function(b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(d){if(d==this.focused){return}d.setValue(c)},this)}});Deluge.MultiOptionsManager=Ext.extend(Deluge.OptionsManager,{constructor:function(a){this.currentId=null;this.stored={};Deluge.MultiOptionsManager.superclass.constructor.call(this,a)},changeId:function(d,b){var c=this.currentId;this.currentId=d;if(!b){for(var a in this.options){if(!this.binds[a]){continue}Ext.each(this.binds[a],function(e){e.setValue(this.get(a))},this)}}return c},commit:function(){this.stored[this.currentId]=Ext.apply(this.stored[this.currentId],this.changed[this.currentId]);this.reset()},get:function(){if(arguments.length==1){var b=arguments[0];return(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}else{if(arguments.length==0){var a={};for(var b in this.options){a[b]=(this.isDirty(b))?this.changed[this.currentId][b]:this.getDefault(b)}return a}else{var a={};Ext.each(arguments,function(c){a[c]=(this.isDirty(c))?this.changed[this.currentId][c]:this.getDefault(c)},this);return a}}},getDefault:function(a){return(this.has(a))?this.stored[this.currentId][a]:this.options[a]},getDirty:function(){return(this.changed[this.currentId])?this.changed[this.currentId]:{}},isDirty:function(a){return(this.changed[this.currentId]&&!Ext.isEmpty(this.changed[this.currentId][a]))},has:function(a){return(this.stored[this.currentId]&&!Ext.isEmpty(this.stored[this.currentId][a]))},reset:function(){if(this.changed[this.currentId]){delete this.changed[this.currentId]}if(this.stored[this.currentId]){delete this.stored[this.currentId]}},resetAll:function(){this.changed={};this.stored={};this.changeId(null)},setDefault:function(c,d){if(c===undefined){return}else{if(d===undefined){for(var b in c){this.setDefault(b,c[b])}}else{var a=this.getDefault(c);d=this.convertValueType(a,d);if(a==d){return}if(!this.stored[this.currentId]){this.stored[this.currentId]={}}this.stored[this.currentId][c]=d;if(!this.isDirty(c)){this.fireEvent("changed",this.currentId,c,d,a)}}}},update:function(d,e){if(d===undefined){return}else{if(e===undefined){for(var c in d){this.update(c,d[c])}}else{if(!this.changed[this.currentId]){this.changed[this.currentId]={}}var a=this.getDefault(d);e=this.convertValueType(a,e);var b=this.get(d);if(b==e){return}if(a==e){if(this.isDirty(d)){delete this.changed[this.currentId][d]}this.fireEvent("changed",this.currentId,d,e,b);return}else{this.changed[this.currentId][d]=e;this.fireEvent("changed",this.currentId,d,e,b)}}}},onFieldChange:function(b,a){this.update(b._doption,b.getValue())},onChange:function(d,b,c,a){if(Ext.isEmpty(this.binds[b])){return}Ext.each(this.binds[b],function(e){if(e==this.focused){return}e.setValue(c)},this)}});Ext.namespace("Deluge.add");Deluge.add.OptionsPanel=Ext.extend(Ext.TabPanel,{torrents:{},constructor:function(a){a=Ext.apply({region:"south",margins:"5 5 5 5",activeTab:0,height:220},a);Deluge.add.OptionsPanel.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.OptionsPanel.superclass.initComponent.call(this);this.files=this.add(new Ext.ux.tree.TreeGrid({layout:"fit",title:_("Files"),rootVisible:false,autoScroll:true,height:170,border:false,animate:false,disabled:true,columns:[{header:_("Filename"),width:275,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:80,dataIndex:"size",renderer:fsize}]}));new Ext.tree.TreeSorter(this.files,{folderSort:true});this.optionsManager=new Deluge.MultiOptionsManager();this.form=this.add({xtype:"form",labelWidth:1,title:_("Options"),bodyStyle:"padding: 5px;",border:false,height:170,disabled:true});var a=this.form.add({xtype:"fieldset",title:_("Download Location"),border:false,autoHeight:true,defaultType:"textfield",labelWidth:1,fieldLabel:""});this.optionsManager.bind("download_location",a.add({fieldLabel:"",name:"download_location",width:400,labelSeparator:""}));var b=this.form.add({border:false,layout:"column",defaultType:"fieldset"});a=b.add({title:_("Allocation"),border:false,autoHeight:true,defaultType:"radio",width:100});this.optionsManager.bind("compact_allocation",a.add({xtype:"radiogroup",columns:1,vertical:true,labelSeparator:"",items:[{name:"compact_allocation",value:false,inputValue:false,boxLabel:_("Full"),fieldLabel:"",labelSeparator:""},{name:"compact_allocation",value:true,inputValue:true,boxLabel:_("Compact"),fieldLabel:"",labelSeparator:"",}]}));a=b.add({title:_("Bandwidth"),border:false,autoHeight:true,labelWidth:100,width:200,defaultType:"spinnerfield"});this.optionsManager.bind("max_download_speed",a.add({fieldLabel:_("Max Down Speed"),name:"max_download_speed",width:60}));this.optionsManager.bind("max_upload_speed",a.add({fieldLabel:_("Max Up Speed"),name:"max_upload_speed",width:60}));this.optionsManager.bind("max_connections",a.add({fieldLabel:_("Max Connections"),name:"max_connections",width:60}));this.optionsManager.bind("max_upload_slots",a.add({fieldLabel:_("Max Upload Slots"),name:"max_upload_slots",width:60}));a=b.add({title:_("General"),border:false,autoHeight:true,defaultType:"checkbox"});this.optionsManager.bind("add_paused",a.add({name:"add_paused",boxLabel:_("Add In Paused State"),fieldLabel:"",labelSeparator:"",}));this.optionsManager.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",boxLabel:_("Prioritize First/Last Pieces"),fieldLabel:"",labelSeparator:"",}));this.form.on("render",this.onFormRender,this)},onFormRender:function(a){a.layout=new Ext.layout.FormLayout();a.layout.setContainer(a);a.doLayout()},addTorrent:function(c){this.torrents[c.info_hash]=c;var b={};this.walkFileTree(c.files_tree,function(e,g,h,f){if(g!="file"){return}b[h[0]]=h[2]},this);var a=[];Ext.each(Ext.keys(b),function(e){a[e]=b[e]});var d=this.optionsManager.changeId(c.info_hash,true);this.optionsManager.setDefault("file_priorities",a);this.optionsManager.changeId(d,true)},clear:function(){this.clearFiles();this.optionsManager.resetAll()},clearFiles:function(){var a=this.files.getRootNode();if(!a.hasChildNodes()){return}a.cascade(function(b){if(!b.parentNode||!b.getOwnerTree()){return}b.remove()})},getDefaults:function(){var a=["add_paused","compact_allocation","download_location","max_connections_per_torrent","max_download_speed_per_torrent","max_upload_slots_per_torrent","max_upload_speed_per_torrent","prioritize_first_last_pieces"];deluge.client.core.get_config_values(a,{success:function(c){var b={file_priorities:[],add_paused:c.add_paused,compact_allocation:c.compact_allocation,download_location:c.download_location,max_connections:c.max_connections_per_torrent,max_download_speed:c.max_download_speed_per_torrent,max_upload_slots:c.max_upload_slots_per_torrent,max_upload_speed:c.max_upload_speed_per_torrent,prioritize_first_last_pieces:c.prioritize_first_last_pieces};this.optionsManager.options=b;this.optionsManager.resetAll()},scope:this})},getFilename:function(a){return this.torrents[a]["filename"]},getOptions:function(a){var c=this.optionsManager.changeId(a,true);var b=this.optionsManager.get();this.optionsManager.changeId(c,true);Ext.each(b.file_priorities,function(e,d){b.file_priorities[d]=(e)?1:0});return b},setTorrent:function(b){if(!b){return}this.torrentId=b;this.optionsManager.changeId(b);this.clearFiles();var a=this.files.getRootNode();var c=this.optionsManager.get("file_priorities");this.walkFileTree(this.torrents[b]["files_tree"],function(d,f,i,e){if(f=="dir"){var h=new Ext.tree.TreeNode({text:d,checked:true});h.on("checkchange",this.onFolderCheck,this);e.appendChild(h);return h}else{var g=new Ext.tree.TreeNode({filename:d,fileindex:i[0],text:d,size:fsize(i[1]),leaf:true,checked:c[i[0]],iconCls:"x-deluge-file",uiProvider:Ext.tree.ColumnNodeUI});g.on("checkchange",this.onNodeCheck,this);e.appendChild(g)}},this,a);a.firstChild.expand()},walkFileTree:function(g,h,e,d){for(var a in g){var f=g[a];var c=(Ext.type(f)=="object")?"dir":"file";if(e){var b=h.apply(e,[a,c,f,d])}else{var b=h(a,c,f,d)}if(c=="dir"){this.walkFileTree(f,h,e,b)}}},onFolderCheck:function(c,b){var a=this.optionsManager.get("file_priorities");c.cascade(function(d){if(!d.ui.checkbox){d.attributes.checked=b}else{d.ui.checkbox.checked=b}a[d.attributes.fileindex]=b},this);this.optionsManager.setDefault("file_priorities",a)},onNodeCheck:function(c,b){var a=this.optionsManager.get("file_priorities");a[c.attributes.fileindex]=b;this.optionsManager.update("file_priorities",a)}});Deluge.add.Window=Ext.extend(Ext.Window,{initComponent:function(){Deluge.add.Window.superclass.initComponent.call(this);this.addEvents("beforeadd","add")},createTorrentId:function(){return new Date().getTime()}});Deluge.add.AddWindow=Ext.extend(Deluge.add.Window,{constructor:function(a){a=Ext.apply({title:_("Add Torrents"),layout:"border",width:470,height:450,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-add-window-icon"},a);Deluge.add.AddWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.AddWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,this);function a(c,d,b){if(b.data.info_hash){return String.format('<div class="x-deluge-add-torrent-name">{0}</div>',c)}else{return String.format('<div class="x-deluge-add-torrent-name-loading">{0}</div>',c)}}this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"info_hash",mapping:1},{name:"text",mapping:2}],id:0}),columns:[{id:"torrent",width:150,sortable:true,renderer:a,dataIndex:"text"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"torrent",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{iconCls:"x-deluge-add-file",text:_("File"),handler:this.onFile,scope:this},{text:_("Url"),iconCls:"icon-add-url",handler:this.onUrl,scope:this},{text:_("Infohash"),iconCls:"icon-add-magnet",disabled:true},"->",{text:_("Remove"),iconCls:"icon-remove",handler:this.onRemove,scope:this}]})});this.optionsPanel=this.add(new Deluge.add.OptionsPanel());this.on("hide",this.onHide,this);this.on("show",this.onShow,this)},clear:function(){this.grid.getStore().removeAll();this.optionsPanel.clear()},onAddClick:function(){var a=[];if(!this.grid){return}this.grid.getStore().each(function(b){var c=b.get("info_hash");a.push({path:this.optionsPanel.getFilename(c),options:this.optionsPanel.getOptions(c)})},this);deluge.client.web.add_torrents(a,{success:function(b){}});this.clear();this.hide()},onCancelClick:function(){this.clear();this.hide()},onFile:function(){this.file.show()},onHide:function(){this.optionsPanel.setActiveTab(0);this.optionsPanel.files.setDisabled(true);this.optionsPanel.form.setDisabled(true)},onRemove:function(){var a=this.grid.getSelectionModel();if(!a.hasSelection()){return}var b=a.getSelected();this.grid.getStore().remove(b);this.optionsPanel.clear();if(this.torrents&&this.torrents[b.id]){delete this.torrents[b.id]}},onSelect:function(b,c,a){this.optionsPanel.setTorrent(a.get("info_hash"));this.optionsPanel.files.setDisabled(false);this.optionsPanel.form.setDisabled(false)},onShow:function(){if(!this.url){this.url=new Deluge.add.UrlWindow();this.url.on("beforeadd",this.onTorrentBeforeAdd,this);this.url.on("add",this.onTorrentAdd,this)}if(!this.file){this.file=new Deluge.add.FileWindow();this.file.on("beforeadd",this.onTorrentBeforeAdd,this);this.file.on("add",this.onTorrentAdd,this)}this.optionsPanel.getDefaults()},onTorrentBeforeAdd:function(b,c){var a=this.grid.getStore();a.loadData([[b,null,c]],true)},onTorrentAdd:function(a,c){var b=this.grid.getStore().getById(a);if(!c){Ext.MessageBox.show({title:_("Error"),msg:_("Not a valid torrent"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});this.grid.getStore().remove(b)}else{b.set("info_hash",c.info_hash);b.set("text",c.name);this.grid.getStore().commitChanges();this.optionsPanel.addTorrent(c)}},onUrl:function(a,b){this.url.show()}});deluge.add=new Deluge.add.AddWindow();Ext.namespace("Ext.deluge.add");Deluge.add.FileWindow=Ext.extend(Deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:115,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from File"),iconCls:"x-deluge-add-file"},a);Deluge.add.FileWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:35,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"torrentFile",width:280,emptyText:_("Select a torrent"),fieldLabel:_("File"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onAddClick:function(c,b){if(this.form.getForm().isValid()){this.torrentId=this.createTorrentId();this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your torrent..."),failure:this.onUploadFailure,success:this.onUploadSuccess,scope:this});var a=this.form.getForm().findField("torrentFile").value;a=a.split("\\").slice(-1)[0];this.fireEvent("beforeadd",this.torrentId,a)}},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",this.torrentId,d)},onUploadFailure:function(a,b){this.hide()},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=b.result.files[0];this.form.getForm().findField("torrentFile").setValue("");Deluge.Client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a})}}});Ext.namespace("Deluge.add");Deluge.add.UrlWindow=Ext.extend(Deluge.add.Window,{constructor:function(a){a=Ext.apply({layout:"fit",width:350,height:155,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",modal:true,plain:true,title:_("Add from Url"),iconCls:"x-deluge-add-url-window-icon"},a);Deluge.add.UrlWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.add.UrlWindow.superclass.initComponent.call(this);this.addButton(_("Add"),this.onAddClick,this);var a=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55});this.urlField=a.add({fieldLabel:_("Url"),id:"url",name:"url",anchor:"100%"});this.urlField.on("specialkey",this.onAdd,this);this.cookieField=a.add({fieldLabel:_("Cookies"),id:"cookies",name:"cookies",anchor:"100%"});this.cookieField.on("specialkey",this.onAdd,this)},onAddClick:function(f,d){if((f.id=="url"||f.id=="cookies")&&d.getKey()!=d.ENTER){return}var f=this.urlField;var b=f.getValue();var c=this.cookieField.getValue();var a=this.createTorrentId();deluge.client.web.download_torrent_from_url(b,c,{success:this.onDownload,scope:this,torrentId:a});this.hide();this.fireEvent("beforeadd",a,b)},onDownload:function(a,c,d,b){this.urlField.setValue("");deluge.client.web.get_torrent_info(a,{success:this.onGotInfo,scope:this,filename:a,torrentId:b.options.torrentId})},onGotInfo:function(d,c,a,b){d.filename=b.options.filename;this.fireEvent("add",b.options.torrentId,d)}});Ext.namespace("Ext.ux.util");Ext.ux.util.RpcClient=Ext.extend(Ext.util.Observable,{_components:[],_methods:[],_requests:{},_url:null,_optionKeys:["scope","success","failure"],constructor:function(a){Ext.ux.util.RpcClient.superclass.constructor.call(this,a);this._url=a.url||null;this._id=0;this.addEvents("connected","error");this.reloadMethods()},reloadMethods:function(){Ext.each(this._components,function(a){delete this[a]},this);this._execute("system.listMethods",{success:this._setMethods,scope:this})},_execute:function(c,a){a=a||{};a.params=a.params||[];a.id=this._id;var b=Ext.encode({method:c,params:a.params,id:a.id});this._id++;return Ext.Ajax.request({url:this._url,method:"POST",success:this._onSuccess,failure:this._onFailure,scope:this,jsonData:b,options:a})},_onFailure:function(b,a){var c=a.options;errorObj={id:c.id,result:null,error:{msg:"HTTP: "+b.status+" "+b.statusText,code:255}};this.fireEvent("error",errorObj,b,a);if(Ext.type(c.failure)!="function"){return}if(c.scope){c.failure.call(c.scope,errorObj,b,a)}else{c.failure(errorObj,b,a)}},_onSuccess:function(c,a){var b=Ext.decode(c.responseText);var d=a.options;if(b.error){this.fireEvent("error",b,c,a);if(Ext.type(d.failure)!="function"){return}if(d.scope){d.failure.call(d.scope,b,c,a)}else{d.failure(b,c,a)}}else{if(Ext.type(d.success)!="function"){return}if(d.scope){d.success.call(d.scope,b.result,b,c,a)}else{d.success(b.result,b,c,a)}}},_parseArgs:function(c){var e=[];Ext.each(c,function(f){e.push(f)});var b=e[e.length-1];if(Ext.type(b)=="object"){var d=Ext.keys(b),a=false;Ext.each(this._optionKeys,function(f){if(d.indexOf(f)>-1){a=true}});if(a){e.remove(b)}else{b={}}}else{b={}}b.params=e;return b},_setMethods:function(b){var d={},a=this;Ext.each(b,function(h){var g=h.split(".");var e=d[g[0]]||{};var f=function(){var i=a._parseArgs(arguments);return a._execute(h,i)};e[g[1]]=f;d[g[0]]=e});for(var c in d){a[c]=d[c]}this._components=Ext.keys(d);this.fireEvent("connected",this)}});(function(){var a=function(c,d,b){return c+":"+b.data.port};Deluge.AddConnectionWindow=Ext.extend(Ext.Window,{constructor:function(b){b=Ext.apply({layout:"fit",width:300,height:195,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Add Connection"),iconCls:"x-deluge-add-window-icon"},b);Deluge.AddConnectionWindow.superclass.constructor.call(this,b)},initComponent:function(){Deluge.AddConnectionWindow.superclass.initComponent.call(this);this.addEvents("hostadded");this.addButton(_("Close"),this.hide,this);this.addButton(_("Add"),this.onAddClick,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",id:"connectionAddForm",baseCls:"x-plain",labelWidth:55});this.hostField=this.form.add({fieldLabel:_("Host"),id:"host",name:"host",anchor:"100%",value:""});this.portField=this.form.add({fieldLabel:_("Port"),id:"port",xtype:"spinnerfield",name:"port",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:65535},value:"58846",anchor:"50%"});this.usernameField=this.form.add({fieldLabel:_("Username"),id:"username",name:"username",anchor:"100%",value:""});this.passwordField=this.form.add({fieldLabel:_("Password"),anchor:"100%",id:"_password",name:"_password",inputType:"password",value:""})},onAddClick:function(){var d=this.hostField.getValue();var b=this.portField.getValue();var e=this.usernameField.getValue();var c=this.passwordField.getValue();deluge.client.web.add_host(d,b,e,c,{success:function(f){if(!f[0]){Ext.MessageBox.show({title:_("Error"),msg:"Unable to add host: "+f[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.fireEvent("hostadded")}this.hide()},scope:this})},onHide:function(){this.form.getForm().reset()}});Deluge.ConnectionManager=Ext.extend(Ext.Window,{layout:"fit",width:300,height:220,bodyStyle:"padding: 10px 5px;",buttonAlign:"right",closeAction:"hide",closable:true,plain:true,title:_("Connection Manager"),iconCls:"x-deluge-connect-window-icon",initComponent:function(){Deluge.ConnectionManager.superclass.initComponent.call(this);this.on("hide",this.onHide,this);this.on("show",this.onShow,this);deluge.events.on("disconnect",this.onDisconnect,this);deluge.events.on("login",this.onLogin,this);deluge.events.on("logout",this.onLogout,this);this.addButton(_("Close"),this.onClose,this);this.addButton(_("Connect"),this.onConnect,this);this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"status",mapping:3},{name:"host",mapping:1},{name:"port",mapping:2},{name:"version",mapping:4}],id:0}),columns:[{header:_("Status"),width:65,sortable:true,renderer:fplain,dataIndex:"status"},{id:"host",header:_("Host"),width:150,sortable:true,renderer:a,dataIndex:"host"},{header:_("Version"),width:75,sortable:true,renderer:fplain,dataIndex:"version"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onSelect,scope:this},selectionchange:{fn:this.onSelectionChanged,scope:this}}}),autoExpandColumn:"host",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({buttons:[{id:"cm-add",cls:"x-btn-text-icon",text:_("Add"),iconCls:"icon-add",handler:this.onAddClick,scope:this},{id:"cm-remove",cls:"x-btn-text-icon",text:_("Remove"),iconCls:"icon-remove",handler:this.onRemove,disabled:true,scope:this},"->",{id:"cm-stop",cls:"x-btn-text-icon",text:_("Stop Daemon"),iconCls:"icon-error",handler:this.onStop,disabled:true,scope:this}]})});this.update=this.update.createDelegate(this)},checkConnected:function(){deluge.client.web.connected({success:function(b){if(b){deluge.events.fire("connect")}else{this.show()}},scope:this})},disconnect:function(){deluge.events.fire("disconnect")},loadHosts:function(){deluge.client.web.get_hosts({success:this.onGetHosts,scope:this})},update:function(){this.grid.getStore().each(function(b){deluge.client.web.get_host_status(b.id,{success:this.onGetHostStatus,scope:this})},this)},updateButtons:function(c){var d=this.buttons[1],b=c.get("status");if(b==_("Connected")){d.enable();d.setText(_("Disconnect"))}else{if(b==_("Offline")){d.disable()}else{d.enable();d.setText(_("Connect"))}}if(b==_("Offline")){if(c.get("host")=="127.0.0.1"||c.get("host")=="localhost"){this.stopHostButton.enable();this.stopHostButton.setText(_("Start Daemon"))}else{this.stopHostButton.disable()}}else{this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}},onAddClick:function(b,c){if(!this.addWindow){this.addWindow=new Deluge.AddConnectionWindow();this.addWindow.on("hostadded",this.onHostAdded,this)}this.addWindow.show()},onHostAdded:function(){this.loadHosts()},onClose:function(b){if(this.running){window.clearInterval(this.running)}this.hide()},onConnect:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")==_("Connected")){deluge.client.web.disconnect({success:function(e){this.update(this);Deluge.Events.fire("disconnect")},scope:this})}else{var d=b.id;deluge.client.web.connect(d,{success:function(e){deluge.client.reloadMethods();deluge.client.on("connected",function(f){deluge.events.fire("connect")},this,{single:true})}});this.hide()}},onDisconnect:function(){if(this.isVisible()){return}this.show()},onGetHosts:function(b){this.grid.getStore().loadData(b);Ext.each(b,function(c){deluge.client.web.get_host_status(c[0],{success:this.onGetHostStatus,scope:this})},this)},onGetHostStatus:function(c){var b=this.grid.getStore().getById(c[0]);b.set("status",c[3]);b.set("version",c[4]);b.commit();if(this.grid.getSelectionModel().getSelected()==b){this.updateButtons(b)}},onHide:function(){if(this.running){window.clearInterval(this.running)}},onLogin:function(){if(deluge.config.first_login){Ext.MessageBox.confirm("Change password","As this is your first login, we recommend that you change your password. Would you like to do this now?",function(b){this.checkConnected();if(b=="yes"){deluge.preferences.show();deluge.preferences.selectPage("Interface")}deluge.client.web.set_config({first_login:false})},this)}else{this.checkConnected()}},onLogout:function(){this.disconnect();if(!this.hidden&&this.rendered){this.hide()}},onRemove:function(c){var b=this.grid.getSelectionModel().getSelected();if(!b){return}deluge.client.web.remove_host(b.id,{success:function(d){if(!d){Ext.MessageBox.show({title:_("Error"),msg:d[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}else{this.grid.getStore().remove(b)}},scope:this})},onSelect:function(c,d,b){this.selectedRow=d},onSelectionChanged:function(c){var b=c.getSelected();if(c.hasSelection()){this.removeHostButton.enable();this.stopHostButton.enable();this.stopHostButton.setText(_("Stop Daemon"))}else{this.removeHostButton.disable();this.stopHostButton.disable()}this.updateButtons(b)},onShow:function(){if(!this.addHostButton){var b=this.grid.getBottomToolbar();this.addHostButton=b.items.get("cm-add");this.removeHostButton=b.items.get("cm-remove");this.stopHostButton=b.items.get("cm-stop")}this.loadHosts();this.running=window.setInterval(this.update,2000,this)},onStop:function(c,d){var b=this.grid.getSelectionModel().getSelected();if(!b){return}if(b.get("status")=="Offline"){deluge.client.web.start_daemon(b.get("port"))}else{deluge.client.web.stop_daemon(b.id,{success:function(e){if(!e[0]){Ext.MessageBox.show({title:_("Error"),msg:e[1],buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"})}}})}}});deluge.connectionManager=new Deluge.ConnectionManager()})();(function(){Ext.namespace("Deluge.details");Deluge.details.TabPanel=Ext.extend(Ext.TabPanel,{constructor:function(a){a=Ext.apply({region:"south",id:"torrentDetails",split:true,height:220,minSize:100,collapsible:true,margins:"0 5 5 5",activeTab:0},a);Deluge.details.TabPanel.superclass.constructor.call(this,a)},clear:function(){this.items.each(function(a){if(a.clear){a.clear.defer(100,a);a.disable()}})},update:function(a){var b=deluge.torrents.getSelected();if(!b){this.clear();return}this.items.each(function(c){if(c.disabled){c.enable()}});a=a||this.getActiveTab();if(a.update){a.update(b.id)}},onRender:function(b,a){Deluge.details.TabPanel.superclass.onRender.call(this,b,a);deluge.events.on("disconnect",this.clear,this);deluge.torrents.on("rowclick",this.onTorrentsClick,this);this.on("tabchange",this.onTabChange,this);deluge.torrents.getSelectionModel().on("selectionchange",function(c){if(!c.hasSelection()){this.clear()}},this)},onTabChange:function(a,b){this.update(b)},onTorrentsClick:function(a,c,b){this.update()}});deluge.details=new Deluge.details.TabPanel()})();Deluge.details.StatusTab=Ext.extend(Ext.Panel,{title:_("Status"),autoScroll:true,onRender:function(b,a){Deluge.details.StatusTab.superclass.onRender.call(this,b,a);this.progressBar=this.add({xtype:"progress",cls:"x-deluge-status-progressbar"});this.status=this.add({cls:"x-deluge-status",id:"deluge-details-status",border:false,width:1000,listeners:{render:{fn:function(c){c.load({url:deluge.config.base+"render/tab_status.html",text:_("Loading")+"..."});c.getUpdater().on("update",this.onPanelUpdate,this)},scope:this}}})},clear:function(){this.progressBar.updateProgress(0," ");for(var a in this.fields){this.fields[a].innerHTML=""}},update:function(a){if(!this.fields){this.getFields()}deluge.client.core.get_torrent_status(a,Deluge.Keys.Status,{success:this.onRequestComplete,scope:this})},onPanelUpdate:function(b,a){this.fields={};Ext.each(Ext.query("dd",this.status.body.dom),function(c){this.fields[c.className]=c},this)},onRequestComplete:function(a){seeders=a.total_seeds>-1?a.num_seeds+" ("+a.total_seeds+")":a.num_seeds;peers=a.total_peers>-1?a.num_peers+" ("+a.total_peers+")":a.num_peers;var b={downloaded:fsize(a.total_done),uploaded:fsize(a.total_uploaded),share:a.ratio.toFixed(3),announce:ftime(a.next_announce),tracker_status:a.tracker_status,downspeed:(a.download_payload_rate)?fspeed(a.download_payload_rate):"0.0 KiB/s",upspeed:(a.upload_payload_rate)?fspeed(a.upload_payload_rate):"0.0 KiB/s",eta:ftime(a.eta),pieces:a.num_pieces+" ("+fsize(a.piece_length)+")",seeders:seeders,peers:peers,avail:a.distributed_copies.toFixed(3),active_time:ftime(a.active_time),seeding_time:ftime(a.seeding_time),seed_rank:a.seed_rank,time_added:fdate(a.time_added)};b.auto_managed=_((a.is_auto_managed)?"True":"False");b.downloaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";b.uploaded+=" ("+((a.total_payload_download)?fsize(a.total_payload_download):"0.0 KiB")+")";for(var c in this.fields){this.fields[c].innerHTML=b[c]}var d=a.state+" "+a.progress.toFixed(2)+"%";this.progressBar.updateProgress(a.progress/100,d)}});deluge.details.add(new Deluge.details.StatusTab());Deluge.details.DetailsTab=Ext.extend(Ext.Panel,{title:_("Details"),fields:{},queuedItems:{},oldData:{},initComponent:function(){Deluge.details.DetailsTab.superclass.initComponent.call(this);this.addItem("torrent_name",_("Name"));this.addItem("hash",_("Hash"));this.addItem("path",_("Path"));this.addItem("size",_("Total Size"));this.addItem("files",_("# of files"));this.addItem("comment",_("Comment"));this.addItem("status",_("Status"));this.addItem("tracker",_("Tracker"))},onRender:function(b,a){Deluge.details.DetailsTab.superclass.onRender.call(this,b,a);this.body.setStyle("padding","10px");this.dl=Ext.DomHelper.append(this.body,{tag:"dl"},true);for(var c in this.queuedItems){this.doAddItem(c,this.queuedItems[c])}},addItem:function(b,a){if(!this.rendered){this.queuedItems[b]=a}else{this.doAddItem(b,a)}},doAddItem:function(b,a){Ext.DomHelper.append(this.dl,{tag:"dt",cls:b,html:a+":"});this.fields[b]=Ext.DomHelper.append(this.dl,{tag:"dd",cls:b,html:""},true)},clear:function(){if(!this.fields){return}for(var a in this.fields){this.fields[a].dom.innerHTML=""}},update:function(a){deluge.client.core.get_torrent_status(a,Deluge.Keys.Details,{success:this.onRequestComplete,scope:this,torrentId:a})},onRequestComplete:function(e,c,a,b){var d={torrent_name:e.name,hash:b.options.torrentId,path:e.save_path,size:fsize(e.total_size),files:e.num_files,status:e.tracker_status,tracker:e.tracker,comment:e.comment};for(var f in this.fields){if(!d[f]){continue}if(d[f]==this.oldData[f]){continue}this.fields[f].dom.innerHTML=Ext.escapeHTML(d[f])}this.oldData=d}});deluge.details.add(new Deluge.details.DetailsTab());(function(){function b(d){var c=d*100;return Deluge.progressBar(c,this.col.width,c.toFixed(2)+"%",0)}function a(c){if(isNaN(c)){return""}return String.format('<div class="{0}">{1}</div>',FILE_PRIORITY_CSS[c],_(FILE_PRIORITY[c]))}Deluge.details.FilesTab=Ext.extend(Ext.ux.tree.TreeGrid,{constructor:function(c){c=Ext.apply({title:_("Files"),rootVisible:false,autoScroll:true,selModel:new Ext.tree.MultiSelectionModel(),columns:[{header:_("Filename"),width:330,dataIndex:"filename"},{xtype:"tgrendercolumn",header:_("Size"),width:150,dataIndex:"size",renderer:fsize},{xtype:"tgrendercolumn",header:_("Progress"),width:150,dataIndex:"progress",renderer:b},{xtype:"tgrendercolumn",header:_("Priority"),width:150,dataIndex:"priority",renderer:a}],root:new Ext.tree.TreeNode({text:"Files"})},c);Deluge.details.FilesTab.superclass.constructor.call(this,c)},initComponent:function(){Deluge.details.FilesTab.superclass.initComponent.call(this)},onRender:function(d,c){Deluge.details.FilesTab.superclass.onRender.call(this,d,c);deluge.menus.filePriorities.on("itemclick",this.onItemClick,this);this.on("contextmenu",this.onContextMenu,this);this.sorter=new Ext.tree.TreeSorter(this,{folderSort:true})},clear:function(){var c=this.getRootNode();if(!c.hasChildNodes()){return}c.cascade(function(e){var d=e.parentNode;if(!d){return}if(!d.ownerTree){return}d.removeChild(e)})},update:function(c){if(this.torrentId!=c){this.clear();this.torrentId=c}deluge.client.web.get_torrent_files(c,{success:this.onRequestComplete,scope:this,torrentId:c})},onContextMenu:function(d,f){f.stopEvent();var c=this.getSelectionModel();if(c.getSelectedNodes().length<2){c.clearSelections();d.select()}deluge.menus.filePriorities.showAt(f.getPoint())},onItemClick:function(j,i){switch(j.id){case"expandAll":this.expandAll();break;default:var h={};function c(e){if(Ext.isEmpty(e.attributes.fileIndex)){return}h[e.attributes.fileIndex]=e.attributes.priority}this.getRootNode().cascade(c);var d=this.getSelectionModel().getSelectedNodes();Ext.each(d,function(k){if(!k.isLeaf()){function e(l){if(Ext.isEmpty(l.attributes.fileIndex)){return}h[l.attributes.fileIndex]=j.filePriority}k.cascade(e)}else{if(!Ext.isEmpty(k.attributes.fileIndex)){h[k.attributes.fileIndex]=j.filePriority;return}}});var g=new Array(Ext.keys(h).length);for(var f in h){g[f]=h[f]}deluge.client.core.set_torrent_file_priorities(this.torrentId,g,{success:function(){Ext.each(d,function(e){e.setColumnValue(3,j.filePriority)})},scope:this});break}},onRequestComplete:function(f,e){function d(j,h){for(var g in j.contents){var i=j.contents[g];var k=h.findChild("id",g);if(i.type=="dir"){if(!k){k=new Ext.tree.TreeNode({id:g,text:g,filename:g,size:i.size,progress:i.progress,priority:i.priority});h.appendChild(k)}d(i,k)}else{if(!k){k=new Ext.tree.TreeNode({id:g,filename:g,text:g,fileIndex:i.index,size:i.size,progress:i.progress,priority:i.priority,leaf:true,iconCls:"x-deluge-file",uiProvider:Ext.ux.tree.TreeGridNodeUI});h.appendChild(k)}}}}var c=this.getRootNode();d(f,c);c.firstChild.expand()}});deluge.details.add(new Deluge.details.FilesTab())})();(function(){function a(e){return String.format('<img src="/flag/{0}" />',e)}function c(g,h,f){var e=(f.data.seed==1024)?"x-deluge-seed":"x-deluge-peer";return String.format('<div class="{0}">{1}</div>',e,g)}function d(f){var e=(f*100).toFixed(0);return Deluge.progressBar(e,this.width-8,e+"%")}function b(e){var f=e.match(/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\:(\d+)/);return((((((+f[1])*256)+(+f[2]))*256)+(+f[3]))*256)+(+f[4])}Deluge.details.PeersTab=Ext.extend(Ext.grid.GridPanel,{constructor:function(e){e=Ext.apply({title:_("Peers"),cls:"x-deluge-peers",store:new Ext.data.SimpleStore({fields:[{name:"country"},{name:"address",sortType:b},{name:"client"},{name:"progress",type:"float"},{name:"downspeed",type:"int"},{name:"upspeed",type:"int"},{name:"seed",type:"int"}],id:0}),columns:[{header:"&nbsp;",width:30,sortable:true,renderer:a,dataIndex:"country"},{header:"Address",width:125,sortable:true,renderer:c,dataIndex:"address"},{header:"Client",width:125,sortable:true,renderer:fplain,dataIndex:"client"},{header:"Progress",width:150,sortable:true,renderer:d,dataIndex:"progress"},{header:"Down Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"downspeed"},{header:"Up Speed",width:100,sortable:true,renderer:fspeed,dataIndex:"upspeed"}],stripeRows:true,deferredRender:false,autoScroll:true},e);Deluge.details.PeersTab.superclass.constructor.call(this,e)},onRender:function(f,e){Deluge.details.PeersTab.superclass.onRender.call(this,f,e)},clear:function(){this.getStore().loadData([])},update:function(e){deluge.client.core.get_torrent_status(e,Deluge.Keys.Peers,{success:this.onRequestComplete,scope:this})},onRequestComplete:function(g,f){if(!g){return}var e=new Array();Ext.each(g.peers,function(h){e.push([h.country,h.ip,h.client,h.progress,h.down_speed,h.up_speed,h.seed])},this);this.getStore().loadData(e)}});deluge.details.add(new Deluge.details.PeersTab())})();Deluge.details.OptionsTab=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({autoScroll:true,bodyStyle:"padding: 5px;",border:false,cls:"x-deluge-options",defaults:{autoHeight:true,labelWidth:1,defaultType:"checkbox"},deferredRender:false,layout:"column",title:_("Options")},a);Deluge.details.OptionsTab.superclass.constructor.call(this,a)},initComponent:function(){Deluge.details.OptionsTab.superclass.initComponent.call(this);this.fieldsets={},this.fields={};this.optionsManager=new Deluge.MultiOptionsManager({options:{max_download_speed:-1,max_upload_speed:-1,max_connections:-1,max_upload_slots:-1,auto_managed:false,stop_at_ratio:false,stop_ratio:2,remove_at_ratio:false,move_completed:null,"private":false,prioritize_first_last:false}});this.fieldsets.bandwidth=this.add({xtype:"fieldset",defaultType:"spinnerfield",bodyStyle:"padding: 5px",layout:"table",layoutConfig:{columns:3},labelWidth:150,style:"margin-left: 10px; margin-right: 5px; padding: 5px",title:_("Bandwidth"),width:250});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Download Speed"),forId:"max_download_speed",cls:"x-deluge-options-label"});this.fields.max_download_speed=this.fieldsets.bandwidth.add({id:"max_download_speed",name:"max_download_speed",width:70,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Speed"),forId:"max_upload_speed",cls:"x-deluge-options-label"});this.fields.max_upload_speed=this.fieldsets.bandwidth.add({id:"max_upload_speed",name:"max_upload_speed",width:70,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}});this.fieldsets.bandwidth.add({xtype:"label",text:_("KiB/s"),style:"margin-left: 10px"});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Connections"),forId:"max_connections",cls:"x-deluge-options-label"});this.fields.max_connections=this.fieldsets.bandwidth.add({id:"max_connections",name:"max_connections",width:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});this.fieldsets.bandwidth.add({xtype:"label",text:_("Max Upload Slots"),forId:"max_upload_slots",cls:"x-deluge-options-label"});this.fields.max_upload_slots=this.fieldsets.bandwidth.add({id:"max_upload_slots",name:"max_upload_slots",width:70,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},colspan:2});this.fieldsets.queue=this.add({xtype:"fieldset",title:_("Queue"),style:"margin-left: 5px; margin-right: 5px; padding: 5px",width:210,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaults:{fieldLabel:"",labelSeparator:""}});this.fields.auto_managed=this.fieldsets.queue.add({xtype:"checkbox",fieldLabel:"",labelSeparator:"",name:"is_auto_managed",boxLabel:_("Auto Managed"),width:200,colspan:2});this.fields.stop_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"stop_at_ratio",width:120,boxLabel:_("Stop seed at ratio"),handler:this.onStopRatioChecked,scope:this});this.fields.stop_ratio=this.fieldsets.queue.add({xtype:"spinnerfield",id:"stop_ratio",name:"stop_ratio",disabled:true,width:50,value:2,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});this.fields.remove_at_ratio=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"remove_at_ratio",ctCls:"x-deluge-indent-checkbox",bodyStyle:"padding-left: 10px",boxLabel:_("Remove at ratio"),disabled:true,colspan:2});this.fields.move_completed=this.fieldsets.queue.add({fieldLabel:"",labelSeparator:"",id:"move_completed",boxLabel:_("Move Completed"),colspan:2});this.rightColumn=this.add({border:false,autoHeight:true,style:"margin-left: 5px",width:210});this.fieldsets.general=this.rightColumn.add({xtype:"fieldset",autoHeight:true,defaultType:"checkbox",title:_("General"),layout:"form"});this.fields["private"]=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Private"),id:"private",disabled:true});this.fields.prioritize_first_last=this.fieldsets.general.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Prioritize First/Last"),id:"prioritize_first_last"});for(var a in this.fields){this.optionsManager.bind(a,this.fields[a])}this.buttonPanel=this.rightColumn.add({layout:"hbox",xtype:"panel",border:false});this.buttonPanel.add({id:"edit_trackers",xtype:"button",text:_("Edit Trackers"),cls:"x-btn-text-icon",iconCls:"x-deluge-edit-trackers",border:false,width:100,handler:this.onEditTrackers,scope:this});this.buttonPanel.add({id:"apply",xtype:"button",text:_("Apply"),style:"margin-left: 10px;",border:false,width:100,handler:this.onApply,scope:this})},onRender:function(b,a){Deluge.details.OptionsTab.superclass.onRender.call(this,b,a);this.layout=new Ext.layout.ColumnLayout();this.layout.setContainer(this);this.doLayout()},clear:function(){if(this.torrentId==null){return}this.torrentId=null;this.optionsManager.changeId(null)},reset:function(){if(this.torrentId){this.optionsManager.reset()}},update:function(a){if(this.torrentId&&!a){this.clear()}if(!a){return}if(this.torrentId!=a){this.torrentId=a;this.optionsManager.changeId(a)}deluge.client.core.get_torrent_status(a,Deluge.Keys.Options,{success:this.onRequestComplete,scope:this})},onApply:function(){var b=this.optionsManager.getDirty();if(!Ext.isEmpty(b.prioritize_first_last)){var a=b.prioritize_first_last;deluge.client.core.set_torrent_prioritize_first_last(this.torrentId,a,{success:function(){this.optionsManager.set("prioritize_first_last",a)},scope:this})}deluge.client.core.set_torrent_options([this.torrentId],b,{success:function(){this.optionsManager.commit()},scope:this})},onEditTrackers:function(){deluge.editTrackers.show()},onStopRatioChecked:function(b,a){this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)},onRequestComplete:function(c,b){this.fields["private"].setValue(c["private"]);this.fields["private"].setDisabled(true);delete c["private"];c.auto_managed=c.is_auto_managed;this.optionsManager.setDefault(c);var a=this.optionsManager.get("stop_at_ratio");this.fields.remove_at_ratio.setDisabled(!a);this.fields.stop_ratio.setDisabled(!a)}});deluge.details.add(new Deluge.details.OptionsTab());(function(){Deluge.AddTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Add Tracker"),width:375,height:150,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Deluge.AddTracker.superclass.constructor.call(this,a)},initComponent:function(){Deluge.AddTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Add"),this.onAddClick,this);this.addEvents("add");this.form=this.add({xtype:"form",defaultType:"textarea",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Trackers"),name:"trackers",anchor:"100%"}]})},onAddClick:function(){var b=this.form.getForm().findField("trackers").getValue();b=b.split("\n");var a=[];Ext.each(b,function(c){if(Ext.form.VTypes.url(c)){a.push(c)}},this);this.fireEvent("add",a);this.hide();this.form.getForm().findField("trackers").setValue("")},onCancelClick:function(){this.form.getForm().findField("trackers").setValue("");this.hide()}});Deluge.EditTracker=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Tracker"),width:375,height:110,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:false},a);Deluge.EditTracker.superclass.constructor.call(this,a)},initComponent:function(){Deluge.EditTracker.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Save"),this.onSaveClick,this);this.on("hide",this.onHide,this);this.form=this.add({xtype:"form",defaultType:"textfield",baseCls:"x-plain",labelWidth:55,items:[{fieldLabel:_("Tracker"),name:"tracker",anchor:"100%"}]})},show:function(a){Deluge.EditTracker.superclass.show.call(this);this.record=a;this.form.getForm().findField("tracker").setValue(a.data.url)},onCancelClick:function(){this.hide()},onHide:function(){this.form.getForm().findField("tracker").setValue("")},onSaveClick:function(){var a=this.form.getForm().findField("tracker").getValue();this.record.set("url",a);this.record.commit();this.hide()}});Deluge.EditTrackers=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Edit Trackers"),width:350,height:220,bodyStyle:"padding: 5px",layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-edit-trackers",plain:true,resizable:true},a);Deluge.EditTrackers.superclass.constructor.call(this,a)},initComponent:function(){Deluge.EditTrackers.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancelClick,this);this.addButton(_("Ok"),this.onOkClick,this);this.addEvents("save");this.on("show",this.onShow,this);this.on("save",this.onSave,this);this.addWindow=new Deluge.AddTracker();this.addWindow.on("add",this.onAddTrackers,this);this.editWindow=new Deluge.EditTracker();this.grid=this.add({xtype:"grid",store:new Ext.data.SimpleStore({fields:[{name:"tier",mapping:0},{name:"url",mapping:1}]}),columns:[{header:_("Tier"),width:50,sortable:true,renderer:fplain,dataIndex:"tier"},{id:"tracker",header:_("Tracker"),sortable:true,renderer:fplain,dataIndex:"url"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{selectionchange:{fn:this.onSelect,scope:this}}}),autoExpandColumn:"tracker",deferredRender:false,autoScroll:true,margins:"0 0 0 0",bbar:new Ext.Toolbar({items:[{text:_("Up"),iconCls:"icon-up",handler:this.onUpClick,scope:this},{text:_("Down"),iconCls:"icon-down",handler:this.onDownClick,scope:this},"->",{text:_("Add"),iconCls:"icon-add",handler:this.onAddClick,scope:this},{text:_("Edit"),iconCls:"icon-edit-trackers",handler:this.onEditClick,scope:this},{text:_("Remove"),iconCls:"icon-remove",handler:this.onRemoveClick,scope:this}]})})},onAddClick:function(){this.addWindow.show()},onAddTrackers:function(b){var a=this.grid.getStore();Ext.each(b,function(d){var e=false,c=-1;a.each(function(f){if(f.get("tier")>c){c=f.get("tier")}if(d==f.get("tracker")){e=true;return false}},this);if(!e){a.loadData([[c+1,d]],true)}},this)},onCancelClick:function(){this.hide()},onEditClick:function(){var a=this.grid.getSelectionModel().getSelected();this.editWindow.show(a)},onHide:function(){this.grid.getStore().removeAll()},onOkClick:function(){var a=[];this.grid.getStore().each(function(b){a.push({tier:b.get("tier"),url:b.get("url")})},this);deluge.client.core.set_torrent_trackers(this.torrentId,a,{failure:this.onSaveFail,scope:this});this.hide()},onRemove:function(){var a=this.grid.getSelectionModel().getSelected();this.grid.getStore().remove(a)},onRequestComplete:function(a){var b=[];Ext.each(a.trackers,function(c){b.push([c.tier,c.url])});this.grid.getStore().loadData(b)},onSaveFail:function(){},onSelect:function(a){if(a.hasSelection()){this.grid.getBottomToolbar().items.get(4).enable()}},onShow:function(){this.grid.getBottomToolbar().items.get(4).disable();var a=deluge.torrents.getSelected();this.torrentId=a.id;deluge.client.core.get_torrent_status(a.id,["trackers"],{success:this.onRequestComplete,scope:this})}});deluge.editTrackers=new Deluge.EditTrackers()})();Ext.namespace("Deluge");Deluge.FileBrowser=Ext.extend(Ext.Window,{title:_("File Browser"),width:500,height:400,initComponent:function(){Deluge.FileBrowser.superclass.initComponent.call(this);this.add({xtype:"toolbar",items:[{text:_("Back"),iconCls:"icon-back"},{text:_("Forward"),iconCls:"icon-forward"},{text:_("Up"),iconCls:"icon-up"},{text:_("Home"),iconCls:"icon-home"}]})}});Deluge.LoginWindow=Ext.extend(Ext.Window,{firstShow:true,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closable:false,closeAction:"hide",iconCls:"x-deluge-login-window-icon",layout:"fit",modal:true,plain:true,resizable:false,title:_("Login"),width:300,height:120,initComponent:function(){Deluge.LoginWindow.superclass.initComponent.call(this);this.on("show",this.onShow,this);this.addButton({text:_("Login"),handler:this.onLogin,scope:this});this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:55,width:300,defaults:{width:200},defaultType:"textfield",});this.passwordField=this.form.add({xtype:"textfield",fieldLabel:_("Password"),id:"_password",name:"password",inputType:"password"});this.passwordField.on("specialkey",this.onSpecialKey,this)},logout:function(){deluge.events.fire("logout");deluge.client.auth.delete_session({success:function(a){this.show(true)},scope:this})},show:function(a){if(this.firstShow){deluge.client.on("error",this.onClientError,this);this.firstShow=false}if(a){return Deluge.LoginWindow.superclass.show.call(this)}deluge.client.auth.check_session({success:function(b){if(b){deluge.events.fire("login")}else{this.show(true)}},failure:function(b){this.show(true)},scope:this})},onSpecialKey:function(b,a){if(a.getKey()==13){this.onLogin()}},onLogin:function(){var a=this.passwordField;deluge.client.auth.login(a.getValue(),{success:function(b){if(b){deluge.events.fire("login");this.hide();a.setRawValue("")}else{Ext.MessageBox.show({title:_("Login Failed"),msg:_("You entered an incorrect password"),buttons:Ext.MessageBox.OK,modal:false,fn:function(){a.focus()},icon:Ext.MessageBox.WARNING,iconCls:"x-deluge-icon-warning"})}},scope:this})},onClientError:function(c,b,a){if(c.error.code==1){deluge.events.fire("logout");this.show(true)}},onShow:function(){this.passwordField.focus(false,150);this.passwordField.setRawValue("")}});deluge.login=new Deluge.LoginWindow();Ext.namespace("Deluge");Deluge.MoveStorage=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Move Storage"),width:375,height:110,layout:"fit",buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-move-storage",plain:true,resizable:false},a);Deluge.MoveStorage.superclass.constructor.call(this,a)},initComponent:function(){Deluge.MoveStorage.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Move"),this.onMove,this);this.form=this.add({xtype:"form",border:false,defaultType:"textfield",width:300,bodyStyle:"padding: 5px"});this.moveLocation=this.form.add({fieldLabel:_("Location"),name:"location",width:240});this.form.add({xtype:"button",text:_("Browse"),handler:function(){if(!this.fileBrowser){this.fileBrowser=new Deluge.FileBrowser()}this.fileBrowser.show()},scope:this})},hide:function(){Deluge.MoveStorage.superclass.hide.call(this);this.torrentIds=null},show:function(a){Deluge.MoveStorage.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide()},onMove:function(){var a=this.moveLocation.getValue();deluge.client.core.move_storage(this.torrentIds,a);this.hide()}});deluge.moveStorage=new Deluge.MoveStorage();Deluge.Plugin=Ext.extend(Ext.util.Observable,{name:null,constructor:function(a){this.name=a.name;this.addEvents({enabled:true,disabled:true});this.isDelugePlugin=true;Deluge.Plugins[this.name]=this;Deluge.Plugin.superclass.constructor.call(this,a)},disable:function(){this.fireEvent("disabled",this);if(this.onDisable){this.onDisable()}},enable:function(){this.fireEvent("enable",this);if(this.onEnable){this.onEnable()}}});Ext.namespace("Deluge.preferences");PreferencesRecord=Ext.data.Record.create([{name:"name",type:"string"}]);Deluge.preferences.PreferencesWindow=Ext.extend(Ext.Window,{currentPage:null,title:_("Preferences"),layout:"border",width:485,height:500,buttonAlign:"right",closeAction:"hide",closable:true,iconCls:"x-deluge-preferences",plain:true,resizable:false,initComponent:function(){Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this);this.categoriesGrid=this.add({xtype:"grid",region:"west",title:_("Categories"),store:new Ext.data.Store(),columns:[{id:"name",renderer:fplain,dataIndex:"name"}],sm:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPageSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 0 5 5",cmargins:"5 0 5 5",width:120,collapsible:true});this.configPanel=this.add({type:"container",autoDestroy:false,region:"center",layout:"card",margins:"5 5 5 5",cmargins:"5 5 5 5"});this.addButton(_("Close"),this.onClose,this);this.addButton(_("Apply"),this.onApply,this);this.addButton(_("Ok"),this.onOk,this);this.pages={};this.optionsManager=new Deluge.OptionsManager();this.on("afterrender",this.onAfterRender,this);this.on("show",this.onShow,this)},onApply:function(b){var c=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(c)){deluge.client.core.set_config(c,{success:this.onSetConfig,scope:this})}for(var a in this.pages){if(this.pages[a].onApply){this.pages[a].onApply()}}},getOptionsManager:function(){return this.optionsManager},addPage:function(c){var a=this.categoriesGrid.getStore();var b=c.title;a.add([new PreferencesRecord({name:b})]);c.bodyStyle="margin: 5px";this.pages[b]=this.configPanel.add(c);return this.pages[b]},removePage:function(c){var b=c.title;var a=this.categoriesGrid.getStore();a.removeAt(a.find("name",b));this.configPanel.remove(c);delete this.pages[c.title]},selectPage:function(b){var a=this.configPanel.items.indexOf(this.pages[b]);this.configPanel.getLayout().setActiveItem(a);this.currentPage=b},onGotConfig:function(a){this.getOptionsManager().set(a)},onPageSelect:function(a,c,b){this.selectPage(b.get("name"))},onSetConfig:function(){this.getOptionsManager().commit()},onAfterRender:function(){if(!this.categoriesGrid.getSelectionModel().hasSelection()){this.categoriesGrid.getSelectionModel().selectFirstRow()}this.configPanel.getLayout().setActiveItem(0)},onShow:function(){if(!deluge.client.core){return}deluge.client.core.get_config({success:this.onGotConfig,scope:this})},onClose:function(){this.hide()},onOk:function(){deluge.client.core.set_config(this.optionsManager.getDirty());this.hide()}});deluge.preferences=new Deluge.preferences.PreferencesWindow();Ext.namespace("Deluge.preferences");Deluge.preferences.Downloads=Ext.extend(Ext.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Downloads"),layout:"form",autoHeight:true,width:320},a);Deluge.preferences.Downloads.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Downloads.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Folders"),labelWidth:150,defaultType:"togglefield",autoHeight:true,labelAlign:"top",width:300,style:"margin-bottom: 5px; padding-bottom: 5px;"});b.bind("download_location",a.add({xtype:"textfield",name:"download_location",fieldLabel:_("Download to"),width:280}));var c=a.add({name:"move_completed_path",fieldLabel:_("Move completed to"),width:280});b.bind("move_completed",c.toggle);b.bind("move_completed_path",c.input);c=a.add({name:"torrentfiles_location",fieldLabel:_("Copy of .torrent files to"),width:280});b.bind("copy_torrent_file",c.toggle);b.bind("torrentfiles_location",c.input);c=a.add({name:"autoadd_location",fieldLabel:_("Autoadd .torrent files from"),width:280});b.bind("autoadd_enable",c.toggle);b.bind("autoadd_location",c.input);a=this.add({xtype:"fieldset",border:false,title:_("Allocation"),autoHeight:true,labelWidth:1,defaultType:"radiogroup",style:"margin-bottom: 5px; margin-top: 0; padding-bottom: 5px; padding-top: 0;",width:240,});b.bind("compact_allocation",a.add({name:"compact_allocation",width:200,labelSeparator:"",disabled:true,defaults:{width:80,height:22,name:"compact_allocation"},items:[{boxLabel:_("Use Full"),inputValue:false},{boxLabel:_("Use Compact"),inputValue:true}]}));a=this.add({xtype:"fieldset",border:false,title:_("Options"),autoHeight:true,labelWidth:1,defaultType:"checkbox",style:"margin-bottom: 0; padding-bottom: 0;",width:280});b.bind("prioritize_first_last_pieces",a.add({name:"prioritize_first_last_pieces",labelSeparator:"",height:22,boxLabel:_("Prioritize first and last pieces of torrent")}));b.bind("add_paused",a.add({name:"add_paused",labelSeparator:"",height:22,boxLabel:_("Add torrents in Paused state")}));this.on("show",this.onShow,this)},onShow:function(){Deluge.preferences.Downloads.superclass.onShow.call(this)}});deluge.preferences.addPage(new Deluge.preferences.Downloads());Ext.namespace("Deluge.preferences");Deluge.preferences.Network=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Network"),layout:"form"},a);Deluge.preferences.Network.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Network.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Incoming Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_port",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_port",height:22,listeners:{check:{fn:function(d,c){this.listenPorts.setDisabled(c)},scope:this}}}));this.listenPorts=a.add({xtype:"uxspinnergroup",name:"listen_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("listen_ports",this.listenPorts);a=this.add({xtype:"fieldset",border:false,title:_("Outgoing Ports"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("random_outgoing_ports",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Use Random Ports"),name:"random_outgoing_ports",height:22,listeners:{check:{fn:function(d,c){this.outgoingPorts.setDisabled(c)},scope:this}}}));this.outgoingPorts=a.add({xtype:"uxspinnergroup",name:"outgoing_ports",fieldLabel:"",labelSeparator:"",colCfg:{labelWidth:40,style:"margin-right: 10px;"},items:[{fieldLabel:"From",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},},{fieldLabel:"To",strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}]});b.bind("outgoing_ports",this.outgoingPorts);a=this.add({xtype:"fieldset",border:false,title:_("Network Interface"),style:"margin-bottom: 5px; padding-bottom: 0px;",autoHeight:true,labelWidth:1,defaultType:"textfield"});b.bind("listen_interface",a.add({name:"listen_interface",fieldLabel:"",labelSeparator:"",width:200}));a=this.add({xtype:"fieldset",border:false,title:_("TOS"),style:"margin-bottom: 5px; padding-bottom: 0px;",bodyStyle:"margin: 0px; padding: 0px",autoHeight:true,defaultType:"textfield"});b.bind("peer_tos",a.add({name:"peer_tos",fieldLabel:_("Peer TOS Byte"),width:80}));a=this.add({xtype:"fieldset",border:false,title:_("Network Extras"),autoHeight:true,layout:"table",layoutConfig:{columns:3},defaultType:"checkbox"});b.bind("upnp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("UPnP"),name:"upnp"}));b.bind("natpmp",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("NAT-PMP"),ctCls:"x-deluge-indent-checkbox",name:"natpmp"}));b.bind("utpex",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("Peer Exchange"),ctCls:"x-deluge-indent-checkbox",name:"utpex"}));b.bind("lsd",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("LSD"),name:"lsd"}));b.bind("dht",a.add({fieldLabel:"",labelSeparator:"",boxLabel:_("DHT"),ctCls:"x-deluge-indent-checkbox",name:"dht"}))}});deluge.preferences.addPage(new Deluge.preferences.Network());Ext.namespace("Deluge.preferences");Deluge.preferences.Encryption=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Encryption"),layout:"form"},a);Deluge.preferences.Encryption.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Encryption.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,defaultType:"combo"});b.bind("enc_in_policy",a.add({fieldLabel:_("Inbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_out_policy",a.add({fieldLabel:_("Outbound"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Forced")],[1,_("Enabled")],[2,_("Disabled")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_level",a.add({fieldLabel:_("Level"),mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("Handshake")],[1,_("Full Stream")],[2,_("Either")]]}),triggerAction:"all",valueField:"id",displayField:"text"}));b.bind("enc_prefer_rc4",a.add({xtype:"checkbox",name:"enc_prefer_rc4",height:40,hideLabel:true,boxLabel:_("Encrypt entire stream")}))}});deluge.preferences.addPage(new Deluge.preferences.Encryption());Ext.namespace("Deluge.preferences");Deluge.preferences.Bandwidth=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Bandwidth"),layout:"form",labelWidth:10},a);Deluge.preferences.Bandwidth.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Bandwidth.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Global Bandwidth Usage"),labelWidth:200,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",autoHeight:true});b.bind("max_connections_global",a.add({name:"max_connections_global",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_global",a.add({name:"max_upload_slots_global",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed",a.add({name:"max_download_speed",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed",a.add({name:"max_upload_speed",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_half_open_connections",a.add({name:"max_half_open_connections",fieldLabel:_("Maximum Half-Open Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_connections_per_second",a.add({name:"max_connections_per_second",fieldLabel:_("Maximum Connection Attempts per Second"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));a=this.add({xtype:"fieldset",border:false,title:"",defaultType:"checkbox",style:"padding-top: 0px; padding-bottom: 5px; margin-top: 0px; margin-bottom: 0px;",autoHeight:true});b.bind("ignore_limits_on_local_network",a.add({name:"ignore_limits_on_local_network",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Ignore limits on local network"),}));b.bind("rate_limit_ip_overhead",a.add({name:"rate_limit_ip_overhead",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Rate limit IP overhead"),}));a=this.add({xtype:"fieldset",border:false,title:_("Per Torrent Bandwidth Usage"),style:"margin-bottom: 0px; padding-bottom: 0px;",defaultType:"spinnerfield",labelWidth:200,autoHeight:true});b.bind("max_connections_per_torrent",a.add({name:"max_connections_per_torrent",fieldLabel:_("Maximum Connections"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_upload_slots_per_torrent",a.add({name:"max_upload_slots_per_torrent",fieldLabel:_("Maximum Upload Slots"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));b.bind("max_download_speed_per_torrent",a.add({name:"max_download_speed_per_torrent",fieldLabel:_("Maximum Download Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}));b.bind("max_upload_speed_per_torrent",a.add({name:"max_upload_speed_per_torrent",fieldLabel:_("Maximum Upload Speed (KiB/s)"),width:80,value:-1,strategy:{xtype:"number",decimalPrecision:1,minValue:-1,maxValue:99999}}))}});deluge.preferences.addPage(new Deluge.preferences.Bandwidth());Ext.namespace("Deluge.preferences");Deluge.preferences.Interface=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Interface"),layout:"form"},a);Deluge.preferences.Interface.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Interface.superclass.initComponent.call(this);var c=this.optionsManager=new Deluge.OptionsManager();this.on("show",this.onShow,this);var a=this.add({xtype:"fieldset",border:false,title:_("Interface"),style:"margin-bottom: 0px; padding-bottom: 5px; padding-top: 5px",autoHeight:true,labelWidth:1,defaultType:"checkbox"});c.bind("show_session_speed",a.add({name:"show_session_speed",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show session speed in titlebar")}));c.bind("sidebar_show_zero",a.add({name:"sidebar_show_zero",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show filters with zero torrents")}));c.bind("sidebar_show_trackers",a.add({name:"sidebar_show_trackers",height:22,fieldLabel:"",labelSeparator:"",boxLabel:_("Show trackers with zero torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Password"),style:"margin-bottom: 0px; padding-bottom: 0px; padding-top: 5px",autoHeight:true,labelWidth:110,defaultType:"textfield",defaults:{width:180,inputType:"password"}});this.oldPassword=a.add({name:"old_password",fieldLabel:_("Old Password")});this.newPassword=a.add({name:"new_password",fieldLabel:_("New Password")});this.confirmPassword=a.add({name:"confirm_password",fieldLabel:_("Confirm Password")});var b=a.add({xtype:"panel",autoHeight:true,border:false,width:320,bodyStyle:"padding-left: 230px"});b.add({xtype:"button",text:_("Change"),listeners:{click:{fn:this.onPasswordChange,scope:this}}});a=this.add({xtype:"fieldset",border:false,title:_("Server"),style:"margin-top: 0px; padding-top: 0px; margin-bottom: 0px; padding-bottom: 0px",autoHeight:true,labelWidth:110,defaultType:"spinnerfield",defaults:{width:80,}});c.bind("session_timeout",a.add({name:"session_timeout",fieldLabel:_("Session Timeout"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));c.bind("port",a.add({name:"port",fieldLabel:_("Port"),strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}}));this.httpsField=c.bind("https",a.add({xtype:"checkbox",name:"https",hideLabel:true,width:280,height:22,boxLabel:_("Use SSL (paths relative to Deluge config folder)")}));this.httpsField.on("check",this.onSSLCheck,this);this.pkeyField=c.bind("pkey",a.add({xtype:"textfield",disabled:true,name:"pkey",width:180,fieldLabel:_("Private Key")}));this.certField=c.bind("cert",a.add({xtype:"textfield",disabled:true,name:"cert",width:180,fieldLabel:_("Certificate")}))},onApply:function(){var a=this.optionsManager.getDirty();if(!Ext.isObjectEmpty(a)){deluge.client.web.set_config(a,{success:this.onSetConfig,scope:this})}},onGotConfig:function(a){this.optionsManager.set(a)},onPasswordChange:function(){var b=this.newPassword.getValue();if(b!=this.confirmPassword.getValue()){Ext.MessageBox.show({title:_("Invalid Password"),msg:_("Your passwords don't match!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});return}var a=this.oldPassword.getValue();deluge.client.auth.change_password(a,b,{success:function(c){if(!c){Ext.MessageBox.show({title:_("Password"),msg:_("Your old password was incorrect!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.ERROR,iconCls:"x-deluge-icon-error"});this.oldPassword.setValue("")}else{Ext.MessageBox.show({title:_("Change Successful"),msg:_("Your password was successfully changed!"),buttons:Ext.MessageBox.OK,modal:false,icon:Ext.MessageBox.INFO,iconCls:"x-deluge-icon-info"});this.oldPassword.setValue("");this.newPassword.setValue("");this.confirmPassword.setValue("")}},scope:this})},onSetConfig:function(){this.optionsManager.commit()},onShow:function(){Deluge.preferences.Interface.superclass.onShow.call(this);deluge.client.web.get_config({success:this.onGotConfig,scope:this})},onSSLCheck:function(b,a){this.pkeyField.setDisabled(!a);this.certField.setDisabled(!a)}});deluge.preferences.addPage(new Deluge.preferences.Interface());Ext.namespace("Deluge.preferences");Deluge.preferences.Other=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Other"),layout:"form"},a);Deluge.preferences.Other.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Other.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Updates"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:22,name:"new_release_check",boxLabel:_("Be alerted about new releases")}));a=this.add({xtype:"fieldset",border:false,title:_("System Information"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});a.add({xtype:"panel",border:false,bodyCfg:{html:_("Help us improve Deluge by sending us your Python version, PyGTK version, OS and processor types. Absolutely no other information is sent.")}});b.bind("send_info",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Yes, please send anonymous statistics"),name:"send_info"}));a=this.add({xtype:"fieldset",border:false,title:_("GeoIP Database"),autoHeight:true,labelWidth:80,defaultType:"textfield"});b.bind("geoip_db_location",a.add({name:"geoip_db_location",fieldLabel:_("Location"),width:200}))}});deluge.preferences.addPage(new Deluge.preferences.Other());Ext.namespace("Deluge.preferences");Deluge.preferences.Daemon=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Daemon"),layout:"form"},a);Deluge.preferences.Daemon.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Daemon.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Port"),autoHeight:true,defaultType:"spinnerfield"});b.bind("daemon_port",a.add({fieldLabel:_("Daemon port"),name:"daemon_port",value:58846,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,title:_("Connections"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("allow_remote",a.add({fieldLabel:"",height:22,labelSeparator:"",boxLabel:_("Allow Remote Connections"),name:"allow_remote"}));a=this.add({xtype:"fieldset",border:false,title:_("Other"),autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("new_release_check",a.add({fieldLabel:"",labelSeparator:"",height:40,boxLabel:_("Periodically check the website for new releases"),id:"new_release_check"}))}});deluge.preferences.addPage(new Deluge.preferences.Daemon());Ext.namespace("Deluge.preferences");Deluge.preferences.Queue=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Queue"),layout:"form"},a);Deluge.preferences.Queue.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Queue.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("General"),style:"padding-top: 5px;",autoHeight:true,labelWidth:1,defaultType:"checkbox"});b.bind("queue_new_to_top",a.add({fieldLabel:"",labelSeparator:"",height:22,boxLabel:_("Queue new torrents to top"),name:"queue_new_to_top"}));a=this.add({xtype:"fieldset",border:false,title:_("Active Torrents"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px;",});b.bind("max_active_limit",a.add({fieldLabel:_("Total Active"),name:"max_active_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_downloading",a.add({fieldLabel:_("Total Active Downloading"),name:"max_active_downloading",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("max_active_seeding",a.add({fieldLabel:_("Total Active Seeding"),name:"max_active_seeding",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("dont_count_slow_torrents",a.add({xtype:"checkbox",name:"dont_count_slow_torrents",height:40,hideLabel:true,boxLabel:_("Do not count slow torrents")}));a=this.add({xtype:"fieldset",border:false,title:_("Seeding"),autoHeight:true,labelWidth:150,defaultType:"spinnerfield",style:"margin-bottom: 0px; padding-bottom: 0px; margin-top: 0; padding-top: 0;",});b.bind("share_ratio_limit",a.add({fieldLabel:_("Share Ratio Limit"),name:"share_ratio_limit",value:8,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_ratio_limit",a.add({fieldLabel:_("Share Time Ratio"),name:"seed_time_ratio_limit",value:3,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("seed_time_limit",a.add({fieldLabel:_("Seed Time (m)"),name:"seed_time_limit",value:5,width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));a=this.add({xtype:"fieldset",border:false,autoHeight:true,layout:"table",layoutConfig:{columns:2},labelWidth:0,defaultType:"checkbox",defaults:{fieldLabel:"",labelSeparator:""}});this.stopAtRatio=a.add({name:"stop_seed_at_ratio",boxLabel:_("Stop seeding when share ratio reaches:")});this.stopAtRatio.on("check",this.onStopRatioCheck,this);b.bind("stop_seed_at_ratio",this.stopAtRatio);this.stopRatio=a.add({xtype:"spinnerfield",name:"stop_seed_ratio",ctCls:"x-deluge-indent-checkbox",disabled:true,value:2,width:60,strategy:{xtype:"number",minValue:-1,maxValue:99999,incrementValue:0.1,alternateIncrementValue:1,decimalPrecision:1}});b.bind("stop_seed_ratio",this.stopRatio);this.removeAtRatio=a.add({name:"remove_seed_at_ratio",ctCls:"x-deluge-indent-checkbox",boxLabel:_("Remove torrent when share ratio is reached"),disabled:true,colspan:2});b.bind("remove_seed_at_ratio",this.removeAtRatio)},onStopRatioCheck:function(b,a){this.stopRatio.setDisabled(!a);this.removeAtRatio.setDisabled(!a)}});deluge.preferences.addPage(new Deluge.preferences.Queue());Ext.namespace("Deluge.preferences");Deluge.preferences.ProxyField=Ext.extend(Ext.form.FieldSet,{constructor:function(a){a=Ext.apply({border:false,autoHeight:true,labelWidth:70},a);Deluge.preferences.ProxyField.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.ProxyField.superclass.initComponent.call(this);this.type=this.add({xtype:"combo",fieldLabel:_("Type"),name:"type",mode:"local",width:150,store:new Ext.data.SimpleStore({fields:["id","text"],data:[[0,_("None")],[1,_("Socksv4")],[2,_("Socksv5")],[3,_("Socksv5 with Auth")],[4,_("HTTP")],[5,_("HTTP with Auth")],]}),value:0,triggerAction:"all",valueField:"id",displayField:"text"});this.hostname=this.add({xtype:"textfield",name:"hostname",fieldLabel:_("Host"),width:220});this.port=this.add({xtype:"spinnerfield",name:"port",fieldLabel:_("Port"),width:80,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999}});this.username=this.add({xtype:"textfield",name:"username",fieldLabel:_("Username"),width:220});this.password=this.add({xtype:"textfield",name:"password",fieldLabel:_("Password"),inputType:"password",width:220});this.type.on("change",this.onFieldChange,this);this.type.on("select",this.onTypeSelect,this);this.setting=false},getName:function(){return this.initialConfig.name},getValue:function(){return{type:this.type.getValue(),hostname:this.hostname.getValue(),port:Number(this.port.getValue()),username:this.username.getValue(),password:this.password.getValue()}},setValue:function(c){this.setting=true;this.type.setValue(c.type);var b=this.type.getStore().find("id",c.type);var a=this.type.getStore().getAt(b);this.hostname.setValue(c.hostname);this.port.setValue(c.port);this.username.setValue(c.username);this.password.setValue(c.password);this.onTypeSelect(this.type,a,b);this.setting=false},onFieldChange:function(e,d,c){if(this.setting){return}var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)},onTypeSelect:function(d,a,b){var c=a.get("id");if(c>0){this.hostname.show();this.port.show()}else{this.hostname.hide();this.port.hide()}if(c==3||c==5){this.username.show();this.password.show()}else{this.username.hide();this.password.hide()}}});Deluge.preferences.Proxy=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Proxy"),layout:"form"},a);Deluge.preferences.Proxy.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Proxy.superclass.initComponent.call(this);this.peer=this.add(new Deluge.preferences.ProxyField({title:_("Peer"),name:"peer"}));this.peer.on("change",this.onProxyChange,this);this.web_seed=this.add(new Deluge.preferences.ProxyField({title:_("Web Seed"),name:"web_seed"}));this.web_seed.on("change",this.onProxyChange,this);this.tracker=this.add(new Deluge.preferences.ProxyField({title:_("Tracker"),name:"tracker"}));this.tracker.on("change",this.onProxyChange,this);this.dht=this.add(new Deluge.preferences.ProxyField({title:_("DHT"),name:"dht"}));this.dht.on("change",this.onProxyChange,this);deluge.preferences.getOptionsManager().bind("proxies",this)},getValue:function(){return{dht:this.dht.getValue(),peer:this.peer.getValue(),tracker:this.tracker.getValue(),web_seed:this.web_seed.getValue()}},setValue:function(b){for(var a in b){this[a].setValue(b[a])}},onProxyChange:function(e,d,c){var b=this.getValue();var a=Ext.apply({},b);a[e.getName()]=c;this.fireEvent("change",this,b,a)}});deluge.preferences.addPage(new Deluge.preferences.Proxy());Ext.namespace("Deluge.preferences");Deluge.preferences.Cache=Ext.extend(Ext.form.FormPanel,{constructor:function(a){a=Ext.apply({border:false,title:_("Cache"),layout:"form"},a);Deluge.preferences.Cache.superclass.constructor.call(this,a)},initComponent:function(){Deluge.preferences.Cache.superclass.initComponent.call(this);var b=deluge.preferences.getOptionsManager();var a=this.add({xtype:"fieldset",border:false,title:_("Settings"),autoHeight:true,labelWidth:180,defaultType:"spinnerfield"});b.bind("cache_size",a.add({fieldLabel:_("Cache Size (16 KiB Blocks)"),name:"cache_size",width:60,value:512,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}));b.bind("cache_expiry",a.add({fieldLabel:_("Cache Expiry (seconds)"),name:"cache_expiry",width:60,value:60,strategy:{xtype:"number",decimalPrecision:0,minValue:-1,maxValue:99999},}))}});deluge.preferences.addPage(new Deluge.preferences.Cache());Ext.namespace("Deluge.preferences");Deluge.preferences.InstallPluginWindow=Ext.extend(Ext.Window,{height:115,width:350,bodyStyle:"padding: 10px 5px;",buttonAlign:"center",closeAction:"hide",iconCls:"x-deluge-install-plugin",layout:"fit",modal:true,plain:true,title:_("Install Plugin"),initComponent:function(){Deluge.add.FileWindow.superclass.initComponent.call(this);this.addButton(_("Install"),this.onInstall,this);this.form=this.add({xtype:"form",baseCls:"x-plain",labelWidth:70,autoHeight:true,fileUpload:true,items:[{xtype:"fileuploadfield",id:"pluginEgg",emptyText:_("Select an egg"),fieldLabel:_("Plugin Egg"),name:"file",buttonCfg:{text:_("Browse")+"..."}}]})},onInstall:function(b,a){this.form.getForm().submit({url:"/upload",waitMsg:_("Uploading your plugin..."),success:this.onUploadSuccess,scope:this})},onUploadPlugin:function(d,c,a,b){this.fireEvent("pluginadded")},onUploadSuccess:function(c,b){this.hide();if(b.result.success){var a=this.form.getForm().findField("pluginEgg").value;var d=b.result.files[0];this.form.getForm().findField("pluginEgg").setValue("");deluge.client.web.upload_plugin(a,d,{success:this.onUploadPlugin,scope:this,filename:a})}}});Deluge.preferences.Plugins=Ext.extend(Ext.Panel,{constructor:function(a){a=Ext.apply({border:false,title:_("Plugins"),layout:"border",height:400,cls:"x-deluge-plugins"},a);Deluge.preferences.Plugins.superclass.constructor.call(this,a)},pluginTemplate:new Ext.Template('<dl class="singleline"><dt>Author:</dt><dd>{author}</dd><dt>Version:</dt><dd>{version}</dd><dt>Author Email:</dt><dd>{email}</dd><dt>Homepage:</dt><dd>{homepage}</dd><dt>Details:</dt><dd>{details}</dd></dl>'),initComponent:function(){Deluge.preferences.Plugins.superclass.initComponent.call(this);this.defaultValues={version:"",email:"",homepage:"",details:""};this.pluginTemplate.compile();var b=function(d,e,c){e.css+=" x-grid3-check-col-td";return'<div class="x-grid3-check-col'+(d?"-on":"")+'"> </div>'};this.grid=this.add({xtype:"grid",region:"center",store:new Ext.data.SimpleStore({fields:[{name:"enabled",mapping:0},{name:"plugin",mapping:1}]}),columns:[{id:"enabled",header:_("Enabled"),width:50,sortable:true,renderer:b,dataIndex:"enabled"},{id:"plugin",header:_("Plugin"),sortable:true,dataIndex:"plugin"}],stripeRows:true,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onPluginSelect,scope:this}}}),autoExpandColumn:"plugin",deferredRender:false,autoScroll:true,margins:"5 5 5 5",bbar:new Ext.Toolbar({items:[{cls:"x-btn-text-icon",iconCls:"x-deluge-install-plugin",text:_("Install"),handler:this.onInstallPluginWindow,scope:this},"->",{cls:"x-btn-text-icon",text:_("Find More"),iconCls:"x-deluge-find-more",handler:this.onFindMorePlugins,scope:this}]})});var a=this.add({xtype:"fieldset",border:false,region:"south",title:_("Info"),autoHeight:true,labelWidth:1});this.pluginInfo=a.add({xtype:"panel",border:false,bodyCfg:{style:"margin-left: 10px"}});this.on("show",this.onShow,this);this.pluginInfo.on("render",this.onPluginInfoRender,this);this.grid.on("cellclick",this.onCellClick,this);deluge.preferences.on("show",this.onPreferencesShow,this);deluge.events.on("PluginDisabledEvent",this.onPluginDisabled,this);deluge.events.on("PluginEnabledEvent",this.onPluginEnabled,this)},disablePlugin:function(a){deluge.client.core.disable_plugin(a)},enablePlugin:function(a){deluge.client.core.enable_plugin(a)},setInfo:function(b){if(!this.pluginInfo.rendered){return}var a=b||this.defaultValues;this.pluginInfo.body.dom.innerHTML=this.pluginTemplate.apply(a)},updatePlugins:function(){deluge.client.web.get_plugins({success:this.onGotPlugins,scope:this})},updatePluginsGrid:function(){var a=[];Ext.each(this.availablePlugins,function(b){if(this.enabledPlugins.indexOf(b)>-1){a.push([true,b])}else{a.push([false,b])}},this);this.grid.getStore().loadData(a)},onCellClick:function(b,f,a,d){if(a!=0){return}var c=b.getStore().getAt(f);c.set("enabled",!c.get("enabled"));c.commit();if(c.get("enabled")){this.enablePlugin(c.get("plugin"))}else{this.disablePlugin(c.get("plugin"))}},onFindMorePlugins:function(){window.open("http://dev.deluge-torrent.org/wiki/Plugins")},onGotPlugins:function(a){this.enabledPlugins=a.enabled_plugins;this.availablePlugins=a.available_plugins;this.setInfo();this.updatePluginsGrid()},onGotPluginInfo:function(b){var a={author:b.Author,version:b.Version,email:b["Author-email"],homepage:b["Home-page"],details:b.Description};this.setInfo(a);delete b},onInstallPluginWindow:function(){if(!this.installWindow){this.installWindow=new Deluge.preferences.InstallPluginWindow();this.installWindow.on("pluginadded",this.onPluginInstall,this)}this.installWindow.show()},onPluginEnabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",true);b.commit()},onPluginDisabled:function(c){var a=this.grid.getStore().find("plugin",c);var b=this.grid.getStore().getAt(a);b.set("enabled",false);b.commit()},onPluginInstall:function(){this.updatePlugins()},onPluginSelect:function(b,c,a){deluge.client.web.get_plugin_info(a.get("plugin"),{success:this.onGotPluginInfo,scope:this})},onPreferencesShow:function(){this.updatePlugins()},onPluginInfoRender:function(b,a){this.setInfo()}});deluge.preferences.addPage(new Deluge.preferences.Plugins());Deluge.RemoveWindow=Ext.extend(Ext.Window,{constructor:function(a){a=Ext.apply({title:_("Remove Torrent"),layout:"fit",width:350,height:100,buttonAlign:"right",closeAction:"hide",closable:true,plain:true,iconCls:"x-deluge-remove-window-icon"},a);Deluge.RemoveWindow.superclass.constructor.call(this,a)},initComponent:function(){Deluge.RemoveWindow.superclass.initComponent.call(this);this.addButton(_("Cancel"),this.onCancel,this);this.addButton(_("Remove With Data"),this.onRemoveData,this);this.addButton(_("Remove Torrent"),this.onRemove,this);this.add({border:false,bodyStyle:"padding: 5px; padding-left: 10px;",html:"Are you sure you wish to remove the torrent(s)?"})},remove:function(a){Ext.each(this.torrentIds,function(b){deluge.client.core.remove_torrent(b,a,{success:function(){this.onRemoved(b)},scope:this,torrentId:b})},this)},show:function(a){Deluge.RemoveWindow.superclass.show.call(this);this.torrentIds=a},onCancel:function(){this.hide();this.torrentIds=null},onRemove:function(){this.remove(false)},onRemoveData:function(){this.remove(true)},onRemoved:function(a){deluge.events.fire("torrentRemoved",a);this.hide();deluge.ui.update()}});deluge.removeWindow=new Deluge.RemoveWindow();(function(){function a(d,f,c){var b=d.toLowerCase().replace(".","_");var e="";if(c.store.id=="tracker_host"){if(d!="Error"){e=String.format("url("+deluge.config.base+"tracker/{0})",d)}else{b=null}}if(e){return String.format('<div class="x-deluge-filter" style="background-image: {2};">{0} ({1})</div>',d,c.data.count,e)}else{if(b){return String.format('<div class="x-deluge-filter x-deluge-{2}">{0} ({1})</div>',d,c.data.count,b)}else{return String.format('<div class="x-deluge-filter">{0} ({1})</div>',d,c.data.count)}}}Deluge.Sidebar=Ext.extend(Ext.Panel,{panels:{},selected:null,constructor:function(b){b=Ext.apply({id:"sidebar",region:"west",cls:"deluge-sidebar",title:_("Filters"),layout:"accordion",split:true,width:200,minSize:175,collapsible:true,margins:"5 0 0 5",cmargins:"5 0 0 5"},b);Deluge.Sidebar.superclass.constructor.call(this,b)},initComponent:function(){Deluge.Sidebar.superclass.initComponent.call(this);deluge.events.on("disconnect",this.onDisconnect,this)},createFilter:function(e,d){var c=new Ext.data.ArrayStore({idIndex:0,fields:[{name:"filter"},{name:"count"}]});c.id=e;var g=e.replace("_"," ");var f=g.split(" ");g="";Ext.each(f,function(h){firstLetter=h.substring(0,1);firstLetter=firstLetter.toUpperCase();h=firstLetter+h.substring(1);g+=h+" "});var b=new Ext.grid.GridPanel({id:e+"-panel",border:false,store:c,title:_(g),columns:[{id:"filter",sortable:false,renderer:a,dataIndex:"filter"}],stripeRows:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:true,listeners:{rowselect:{fn:this.onFilterSelect,scope:this}}}),hideHeaders:true,autoExpandColumn:"filter",deferredRender:false,autoScroll:true});if(deluge.config.sidebar_show_zero==false){d=this.removeZero(d)}c.loadData(d);this.add(b);this.doLayout();this.panels[e]=b;b.getSelectionModel().selectFirstRow()},getFilters:function(){var b={};this.items.each(function(c){var f=c.getSelectionModel();if(!f.hasSelection()){return}var d=f.getSelected();var e=c.getStore().id;if(d.id=="All"){return}b[e]=d.id},this);return b},onDisconnect:function(){Ext.each(Ext.getKeys(this.panels),function(b){this.remove(b+"-panel")},this);this.panels={};this.selected=null},onFilterSelect:function(c,d,b){deluge.ui.update()},removeZero:function(b){var c=[];Ext.each(b,function(d){if(d[1]>0||d[0]==_("All")){c.push(d)}});return c},update:function(d){for(var c in d){var b=d[c];if(Ext.getKeys(this.panels).indexOf(c)>-1){this.updateFilter(c,b)}else{this.createFilter(c,b)}}Ext.each(Ext.keys(this.panels),function(e){if(Ext.keys(d).indexOf(e)==-1){this.panels[e]}},this)},updateFilter:function(d,c){if(deluge.config.sidebar_show_zero==false){c=this.removeZero(c)}var b=this.panels[d].getStore();var e=[];Ext.each(c,function(h,g){var f=b.getById(h[0]);if(!f){f=new b.recordType({filter:h[0],count:h[1]});f.id=h[0];b.insert(g,[f])}f.beginEdit();f.set("filter",h[0]);f.set("count",h[1]);f.endEdit();e[h[0]]=true},this);b.each(function(f){if(e[f.id]){return}b.remove(f)},this);b.commitChanges()}});deluge.sidebar=new Deluge.Sidebar()})();Deluge.Statusbar=Ext.extend(Ext.ux.StatusBar,{constructor:function(a){a=Ext.apply({id:"deluge-statusbar",defaultIconCls:"x-not-connected",defaultText:_("Not Connected")},a);Deluge.Statusbar.superclass.constructor.call(this,a)},initComponent:function(){Deluge.Statusbar.superclass.initComponent.call(this);deluge.events.on("connect",this.onConnect,this);deluge.events.on("disconnect",this.onDisconnect,this)},createButtons:function(){this.buttons=this.add({id:"statusbar-connections",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-connections",tooltip:_("Connections"),menu:deluge.menus.connections},"-",{id:"statusbar-downspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-downloading",tooltip:_("Download Speed"),menu:deluge.menus.download},"-",{id:"statusbar-upspeed",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-seeding",tooltip:_("Upload Speed"),menu:deluge.menus.upload},"-",{id:"statusbar-traffic",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-traffic",tooltip:_("Protocol Traffic Download/Upload")},"-",{id:"statusbar-dht",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-dht",tooltip:_("DHT Nodes")},"-",{id:"statusbar-freespace",text:" ",cls:"x-btn-text-icon",iconCls:"x-deluge-freespace",tooltip:_("Freespace in download location")});this.created=true},onConnect:function(){this.setStatus({iconCls:"x-connected",text:""});if(!this.created){this.createButtons()}else{Ext.each(this.buttons,function(a){a.show();a.enable()})}this.doLayout()},onDisconnect:function(){this.clearStatus({useDefaults:true});Ext.each(this.buttons,function(a){a.hide();a.disable()});this.doLayout()},update:function(b){if(!b){return}function c(d){return d+" KiB/s"}var a=function(f,e){var g=this.items.get("statusbar-"+f);if(e.limit.value>0){var h=(e.value.formatter)?e.value.formatter(e.value.value,true):e.value.value;var d=(e.limit.formatter)?e.limit.formatter(e.limit.value,true):e.limit.value;var i=String.format(e.format,h,d)}else{var i=(e.value.formatter)?e.value.formatter(e.value.value,true):e.value.value}g.setText(i)}.createDelegate(this);a("connections",{value:{value:b.num_connections},limit:{value:b.max_num_connections},format:"{0} ({1})"});a("downspeed",{value:{value:b.download_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_download,formatter:c},format:"{0} ({1})"});a("upspeed",{value:{value:b.upload_rate,formatter:Deluge.Formatters.speed},limit:{value:b.max_upload,formatter:c},format:"{0} ({1})"});a("traffic",{value:{value:b.download_protocol_rate,formatter:Deluge.Formatters.speed},limit:{value:b.upload_protocol_rate,formatter:Deluge.Formatters.speed},format:"{0}/{1}"});this.items.get("statusbar-dht").setText(b.dht_nodes);this.items.get("statusbar-freespace").setText(fsize(b.free_space));deluge.menus.connections.setValue(b.max_num_connections);deluge.menus.download.setValue(b.max_download);deluge.menus.upload.setValue(b.max_upload)}});deluge.statusbar=new Deluge.Statusbar();Deluge.Toolbar=Ext.extend(Ext.Toolbar,{constructor:function(a){a=Ext.apply({items:[{id:"create",disabled:true,text:_("Create"),iconCls:"icon-create",handler:this.onTorrentAction},{id:"add",disabled:true,text:_("Add"),iconCls:"icon-add",handler:this.onTorrentAdd},{id:"remove",disabled:true,text:_("Remove"),iconCls:"icon-remove",handler:this.onTorrentAction},"|",{id:"pause",disabled:true,text:_("Pause"),iconCls:"icon-pause",handler:this.onTorrentAction},{id:"resume",disabled:true,text:_("Resume"),iconCls:"icon-resume",handler:this.onTorrentAction},"|",{id:"up",cls:"x-btn-text-icon",disabled:true,text:_("Up"),iconCls:"icon-up",handler:this.onTorrentAction},{id:"down",disabled:true,text:_("Down"),iconCls:"icon-down",handler:this.onTorrentAction},"|",{id:"preferences",text:_("Preferences"),iconCls:"x-deluge-preferences",handler:this.onPreferencesClick,scope:this},{id:"connectionman",text:_("Connection Manager"),iconCls:"x-deluge-connection-manager",handler:this.onConnectionManagerClick,scope:this},"->",{id:"help",iconCls:"icon-help",text:_("Help"),handler:this.onHelpClick,scope:this},{id:"logout",iconCls:"icon-logout",disabled:true,text:_("Logout"),handler:this.onLogout,scope:this}]},a);Deluge.Toolbar.superclass.constructor.call(this,a)},connectedButtons:["add","remove","pause","resume","up","down"],initComponent:function(){Deluge.Toolbar.superclass.initComponent.call(this);deluge.events.on("connect",this.onConnect,this);deluge.events.on("login",this.onLogin,this)},onConnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).enable()},this)},onDisconnect:function(){Ext.each(this.connectedButtons,function(a){this.items.get(a).disable()},this)},onLogin:function(){this.items.get("logout").enable()},onLogout:function(){this.items.get("logout").disable();deluge.login.logout()},onConnectionManagerClick:function(){deluge.connectionManager.show()},onHelpClick:function(){window.open("http://dev.deluge-torrent.org/wiki/UserGuide")},onPreferencesClick:function(){deluge.preferences.show()},onTorrentAction:function(c){var b=deluge.torrents.getSelections();var a=[];Ext.each(b,function(d){a.push(d.id)});switch(c.id){case"remove":deluge.removeWindow.show(a);break;case"pause":case"resume":deluge.client.core[c.id+"_torrent"](a,{success:function(){deluge.ui.update()}});break;case"up":case"down":deluge.client.core["queue_"+c.id](a,{success:function(){deluge.ui.update()}});break}},onTorrentAdd:function(){deluge.add.show()}});deluge.toolbar=new Deluge.Toolbar();Deluge.Torrent=Ext.data.Record.create([{name:"queue",type:"int"},{name:"name",type:"string"},{name:"total_size",type:"int"},{name:"state",type:"string"},{name:"progress",type:"int"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_rate",type:"int"},{name:"eta",type:"int"},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host",type:"string"}]);(function(){function c(j){return(j==99999)?"":j+1}function e(k,l,j){return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>',j.data.state.toLowerCase(),k)}function g(j){if(!j){return}return fspeed(j)}function i(m,n,l){m=new Number(m);var j=m;var o=l.data.state+" "+m.toFixed(2)+"%";var k=new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]);return Deluge.progressBar(m,k-8,o)}function a(k,l,j){if(j.data.total_seeds>-1){return String.format("{0} ({1})",k,j.data.total_seeds)}else{return k}}function d(k,l,j){if(j.data.total_peers>-1){return String.format("{0} ({1})",k,j.data.total_peers)}else{return k}}function b(k,l,j){return(k<0)?"∞":new Number(k).toFixed(3)}function f(k,l,j){return String.format('<div style="background: url('+deluge.config.base+'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>',k)}function h(j){return j*-1}Deluge.TorrentGrid=Ext.extend(Ext.grid.GridPanel,{torrents:{},constructor:function(j){j=Ext.apply({id:"torrentGrid",store:new Ext.data.JsonStore({root:"torrents",idProperty:"id",fields:[{name:"queue"},{name:"name"},{name:"total_size",type:"int"},{name:"state"},{name:"progress",type:"float"},{name:"num_seeds",type:"int"},{name:"total_seeds",type:"int"},{name:"num_peers",type:"int"},{name:"total_peers",type:"int"},{name:"download_payload_rate",type:"int"},{name:"upload_payload_speed",type:"int"},{name:"eta",type:"int",sortType:h},{name:"ratio",type:"float"},{name:"distributed_copies",type:"float"},{name:"time_added",type:"int"},{name:"tracker_host"}]}),columns:[{id:"queue",header:_("#"),width:30,sortable:true,renderer:c,dataIndex:"queue"},{id:"name",header:_("Name"),width:150,sortable:true,renderer:e,dataIndex:"name"},{header:_("Size"),width:75,sortable:true,renderer:fsize,dataIndex:"total_size"},{header:_("Progress"),width:150,sortable:true,renderer:i,dataIndex:"progress"},{header:_("Seeders"),width:60,sortable:true,renderer:a,dataIndex:"num_seeds"},{header:_("Peers"),width:60,sortable:true,renderer:d,dataIndex:"num_peers"},{header:_("Down Speed"),width:80,sortable:true,renderer:g,dataIndex:"download_payload_rate"},{header:_("Up Speed"),width:80,sortable:true,renderer:g,dataIndex:"upload_payload_rate"},{header:_("ETA"),width:60,sortable:true,renderer:ftime,dataIndex:"eta"},{header:_("Ratio"),width:60,sortable:true,renderer:b,dataIndex:"ratio"},{header:_("Avail"),width:60,sortable:true,renderer:b,dataIndex:"distributed_copies"},{header:_("Added"),width:80,sortable:true,renderer:fdate,dataIndex:"time_added"},{header:_("Tracker"),width:120,sortable:true,renderer:f,dataIndex:"tracker_host"}],region:"center",cls:"deluge-torrents",stripeRows:true,autoExpandColumn:"name",deferredRender:false,autoScroll:true,margins:"5 5 0 0",stateful:true,view:new Ext.ux.grid.BufferView({rowHeight:26,scrollDelay:false})},j);Deluge.TorrentGrid.superclass.constructor.call(this,j)},initComponent:function(){Deluge.TorrentGrid.superclass.initComponent.call(this);deluge.events.on("torrentRemoved",this.onTorrentRemoved,this);deluge.events.on("logout",this.onDisconnect,this);this.on("rowcontextmenu",function(j,m,l){l.stopEvent();var k=j.getSelectionModel();if(!k.hasSelection()){k.selectRow(m)}deluge.menus.torrent.showAt(l.getPoint())})},getTorrent:function(j){return this.getStore().getAt(j)},getSelected:function(){return this.getSelectionModel().getSelected()},getSelections:function(){return this.getSelectionModel().getSelections()},update:function(q){var o=this.getStore();var m=[];for(var p in q){var r=q[p];if(this.torrents[p]){var l=o.getById(p);l.beginEdit();for(var n in r){if(l.get(n)!=r[n]){l.set(n,r[n])}}l.endEdit()}else{var l=new Deluge.Torrent(r);l.id=p;this.torrents[p]=1;m.push(l)}}o.add(m);o.each(function(k){if(!q[k.id]){o.remove(k);delete this.torrents[k.id]}},this);o.commitChanges();var j=o.getSortState();if(!j){return}o.sort(j.field,j.direction)},onDisconnect:function(){this.getStore().removeAll();this.torrents={}},onTorrentRemoved:function(k){var j=this.getSelectionModel();Ext.each(k,function(m){var l=this.getStore().getById(m);if(j.isSelected(l)){j.deselectRow(this.getStore().indexOf(l))}this.getStore().remove(l)},this)}});deluge.torrents=new Deluge.TorrentGrid()})();deluge.ui={errorCount:0,filters:null,initialize:function(){this.MainPanel=new Ext.Panel({id:"mainPanel",iconCls:"x-deluge-main-panel",title:"Deluge",layout:"border",tbar:deluge.toolbar,items:[deluge.sidebar,deluge.details,deluge.torrents],bbar:deluge.statusbar});this.Viewport=new Ext.Viewport({layout:"fit",items:[this.MainPanel]});deluge.events.on("connect",this.onConnect,this);deluge.events.on("disconnect",this.onDisconnect,this);deluge.client=new Ext.ux.util.RpcClient({url:deluge.config.base+"json"});for(var a in deluge.dlugins){a=deluge.plugins[a];a.enable()}Ext.QuickTips.init();deluge.client.on("connected",function(b){deluge.login.show()},this,{single:true});this.update=this.update.createDelegate(this);this.originalTitle=document.title},update:function(){var a=deluge.sidebar.getFilters();deluge.client.web.update_ui(Deluge.Keys.Grid,a,{success:this.onUpdate,failure:this.onUpdateError,scope:this});deluge.details.update()},onUpdateError:function(a){if(this.errorCount==2){Ext.MessageBox.show({title:"Lost Connection",msg:"The connection to the webserver has been lost!",buttons:Ext.MessageBox.OK,icon:Ext.MessageBox.ERROR})}this.errorCount++},onUpdate:function(a){if(!a.connected){deluge.events.fire("disconnect")}if(deluge.config.show_session_speed){document.title=this.originalTitle+" (Down: "+fspeed(a.stats.download_rate,true)+" Up: "+fspeed(a.stats.upload_rate,true)+")"}deluge.torrents.update(a.torrents);deluge.statusbar.update(a.stats);deluge.sidebar.update(a.filters);this.errorCount=0},onConnect:function(){if(!this.running){this.running=setInterval(this.update,2000);this.update()}},onDisconnect:function(){this.stop()},onPluginEnabled:function(a){deluge.client.web.get_plugin_resources(a,{success:this.onGotPluginResources,scope:this})},onGotPluginResources:function(b){var a=(deluge.debug)?b.debug_scripts:b.scripts;Ext.each(a,function(c){Ext.ux.JSLoader({url:c,onLoad:this.onPluginLoaded,pluginName:b.name})},this)},onPluginDisabled:function(a){deluge.plugins[a].disable()},onPluginLoaded:function(a){if(!deluge.plugins[a.pluginName]){return}deluge.plugins[a.pluginName].enable()},stop:function(){if(this.running){clearInterval(this.running);this.running=false;deluge.torrents.getStore().removeAll()}}};Ext.onReady(function(a){deluge.ui.initialize()});
Note: See TracChangeset for help on using the changeset viewer.