Changeset ee8531a
- Timestamp:
- 03/24/2010 06:04:06 PM (15 years ago)
- Branches:
- 2.0.x, develop, extjs4-port, master
- Children:
- afbca0
- Parents:
- 7d27b8
- Location:
- deluge/ui/web/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/ui/web/js/deluge-all-debug.js
r7d27b8 ree8531a 32 32 */ 33 33 34 // Create the namespace Ext.deluge35 Ext.namespace('Ext.deluge');36 34 37 35 // Setup the state manager 38 36 Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); 39 37 38 // Add some additional functions to ext and setup some of the 39 // configurable parameters 40 40 (function() { 41 41 42 Ext.apply(Ext, { 42 43 escapeHTML: function(text) { … … 86 87 }); 87 88 Ext.getKeys = Ext.keys; 88 Ext.BLANK_IMAGE_URL = '/images/s.gif';89 Ext.BLANK_IMAGE_URL = deluge.config.base + 'images/s.gif'; 89 90 Ext.USE_NATIVE_JSON = true; 90 91 })(); 91 92 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 94 Deluge = { 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) { 107 120 modifier = Ext.value(modifier, 10); 108 121 var progressWidth = ((width / 100.0) * progress).toFixed(0); 109 122 var barWidth = progressWidth - 1; 110 123 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); 112 125 } 113 126 114 Deluge.Plugins = {}; 115 })(); 127 } 128 129 // Setup a space for plugins to insert themselves 130 deluge.plugins = {}; 116 131 117 132 // Hinting for gettext_gen.py … … 206 221 * 207 222 * @param {Number} bytes the filesize in bytes 223 * @param {Boolean} showZero pass in true to displays 0 values 208 224 * @return {String} formatted string with KiB, MiB or GiB units. 209 225 */ 210 size: function(bytes ) {211 if (!bytes ) return '';226 size: function(bytes, showZero) { 227 if (!bytes && !showZero) return ''; 212 228 bytes = bytes / 1024.0; 213 229 … … 225 241 * 226 242 * @param {Number} bits the number of bits per second 243 * @param {Boolean} showZero pass in true to displays 0 values 227 244 * @return {String} formatted string with KiB, MiB or GiB units. 228 245 */ 229 speed: function(bits ) {230 return (!bits ) ? '' : fsize(bits) + '/s';246 speed: function(bits, showZero) { 247 return (!bits && !showZero) ? '' : fsize(bits, showZero) + '/s'; 231 248 }, 232 249 … … 400 417 }); 401 418 /* 402 Script: deluge -menus.js419 Script: deluge.menus.js 403 420 Contains all the menus contained within the UI for easy access and editing. 404 421 … … 433 450 */ 434 451 435 Deluge.Menus = {452 deluge.menus = { 436 453 onTorrentAction: function(item, e) { 437 var selection = Deluge.Torrents.getSelections();454 var selection = deluge.torrents.getSelections(); 438 455 var ids = []; 439 456 Ext.each(selection, function(record) { … … 445 462 case 'pause': 446 463 case 'resume': 447 Deluge.Client.core[action + '_torrent'](ids, {464 deluge.client.core[action + '_torrent'](ids, { 448 465 success: function() { 449 Deluge.UI.update();466 deluge.ui.update(); 450 467 } 451 468 }); … … 455 472 case 'down': 456 473 case 'bottom': 457 Deluge.Client.core['queue_' + action](ids, {474 deluge.client.core['queue_' + action](ids, { 458 475 success: function() { 459 Deluge.UI.update();476 deluge.ui.update(); 460 477 } 461 478 }); 462 479 break; 463 480 case 'edit_trackers': 464 Deluge.EditTrackers.show();481 deluge.editTrackers.show(); 465 482 break; 466 483 case 'update': 467 Deluge.Client.core.force_reannounce(ids, {484 deluge.client.core.force_reannounce(ids, { 468 485 success: function() { 469 Deluge.UI.update();486 deluge.ui.update(); 470 487 } 471 488 }); 472 489 break; 473 490 case 'remove': 474 Deluge.RemoveWindow.show(ids);491 deluge.removeWindow.show(ids); 475 492 break; 476 493 case 'recheck': 477 Deluge.Client.core.force_recheck(ids, {494 deluge.client.core.force_recheck(ids, { 478 495 success: function() { 479 Deluge.UI.update();496 deluge.ui.update(); 480 497 } 481 498 }); 482 499 break; 483 500 case 'move': 484 Deluge.MoveStorage.show(ids);501 deluge.moveStorage.show(ids); 485 502 break; 486 503 } … … 488 505 } 489 506 490 Deluge.Menus.Torrent = new Ext.menu.Menu({507 deluge.menus.torrent = new Ext.menu.Menu({ 491 508 id: 'torrentMenu', 492 509 items: [{ … … 494 511 text: _('Pause'), 495 512 iconCls: 'icon-pause', 496 handler: Deluge.Menus.onTorrentAction,497 scope: Deluge.Menus513 handler: deluge.menus.onTorrentAction, 514 scope: deluge.menus 498 515 }, { 499 516 torrentAction: 'resume', 500 517 text: _('Resume'), 501 518 iconCls: 'icon-resume', 502 handler: Deluge.Menus.onTorrentAction,503 scope: Deluge.Menus519 handler: deluge.menus.onTorrentAction, 520 scope: deluge.menus 504 521 }, '-', { 505 522 text: _('Options'), … … 562 579 }, { 563 580 text: _('Upload Slot Limit'), 564 icon : '/icons/upload_slots.png',581 iconCls: 'icon-upload-slots', 565 582 menu: new Ext.menu.Menu({ 566 583 items: [{ … … 592 609 text: _('Top'), 593 610 iconCls: 'icon-top', 594 handler: Deluge.Menus.onTorrentAction,595 scope: Deluge.Menus611 handler: deluge.menus.onTorrentAction, 612 scope: deluge.menus 596 613 },{ 597 614 torrentAction: 'up', 598 615 text: _('Up'), 599 616 iconCls: 'icon-up', 600 handler: Deluge.Menus.onTorrentAction,601 scope: Deluge.Menus617 handler: deluge.menus.onTorrentAction, 618 scope: deluge.menus 602 619 },{ 603 620 torrentAction: 'down', 604 621 text: _('Down'), 605 622 iconCls: 'icon-down', 606 handler: Deluge.Menus.onTorrentAction,607 scope: Deluge.Menus623 handler: deluge.menus.onTorrentAction, 624 scope: deluge.menus 608 625 },{ 609 626 torrentAction: 'bottom', 610 627 text: _('Bottom'), 611 628 iconCls: 'icon-bottom', 612 handler: Deluge.Menus.onTorrentAction,613 scope: Deluge.Menus629 handler: deluge.menus.onTorrentAction, 630 scope: deluge.menus 614 631 }] 615 632 }) … … 618 635 text: _('Update Tracker'), 619 636 iconCls: 'icon-update-tracker', 620 handler: Deluge.Menus.onTorrentAction,621 scope: Deluge.Menus637 handler: deluge.menus.onTorrentAction, 638 scope: deluge.menus 622 639 }, { 623 640 torrentAction: 'edit_trackers', 624 641 text: _('Edit Trackers'), 625 642 iconCls: 'icon-edit-trackers', 626 handler: Deluge.Menus.onTorrentAction,627 scope: Deluge.Menus643 handler: deluge.menus.onTorrentAction, 644 scope: deluge.menus 628 645 }, '-', { 629 646 torrentAction: 'remove', 630 647 text: _('Remove Torrent'), 631 648 iconCls: 'icon-remove', 632 handler: Deluge.Menus.onTorrentAction,633 scope: Deluge.Menus649 handler: deluge.menus.onTorrentAction, 650 scope: deluge.menus 634 651 }, '-', { 635 652 torrentAction: 'recheck', 636 653 text: _('Force Recheck'), 637 654 iconCls: 'icon-recheck', 638 handler: Deluge.Menus.onTorrentAction,639 scope: Deluge.Menus655 handler: deluge.menus.onTorrentAction, 656 scope: deluge.menus 640 657 }, { 641 658 torrentAction: 'move', 642 659 text: _('Move Storage'), 643 660 iconCls: 'icon-move', 644 handler: Deluge.Menus.onTorrentAction,645 scope: Deluge.Menus661 handler: deluge.menus.onTorrentAction, 662 scope: deluge.menus 646 663 }] 647 664 }); 648 665 649 Ext.deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, {666 Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { 650 667 651 668 setValue: function(value) { 669 var beenSet = false; 670 // set the new value 652 671 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'); 655 690 item.suspendEvents(); 656 691 item.setChecked(true); … … 659 694 }); 660 695 661 Deluge.Menus.Connections = new Ext.deluge.StatusbarMenu({696 deluge.menus.connections = new Deluge.StatusbarMenu({ 662 697 id: 'connectionsMenu', 663 698 items: [{ 664 id: '50',665 699 text: '50', 700 value: '50', 666 701 group: 'max_connections_global', 667 702 checked: false, 668 703 checkHandler: onLimitChanged 669 704 },{ 670 id: '100',671 705 text: '100', 706 value: '100', 672 707 group: 'max_connections_global', 673 708 checked: false, 674 709 checkHandler: onLimitChanged 675 710 },{ 676 id: '200',677 711 text: '200', 712 value: '200', 678 713 group: 'max_connections_global', 679 714 checked: false, 680 715 checkHandler: onLimitChanged 681 716 },{ 682 id: '300',683 717 text: '300', 718 value: '300', 684 719 group: 'max_connections_global', 685 720 checked: false, 686 721 checkHandler: onLimitChanged 687 722 },{ 688 id: '500',689 723 text: '500', 724 value: '500', 690 725 group: 'max_connections_global', 691 726 checked: false, 692 727 checkHandler: onLimitChanged 693 728 },{ 694 id: '-1',695 729 text: _('Unlimited'), 730 value: '-1', 696 731 group: 'max_connections_global', 697 732 checked: false, 698 733 checkHandler: onLimitChanged 699 734 },'-',{ 700 id: 'other',701 735 text: _('Other'), 736 value: 'other', 702 737 group: 'max_connections_global', 703 738 checked: false, … … 706 741 }); 707 742 708 Deluge.Menus.Download = new Ext.deluge.StatusbarMenu({743 deluge.menus.download = new Deluge.StatusbarMenu({ 709 744 id: 'downspeedMenu', 710 745 items: [{ 711 id: '5',746 value: '5', 712 747 text: '5 KiB/s', 713 748 group: 'max_download_speed', … … 715 750 checkHandler: onLimitChanged 716 751 },{ 717 id: '10',752 value: '10', 718 753 text: '10 KiB/s', 719 754 group: 'max_download_speed', … … 721 756 checkHandler: onLimitChanged 722 757 },{ 723 id: '30',758 value: '30', 724 759 text: '30 KiB/s', 725 760 group: 'max_download_speed', … … 727 762 checkHandler: onLimitChanged 728 763 },{ 729 id: '80',764 value: '80', 730 765 text: '80 KiB/s', 731 766 group: 'max_download_speed', … … 733 768 checkHandler: onLimitChanged 734 769 },{ 735 id: '300',770 value: '300', 736 771 text: '300 KiB/s', 737 772 group: 'max_download_speed', … … 739 774 checkHandler: onLimitChanged 740 775 },{ 741 id: '-1',776 value: '-1', 742 777 text: _('Unlimited'), 743 778 group: 'max_download_speed', … … 745 780 checkHandler: onLimitChanged 746 781 },'-',{ 747 id: 'other',782 value: 'other', 748 783 text: _('Other'), 749 784 group: 'max_download_speed', … … 753 788 }); 754 789 755 Deluge.Menus.Upload = new Ext.deluge.StatusbarMenu({790 deluge.menus.upload = new Deluge.StatusbarMenu({ 756 791 id: 'upspeedMenu', 757 792 items: [{ 758 id: '5',793 value: '5', 759 794 text: '5 KiB/s', 760 795 group: 'max_upload_speed', … … 762 797 checkHandler: onLimitChanged 763 798 },{ 764 id: '10',799 value: '10', 765 800 text: '10 KiB/s', 766 801 group: 'max_upload_speed', … … 768 803 checkHandler: onLimitChanged 769 804 },{ 770 id: '30',805 value: '30', 771 806 text: '30 KiB/s', 772 807 group: 'max_upload_speed', … … 774 809 checkHandler: onLimitChanged 775 810 },{ 776 id: '80',811 value: '80', 777 812 text: '80 KiB/s', 778 813 group: 'max_upload_speed', … … 780 815 checkHandler: onLimitChanged 781 816 },{ 782 id: '300',817 value: '300', 783 818 text: '300 KiB/s', 784 819 group: 'max_upload_speed', … … 786 821 checkHandler: onLimitChanged 787 822 },{ 788 id: '-1',823 value: '-1', 789 824 text: _('Unlimited'), 790 825 group: 'max_upload_speed', … … 792 827 checkHandler: onLimitChanged 793 828 },'-',{ 794 id: 'other',829 value: 'other', 795 830 text: _('Other'), 796 831 group: 'max_upload_speed', … … 800 835 }); 801 836 802 Deluge.Menus.FilePriorities = new Ext.menu.Menu({837 deluge.menus.filePriorities = new Ext.menu.Menu({ 803 838 id: 'filePrioritiesMenu', 804 839 items: [{ 805 840 id: 'expandAll', 806 841 text: _('Expand All'), 807 icon : '/icons/expand_all.png'842 iconCls: 'icon-expand-all' 808 843 }, '-', { 809 844 id: 'no_download', 810 845 text: _('Do Not Download'), 811 icon : '/icons/no_download.png',846 iconCls: 'icon-do-not-download', 812 847 filePriority: 0 813 848 }, { 814 849 id: 'normal', 815 850 text: _('Normal Priority'), 816 icon : '/icons/normal.png',851 iconCls: 'icon-normal', 817 852 filePriority: 1 818 853 }, { 819 854 id: 'high', 820 855 text: _('High Priority'), 821 icon : '/icons/high.png',856 iconCls: 'icon-high', 822 857 filePriority: 2 823 858 }, { 824 859 id: 'highest', 825 860 text: _('Highest Priority'), 826 icon : '/icons/highest.png',861 iconCls: 'icon-highest', 827 862 filePriority: 5 828 863 }] … … 830 865 831 866 function onLimitChanged(item, checked) { 832 if (item. id== "other") {867 if (item.value == "other") { 833 868 } else { 834 869 config = {} 835 config[item.group] = item. id836 Deluge.Client.core.set_config(config, {870 config[item.group] = item.value 871 deluge.client.core.set_config(config, { 837 872 success: function() { 838 Deluge.UI.update();873 deluge.ui.update(); 839 874 } 840 875 }); … … 842 877 } 843 878 /* 844 Script: Deluge.Events .js879 Script: Deluge.EventsManager.js 845 880 Class for holding global events that occur within the UI. 846 881 … … 874 909 */ 875 910 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 */ 917 Deluge.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 877 924 /** 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. 882 926 */ 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); 901 934 } 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: this910 });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 // private932 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 // private949 onGetEventsFailure: function(events) {950 // the request timed out so we just want to open up another951 // one.952 if (this.running) this.getEvents();953 935 } 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 }, 955 946 956 947 /** 957 * Appends an event handler to this object (shorthand for {@link #addListener}) 958 * @method 948 * Starts the EventsManagerManager checking for events. 959 949 */ 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 }, 961 957 962 958 /** 963 * Fires the specified event with the passed parameters (minus the 964 * event name). 965 * @method 959 * Stops the EventsManagerManager checking for events. 966 960 */ 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 */ 994 Deluge.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 */ 1001 Deluge.EventsManager.prototype.fire = Deluge.EventsManager.prototype.fireEvent 1002 deluge.events = new Deluge.EventsManager(); 970 1003 /* 971 1004 Script: … … 1535 1568 */ 1536 1569 1537 Ext.namespace(' Ext.deluge.add');1538 Ext.deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {1570 Ext.namespace('Deluge.add'); 1571 Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, { 1539 1572 1540 1573 torrents: {}, … … 1547 1580 height: 220 1548 1581 }, config); 1549 Ext.deluge.add.OptionsPanel.superclass.constructor.call(this, config);1582 Deluge.add.OptionsPanel.superclass.constructor.call(this, config); 1550 1583 }, 1551 1584 1552 1585 initComponent: function() { 1553 Ext.deluge.add.OptionsPanel.superclass.initComponent.call(this);1586 Deluge.add.OptionsPanel.superclass.initComponent.call(this); 1554 1587 this.files = this.add(new Ext.ux.tree.TreeGrid({ 1555 1588 layout: 'fit', … … 1740 1773 'prioritize_first_last_pieces']; 1741 1774 1742 Deluge.Client.core.get_config_values(keys, {1775 deluge.client.core.get_config_values(keys, { 1743 1776 success: function(config) { 1744 1777 var options = { … … 1846 1879 }); 1847 1880 1848 Ext.deluge.add.Window = Ext.extend(Ext.Window, {1881 Deluge.add.Window = Ext.extend(Ext.Window, { 1849 1882 initComponent: function() { 1850 Ext.deluge.add.Window.superclass.initComponent.call(this);1883 Deluge.add.Window.superclass.initComponent.call(this); 1851 1884 this.addEvents( 1852 1885 'beforeadd', … … 1860 1893 }); 1861 1894 1862 Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {1895 Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { 1863 1896 1864 1897 constructor: function(config) { … … 1875 1908 iconCls: 'x-deluge-add-window-icon' 1876 1909 }, config); 1877 Ext.deluge.add.AddWindow.superclass.constructor.call(this, config);1910 Deluge.add.AddWindow.superclass.constructor.call(this, config); 1878 1911 }, 1879 1912 1880 1913 initComponent: function() { 1881 Ext.deluge.add.AddWindow.superclass.initComponent.call(this);1914 Deluge.add.AddWindow.superclass.initComponent.call(this); 1882 1915 1883 1916 this.addButton(_('Cancel'), this.onCancelClick, this); … … 1926 1959 bbar: new Ext.Toolbar({ 1927 1960 items: [{ 1928 id: 'file',1929 cls: 'x-btn-text-icon',1930 1961 iconCls: 'x-deluge-add-file', 1931 1962 text: _('File'), … … 1933 1964 scope: this 1934 1965 }, { 1935 id: 'url',1936 cls: 'x-btn-text-icon',1937 1966 text: _('Url'), 1938 icon : '/icons/add_url.png',1967 iconCls: 'icon-add-url', 1939 1968 handler: this.onUrl, 1940 1969 scope: this 1941 1970 }, { 1942 id: 'infohash',1943 cls: 'x-btn-text-icon',1944 1971 text: _('Infohash'), 1945 icon : '/icons/add_magnet.png',1972 iconCls: 'icon-add-magnet', 1946 1973 disabled: true 1947 1974 }, '->', { 1948 id: 'remove',1949 cls: 'x-btn-text-icon',1950 1975 text: _('Remove'), 1951 icon : '/icons/remove.png',1976 iconCls: 'icon-remove', 1952 1977 handler: this.onRemove, 1953 1978 scope: this … … 1956 1981 }); 1957 1982 1958 this.optionsPanel = this.add(new Ext.deluge.add.OptionsPanel());1983 this.optionsPanel = this.add(new Deluge.add.OptionsPanel()); 1959 1984 this.on('hide', this.onHide, this); 1960 1985 this.on('show', this.onShow, this); … … 1977 2002 }, this); 1978 2003 1979 Deluge.Client.web.add_torrents(torrents, {2004 deluge.client.web.add_torrents(torrents, { 1980 2005 success: function(result) { 1981 2006 } … … 2018 2043 onShow: function() { 2019 2044 if (!this.url) { 2020 this.url = new Ext.deluge.add.UrlWindow();2045 this.url = new Deluge.add.UrlWindow(); 2021 2046 this.url.on('beforeadd', this.onTorrentBeforeAdd, this); 2022 2047 this.url.on('add', this.onTorrentAdd, this); … … 2024 2049 2025 2050 if (!this.file) { 2026 this.file = new Ext.deluge.add.FileWindow();2051 this.file = new Deluge.add.FileWindow(); 2027 2052 this.file.on('beforeadd', this.onTorrentBeforeAdd, this); 2028 2053 this.file.on('add', this.onTorrentAdd, this); … … 2038 2063 2039 2064 onTorrentAdd: function(torrentId, info) { 2065 var r = this.grid.getStore().getById(torrentId); 2040 2066 if (!info) { 2041 2067 Ext.MessageBox.show({ … … 2047 2073 iconCls: 'x-deluge-icon-error' 2048 2074 }); 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); 2050 2081 } 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);2057 2082 }, 2058 2083 … … 2061 2086 } 2062 2087 }); 2063 Deluge.Add = new Ext.deluge.add.AddWindow();2088 deluge.add = new Deluge.add.AddWindow(); 2064 2089 /* 2065 2090 Script: Deluge.Add.File.js … … 2097 2122 2098 2123 Ext.namespace('Ext.deluge.add'); 2099 Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {2124 Deluge.add.FileWindow = Ext.extend(Deluge.add.Window, { 2100 2125 constructor: function(config) { 2101 2126 config = Ext.apply({ … … 2111 2136 iconCls: 'x-deluge-add-file' 2112 2137 }, config); 2113 Ext.deluge.add.FileWindow.superclass.constructor.call(this, config);2138 Deluge.add.FileWindow.superclass.constructor.call(this, config); 2114 2139 }, 2115 2140 2116 2141 initComponent: function() { 2117 Ext.deluge.add.FileWindow.superclass.initComponent.call(this);2142 Deluge.add.FileWindow.superclass.initComponent.call(this); 2118 2143 this.addButton(_('Add'), this.onAddClick, this); 2119 2144 … … 2144 2169 url: '/upload', 2145 2170 waitMsg: _('Uploading your torrent...'), 2171 failure: this.onUploadFailure, 2146 2172 success: this.onUploadSuccess, 2147 2173 scope: this 2148 2174 }); 2149 2175 var name = this.form.getForm().findField('torrentFile').value; 2176 name = name.split('\\').slice(-1)[0]; 2150 2177 this.fireEvent('beforeadd', this.torrentId, name); 2151 2178 } … … 2155 2182 info['filename'] = request.options.filename; 2156 2183 this.fireEvent('add', this.torrentId, info); 2184 }, 2185 2186 onUploadFailure: function(form, action) { 2187 this.hide(); 2157 2188 }, 2158 2189 … … 2204 2235 */ 2205 2236 2206 Ext.namespace(' Ext.deluge.add');2207 Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {2237 Ext.namespace('Deluge.add'); 2238 Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, { 2208 2239 constructor: function(config) { 2209 2240 config = Ext.apply({ … … 2219 2250 iconCls: 'x-deluge-add-url-window-icon' 2220 2251 }, config); 2221 Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);2252 Deluge.add.UrlWindow.superclass.constructor.call(this, config); 2222 2253 }, 2223 2254 2224 2255 initComponent: function() { 2225 Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);2256 Deluge.add.UrlWindow.superclass.initComponent.call(this); 2226 2257 this.addButton(_('Add'), this.onAddClick, this); 2227 2258 … … 2258 2289 var torrentId = this.createTorrentId(); 2259 2290 2260 Deluge.Client.web.download_torrent_from_url(url, cookies, {2291 deluge.client.web.download_torrent_from_url(url, cookies, { 2261 2292 success: this.onDownload, 2262 2293 scope: this, … … 2269 2300 onDownload: function(filename, obj, resp, req) { 2270 2301 this.urlField.setValue(''); 2271 Deluge.Client.web.get_torrent_info(filename, {2302 deluge.client.web.get_torrent_info(filename, { 2272 2303 success: this.onGotInfo, 2273 2304 scope: this, … … 2479 2510 }); 2480 2511 /* 2481 Script: deluge-connections.js2512 Script: Deluge.ConnectionManager.js 2482 2513 Contains all objects and functions related to the connection manager. 2483 2514 … … 2517 2548 } 2518 2549 2519 Ext.deluge.AddConnectionWindow = Ext.extend(Ext.Window, {2550 Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { 2520 2551 2521 2552 constructor: function(config) { … … 2532 2563 iconCls: 'x-deluge-add-window-icon' 2533 2564 }, config); 2534 Ext.deluge.AddConnectionWindow.superclass.constructor.call(this, config);2565 Deluge.AddConnectionWindow.superclass.constructor.call(this, config); 2535 2566 }, 2536 2567 2537 2568 initComponent: function() { 2538 Ext.deluge.AddConnectionWindow.superclass.initComponent.call(this);2569 Deluge.AddConnectionWindow.superclass.initComponent.call(this); 2539 2570 2540 2571 this.addEvents('hostadded'); … … 2564 2595 fieldLabel: _('Port'), 2565 2596 id: 'port', 2566 xtype: 'uxspinner', 2567 ctCls: 'x-form-uxspinner', 2597 xtype: 'spinnerfield', 2568 2598 name: 'port', 2569 2599 strategy: { … … 2601 2631 var password = this.passwordField.getValue(); 2602 2632 2603 Deluge.Client.web.add_host(host, port, username, password, {2633 deluge.client.web.add_host(host, port, username, password, { 2604 2634 success: function(result) { 2605 2635 if (!result[0]) { … … 2626 2656 }); 2627 2657 2628 Ext.deluge.ConnectionManager = Ext.extend(Ext.Window, {2658 Deluge.ConnectionManager = Ext.extend(Ext.Window, { 2629 2659 2630 2660 layout: 'fit', … … 2640 2670 2641 2671 initComponent: function() { 2642 Ext.deluge.ConnectionManager.superclass.initComponent.call(this);2672 Deluge.ConnectionManager.superclass.initComponent.call(this); 2643 2673 this.on('hide', this.onHide, this); 2644 2674 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); 2647 2679 2648 2680 this.addButton(_('Close'), this.onClose, this); … … 2698 2730 cls: 'x-btn-text-icon', 2699 2731 text: _('Add'), 2700 icon : '/icons/add.png',2732 iconCls: 'icon-add', 2701 2733 handler: this.onAddClick, 2702 2734 scope: this … … 2705 2737 cls: 'x-btn-text-icon', 2706 2738 text: _('Remove'), 2707 icon : '/icons/remove.png',2739 iconCls: 'icon-remove', 2708 2740 handler: this.onRemove, 2709 2741 disabled: true, … … 2713 2745 cls: 'x-btn-text-icon', 2714 2746 text: _('Stop Daemon'), 2715 icon : '/icons/error.png',2747 iconCls: 'icon-error', 2716 2748 handler: this.onStop, 2717 2749 disabled: true, … … 2725 2757 }, 2726 2758 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 2727 2776 disconnect: function() { 2728 Deluge.Events.fire('disconnect');2777 deluge.events.fire('disconnect'); 2729 2778 }, 2730 2779 2731 2780 loadHosts: function() { 2732 Deluge.Client.web.get_hosts({2781 deluge.client.web.get_hosts({ 2733 2782 success: this.onGetHosts, 2734 2783 scope: this … … 2738 2787 update: function() { 2739 2788 this.grid.getStore().each(function(r) { 2740 Deluge.Client.web.get_host_status(r.id, {2789 deluge.client.web.get_host_status(r.id, { 2741 2790 success: this.onGetHostStatus, 2742 2791 scope: this … … 2780 2829 onAddClick: function(button, e) { 2781 2830 if (!this.addWindow) { 2782 this.addWindow = new Ext.deluge.AddConnectionWindow();2831 this.addWindow = new Deluge.AddConnectionWindow(); 2783 2832 this.addWindow.on('hostadded', this.onHostAdded, this); 2784 2833 } … … 2790 2839 }, 2791 2840 2841 // private 2792 2842 onClose: function(e) { 2793 2843 if (this.running) window.clearInterval(this.running); … … 2795 2845 }, 2796 2846 2847 // private 2797 2848 onConnect: function(e) { 2798 2849 var selected = this.grid.getSelectionModel().getSelected(); … … 2800 2851 2801 2852 if (selected.get('status') == _('Connected')) { 2802 Deluge.Client.web.disconnect({2853 deluge.client.web.disconnect({ 2803 2854 success: function(result) { 2804 2855 this.update(this); … … 2809 2860 } else { 2810 2861 var id = selected.id; 2811 Deluge.Client.web.connect(id, {2862 deluge.client.web.connect(id, { 2812 2863 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'); 2816 2867 }, this, {single: true}); 2817 2868 } … … 2821 2872 }, 2822 2873 2874 onDisconnect: function() { 2875 if (this.isVisible()) return; 2876 this.show(); 2877 }, 2878 2879 // private 2823 2880 onGetHosts: function(hosts) { 2824 2881 this.grid.getStore().loadData(hosts); 2825 2882 Ext.each(hosts, function(host) { 2826 Deluge.Client.web.get_host_status(host[0], {2883 deluge.client.web.get_host_status(host[0], { 2827 2884 success: this.onGetHostStatus, 2828 2885 scope: this … … 2831 2888 }, 2832 2889 2890 // private 2833 2891 onGetHostStatus: function(host) { 2834 2892 var record = this.grid.getStore().getById(host[0]); … … 2839 2897 }, 2840 2898 2899 // private 2841 2900 onHide: function() { 2842 2901 if (this.running) window.clearInterval(this.running); 2843 2902 }, 2844 2903 2904 // private 2845 2905 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 } 2856 2921 }, 2857 2922 2923 // private 2858 2924 onLogout: function() { 2859 2925 this.disconnect(); … … 2863 2929 }, 2864 2930 2931 // private 2865 2932 onRemove: function(button) { 2866 2933 var connection = this.grid.getSelectionModel().getSelected(); 2867 2934 if (!connection) return; 2868 2935 2869 Deluge.Client.web.remove_host(connection.id, {2936 deluge.client.web.remove_host(connection.id, { 2870 2937 success: function(result) { 2871 2938 if (!result) { … … 2886 2953 }, 2887 2954 2955 // private 2888 2956 onSelect: function(selModel, rowIndex, record) { 2889 2957 this.selectedRow = rowIndex; 2890 2958 }, 2891 2959 2960 // private 2892 2961 onSelectionChanged: function(selModel) { 2893 2962 var record = selModel.getSelected(); … … 2903 2972 }, 2904 2973 2974 // private 2905 2975 onShow: function() { 2906 2976 if (!this.addHostButton) { … … 2913 2983 this.running = window.setInterval(this.update, 2000, this); 2914 2984 }, 2915 2985 2986 // private 2916 2987 onStop: function(button, e) { 2917 2988 var connection = this.grid.getSelectionModel().getSelected(); … … 2920 2991 if (connection.get('status') == 'Offline') { 2921 2992 // 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')); 2923 2994 } else { 2924 2995 // This means we need to stop the daemon 2925 Deluge.Client.web.stop_daemon(connection.id, {2996 deluge.client.web.stop_daemon(connection.id, { 2926 2997 success: function(result) { 2927 2998 if (!result[0]) { … … 2940 3011 } 2941 3012 }); 2942 Deluge.ConnectionManager = new Ext.deluge.ConnectionManager();3013 deluge.connectionManager = new Deluge.ConnectionManager(); 2943 3014 })(); 2944 3015 /* … … 2977 3048 2978 3049 (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, { 2981 3052 2982 3053 constructor: function(config) { … … 2991 3062 activeTab: 0 2992 3063 }, config); 2993 Ext.deluge.details.TabPanel.superclass.constructor.call(this, config);3064 Deluge.details.TabPanel.superclass.constructor.call(this, config); 2994 3065 }, 2995 3066 … … 3005 3076 3006 3077 update: function(tab) { 3007 var torrent = Deluge.Torrents.getSelected();3078 var torrent = deluge.torrents.getSelected(); 3008 3079 if (!torrent) { 3009 3080 this.clear(); … … 3024 3095 // been created yet. 3025 3096 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); 3029 3100 this.on('tabchange', this.onTabChange, this); 3030 3101 3031 Deluge.Torrents.getSelectionModel().on('selectionchange', function(selModel) {3102 deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) { 3032 3103 if (!selModel.hasSelection()) this.clear(); 3033 3104 }, this); … … 3042 3113 } 3043 3114 }); 3044 Deluge.Details = new Ext.deluge.details.TabPanel();3115 deluge.details = new Deluge.details.TabPanel(); 3045 3116 })(); 3046 3117 /* … … 3077 3148 */ 3078 3149 3079 Ext.deluge.details.StatusTab = Ext.extend(Ext.Panel, {3150 Deluge.details.StatusTab = Ext.extend(Ext.Panel, { 3080 3151 title: _('Status'), 3081 3152 autoScroll: true, 3082 3153 3083 3154 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); 3085 3156 3086 3157 this.progressBar = this.add({ … … 3099 3170 fn: function(panel) { 3100 3171 panel.load({ 3101 url: '/render/tab_status.html',3172 url: deluge.config.base + 'render/tab_status.html', 3102 3173 text: _('Loading') + '...' 3103 3174 }); … … 3119 3190 update: function(torrentId) { 3120 3191 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, { 3122 3193 success: this.onRequestComplete, 3123 3194 scope: this … … 3162 3233 } 3163 3234 var text = status.state + ' ' + status.progress.toFixed(2) + '%'; 3164 this.progressBar.updateProgress(status.progress , text);3235 this.progressBar.updateProgress(status.progress / 100.0, text); 3165 3236 } 3166 3237 }); 3167 Deluge.Details.add(new Ext.deluge.details.StatusTab());3238 deluge.details.add(new Deluge.details.StatusTab()); 3168 3239 /* 3169 3240 Script: Deluge.Details.Details.js … … 3200 3271 */ 3201 3272 3202 Ext.deluge.details.DetailsTab = Ext.extend(Ext.Panel, {3273 Deluge.details.DetailsTab = Ext.extend(Ext.Panel, { 3203 3274 title: _('Details'), 3204 3275 … … 3210 3281 3211 3282 initComponent: function() { 3212 Ext.deluge.details.DetailsTab.superclass.initComponent.call(this);3283 Deluge.details.DetailsTab.superclass.initComponent.call(this); 3213 3284 this.addItem('torrent_name', _('Name')); 3214 3285 this.addItem('hash', _('Hash')); … … 3222 3293 3223 3294 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); 3225 3296 this.body.setStyle('padding', '10px'); 3226 3297 this.dl = Ext.DomHelper.append(this.body, {tag: 'dl'}, true); … … 3253 3324 3254 3325 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, { 3256 3327 success: this.onRequestComplete, 3257 3328 scope: this, … … 3280 3351 } 3281 3352 }); 3282 Deluge.Details.add(new Ext.deluge.details.DetailsTab());3353 deluge.details.add(new Deluge.details.DetailsTab()); 3283 3354 /* 3284 3355 Script: Deluge.Details.Files.js … … 3324 3395 } 3325 3396 3326 Ext.deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {3397 Deluge.details.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { 3327 3398 3328 3399 constructor: function(config) { … … 3362 3433 }, config); 3363 3434 3364 Ext.deluge.details.FilesTab.superclass.constructor.call(this, config);3435 Deluge.details.FilesTab.superclass.constructor.call(this, config); 3365 3436 }, 3366 3437 3367 3438 initComponent: function() { 3368 3439 3369 Ext.deluge.details.FilesTab.superclass.initComponent.call(this);3440 Deluge.details.FilesTab.superclass.initComponent.call(this); 3370 3441 }, 3371 3442 3372 3443 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); 3375 3446 this.on('contextmenu', this.onContextMenu, this); 3376 3447 this.sorter = new Ext.tree.TreeSorter(this, { … … 3396 3467 } 3397 3468 3398 Deluge.Client.web.get_torrent_files(torrentId, {3469 deluge.client.web.get_torrent_files(torrentId, { 3399 3470 success: this.onRequestComplete, 3400 3471 scope: this, … … 3410 3481 node.select(); 3411 3482 } 3412 Deluge.Menus.FilePriorities.showAt(e.getPoint());3483 deluge.menus.filePriorities.showAt(e.getPoint()); 3413 3484 }, 3414 3485 … … 3445 3516 } 3446 3517 3447 Deluge.Client.core.set_torrent_file_priorities(this.torrentId, priorities, {3518 deluge.client.core.set_torrent_file_priorities(this.torrentId, priorities, { 3448 3519 success: function() { 3449 3520 Ext.each(nodes, function(node) { … … 3499 3570 } 3500 3571 }); 3501 Deluge.Details.add(new Ext.deluge.details.FilesTab());3572 deluge.details.add(new Deluge.details.FilesTab()); 3502 3573 })(); 3503 3574 /* … … 3552 3623 } 3553 3624 3554 Ext.deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {3625 Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, { 3555 3626 3556 3627 constructor: function(config) { … … 3611 3682 autoScroll:true 3612 3683 }, config); 3613 Ext.deluge.details.PeersTab.superclass.constructor.call(this, config);3684 Deluge.details.PeersTab.superclass.constructor.call(this, config); 3614 3685 }, 3615 3686 3616 3687 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); 3618 3689 }, 3619 3690 … … 3623 3694 3624 3695 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, { 3626 3697 success: this.onRequestComplete, 3627 3698 scope: this … … 3638 3709 } 3639 3710 }); 3640 Deluge.Details.add(new Ext.deluge.details.PeersTab());3711 deluge.details.add(new Deluge.details.PeersTab()); 3641 3712 })(); 3642 3713 /* … … 3674 3745 3675 3746 3676 Ext.deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, {3747 Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { 3677 3748 3678 3749 constructor: function(config) { … … 3691 3762 title: _('Options') 3692 3763 }, config); 3693 Ext.deluge.details.OptionsTab.superclass.constructor.call(this, config);3764 Deluge.details.OptionsTab.superclass.constructor.call(this, config); 3694 3765 }, 3695 3766 3696 3767 initComponent: function() { 3697 Ext.deluge.details.OptionsTab.superclass.initComponent.call(this);3768 Deluge.details.OptionsTab.superclass.initComponent.call(this); 3698 3769 3699 3770 this.fieldsets = {}, this.fields = {}; … … 3984 4055 3985 4056 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); 3987 4058 3988 4059 // This is another hack I think, so keep an eye out here when upgrading. … … 4011 4082 this.optionsManager.changeId(torrentId); 4012 4083 } 4013 Deluge.Client.core.get_torrent_status(torrentId, Deluge.Keys.Options, {4084 deluge.client.core.get_torrent_status(torrentId, Deluge.Keys.Options, { 4014 4085 success: this.onRequestComplete, 4015 4086 scope: this … … 4021 4092 if (!Ext.isEmpty(changed['prioritize_first_last'])) { 4022 4093 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, { 4024 4095 success: function() { 4025 4096 this.optionsManager.set('prioritize_first_last', value); … … 4028 4099 }); 4029 4100 } 4030 Deluge.Client.core.set_torrent_options([this.torrentId], changed, {4101 deluge.client.core.set_torrent_options([this.torrentId], changed, { 4031 4102 success: function() { 4032 4103 this.optionsManager.commit(); … … 4037 4108 4038 4109 onEditTrackers: function() { 4039 Deluge.EditTrackers.show();4110 deluge.editTrackers.show(); 4040 4111 }, 4041 4112 … … 4056 4127 } 4057 4128 }); 4058 Deluge.Details.add(new Ext.deluge.details.OptionsTab());4129 deluge.details.add(new Deluge.details.OptionsTab()); 4059 4130 /* 4060 4131 Script: Deluge.EditTrackers.js … … 4092 4163 4093 4164 (function() { 4094 Ext.deluge.AddTracker = Ext.extend(Ext.Window, {4165 Deluge.AddTracker = Ext.extend(Ext.Window, { 4095 4166 constructor: function(config) { 4096 4167 config = Ext.apply({ … … 4107 4178 resizable: false 4108 4179 }, config); 4109 Ext.deluge.AddTracker.superclass.constructor.call(this, config);4180 Deluge.AddTracker.superclass.constructor.call(this, config); 4110 4181 }, 4111 4182 4112 4183 initComponent: function() { 4113 Ext.deluge.AddTracker.superclass.initComponent.call(this);4184 Deluge.AddTracker.superclass.initComponent.call(this); 4114 4185 4115 4186 this.addButton(_('Cancel'), this.onCancelClick, this); … … 4151 4222 }); 4152 4223 4153 Ext.deluge.EditTracker = Ext.extend(Ext.Window, {4224 Deluge.EditTracker = Ext.extend(Ext.Window, { 4154 4225 constructor: function(config) { 4155 4226 config = Ext.apply({ … … 4166 4237 resizable: false 4167 4238 }, config); 4168 Ext.deluge.EditTracker.superclass.constructor.call(this, config);4239 Deluge.EditTracker.superclass.constructor.call(this, config); 4169 4240 }, 4170 4241 4171 4242 initComponent: function() { 4172 Ext.deluge.EditTracker.superclass.initComponent.call(this);4243 Deluge.EditTracker.superclass.initComponent.call(this); 4173 4244 4174 4245 this.addButton(_('Cancel'), this.onCancelClick, this); … … 4190 4261 4191 4262 show: function(record) { 4192 Ext.deluge.EditTracker.superclass.show.call(this);4263 Deluge.EditTracker.superclass.show.call(this); 4193 4264 4194 4265 this.record = record; … … 4212 4283 }); 4213 4284 4214 Ext.deluge.EditTrackers = Ext.extend(Ext.Window, {4285 Deluge.EditTrackers = Ext.extend(Ext.Window, { 4215 4286 4216 4287 constructor: function(config) { … … 4228 4299 resizable: true 4229 4300 }, config); 4230 Ext.deluge.EditTrackers.superclass.constructor.call(this, config);4301 Deluge.EditTrackers.superclass.constructor.call(this, config); 4231 4302 }, 4232 4303 4233 4304 initComponent: function() { 4234 Ext.deluge.EditTrackers.superclass.initComponent.call(this);4305 Deluge.EditTrackers.superclass.initComponent.call(this); 4235 4306 4236 4307 this.addButton(_('Cancel'), this.onCancelClick, this); … … 4241 4312 this.on('save', this.onSave, this); 4242 4313 4243 this.addWindow = new Ext.deluge.AddTracker();4314 this.addWindow = new Deluge.AddTracker(); 4244 4315 this.addWindow.on('add', this.onAddTrackers, this); 4245 this.editWindow = new Ext.deluge.EditTracker();4316 this.editWindow = new Deluge.EditTracker(); 4246 4317 4247 4318 this.grid = this.add({ … … 4280 4351 items: [ 4281 4352 { 4282 cls: 'x-btn-text-icon',4283 4353 text: _('Up'), 4284 icon : '/icons/up.png',4354 iconCls: 'icon-up', 4285 4355 handler: this.onUpClick, 4286 4356 scope: this 4287 4357 }, { 4288 cls: 'x-btn-text-icon',4289 4358 text: _('Down'), 4290 icon : '/icons/down.png',4359 iconCls: 'icon-down', 4291 4360 handler: this.onDownClick, 4292 4361 scope: this 4293 4362 }, '->', { 4294 cls: 'x-btn-text-icon',4295 4363 text: _('Add'), 4296 icon : '/icons/add.png',4364 iconCls: 'icon-add', 4297 4365 handler: this.onAddClick, 4298 4366 scope: this 4299 4367 }, { 4300 cls: 'x-btn-text-icon',4301 4368 text: _('Edit'), 4302 icon : '/icons/edit_trackers.png',4369 iconCls: 'icon-edit-trackers', 4303 4370 handler: this.onEditClick, 4304 4371 scope: this 4305 4372 }, { 4306 cls: 'x-btn-text-icon',4307 4373 text: _('Remove'), 4308 icon : '/icons/remove.png',4374 iconCls: 'icon-remove', 4309 4375 handler: this.onRemoveClick, 4310 4376 scope: this … … 4360 4426 }, this); 4361 4427 4362 Deluge.Client.core.set_torrent_trackers(this.torrentId, trackers, {4428 deluge.client.core.set_torrent_trackers(this.torrentId, trackers, { 4363 4429 failure: this.onSaveFail, 4364 4430 scope: this … … 4394 4460 onShow: function() { 4395 4461 this.grid.getBottomToolbar().items.get(4).disable(); 4396 var r = Deluge.Torrents.getSelected();4462 var r = deluge.torrents.getSelected(); 4397 4463 this.torrentId = r.id; 4398 Deluge.Client.core.get_torrent_status(r.id, ['trackers'], {4464 deluge.client.core.get_torrent_status(r.id, ['trackers'], { 4399 4465 success: this.onRequestComplete, 4400 4466 scope: this … … 4402 4468 } 4403 4469 }); 4404 Deluge.EditTrackers = new Ext.deluge.EditTrackers();4470 deluge.editTrackers = new Deluge.EditTrackers(); 4405 4471 })(); 4406 4472 Ext.namespace('Deluge'); 4407 4473 Deluge.FileBrowser = Ext.extend(Ext.Window, { 4408 4474 4409 title: 'Filebrowser', 4410 4475 title: _('File Browser'), 4476 4477 width: 500, 4478 height: 400, 4479 4411 4480 initComponent: function() { 4412 4481 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 }); 4413 4499 } 4414 4500 … … 4448 4534 */ 4449 4535 4450 Ext.deluge.LoginWindow = Ext.extend(Ext.Window, {4536 Deluge.LoginWindow = Ext.extend(Ext.Window, { 4451 4537 4452 4538 firstShow: true, … … 4465 4551 4466 4552 initComponent: function() { 4467 Ext.deluge.LoginWindow.superclass.initComponent.call(this);4553 Deluge.LoginWindow.superclass.initComponent.call(this); 4468 4554 this.on('show', this.onShow, this); 4469 4555 … … 4494 4580 4495 4581 logout: function() { 4496 Deluge.Events.fire('logout');4497 Deluge.Client.auth.delete_session({4582 deluge.events.fire('logout'); 4583 deluge.client.auth.delete_session({ 4498 4584 success: function(result) { 4499 4585 this.show(true); … … 4505 4591 show: function(skipCheck) { 4506 4592 if (this.firstShow) { 4507 Deluge.Client.on('error', this.onClientError, this);4593 deluge.client.on('error', this.onClientError, this); 4508 4594 this.firstShow = false; 4509 4595 } 4510 4596 4511 4597 if (skipCheck) { 4512 return Ext.deluge.LoginWindow.superclass.show.call(this);4598 return Deluge.LoginWindow.superclass.show.call(this); 4513 4599 } 4514 4600 4515 Deluge.Client.auth.check_session({4601 deluge.client.auth.check_session({ 4516 4602 success: function(result) { 4517 4603 if (result) { 4518 Deluge.Events.fire('login');4604 deluge.events.fire('login'); 4519 4605 } else { 4520 4606 this.show(true); … … 4534 4620 onLogin: function() { 4535 4621 var passwordField = this.passwordField; 4536 Deluge.Client.auth.login(passwordField.getValue(), {4622 deluge.client.auth.login(passwordField.getValue(), { 4537 4623 success: function(result) { 4538 4624 if (result) { 4539 Deluge.Events.fire('login');4625 deluge.events.fire('login'); 4540 4626 this.hide(); 4541 4627 passwordField.setRawValue(''); … … 4560 4646 onClientError: function(errorObj, response, requestOptions) { 4561 4647 if (errorObj.error.code == 1) { 4562 Deluge.Events.fire('logout');4648 deluge.events.fire('logout'); 4563 4649 this.show(true); 4564 4650 } … … 4571 4657 }); 4572 4658 4573 Deluge.Login = new Ext.deluge.LoginWindow();4659 deluge.login = new Deluge.LoginWindow(); 4574 4660 /* 4575 4661 Script: Deluge.MoveStorage.js … … 4605 4691 */ 4606 4692 4607 Ext.namespace(' Ext.deluge');4608 Ext.deluge.MoveStorage = Ext.extend(Ext.Window, {4693 Ext.namespace('Deluge'); 4694 Deluge.MoveStorage = Ext.extend(Ext.Window, { 4609 4695 4610 4696 constructor: function(config) { … … 4621 4707 resizable: false 4622 4708 }, config); 4623 Ext.deluge.MoveStorage.superclass.constructor.call(this, config);4709 Deluge.MoveStorage.superclass.constructor.call(this, config); 4624 4710 }, 4625 4711 4626 4712 initComponent: function() { 4627 Ext.deluge.MoveStorage.superclass.initComponent.call(this);4713 Deluge.MoveStorage.superclass.initComponent.call(this); 4628 4714 4629 4715 this.addButton(_('Cancel'), this.onCancel, this); … … 4643 4729 width: 240 4644 4730 }); 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 }); 4645 4742 }, 4646 4743 4647 4744 hide: function() { 4648 Ext.deluge.MoveStorage.superclass.hide.call(this);4745 Deluge.MoveStorage.superclass.hide.call(this); 4649 4746 this.torrentIds = null; 4650 4747 }, 4651 4748 4652 4749 show: function(torrentIds) { 4653 Ext.deluge.MoveStorage.superclass.show.call(this);4750 Deluge.MoveStorage.superclass.show.call(this); 4654 4751 this.torrentIds = torrentIds; 4655 4752 }, … … 4661 4758 onMove: function() { 4662 4759 var dest = this.moveLocation.getValue(); 4663 Deluge.Client.core.move_storage(this.torrentIds, dest);4760 deluge.client.core.move_storage(this.torrentIds, dest); 4664 4761 this.hide(); 4665 4762 } 4666 4763 }); 4667 Deluge.MoveStorage = new Ext.deluge.MoveStorage();4764 deluge.moveStorage = new Deluge.MoveStorage(); 4668 4765 /* 4669 4766 Script: Deluge.Plugin.js … … 4785 4882 */ 4786 4883 4787 Ext.deluge.PreferencesWindow = Ext.extend(Ext.Window, { 4788 4884 Ext.namespace('Deluge.preferences'); 4885 PreferencesRecord = Ext.data.Record.create([{name:'name', type:'string'}]); 4886 4887 /** 4888 * @class Deluge.preferences.PreferencesWindow 4889 * @extends Ext.Window 4890 */ 4891 Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, { 4892 4893 /** 4894 * @property {String} currentPage The currently selected page. 4895 */ 4789 4896 currentPage: null, 4790 4897 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 4829 4910 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 4832 4941 this.configPanel = this.add({ 4942 type: 'container', 4943 autoDestroy: false, 4833 4944 region: 'center', 4834 header: false, 4835 layout: 'fit', 4836 height: 400, 4837 autoScroll: true, 4945 layout: 'card', 4946 //height: 400, 4947 //autoScroll: true, 4838 4948 margins: '5 5 5 5', 4839 4949 cmargins: '5 5 5 5' … … 4846 4956 this.pages = {}; 4847 4957 this.optionsManager = new Deluge.OptionsManager(); 4958 this.on('afterrender', this.onAfterRender, this); 4848 4959 this.on('show', this.onShow, this); 4849 4960 }, … … 4852 4963 var changed = this.optionsManager.getDirty(); 4853 4964 if (!Ext.isObjectEmpty(changed)) { 4854 Deluge.Client.core.set_config(changed, {4965 deluge.client.core.set_config(changed, { 4855 4966 success: this.onSetConfig, 4856 4967 scope: this … … 4863 4974 }, 4864 4975 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; 4872 4983 }, 4873 4984 4874 4985 /** 4875 4986 * Adds a page to the preferences window. 4876 * @param { mixed} page4987 * @param {Mixed} page 4877 4988 */ 4878 4989 addPage: function(page) { 4879 4990 var store = this.categoriesGrid.getStore(); 4880 4991 var name = page.title; 4881 store. loadData([[name]], true);4992 store.add([new PreferencesRecord({name: name})]); 4882 4993 page['bodyStyle'] = 'margin: 5px'; 4883 4994 this.pages[name] = this.configPanel.add(page); … … 4896 5007 delete this.pages[page.title]; 4897 5008 }, 4898 4899 /** 4900 * Return the options manager for the preferences window.4901 * @ returns {Deluge.OptionsManager} the options manager5009 5010 /** 5011 * Select which preferences page is displayed. 5012 * @param {String} page The page name to change to 4902 5013 */ 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 4907 5021 onGotConfig: function(config) { 4908 5022 this.getOptionsManager().set(config); 4909 5023 }, 4910 5024 5025 // private 4911 5026 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 4927 5031 onSetConfig: function() { 4928 5032 this.getOptionsManager().commit(); 4929 5033 }, 4930 4931 onShow: function() { 5034 5035 // private 5036 onAfterRender: function() { 4932 5037 if (!this.categoriesGrid.getSelectionModel().hasSelection()) { 4933 5038 this.categoriesGrid.getSelectionModel().selectFirstRow(); 4934 5039 } 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({ 4937 5047 success: this.onGotConfig, 4938 5048 scope: this 4939 5049 }) 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(); 4940 5061 } 4941 5062 }); 4942 4943 Deluge.Preferences = new Ext.deluge.PreferencesWindow(); 5063 deluge.preferences = new Deluge.preferences.PreferencesWindow(); 4944 5064 /* 4945 5065 Script: Deluge.Preferences.Downloads.js … … 4975 5095 */ 4976 5096 4977 Ext.namespace('Ext.deluge.preferences'); 4978 Ext.deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { 5097 Ext.namespace('Deluge.preferences'); 5098 5099 /** 5100 * @class Deluge.preferences.Downloads 5101 * @extends Ext.form.FormPanel 5102 */ 5103 Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { 4979 5104 constructor: function(config) { 4980 5105 config = Ext.apply({ … … 4985 5110 width: 320 4986 5111 }, config); 4987 Ext.deluge.preferences.Downloads.superclass.constructor.call(this, config);5112 Deluge.preferences.Downloads.superclass.constructor.call(this, config); 4988 5113 }, 4989 5114 4990 5115 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(); 4994 5119 var fieldset = this.add({ 4995 5120 xtype: 'fieldset', … … 5091 5216 5092 5217 onShow: function() { 5093 Ext.deluge.preferences.Downloads.superclass.onShow.call(this);5218 Deluge.preferences.Downloads.superclass.onShow.call(this); 5094 5219 } 5095 5220 }); 5096 Deluge.Preferences.addPage(new Ext.deluge.preferences.Downloads());5221 deluge.preferences.addPage(new Deluge.preferences.Downloads()); 5097 5222 /* 5098 Script: Deluge.Preferences.Network.js5223 Script: deluge.preferences.Network.js 5099 5224 The network preferences page. 5100 5225 … … 5128 5253 */ 5129 5254 5130 Ext.namespace('Ext.deluge.preferences'); 5131 5132 Ext.deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { 5255 Ext.namespace('Deluge.preferences'); 5256 5257 /** 5258 * @class Deluge.preferences.Network 5259 * @extends Ext.form.FormPanel 5260 */ 5261 Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { 5133 5262 constructor: function(config) { 5134 5263 config = Ext.apply({ … … 5137 5266 layout: 'form' 5138 5267 }, config); 5139 Ext.deluge.preferences.Network.superclass.constructor.call(this, config);5268 Deluge.preferences.Network.superclass.constructor.call(this, config); 5140 5269 }, 5141 5270 5142 5271 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(); 5145 5274 5146 5275 var fieldset = this.add({ … … 5329 5458 } 5330 5459 }); 5331 Deluge.Preferences.addPage(new Ext.deluge.preferences.Network());5460 deluge.preferences.addPage(new Deluge.preferences.Network()); 5332 5461 /* 5333 Script: Deluge.Preferences.Encryption.js5462 Script: deluge.preferences.Encryption.js 5334 5463 The encryption preferences page. 5335 5464 … … 5363 5492 */ 5364 5493 5365 Ext.namespace('Ext.deluge.preferences'); 5366 Ext.deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, { 5494 Ext.namespace('Deluge.preferences'); 5495 5496 /** 5497 * @class Deluge.preferences.Encryption 5498 * @extends Ext.form.FormPanel 5499 */ 5500 Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, { 5367 5501 constructor: function(config) { 5368 5502 config = Ext.apply({ … … 5371 5505 layout: 'form' 5372 5506 }, config); 5373 Ext.deluge.preferences.Encryption.superclass.constructor.call(this, config);5507 Deluge.preferences.Encryption.superclass.constructor.call(this, config); 5374 5508 }, 5375 5509 5376 5510 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(); 5380 5514 5381 5515 var fieldset = this.add({ … … 5443 5577 } 5444 5578 }); 5445 Deluge.Preferences.addPage(new Ext.deluge.preferences.Encryption());/* 5446 Script: Deluge.Preferences.Bandwidth.js 5579 deluge.preferences.addPage(new Deluge.preferences.Encryption()); 5580 /* 5581 Script: deluge.preferences.Bandwidth.js 5447 5582 The bandwidth preferences page. 5448 5583 … … 5476 5611 */ 5477 5612 5478 Ext.namespace('Ext.deluge.preferences'); 5479 Ext.deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { 5613 Ext.namespace('Deluge.preferences'); 5614 5615 /** 5616 * @class Deluge.preferences.Bandwidth 5617 * @extends Ext.form.FormPanel 5618 */ 5619 Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { 5480 5620 constructor: function(config) { 5481 5621 config = Ext.apply({ … … 5485 5625 labelWidth: 10 5486 5626 }, config); 5487 Ext.deluge.preferences.Bandwidth.superclass.constructor.call(this, config);5627 Deluge.preferences.Bandwidth.superclass.constructor.call(this, config); 5488 5628 }, 5489 5629 5490 5630 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(); 5494 5634 var fieldset = this.add({ 5495 5635 xtype: 'fieldset', … … 5656 5796 } 5657 5797 }); 5658 Deluge.Preferences.addPage(new Ext.deluge.preferences.Bandwidth());5798 deluge.preferences.addPage(new Deluge.preferences.Bandwidth()); 5659 5799 /* 5660 5800 Script: Deluge.Preferences.Interface.js … … 5690 5830 */ 5691 5831 5692 Ext.namespace('Ext.deluge.preferences'); 5693 Ext.deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { 5832 Ext.namespace('Deluge.preferences'); 5833 5834 /** 5835 * @class Deluge.preferences.Interface 5836 * @extends Ext.form.FormPanel 5837 */ 5838 Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { 5694 5839 constructor: function(config) { 5695 5840 config = Ext.apply({ … … 5698 5843 layout: 'form' 5699 5844 }, config); 5700 Ext.deluge.preferences.Interface.superclass.constructor.call(this, config);5845 Deluge.preferences.Interface.superclass.constructor.call(this, config); 5701 5846 }, 5702 5847 5703 5848 initComponent: function() { 5704 Ext.deluge.preferences.Interface.superclass.initComponent.call(this);5849 Deluge.preferences.Interface.superclass.initComponent.call(this); 5705 5850 5706 5851 var optMan = this.optionsManager = new Deluge.OptionsManager(); … … 5843 5988 var changed = this.optionsManager.getDirty(); 5844 5989 if (!Ext.isObjectEmpty(changed)) { 5845 Deluge.Client.web.set_config(changed, {5990 deluge.client.web.set_config(changed, { 5846 5991 success: this.onSetConfig, 5847 5992 scope: this … … 5869 6014 5870 6015 var oldPassword = this.oldPassword.getValue(); 5871 Deluge.Client.auth.change_password(oldPassword, newPassword, {6016 deluge.client.auth.change_password(oldPassword, newPassword, { 5872 6017 success: function(result) { 5873 6018 if (!result) { … … 5904 6049 5905 6050 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({ 5908 6053 success: this.onGotConfig, 5909 6054 scope: this … … 5916 6061 } 5917 6062 }); 5918 Deluge.Preferences.addPage(new Ext.deluge.preferences.Interface());6063 deluge.preferences.addPage(new Deluge.preferences.Interface()); 5919 6064 /* 5920 6065 Script: Deluge.Preferences.Other.js … … 5950 6095 */ 5951 6096 5952 Ext.namespace('Ext.deluge.preferences'); 5953 Ext.deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, { 6097 Ext.namespace('Deluge.preferences'); 6098 6099 /** 6100 * @class Deluge.preferences.Other 6101 * @extends Ext.form.FormPanel 6102 */ 6103 Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, { 5954 6104 constructor: function(config) { 5955 6105 config = Ext.apply({ … … 5958 6108 layout: 'form' 5959 6109 }, config); 5960 Ext.deluge.preferences.Other.superclass.constructor.call(this, config);6110 Deluge.preferences.Other.superclass.constructor.call(this, config); 5961 6111 }, 5962 6112 5963 6113 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(); 5967 6117 5968 6118 var fieldset = this.add({ … … 6022 6172 } 6023 6173 }); 6024 Deluge.Preferences.addPage(new Ext.deluge.preferences.Other());6174 deluge.preferences.addPage(new Deluge.preferences.Other()); 6025 6175 /* 6026 6176 Script: Deluge.Preferences.Daemon.js … … 6056 6206 */ 6057 6207 6058 Ext.namespace('Ext.deluge.preferences'); 6059 Ext.deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { 6208 Ext.namespace('Deluge.preferences'); 6209 6210 /** 6211 * @class Deluge.preferences.Daemon 6212 * @extends Ext.form.FormPanel 6213 */ 6214 Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { 6060 6215 constructor: function(config) { 6061 6216 config = Ext.apply({ … … 6064 6219 layout: 'form' 6065 6220 }, config); 6066 Ext.deluge.preferences.Daemon.superclass.constructor.call(this, config);6221 Deluge.preferences.Daemon.superclass.constructor.call(this, config); 6067 6222 }, 6068 6223 6069 6224 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(); 6073 6228 6074 6229 var fieldset = this.add({ … … 6124 6279 } 6125 6280 }); 6126 Deluge.Preferences.addPage(new Ext.deluge.preferences.Daemon());6281 deluge.preferences.addPage(new Deluge.preferences.Daemon()); 6127 6282 /* 6128 6283 Script: Deluge.Preferences.Queue.js … … 6158 6313 */ 6159 6314 6160 Ext.namespace('Ext.deluge.preferences'); 6161 Ext.deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { 6315 Ext.namespace('Deluge.preferences'); 6316 6317 /** 6318 * @class Deluge.preferences.Queue 6319 * @extends Ext.form.FormPanel 6320 */ 6321 Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { 6162 6322 constructor: function(config) { 6163 6323 config = Ext.apply({ … … 6166 6326 layout: 'form' 6167 6327 }, config); 6168 Ext.deluge.preferences.Queue.superclass.constructor.call(this, config);6328 Deluge.preferences.Queue.superclass.constructor.call(this, config); 6169 6329 }, 6170 6330 6171 6331 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(); 6175 6335 6176 6336 var fieldset = this.add({ … … 6345 6505 } 6346 6506 }); 6347 Deluge.Preferences.addPage(new Ext.deluge.preferences.Queue());6507 deluge.preferences.addPage(new Deluge.preferences.Queue()); 6348 6508 /* 6349 6509 Script: Deluge.Preferences.Proxy.js … … 6379 6539 */ 6380 6540 6381 Ext.namespace('Ext.deluge.preferences'); 6382 Ext.deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { 6541 Ext.namespace('Deluge.preferences'); 6542 6543 /** 6544 * @class Deluge.preferences.ProxyField 6545 * @extends Ext.form.FormSet 6546 */ 6547 Deluge.preferences.ProxyField = Ext.extend(Ext.form.FieldSet, { 6383 6548 6384 6549 constructor: function(config) { … … 6388 6553 labelWidth: 70 6389 6554 }, config); 6390 Ext.deluge.preferences.ProxyField.superclass.constructor.call(this, config);6555 Deluge.preferences.ProxyField.superclass.constructor.call(this, config); 6391 6556 }, 6392 6557 6393 6558 initComponent: function() { 6394 Ext.deluge.preferences.ProxyField.superclass.initComponent.call(this);6559 Deluge.preferences.ProxyField.superclass.initComponent.call(this); 6395 6560 this.type = this.add({ 6396 6561 xtype: 'combo', … … 6513 6678 }); 6514 6679 6515 6516 Ext.deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { 6680 /** 6681 * @class Deluge.preferences.Proxy 6682 * @extends Ext.form.FormPanel 6683 */ 6684 Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { 6517 6685 constructor: function(config) { 6518 6686 config = Ext.apply({ … … 6521 6689 layout: 'form' 6522 6690 }, config); 6523 Ext.deluge.preferences.Proxy.superclass.constructor.call(this, config);6691 Deluge.preferences.Proxy.superclass.constructor.call(this, config); 6524 6692 }, 6525 6693 6526 6694 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({ 6529 6697 title: _('Peer'), 6530 6698 name: 'peer' … … 6532 6700 this.peer.on('change', this.onProxyChange, this); 6533 6701 6534 this.web_seed = this.add(new Ext.deluge.preferences.ProxyField({6702 this.web_seed = this.add(new Deluge.preferences.ProxyField({ 6535 6703 title: _('Web Seed'), 6536 6704 name: 'web_seed' … … 6538 6706 this.web_seed.on('change', this.onProxyChange, this); 6539 6707 6540 this.tracker = this.add(new Ext.deluge.preferences.ProxyField({6708 this.tracker = this.add(new Deluge.preferences.ProxyField({ 6541 6709 title: _('Tracker'), 6542 6710 name: 'tracker' … … 6544 6712 this.tracker.on('change', this.onProxyChange, this); 6545 6713 6546 this.dht = this.add(new Ext.deluge.preferences.ProxyField({6714 this.dht = this.add(new Deluge.preferences.ProxyField({ 6547 6715 title: _('DHT'), 6548 6716 name: 'dht' … … 6550 6718 this.dht.on('change', this.onProxyChange, this); 6551 6719 6552 Deluge.Preferences.getOptionsManager().bind('proxies', this);6720 deluge.preferences.getOptionsManager().bind('proxies', this); 6553 6721 }, 6554 6722 … … 6576 6744 } 6577 6745 }); 6578 Deluge.Preferences.addPage(new Ext.deluge.preferences.Proxy());6746 deluge.preferences.addPage(new Deluge.preferences.Proxy()); 6579 6747 /* 6580 Script: Deluge.Preferences.Cache.js6748 Script: deluge.preferences.Cache.js 6581 6749 The cache preferences page. 6582 6750 … … 6610 6778 */ 6611 6779 6612 Ext.namespace('Ext.deluge.preferences'); 6613 Ext.deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { 6780 Ext.namespace('Deluge.preferences'); 6781 6782 /** 6783 * @class Deluge.preferences.Cache 6784 * @extends Ext.form.FormPanel 6785 */ 6786 Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { 6614 6787 constructor: function(config) { 6615 6788 config = Ext.apply({ … … 6618 6791 layout: 'form' 6619 6792 }, config); 6620 Ext.deluge.preferences.Cache.superclass.constructor.call(this, config);6793 Deluge.preferences.Cache.superclass.constructor.call(this, config); 6621 6794 }, 6622 6795 6623 6796 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(); 6627 6800 6628 6801 var fieldset = this.add({ … … 6660 6833 } 6661 6834 }); 6662 Deluge.Preferences.addPage(new Ext.deluge.preferences.Cache());6835 deluge.preferences.addPage(new Deluge.preferences.Cache()); 6663 6836 /* 6664 6837 Script: Deluge.Preferences.Plugins.js … … 6694 6867 */ 6695 6868 6696 Ext.namespace('Ext.deluge.preferences'); 6697 6698 Ext.deluge.preferences.InstallPlugin = Ext.extend(Ext.Window, { 6869 Ext.namespace('Deluge.preferences'); 6870 6871 /** 6872 * @class Deluge.preferences.InstallPluginWindow 6873 * @extends Ext.Window 6874 */ 6875 Deluge.preferences.InstallPluginWindow = Ext.extend(Ext.Window, { 6699 6876 6700 6877 height: 115, … … 6718 6895 6719 6896 initComponent: function() { 6720 Ext.deluge.add.FileWindow.superclass.initComponent.call(this);6897 Deluge.add.FileWindow.superclass.initComponent.call(this); 6721 6898 this.addButton(_('Install'), this.onInstall, this); 6722 6899 … … 6759 6936 var path = upload.result.files[0] 6760 6937 this.form.getForm().findField('pluginEgg').setValue(''); 6761 Deluge.Client.web.upload_plugin(filename, path, {6938 deluge.client.web.upload_plugin(filename, path, { 6762 6939 success: this.onUploadPlugin, 6763 6940 scope: this, … … 6767 6944 } 6768 6945 }); 6769 6770 6771 Ext.deluge.preferences.Plugins = Ext.extend(Ext.Panel, { 6946 6947 /** 6948 * @class Deluge.preferences.Plugins 6949 * @extends Ext.Panel 6950 */ 6951 Deluge.preferences.Plugins = Ext.extend(Ext.Panel, { 6772 6952 constructor: function(config) { 6773 6953 config = Ext.apply({ … … 6778 6958 cls: 'x-deluge-plugins' 6779 6959 }, config); 6780 Ext.deluge.preferences.Plugins.superclass.constructor.call(this, config);6960 Deluge.preferences.Plugins.superclass.constructor.call(this, config); 6781 6961 }, 6782 6962 … … 6792 6972 6793 6973 initComponent: function() { 6794 Ext.deluge.preferences.Plugins.superclass.initComponent.call(this);6974 Deluge.preferences.Plugins.superclass.initComponent.call(this); 6795 6975 this.defaultValues = { 6796 6976 'version': '', … … 6847 7027 iconCls: 'x-deluge-install-plugin', 6848 7028 text: _('Install'), 6849 handler: this.onInstallPlugin ,7029 handler: this.onInstallPluginWindow, 6850 7030 scope: this 6851 7031 }, '->', { … … 6878 7058 this.pluginInfo.on('render', this.onPluginInfoRender, this); 6879 7059 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); 6883 7063 }, 6884 7064 6885 7065 disablePlugin: function(plugin) { 6886 Deluge.Client.core.disable_plugin(plugin);7066 deluge.client.core.disable_plugin(plugin); 6887 7067 }, 6888 7068 6889 7069 enablePlugin: function(plugin) { 6890 Deluge.Client.core.enable_plugin(plugin);7070 deluge.client.core.enable_plugin(plugin); 6891 7071 }, 6892 7072 … … 6898 7078 6899 7079 updatePlugins: function() { 6900 Deluge.Client.web.get_plugins({7080 deluge.client.web.get_plugins({ 6901 7081 success: this.onGotPlugins, 6902 7082 scope: this … … 6951 7131 }, 6952 7132 6953 onInstallPlugin : function() {7133 onInstallPluginWindow: function() { 6954 7134 if (!this.installWindow) { 6955 this.installWindow = new Ext.deluge.preferences.InstallPlugin();7135 this.installWindow = new Deluge.preferences.InstallPluginWindow(); 6956 7136 this.installWindow.on('pluginadded', this.onPluginInstall, this); 6957 7137 } … … 6978 7158 6979 7159 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'), { 6981 7161 success: this.onGotPluginInfo, 6982 7162 scope: this … … 6992 7172 } 6993 7173 }); 6994 Deluge.Preferences.addPage(new Ext.deluge.preferences.Plugins());7174 deluge.preferences.addPage(new Deluge.preferences.Plugins()); 6995 7175 /* 6996 7176 Script: … … 7027 7207 7028 7208 /** 7029 * @class Ext.deluge.RemoveWindow7209 * @class Deluge.RemoveWindow 7030 7210 */ 7031 Ext.deluge.RemoveWindow = Ext.extend(Ext.Window, {7211 Deluge.RemoveWindow = Ext.extend(Ext.Window, { 7032 7212 7033 7213 constructor: function(config) { … … 7043 7223 iconCls: 'x-deluge-remove-window-icon' 7044 7224 }, config); 7045 Ext.deluge.RemoveWindow.superclass.constructor.call(this, config);7225 Deluge.RemoveWindow.superclass.constructor.call(this, config); 7046 7226 }, 7047 7227 7048 7228 initComponent: function() { 7049 Ext.deluge.RemoveWindow.superclass.initComponent.call(this);7229 Deluge.RemoveWindow.superclass.initComponent.call(this); 7050 7230 this.addButton(_('Cancel'), this.onCancel, this); 7051 7231 this.addButton(_('Remove With Data'), this.onRemoveData, this); … … 7061 7241 remove: function(removeData) { 7062 7242 Ext.each(this.torrentIds, function(torrentId) { 7063 Deluge.Client.core.remove_torrent(torrentId, removeData, {7243 deluge.client.core.remove_torrent(torrentId, removeData, { 7064 7244 success: function() { 7065 7245 this.onRemoved(torrentId); … … 7073 7253 7074 7254 show: function(ids) { 7075 Ext.deluge.RemoveWindow.superclass.show.call(this);7255 Deluge.RemoveWindow.superclass.show.call(this); 7076 7256 this.torrentIds = ids; 7077 7257 }, … … 7091 7271 7092 7272 onRemoved: function(torrentId) { 7093 Deluge.Events.fire('torrentRemoved', torrentId);7273 deluge.events.fire('torrentRemoved', torrentId); 7094 7274 this.hide(); 7095 Deluge.UI.update();7275 deluge.ui.update(); 7096 7276 } 7097 7277 }); 7098 7278 7099 Deluge.RemoveWindow = new Ext.deluge.RemoveWindow();7279 deluge.removeWindow = new Deluge.RemoveWindow(); 7100 7280 /* 7101 Script: deluge-bars.js7281 Script: Deluge.Sidebar.js 7102 7282 Contains all objects and functions related to the statusbar, toolbar and 7103 7283 sidebar. … … 7145 7325 if (r.store.id == 'tracker_host') { 7146 7326 if (value != 'Error') { 7147 image = String.format('url( /tracker/{0})', value);7327 image = String.format('url(' + deluge.config.base + 'tracker/{0})', value); 7148 7328 } else { 7149 7329 lname = null; … … 7160 7340 7161 7341 /** 7162 * @class Ext.deluge.Sidebar7342 * @class Deluge.Sidebar 7163 7343 * @author Damien Churchill <damoxc@gmail.com> 7164 7344 * @version 1.3 7165 7345 */ 7166 Ext.deluge.Sidebar = Ext.extend(Ext.Panel, {7346 Deluge.Sidebar = Ext.extend(Ext.Panel, { 7167 7347 7168 7348 // private … … 7186 7366 cmargins: '5 0 0 5' 7187 7367 }, config); 7188 Ext.deluge.Sidebar.superclass.constructor.call(this, config);7368 Deluge.Sidebar.superclass.constructor.call(this, config); 7189 7369 }, 7190 7370 7191 7371 // private 7192 7372 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); 7195 7375 }, 7196 7376 7197 7377 createFilter: function(filter, states) { 7198 var store = new Ext.data. SimpleStore({7199 id : filter,7378 var store = new Ext.data.ArrayStore({ 7379 idIndex: 0, 7200 7380 fields: [ 7201 7381 {name: 'filter'}, … … 7203 7383 ] 7204 7384 }); 7385 store.id = filter; 7205 7386 7206 7387 var title = filter.replace('_', ' '); … … 7235 7416 }); 7236 7417 7237 if ( Deluge.config['sidebar_show_zero'] == false) {7418 if (deluge.config['sidebar_show_zero'] == false) { 7238 7419 states = this.removeZero(states); 7239 7420 } … … 7245 7426 this.panels[filter] = panel; 7246 7427 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(); 7255 7429 }, 7256 7430 7257 7431 getFilters: function() { 7258 7432 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 7271 7448 return filters; 7272 7449 }, … … 7282 7459 7283 7460 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(); 7294 7462 }, 7295 7463 … … 7327 7495 7328 7496 updateFilter: function(filter, states) { 7329 if ( Deluge.config['sidebar_show_zero']== false) {7497 if (deluge.config.sidebar_show_zero == false) { 7330 7498 states = this.removeZero(states); 7331 7499 } 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(); 7337 7527 } 7338 7528 }); 7339 Deluge.Sidebar = new Ext.deluge.Sidebar();7529 deluge.sidebar = new Deluge.Sidebar(); 7340 7530 })(); 7341 Ext.deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, {7531 Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { 7342 7532 constructor: function(config) { 7343 7533 config = Ext.apply({ … … 7346 7536 defaultText: _('Not Connected') 7347 7537 }, config); 7348 Ext.deluge.Statusbar.superclass.constructor.call(this, config);7538 Deluge.Statusbar.superclass.constructor.call(this, config); 7349 7539 }, 7350 7540 7351 7541 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); 7356 7546 }, 7357 7547 7358 7548 createButtons: function() { 7359 this. add({7549 this.buttons = this.add({ 7360 7550 id: 'statusbar-connections', 7361 7551 text: ' ', … … 7363 7553 iconCls: 'x-deluge-connections', 7364 7554 tooltip: _('Connections'), 7365 menu: Deluge.Menus.Connections7555 menu: deluge.menus.connections 7366 7556 }, '-', { 7367 7557 id: 'statusbar-downspeed', … … 7370 7560 iconCls: 'x-deluge-downloading', 7371 7561 tooltip: _('Download Speed'), 7372 menu: Deluge.Menus.Download7562 menu: deluge.menus.download 7373 7563 }, '-', { 7374 7564 id: 'statusbar-upspeed', … … 7377 7567 iconCls: 'x-deluge-seeding', 7378 7568 tooltip: _('Upload Speed'), 7379 menu: Deluge.Menus.Upload7569 menu: deluge.menus.upload 7380 7570 }, '-', { 7381 7571 id: 'statusbar-traffic', … … 7401 7591 7402 7592 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) { 7410 7601 item.show(); 7411 7602 item.enable(); 7412 7603 }); 7413 7604 } 7605 this.doLayout(); 7414 7606 }, 7415 7607 7416 7608 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) { 7419 7611 item.hide(); 7420 7612 item.disable(); 7421 7613 }); 7614 this.doLayout(); 7422 7615 }, 7423 7616 … … 7430 7623 var item = this.items.get('statusbar-' + name); 7431 7624 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; 7434 7627 var str = String.format(config.format, value, limit); 7435 7628 } 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; 7437 7630 } 7438 7631 item.setText(str); … … 7484 7677 this.items.get('statusbar-freespace').setText(fsize(stats.free_space)); 7485 7678 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); 7489 7682 } 7490 7683 }); 7491 Deluge.Statusbar = new Ext.deluge.Statusbar();7684 deluge.statusbar = new Deluge.Statusbar(); 7492 7685 /* 7493 7686 Script: Deluge.Toolbar.js … … 7526 7719 /** 7527 7720 * An extension of the <tt>Ext.Toolbar</tt> class that provides an extensible toolbar for Deluge. 7528 * @class Ext.deluge.Toolbar7721 * @class Deluge.Toolbar 7529 7722 * @extends Ext.Toolbar 7530 7723 */ 7531 Ext.deluge.Toolbar = Ext.extend(Ext.Toolbar, {7724 Deluge.Toolbar = Ext.extend(Ext.Toolbar, { 7532 7725 constructor: function(config) { 7533 7726 config = Ext.apply({ … … 7535 7728 { 7536 7729 id: 'create', 7537 cls: 'x-btn-text-icon',7538 7730 disabled: true, 7539 7731 text: _('Create'), 7540 icon : '/icons/create.png',7732 iconCls: 'icon-create', 7541 7733 handler: this.onTorrentAction 7542 7734 },{ 7543 7735 id: 'add', 7544 cls: 'x-btn-text-icon',7545 7736 disabled: true, 7546 7737 text: _('Add'), 7547 icon : '/icons/add.png',7738 iconCls: 'icon-add', 7548 7739 handler: this.onTorrentAdd 7549 7740 },{ 7550 7741 id: 'remove', 7551 cls: 'x-btn-text-icon',7552 7742 disabled: true, 7553 7743 text: _('Remove'), 7554 icon : '/icons/remove.png',7744 iconCls: 'icon-remove', 7555 7745 handler: this.onTorrentAction 7556 7746 },'|',{ 7557 7747 id: 'pause', 7558 cls: 'x-btn-text-icon',7559 7748 disabled: true, 7560 7749 text: _('Pause'), 7561 icon : '/icons/pause.png',7750 iconCls: 'icon-pause', 7562 7751 handler: this.onTorrentAction 7563 7752 },{ 7564 7753 id: 'resume', 7565 cls: 'x-btn-text-icon',7566 7754 disabled: true, 7567 7755 text: _('Resume'), 7568 icon : '/icons/start.png',7756 iconCls: 'icon-resume', 7569 7757 handler: this.onTorrentAction 7570 7758 },'|',{ … … 7573 7761 disabled: true, 7574 7762 text: _('Up'), 7575 icon : '/icons/up.png',7763 iconCls: 'icon-up', 7576 7764 handler: this.onTorrentAction 7577 7765 },{ 7578 7766 id: 'down', 7579 cls: 'x-btn-text-icon',7580 7767 disabled: true, 7581 7768 text: _('Down'), 7582 icon : '/icons/down.png',7769 iconCls: 'icon-down', 7583 7770 handler: this.onTorrentAction 7584 7771 },'|',{ 7585 7772 id: 'preferences', 7586 cls: 'x-btn-text-icon',7587 7773 text: _('Preferences'), 7588 7774 iconCls: 'x-deluge-preferences', … … 7591 7777 },{ 7592 7778 id: 'connectionman', 7593 cls: 'x-btn-text-icon',7594 7779 text: _('Connection Manager'), 7595 7780 iconCls: 'x-deluge-connection-manager', … … 7598 7783 },'->',{ 7599 7784 id: 'help', 7600 cls: 'x-btn-text-icon', 7601 icon: '/icons/help.png', 7785 iconCls: 'icon-help', 7602 7786 text: _('Help'), 7603 7787 handler: this.onHelpClick, … … 7605 7789 },{ 7606 7790 id: 'logout', 7607 cls: 'x-btn-text-icon', 7608 icon: '/icons/logout.png', 7791 iconCls: 'icon-logout', 7609 7792 disabled: true, 7610 7793 text: _('Logout'), … … 7614 7797 ] 7615 7798 }, config); 7616 Ext.deluge.Toolbar.superclass.constructor.call(this, config);7799 Deluge.Toolbar.superclass.constructor.call(this, config); 7617 7800 }, 7618 7801 … … 7622 7805 7623 7806 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); 7627 7810 }, 7628 7811 … … 7645 7828 onLogout: function() { 7646 7829 this.items.get('logout').disable(); 7647 Deluge.Login.logout();7830 deluge.login.logout(); 7648 7831 }, 7649 7832 7650 7833 onConnectionManagerClick: function() { 7651 Deluge.ConnectionManager.show();7834 deluge.connectionManager.show(); 7652 7835 }, 7653 7836 … … 7657 7840 7658 7841 onPreferencesClick: function() { 7659 Deluge.Preferences.show();7842 deluge.preferences.show(); 7660 7843 }, 7661 7844 7662 7845 onTorrentAction: function(item) { 7663 var selection = Deluge.Torrents.getSelections();7846 var selection = deluge.torrents.getSelections(); 7664 7847 var ids = []; 7665 7848 Ext.each(selection, function(record) { … … 7669 7852 switch (item.id) { 7670 7853 case 'remove': 7671 Deluge.RemoveWindow.show(ids);7854 deluge.removeWindow.show(ids); 7672 7855 break; 7673 7856 case 'pause': 7674 7857 case 'resume': 7675 Deluge.Client.core[item.id + '_torrent'](ids, {7858 deluge.client.core[item.id + '_torrent'](ids, { 7676 7859 success: function() { 7677 Deluge.UI.update();7860 deluge.ui.update(); 7678 7861 } 7679 7862 }); … … 7681 7864 case 'up': 7682 7865 case 'down': 7683 Deluge.Client.core['queue_' + item.id](ids, {7866 deluge.client.core['queue_' + item.id](ids, { 7684 7867 success: function() { 7685 Deluge.UI.update();7868 deluge.ui.update(); 7686 7869 } 7687 7870 }); … … 7691 7874 7692 7875 onTorrentAdd: function() { 7693 Deluge.Add.show();7876 deluge.add.show(); 7694 7877 } 7695 7878 }); 7696 7879 7697 Deluge.Toolbar = new Ext.deluge.Toolbar();7880 deluge.toolbar = new Deluge.Toolbar(); 7698 7881 /* 7699 7882 Script: Deluge.Torrent.js … … 7862 8045 } 7863 8046 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); 7865 8048 } 7866 8049 … … 7870 8053 7871 8054 /** 7872 * Ext.deluge.TorrentGrid Class8055 * Deluge.TorrentGrid Class 7873 8056 * 7874 8057 * @author Damien Churchill <damoxc@gmail.com> 7875 8058 * @version 1.3 7876 8059 * 7877 * @class Ext.deluge.TorrentGrid8060 * @class Deluge.TorrentGrid 7878 8061 * @extends Ext.grid.GridPanel 7879 8062 * @constructor 7880 8063 * @param {Object} config Configuration options 7881 8064 */ 7882 Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {8065 Deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, { 7883 8066 7884 8067 // object to store contained torrent ids … … 8004 8187 }) 8005 8188 }, config); 8006 Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);8189 Deluge.TorrentGrid.superclass.constructor.call(this, config); 8007 8190 }, 8008 8191 8009 8192 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); 8013 8196 8014 8197 this.on('rowcontextmenu', function(grid, rowIndex, e) { … … 8018 8201 selection.selectRow(rowIndex); 8019 8202 } 8020 Deluge.Menus.Torrent.showAt(e.getPoint());8203 deluge.menus.torrent.showAt(e.getPoint()); 8021 8204 }); 8022 8205 }, … … 8040 8223 }, 8041 8224 8225 /** 8226 * Returns the currently selected records. 8227 */ 8042 8228 getSelections: function() { 8043 8229 return this.getSelectionModel().getSelections(); … … 8074 8260 if (!torrents[record.id]) { 8075 8261 store.remove(record); 8262 delete this.torrents[record.id]; 8076 8263 } 8077 } );8264 }, this); 8078 8265 store.commitChanges(); 8266 8267 var sortState = store.getSortState() 8268 if (!sortState) return; 8269 store.sort(sortState.field, sortState.direction); 8079 8270 }, 8080 8271 … … 8082 8273 onDisconnect: function() { 8083 8274 this.getStore().removeAll(); 8275 this.torrents = {}; 8084 8276 }, 8085 8277 … … 8096 8288 } 8097 8289 }); 8098 Deluge.Torrents = new Ext.deluge.TorrentGrid();8290 deluge.torrents = new Deluge.TorrentGrid(); 8099 8291 })(); 8100 8292 /* … … 8138 8330 * together and handles the 2 second poll. 8139 8331 */ 8140 Deluge.UI= {8332 deluge.ui = { 8141 8333 8142 8334 errorCount: 0, … … 8154 8346 title: 'Deluge', 8155 8347 layout: 'border', 8156 tbar: Deluge.Toolbar,8348 tbar: deluge.toolbar, 8157 8349 items: [ 8158 Deluge.Sidebar,8159 Deluge.Details,8160 Deluge.Torrents8350 deluge.sidebar, 8351 deluge.details, 8352 deluge.torrents 8161 8353 ], 8162 bbar: Deluge.Statusbar8354 bbar: deluge.statusbar 8163 8355 }); 8164 8356 … … 8168 8360 }); 8169 8361 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]; 8178 8370 plugin.enable(); 8179 8371 } … … 8182 8374 Ext.QuickTips.init(); 8183 8375 8184 Deluge.Client.on('connected', function(e) {8185 Deluge.Login.show();8376 deluge.client.on('connected', function(e) { 8377 deluge.login.show(); 8186 8378 }, this, {single: true}); 8187 8379 8188 8380 this.update = this.update.createDelegate(this); 8381 8382 this.originalTitle = document.title; 8189 8383 }, 8190 8384 8191 8385 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, { 8194 8388 success: this.onUpdate, 8195 8389 failure: this.onUpdateError, 8196 8390 scope: this 8197 8391 }); 8198 Deluge.Details.update();8392 deluge.details.update(); 8199 8393 }, 8200 8394 … … 8217 8411 */ 8218 8412 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']); 8223 8423 this.errorCount = 0; 8224 8424 }, … … 8245 8445 8246 8446 onPluginEnabled: function(pluginName) { 8247 Deluge.Client.web.get_plugin_resources(pluginName, {8447 deluge.client.web.get_plugin_resources(pluginName, { 8248 8448 success: this.onGotPluginResources, 8249 8449 scope: this … … 8252 8452 8253 8453 onGotPluginResources: function(resources) { 8254 var scripts = ( Deluge.debug) ? resources.debug_scripts : resources.scripts;8454 var scripts = (deluge.debug) ? resources.debug_scripts : resources.scripts; 8255 8455 Ext.each(scripts, function(script) { 8256 8456 Ext.ux.JSLoader({ … … 8263 8463 8264 8464 onPluginDisabled: function(pluginName) { 8265 Deluge.Plugins[pluginName].disable();8465 deluge.plugins[pluginName].disable(); 8266 8466 }, 8267 8467 8268 8468 onPluginLoaded: function(options) { 8269 8469 // This could happen if the plugin has multiple scripts 8270 if (! Deluge.Plugins[options.pluginName]) return;8470 if (!deluge.plugins[options.pluginName]) return; 8271 8471 8272 8472 // Enable the plugin 8273 Deluge.Plugins[options.pluginName].enable();8473 deluge.plugins[options.pluginName].enable(); 8274 8474 }, 8275 8475 … … 8282 8482 clearInterval(this.running); 8283 8483 this.running = false; 8284 Deluge.Torrents.getStore().removeAll();8484 deluge.torrents.getStore().removeAll(); 8285 8485 } 8286 8486 } … … 8288 8488 8289 8489 Ext.onReady(function(e) { 8290 Deluge.UI.initialize();8490 deluge.ui.initialize(); 8291 8491 }); -
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("<","<").replace(">",">");return a.replace("&","&")},isObjectEmpty:function(b){for(var a in b){return false}return true},isObjectsEqual:function(d,c){var b=true;if(!d||!c){return false}for(var a in d){if(d[a]!=c[a]){b=false}}return b},keys:function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b},values:function(c){var a=[];for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys;Ext.BLANK_IMAGE_URL="/images/s.gif";Ext.USE_NATIVE_JSON=true})();(function(){var a='<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:" ",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()});1 Ext.state.Manager.setProvider(new Ext.state.CookieProvider());(function(){Ext.apply(Ext,{escapeHTML:function(a){a=String(a).replace("<","<").replace(">",">");return a.replace("&","&")},isObjectEmpty:function(b){for(var a in b){return false}return true},isObjectsEqual:function(d,c){var b=true;if(!d||!c){return false}for(var a in d){if(d[a]!=c[a]){b=false}}return b},keys:function(c){var b=[];for(var a in c){if(c.hasOwnProperty(a)){b.push(a)}}return b},values:function(c){var a=[];for(var b in c){if(c.hasOwnProperty(b)){a.push(c[b])}}return a},splat:function(b){var a=Ext.type(b);return(a)?((a!="array")?[b]:b):[]}});Ext.getKeys=Ext.keys;Ext.BLANK_IMAGE_URL=deluge.config.base+"images/s.gif";Ext.USE_NATIVE_JSON=true})();Deluge={progressTpl:'<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:" ",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.