From 610a1bb3139f8ded69561b290d7ce61b5a039676 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 17 Jan 2021 15:48:35 +0000 Subject: [Lint] Update pre-commit hook and isort versions * Fixed black hook requiring Py3.6 to installed locally. Will now assume Py3.6+ in installed. * Added isort traceback in pre-commit flake8 hook fails * Updated versions of Black, Prettier and isort * Keep Flake8 at 3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638 * New pyproject config for isort v5 with fixes for Python 2 imports. * Fixed travis config to run Python 3.6 for lint run. Replaced the virtualenv with_system_site_packages config with Travis specific Python config value so lint run doesn't attempt to append with_system_site_packages to Python 3.6 command. --- .pre-commit-config.yaml | 15 +++-- .travis.yml | 23 +++---- deluge/common.py | 13 ++-- deluge/config.py | 8 +-- deluge/core/core.py | 4 +- deluge/core/daemon.py | 5 +- deluge/core/filtermanager.py | 4 +- deluge/core/torrent.py | 4 +- .../plugins/AutoAdd/deluge_autoadd/data/autoadd.js | 50 ++++++--------- .../AutoAdd/deluge_autoadd/data/autoadd_options.js | 64 +++++++++---------- .../data/autoadd_options/main_tab.js | 14 ++-- .../data/autoadd_options/options_tab.js | 12 ++-- .../Blocklist/deluge_blocklist/data/blocklist.js | 36 +++++------ .../plugins/Execute/deluge_execute/data/execute.js | 68 ++++++++------------ .../Extractor/deluge_extractor/data/extractor.js | 14 ++-- deluge/plugins/Label/deluge_label/data/label.js | 73 ++++++++++----------- .../deluge_notifications/data/notifications.js | 46 +++++++------- .../Notifications/deluge_notifications/gtkui.py | 2 +- .../Scheduler/deluge_scheduler/data/scheduler.js | 62 +++++++++--------- deluge/plugins/Stats/deluge_stats/data/stats.js | 6 +- .../plugins/Stats/deluge_stats/tests/test_stats.py | 7 +- deluge/plugins/Toggle/deluge_toggle/data/toggle.js | 6 +- deluge/ui/console/cmdline/commands/add.py | 2 +- deluge/ui/console/cmdline/commands/plugin.py | 2 +- deluge/ui/console/console.py | 4 +- deluge/ui/console/modes/basemode.py | 4 +- deluge/ui/console/modes/torrentdetail.py | 2 +- deluge/ui/console/parser.py | 18 +++--- deluge/ui/console/widgets/fields.py | 4 +- deluge/ui/gtk3/__init__.py | 3 +- deluge/ui/gtk3/dialogs.py | 2 +- deluge/ui/gtk3/gtkui.py | 2 +- deluge/ui/gtk3/ipcinterface.py | 4 +- deluge/ui/gtk3/listview.py | 11 ++-- deluge/ui/gtk3/peers_tab.py | 2 +- deluge/ui/gtk3/preferences.py | 2 +- deluge/ui/gtk3/torrentdetails.py | 4 +- deluge/ui/web/js/deluge-all/AboutWindow.js | 20 +++--- deluge/ui/web/js/deluge-all/AddConnectionWindow.js | 8 +-- deluge/ui/web/js/deluge-all/AddTrackerWindow.js | 25 +++----- deluge/ui/web/js/deluge-all/Client.js | 24 +++---- deluge/ui/web/js/deluge-all/ConnectionManager.js | 60 +++++++++--------- deluge/ui/web/js/deluge-all/Deluge.js | 24 ++++--- .../ui/web/js/deluge-all/EditConnectionWindow.js | 20 ++---- deluge/ui/web/js/deluge-all/EditTrackerWindow.js | 25 +++----- deluge/ui/web/js/deluge-all/EditTrackersWindow.js | 46 ++++++-------- deluge/ui/web/js/deluge-all/EventsManager.js | 20 +++--- deluge/ui/web/js/deluge-all/FileBrowser.js | 2 +- deluge/ui/web/js/deluge-all/FilterPanel.js | 20 +++--- deluge/ui/web/js/deluge-all/Formatters.js | 14 ++-- deluge/ui/web/js/deluge-all/Keys.js | 2 +- deluge/ui/web/js/deluge-all/LoginWindow.js | 24 +++---- deluge/ui/web/js/deluge-all/Menus.js | 8 +-- deluge/ui/web/js/deluge-all/MoveStorage.js | 12 ++-- deluge/ui/web/js/deluge-all/MultiOptionsManager.js | 28 ++++---- deluge/ui/web/js/deluge-all/OptionsManager.js | 38 +++++------ deluge/ui/web/js/deluge-all/OtherLimitWindow.js | 17 ++--- deluge/ui/web/js/deluge-all/Plugin.js | 16 ++--- deluge/ui/web/js/deluge-all/RemoveWindow.js | 16 ++--- deluge/ui/web/js/deluge-all/Sidebar.js | 26 ++++---- deluge/ui/web/js/deluge-all/Statusbar.js | 22 +++---- deluge/ui/web/js/deluge-all/StatusbarMenu.js | 14 ++-- deluge/ui/web/js/deluge-all/Toolbar.js | 34 +++++----- deluge/ui/web/js/deluge-all/TorrentGrid.js | 34 +++++----- deluge/ui/web/js/deluge-all/UI.js | 38 +++++------ deluge/ui/web/js/deluge-all/add/AddWindow.js | 44 ++++++------- deluge/ui/web/js/deluge-all/add/FilesTab.js | 16 ++--- deluge/ui/web/js/deluge-all/add/OptionsPanel.js | 26 ++++---- deluge/ui/web/js/deluge-all/add/OptionsTab.js | 6 +- deluge/ui/web/js/deluge-all/add/UrlWindow.js | 10 +-- deluge/ui/web/js/deluge-all/add/Window.js | 4 +- deluge/ui/web/js/deluge-all/data/SortTypes.js | 4 +- .../ui/web/js/deluge-all/details/DetailsPanel.js | 18 +++--- deluge/ui/web/js/deluge-all/details/DetailsTab.js | 14 ++-- deluge/ui/web/js/deluge-all/details/FilesTab.js | 38 +++++------ deluge/ui/web/js/deluge-all/details/OptionsTab.js | 24 +++---- deluge/ui/web/js/deluge-all/details/PeersTab.js | 14 ++-- deluge/ui/web/js/deluge-all/details/StatusTab.js | 14 ++-- .../web/js/deluge-all/preferences/BandwidthPage.js | 4 +- .../ui/web/js/deluge-all/preferences/CachePage.js | 2 +- .../ui/web/js/deluge-all/preferences/DaemonPage.js | 2 +- .../web/js/deluge-all/preferences/DownloadsPage.js | 4 +- .../js/deluge-all/preferences/EncryptionPage.js | 2 +- .../deluge-all/preferences/InstallPluginWindow.js | 8 +-- .../web/js/deluge-all/preferences/InterfacePage.js | 22 +++---- .../web/js/deluge-all/preferences/NetworkPage.js | 8 +-- .../ui/web/js/deluge-all/preferences/OtherPage.js | 4 +- .../web/js/deluge-all/preferences/PluginsPage.js | 46 +++++++------- .../js/deluge-all/preferences/PreferencesWindow.js | 30 ++++----- .../ui/web/js/deluge-all/preferences/ProxyField.js | 12 ++-- .../ui/web/js/deluge-all/preferences/ProxyPage.js | 10 +-- .../ui/web/js/deluge-all/preferences/QueuePage.js | 4 +- deluge/ui/web/js/extjs/ext-extensions/JSLoader.js | 8 +-- deluge/ui/web/js/extjs/ext-extensions/Spinner.js | 74 +++++++++++----------- deluge/ui/web/js/extjs/ext-extensions/StatusBar.js | 18 +++--- .../extjs/ext-extensions/form/FileUploadField.js | 34 +++++----- .../js/extjs/ext-extensions/form/RadioGroupFix.js | 12 ++-- .../js/extjs/ext-extensions/form/SpinnerField.js | 10 +-- .../js/extjs/ext-extensions/form/SpinnerGroup.js | 24 +++---- .../js/extjs/ext-extensions/form/ToggleField.js | 13 ++-- .../web/js/extjs/ext-extensions/grid/BufferView.js | 32 +++++----- .../extjs/ext-extensions/layout/FormLayoutFix.js | 2 +- .../ext-extensions/tree/MultiSelectionModelFix.js | 6 +- .../web/js/extjs/ext-extensions/tree/TreeGrid.js | 48 +++++++------- .../ext-extensions/tree/TreeGridColumnResizer.js | 18 +++--- .../extjs/ext-extensions/tree/TreeGridColumns.js | 4 +- .../js/extjs/ext-extensions/tree/TreeGridLoader.js | 2 +- .../js/extjs/ext-extensions/tree/TreeGridNodeUI.js | 10 +-- .../extjs/ext-extensions/tree/TreeGridNodeUIFix.js | 2 +- .../ext-extensions/tree/TreeGridRenderColumn.js | 2 +- .../js/extjs/ext-extensions/tree/TreeGridSorter.js | 14 ++-- pyproject.toml | 5 ++ requirements-tests.txt | 2 +- setup.cfg | 18 ------ 114 files changed, 954 insertions(+), 1033 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c80703764..133d536dd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,28 +6,29 @@ exclude: > )$ repos: - repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 20.8b1 hooks: - id: black name: Fmt Black - language_version: python3.6 - - repo: https://github.com/prettier/prettier - rev: 1.19.1 + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.2.1 hooks: - id: prettier name: Fmt Prettier # Workaround to list modified files only. args: [--list-different] - repo: https://gitlab.com/pycqa/flake8 + # v3.7.9 due to E402 issue: https://gitlab.com/pycqa/flake8/-/issues/638 rev: 3.7.9 hooks: - id: flake8 name: Chk Flake8 additional_dependencies: - - flake8-isort==2.7 - - pep8-naming==0.8.2 + - flake8-isort==4.0.0 + - pep8-naming==0.11.1 + args: [--isort-show-traceback] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.4.0 + rev: v3.4.0 hooks: - id: double-quote-string-fixer name: Fix Double-quotes diff --git a/.travis.yml b/.travis.yml index b10ec78a9..ac4c79b1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,10 +4,8 @@ dist: xenial language: python python: # Travis Xenial Python to support system_site_packages - - 3.5 + - 3.5_with_system_site_packages cache: pip -virtualenv: - system_site_packages: true env: global: @@ -21,19 +19,20 @@ jobs: include: - name: Unit tests env: TOX_ENV=py3 - - name: Unit tests - libtorrent 1.2 - env: TOX_ENV=py3 - addons: - apt: - sources: [sourceline: "ppa:libtorrent.org/1.2-daily"] - packages: [python3-libtorrent, python3-venv] + #~ - name: Unit tests - libtorrent 1.2 + #~ env: TOX_ENV=py3 + #~ addons: + #~ apt: + #~ sources: [sourceline: "ppa:libtorrent.org/1.2-daily"] + #~ packages: [python3-libtorrent, python3-venv] - name: Unit tests - Python 2 env: TOX_ENV=py27 - python: 2.7 + python: 2.7_with_system_site_packages - if: commit_message =~ SECURITY_TEST env: TOX_ENV=security - name: Code linting env: TOX_ENV=lint + python: 3.6 - name: Docs build env: TOX_ENV=docs - name: GTK unit tests @@ -73,7 +72,9 @@ install: before_script: - export PYTHONPATH=$PYTHONPATH:$PWD # Verify libtorrent installed and version - - python -c "import libtorrent as lt; print(lt.__version__)" + - "if [ $TOX_ENV != 'lint' ]; then + python -c 'import libtorrent as lt; print(lt.__version__)'; + fi" # Start xvfb for the GTKUI tests - "if [ $TOX_ENV == 'gtkui' ]; then /sbin/start-stop-daemon --start --quiet --background \ diff --git a/deluge/common.py b/deluge/common.py index d50fe5ac2..e90d166c0 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -43,8 +43,8 @@ try: from urllib.request import pathname2url except ImportError: # PY2 fallback - from urlparse import urljoin # pylint: disable=ungrouped-imports from urllib import pathname2url, unquote_plus # pylint: disable=ungrouped-imports + from urlparse import urljoin # pylint: disable=ungrouped-imports # Windows workaround for HTTPS requests requiring certificate authority bundle. # see: https://twistedmatrix.com/trac/ticket/9209 @@ -1013,9 +1013,9 @@ def decode_bytes(byte_str, encoding='utf8'): if encoding.lower() not in ['utf8', 'utf-8']: encodings.insert(0, lambda: (encoding, 'strict')) - for l in encodings: + for enc in encodings: try: - return byte_str.decode(*l()) + return byte_str.decode(*enc()) except UnicodeDecodeError: pass return '' @@ -1144,6 +1144,7 @@ AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL def create_auth_file(): import stat + import deluge.configmanager auth_file = deluge.configmanager.get_config_dir('auth') @@ -1159,6 +1160,7 @@ def create_auth_file(): def create_localclient_account(append=False): import random from hashlib import sha1 as sha + import deluge.configmanager auth_file = deluge.configmanager.get_config_dir('auth') @@ -1244,8 +1246,7 @@ def set_env_variable(name, value): os.environ[name] = value.encode('utf8') if windows_check(): - from ctypes import windll - from ctypes import cdll + from ctypes import cdll, windll # Update the copy maintained by Windows (so SysInternals Process Explorer sees it) result = windll.kernel32.SetEnvironmentVariableW(name, value) @@ -1274,7 +1275,7 @@ def unicode_argv(): # Versions 2.x of Python don't support Unicode in sys.argv on # Windows, with the underlying Windows API instead replacing multi-byte # characters with '?'. - from ctypes import POINTER, byref, cdll, c_int, windll + from ctypes import POINTER, byref, c_int, cdll, windll from ctypes.wintypes import LPCWSTR, LPWSTR get_cmd_linew = cdll.kernel32.GetCommandLineW diff --git a/deluge/config.py b/deluge/config.py index 90944a38f..80b30faf5 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -204,9 +204,9 @@ class Config(object): global callLater if callLater is None: # Must import here and not at the top or it will throw ReactorAlreadyInstalledError - from twisted.internet.reactor import ( + from twisted.internet.reactor import ( # pylint: disable=redefined-outer-name callLater, - ) # pylint: disable=redefined-outer-name + ) # Run the set_function for this key if any try: for func in self.__set_functions[key]: @@ -304,9 +304,9 @@ class Config(object): global callLater if callLater is None: # Must import here and not at the top or it will throw ReactorAlreadyInstalledError - from twisted.internet.reactor import ( + from twisted.internet.reactor import ( # pylint: disable=redefined-outer-name callLater, - ) # pylint: disable=redefined-outer-name + ) # We set the save_timer for 5 seconds if not already set if not self._save_timer or not self._save_timer.active(): diff --git a/deluge/core/core.py b/deluge/core/core.py index 8498ff9a8..2160f769a 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -57,10 +57,10 @@ from deluge.event import ( from deluge.httpdownloader import download_file try: - from urllib.request import urlopen, URLError + from urllib.request import URLError, urlopen except ImportError: # PY2 fallback - from urllib2 import urlopen, URLError + from urllib2 import URLError, urlopen log = logging.getLogger(__name__) diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py index d7ab813ba..3c2ac643b 100644 --- a/deluge/core/daemon.py +++ b/deluge/core/daemon.py @@ -200,6 +200,7 @@ class Daemon(object): if rpc not in self.get_method_list(): return False - return self.rpcserver.get_session_auth_level() >= self.rpcserver.get_rpc_auth_level( - rpc + return ( + self.rpcserver.get_session_auth_level() + >= self.rpcserver.get_rpc_auth_level(rpc) ) diff --git a/deluge/core/filtermanager.py b/deluge/core/filtermanager.py index 9d8964689..90589ef1f 100644 --- a/deluge/core/filtermanager.py +++ b/deluge/core/filtermanager.py @@ -100,9 +100,7 @@ def tracker_error_filter(torrent_ids, values): class FilterManager(component.Component): - """FilterManager - - """ + """FilterManager""" def __init__(self, core): component.Component.__init__(self, 'FilterManager') diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index b69909cbb..be91b9da5 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -1340,8 +1340,8 @@ class Torrent(object): def scrape_tracker(self): """Scrape the tracker - A scrape request queries the tracker for statistics such as total - number of incomplete peers, complete peers, number of downloads etc. + A scrape request queries the tracker for statistics such as total + number of incomplete peers, complete peers, number of downloads etc. """ try: self.handle.scrape_tracker() diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js index 40086b3fa..ebed40180 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd.js @@ -25,7 +25,7 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { border: false, watchdirs: {}, - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.AutoAddPage.superclass.initComponent.call(this); var autoAdd = this; @@ -41,10 +41,10 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { sortable: true, dataIndex: 'enabled', tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { - getCheckbox: function(checked, selected) { + getCheckbox: function (checked, selected) { Deluge.ux.AutoAdd.onClickFunctions[ selected.id - ] = function() { + ] = function () { if (selected.enabled) { deluge.client.autoadd.disable_watchdir( selected.id @@ -122,9 +122,9 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { this.on('show', this.onPreferencesShow, this); }, - updateWatchDirs: function() { + updateWatchDirs: function () { deluge.client.autoadd.get_watchdirs({ - success: function(watchdirs) { + success: function (watchdirs) { this.watchdirs = watchdirs; var watchdirsArray = []; for (var id in watchdirs) { @@ -145,12 +145,12 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { }); }, - onAddClick: function() { + onAddClick: function () { if (!this.addWin) { this.addWin = new Deluge.ux.AutoAdd.AddAutoAddCommandWindow(); this.addWin.on( 'watchdiradd', - function() { + function () { this.updateWatchDirs(); }, this @@ -159,12 +159,12 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { this.addWin.show(); }, - onEditClick: function() { + onEditClick: function () { if (!this.editWin) { this.editWin = new Deluge.ux.AutoAdd.EditAutoAddCommandWindow(); this.editWin.on( 'watchdiredit', - function() { + function () { this.updateWatchDirs(); }, this @@ -174,39 +174,27 @@ Deluge.ux.preferences.AutoAddPage = Ext.extend(Ext.Panel, { this.editWin.show(id, this.watchdirs[id]); }, - onPreferencesShow: function() { + onPreferencesShow: function () { this.updateWatchDirs(); }, - onRemoveClick: function() { + onRemoveClick: function () { var record = this.list.getSelectedRecords()[0]; deluge.client.autoadd.remove(record.id, { - success: function() { + success: function () { this.updateWatchDirs(); }, scope: this, }); }, - onSelectionChange: function(dv, selections) { + onSelectionChange: function (dv, selections) { if (selections.length) { - this.panel - .getBottomToolbar() - .items.get(1) - .enable(); - this.panel - .getBottomToolbar() - .items.get(3) - .enable(); + this.panel.getBottomToolbar().items.get(1).enable(); + this.panel.getBottomToolbar().items.get(3).enable(); } else { - this.panel - .getBottomToolbar() - .items.get(1) - .disable(); - this.panel - .getBottomToolbar() - .items.get(3) - .disable(); + this.panel.getBottomToolbar().items.get(1).disable(); + this.panel.getBottomToolbar().items.get(3).disable(); } }, }); @@ -218,12 +206,12 @@ Deluge.plugins.AutoAddPlugin = Ext.extend(Deluge.Plugin, { prefsPage: null, }, - onDisable: function() { + onDisable: function () { deluge.preferences.removePage(Deluge.plugins.AutoAddPlugin.prefsPage); Deluge.plugins.AutoAddPlugin.prefsPage = null; }, - onEnable: function() { + onEnable: function () { /* * Called for each of the JavaScript files. * This will prevent adding unnecessary tabs to the preferences window. diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js index 49f752fbf..797d76585 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options.js @@ -60,7 +60,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { ], }), - initComponent: function() { + initComponent: function () { Deluge.ux.AutoAdd.AutoAddWindowBase.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); @@ -81,11 +81,11 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { }); }, - onCancelClick: function() { + onCancelClick: function () { this.hide(); }, - getOptions: function() { + getOptions: function () { var options = {}; options['enabled'] = Ext.getCmp('enabled').getValue(); @@ -102,22 +102,22 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { options['append_extension'] = Ext.getCmp('append_extension').getValue(); options['owner'] = Ext.getCmp('owner').getValue(); - this.toggle_ids.forEach(function(toggle_id) { + this.toggle_ids.forEach(function (toggle_id) { options[toggle_id] = Ext.getCmp(toggle_id).getValue(); }); - this.spin_ids.forEach(function(spin_id) { + this.spin_ids.forEach(function (spin_id) { options[spin_id] = Ext.getCmp(spin_id).getValue(); options[spin_id + '_toggle'] = Ext.getCmp( spin_id + '_toggle' ).getValue(); }); - this.spin_int_ids.forEach(function(spin_int_id) { + this.spin_int_ids.forEach(function (spin_int_id) { options[spin_int_id] = Ext.getCmp(spin_int_id).getValue(); options[spin_int_id + '_toggle'] = Ext.getCmp( spin_int_id + '_toggle' ).getValue(); }); - this.chk_ids.forEach(function(chk_id) { + this.chk_ids.forEach(function (chk_id) { options[chk_id] = Ext.getCmp(chk_id).getValue(); options[chk_id + '_toggle'] = Ext.getCmp( chk_id + '_toggle' @@ -137,7 +137,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { return options; }, - loadOptions: function(options) { + loadOptions: function (options) { /* * Populate all available options data to the UI */ @@ -193,7 +193,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { : false ); - this.spin_ids.forEach(function(spin_id) { + this.spin_ids.forEach(function (spin_id) { Ext.getCmp(spin_id).setValue( options[spin_id] !== undefined ? options[spin_id] : 0 ); @@ -203,7 +203,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { : false ); }); - this.chk_ids.forEach(function(chk_id) { + this.chk_ids.forEach(function (chk_id) { Ext.getCmp(chk_id).setValue( options[chk_id] !== undefined ? options[chk_id] : true ); @@ -237,14 +237,14 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { 'path', 'download_location', 'copy_torrent', - ].forEach(function(field) { + ].forEach(function (field) { value = options[field] !== undefined ? options[field] : ''; Ext.getCmp(field).setValue(value); }); if (Object.keys(options).length === 0) { deluge.client.core.get_config({ - success: function(config) { + success: function (config) { var value; Ext.getCmp('download_location').setValue( options['download_location'] !== undefined @@ -291,11 +291,11 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { } deluge.client.core.get_enabled_plugins({ - success: function(plugins) { + success: function (plugins) { if (plugins !== undefined && plugins.indexOf('Label') > -1) { this.MainTab.LabelFset.setVisible(true); deluge.client.label.get_labels({ - success: function(labels) { + success: function (labels) { for ( var index = 0; index < labels.length; @@ -305,7 +305,7 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { } this.labels.loadData(labels, false); }, - failure: function(failure) { + failure: function (failure) { console.error(failure); }, scope: this, @@ -324,30 +324,26 @@ Deluge.ux.AutoAdd.AutoAddWindowBase = Ext.extend(Ext.Window, { accounts[index] = [accounts[index]['username']]; } me.accounts.loadData(accounts, false); - Ext.getCmp('owner') - .setValue(owner) - .enable(); + Ext.getCmp('owner').setValue(owner).enable(); } function on_accounts_failure(failure) { deluge.client.autoadd.get_auth_user({ - success: function(user) { + success: function (user) { me.accounts.loadData([[user]], false); - Ext.getCmp('owner') - .setValue(user) - .disable(true); + Ext.getCmp('owner').setValue(user).disable(true); }, scope: this, }); } deluge.client.autoadd.is_admin_level({ - success: function(is_admin) { + success: function (is_admin) { if (is_admin) { deluge.client.core.get_known_accounts({ - success: function(accounts) { + success: function (accounts) { deluge.client.autoadd.get_auth_user({ - success: function(user) { + success: function (user) { on_accounts( accounts, options['owner'] !== undefined @@ -379,7 +375,7 @@ Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend( { title: _('Edit Watch Folder'), - initComponent: function() { + initComponent: function () { Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.initComponent.call( this ); @@ -389,7 +385,7 @@ Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend( }); }, - show: function(watchdir_id, options) { + show: function (watchdir_id, options) { Deluge.ux.AutoAdd.EditAutoAddCommandWindow.superclass.show.call( this ); @@ -397,11 +393,11 @@ Deluge.ux.AutoAdd.EditAutoAddCommandWindow = Ext.extend( this.loadOptions(options); }, - onSaveClick: function() { + onSaveClick: function () { try { var options = this.getOptions(); deluge.client.autoadd.set_options(this.watchdir_id, options, { - success: function() { + success: function () { this.fireEvent('watchdiredit', this, options); }, scope: this, @@ -429,7 +425,7 @@ Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend( { title: _('Add Watch Folder'), - initComponent: function() { + initComponent: function () { Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.initComponent.call( this ); @@ -439,21 +435,21 @@ Deluge.ux.AutoAdd.AddAutoAddCommandWindow = Ext.extend( }); }, - show: function() { + show: function () { Deluge.ux.AutoAdd.AddAutoAddCommandWindow.superclass.show.call( this ); this.loadOptions(); }, - onAddClick: function() { + onAddClick: function () { var options = this.getOptions(); deluge.client.autoadd.add(options, { - success: function() { + success: function () { this.fireEvent('watchdiradd', this, options); this.hide(); }, - failure: function(err) { + failure: function (err) { const regex = /: (.*\n)\n?\]/m; var error; if ((error = regex.exec(err.error.message)) !== null) { diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/main_tab.js b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/main_tab.js index 79d2600de..f685ff29f 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/main_tab.js +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/main_tab.js @@ -19,7 +19,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { id: 'main_tab_panel', title: _('Main'), - initComponent: function() { + initComponent: function () { Deluge.ux.AutoAdd.AutoAddMainPanel.superclass.initComponent.call(this); this.watchFolderFset = new Ext.form.FieldSet({ xtype: 'fieldset', @@ -69,7 +69,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { checked: true, hideLabel: true, listeners: { - check: function(cb, newValue) { + check: function (cb, newValue) { if (newValue) { Ext.getCmp( 'append_extension' @@ -98,7 +98,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { ), hideLabel: true, listeners: { - check: function(cb, newValue) { + check: function (cb, newValue) { if (newValue) { Ext.getCmp( 'append_extension' @@ -141,7 +141,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { ), hideLabel: true, listeners: { - check: function(cb, newValue) { + check: function (cb, newValue) { if (newValue) { Ext.getCmp( 'append_extension' @@ -201,7 +201,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { xtype: 'checkbox', boxLabel: _('Set download folder'), listeners: { - check: function(cb, checked) { + check: function (cb, checked) { Ext.getCmp('download_location').setDisabled( !checked ); @@ -233,7 +233,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { xtype: 'checkbox', boxLabel: _('Set move completed folder'), listeners: { - check: function(cb, checked) { + check: function (cb, checked) { Ext.getCmp('move_completed_path').setDisabled( !checked ); @@ -271,7 +271,7 @@ Deluge.ux.AutoAdd.AutoAddMainPanel = Ext.extend(Ext.Panel, { xtype: 'checkbox', boxLabel: _('Label:'), listeners: { - check: function(cb, checked) { + check: function (cb, checked) { Ext.getCmp('label').setDisabled(!checked); }, }, diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/options_tab.js b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/options_tab.js index a69490c25..4ce030efe 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/options_tab.js +++ b/deluge/plugins/AutoAdd/deluge_autoadd/data/autoadd_options/options_tab.js @@ -19,7 +19,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, { id: 'options_tab_panel', title: _('Options'), - initComponent: function() { + initComponent: function () { Deluge.ux.AutoAdd.AutoAddOptionsPanel.superclass.initComponent.call( this ); @@ -149,7 +149,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, { hideLabel: true, width: 175, listeners: { - check: function(cb, checked) { + check: function (cb, checked) { Ext.getCmp('stop_ratio').setDisabled( !checked ); @@ -223,7 +223,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, { this.add([this.ownerFset, this.bandwidthFset, this.queueFset]); }, - _getBandwidthContainer: function(values) { + _getBandwidthContainer: function (values) { return new Ext.Container({ xtype: 'container', layout: 'hbox', @@ -236,7 +236,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, { boxLabel: _(values.labelCheckbox), width: 175, listeners: { - check: function(cb, checked) { + check: function (cb, checked) { Ext.getCmp(values.idSpinner).setDisabled(!checked); }, }, @@ -257,7 +257,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, { }); }, - _getQueueContainer: function(values) { + _getQueueContainer: function (values) { return new Ext.Container({ xtype: 'container', layout: 'hbox', @@ -270,7 +270,7 @@ Deluge.ux.AutoAdd.AutoAddOptionsPanel = Ext.extend(Ext.Panel, { boxLabel: _(values.labelCheckbox), width: 175, listeners: { - check: function(cb, checked) { + check: function (cb, checked) { Ext.getCmp(values.nameRadio).setDisabled(!checked); Ext.getCmp('not_' + values.nameRadio).setDisabled( !checked diff --git a/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js b/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js index 8e4769c5f..8f1b93c21 100644 --- a/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js +++ b/deluge/plugins/Blocklist/deluge_blocklist/data/blocklist.js @@ -22,7 +22,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { border: false, autoScroll: true, - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.BlocklistPage.superclass.initComponent.call(this); this.URLFset = this.add({ @@ -210,11 +210,11 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { fields: [{ name: 'ip' }], }), listeners: { - afteredit: function(e) { + afteredit: function (e) { e.record.commit(); }, }, - setEmptyText: function(text) { + setEmptyText: function (text) { if (this.viewReady) { this.getView().emptyText = text; this.getView().refresh(); @@ -222,7 +222,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { Ext.apply(this.viewConfig, { emptyText: text }); } }, - loadData: function(data) { + loadData: function (data) { this.getStore().loadData(data); if (this.viewReady) { this.getView().updateHeaders(); @@ -264,7 +264,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { this.forceDownload.setHandler(this.forceDown, this); }, - onApply: function() { + onApply: function () { var config = {}; config['url'] = this.URL.getValue(); @@ -285,13 +285,13 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { deluge.client.blocklist.set_config(config); }, - onOk: function() { + onOk: function () { this.onApply(); }, - onUpdate: function() { + onUpdate: function () { deluge.client.blocklist.get_status({ - success: function(status) { + success: function (status) { if (status['state'] == 'Downloading') { this.InfoFset.hide(); this.checkDownload.getComponent(0).setDisabled(true); @@ -339,19 +339,19 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { }); }, - checkDown: function() { + checkDown: function () { this.onApply(); deluge.client.blocklist.check_import(); }, - forceDown: function() { + forceDown: function () { this.onApply(); deluge.client.blocklist.check_import((force = true)); }, - updateConfig: function() { + updateConfig: function () { deluge.client.blocklist.get_config({ - success: function(config) { + success: function (config) { this.URL.setValue(config['url']); this.checkListDays.setValue(config['check_after_days']); this.chkImportOnStart.setValue(config['load_on_start']); @@ -369,7 +369,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { }); deluge.client.blocklist.get_status({ - success: function(status) { + success: function (status) { this.lblFileSize.setText(fsize(status['file_size'])); this.lblDate.setText(fdate(status['file_date'])); this.lblType.setText(status['file_type']); @@ -381,7 +381,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { }); }, - addIP: function() { + addIP: function () { var store = this.WhitelistFset.getComponent(0).getStore(); var IP = store.recordType; var i = new IP({ @@ -392,7 +392,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { this.WhitelistFset.getComponent(0).startEditing(0, 0); }, - deleteIP: function() { + deleteIP: function () { var selections = this.WhitelistFset.getComponent(0) .getSelectionModel() .getSelections(); @@ -403,7 +403,7 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { store.commitChanges(); }, - onDestroy: function() { + onDestroy: function () { Ext.TaskMgr.stop(this.updateTask); deluge.preferences.un('show', this.updateConfig, this); @@ -415,11 +415,11 @@ Deluge.ux.preferences.BlocklistPage = Ext.extend(Ext.Panel, { Deluge.plugins.BlocklistPlugin = Ext.extend(Deluge.Plugin, { name: 'Blocklist', - onDisable: function() { + onDisable: function () { deluge.preferences.removePage(this.prefsPage); }, - onEnable: function() { + onEnable: function () { this.prefsPage = deluge.preferences.addPage( new Deluge.ux.preferences.BlocklistPage() ); diff --git a/deluge/plugins/Execute/deluge_execute/data/execute.js b/deluge/plugins/Execute/deluge_execute/data/execute.js index bd6ac9860..dc0b11126 100644 --- a/deluge/plugins/Execute/deluge_execute/data/execute.js +++ b/deluge/plugins/Execute/deluge_execute/data/execute.js @@ -18,7 +18,7 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, { height: 130, closeAction: 'hide', - initComponent: function() { + initComponent: function () { Deluge.ux.ExecuteWindowBase.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); @@ -56,7 +56,7 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, { }); }, - onCancelClick: function() { + onCancelClick: function () { this.hide(); }, }); @@ -64,7 +64,7 @@ Deluge.ux.ExecuteWindowBase = Ext.extend(Ext.Window, { Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { title: _('Edit Command'), - initComponent: function() { + initComponent: function () { Deluge.ux.EditExecuteCommandWindow.superclass.initComponent.call(this); this.addButton(_('Save'), this.onSaveClick, this); this.addEvents({ @@ -72,7 +72,7 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { }); }, - show: function(command) { + show: function (command) { Deluge.ux.EditExecuteCommandWindow.superclass.show.call(this); this.command = command; this.form.getForm().setValues({ @@ -81,14 +81,14 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { }); }, - onSaveClick: function() { + onSaveClick: function () { var values = this.form.getForm().getFieldValues(); deluge.client.execute.save_command( this.command.id, values.event, values.command, { - success: function() { + success: function () { this.fireEvent( 'commandedit', this, @@ -106,7 +106,7 @@ Deluge.ux.EditExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { title: _('Add Command'), - initComponent: function() { + initComponent: function () { Deluge.ux.AddExecuteCommandWindow.superclass.initComponent.call(this); this.addButton(_('Add'), this.onAddClick, this); this.addEvents({ @@ -114,10 +114,10 @@ Deluge.ux.AddExecuteCommandWindow = Ext.extend(Deluge.ux.ExecuteWindowBase, { }); }, - onAddClick: function() { + onAddClick: function () { var values = this.form.getForm().getFieldValues(); deluge.client.execute.add_command(values.event, values.command, { - success: function() { + success: function () { this.fireEvent( 'commandadd', this, @@ -143,7 +143,7 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { layout: 'fit', border: false, - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.ExecutePage.superclass.initComponent.call(this); var event_map = (this.event_map = { complete: _('Torrent Complete'), @@ -166,7 +166,7 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { sortable: true, dataIndex: 'event', tpl: new Ext.XTemplate('{[this.getEvent(values.event)]}', { - getEvent: function(e) { + getEvent: function (e) { return event_map[e] ? event_map[e] : e; }, }), @@ -215,21 +215,21 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { this.on('show', this.onPreferencesShow, this); }, - updateCommands: function() { + updateCommands: function () { deluge.client.execute.get_commands({ - success: function(commands) { + success: function (commands) { this.list.getStore().loadData(commands); }, scope: this, }); }, - onAddClick: function() { + onAddClick: function () { if (!this.addWin) { this.addWin = new Deluge.ux.AddExecuteCommandWindow(); this.addWin.on( 'commandadd', - function() { + function () { this.updateCommands(); }, this @@ -238,19 +238,19 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { this.addWin.show(); }, - onCommandAdded: function(win, evt, cmd) { + onCommandAdded: function (win, evt, cmd) { var record = new this.list.getStore().recordType({ event: evt, command: cmd, }); }, - onEditClick: function() { + onEditClick: function () { if (!this.editWin) { this.editWin = new Deluge.ux.EditExecuteCommandWindow(); this.editWin.on( 'commandedit', - function() { + function () { this.updateCommands(); }, this @@ -259,39 +259,27 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { this.editWin.show(this.list.getSelectedRecords()[0]); }, - onPreferencesShow: function() { + onPreferencesShow: function () { this.updateCommands(); }, - onRemoveClick: function() { + onRemoveClick: function () { var record = this.list.getSelectedRecords()[0]; deluge.client.execute.remove_command(record.id, { - success: function() { + success: function () { this.updateCommands(); }, scope: this, }); }, - onSelectionChange: function(dv, selections) { + onSelectionChange: function (dv, selections) { if (selections.length) { - this.panel - .getBottomToolbar() - .items.get(1) - .enable(); - this.panel - .getBottomToolbar() - .items.get(3) - .enable(); + this.panel.getBottomToolbar().items.get(1).enable(); + this.panel.getBottomToolbar().items.get(3).enable(); } else { - this.panel - .getBottomToolbar() - .items.get(1) - .disable(); - this.panel - .getBottomToolbar() - .items.get(3) - .disable(); + this.panel.getBottomToolbar().items.get(1).disable(); + this.panel.getBottomToolbar().items.get(3).disable(); } }, }); @@ -299,11 +287,11 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { Deluge.plugins.ExecutePlugin = Ext.extend(Deluge.Plugin, { name: 'Execute', - onDisable: function() { + onDisable: function () { deluge.preferences.removePage(this.prefsPage); }, - onEnable: function() { + onEnable: function () { this.prefsPage = deluge.preferences.addPage( new Deluge.ux.preferences.ExecutePage() ); diff --git a/deluge/plugins/Extractor/deluge_extractor/data/extractor.js b/deluge/plugins/Extractor/deluge_extractor/data/extractor.js index b11cb30f6..952b6450b 100644 --- a/deluge/plugins/Extractor/deluge_extractor/data/extractor.js +++ b/deluge/plugins/Extractor/deluge_extractor/data/extractor.js @@ -21,7 +21,7 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, { layout: 'fit', border: false, - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.ExtractorPage.superclass.initComponent.call(this); this.form = this.add({ @@ -59,7 +59,7 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, { this.on('show', this.updateConfig, this); }, - onApply: function() { + onApply: function () { // build settings object var config = {}; @@ -69,13 +69,13 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, { deluge.client.extractor.set_config(config); }, - onOk: function() { + onOk: function () { this.onApply(); }, - updateConfig: function() { + updateConfig: function () { deluge.client.extractor.get_config({ - success: function(config) { + success: function (config) { this.extract_path.setValue(config['extract_path']); this.use_name_folder.setValue(config['use_name_folder']); }, @@ -87,11 +87,11 @@ Deluge.ux.preferences.ExtractorPage = Ext.extend(Ext.Panel, { Deluge.plugins.ExtractorPlugin = Ext.extend(Deluge.Plugin, { name: 'Extractor', - onDisable: function() { + onDisable: function () { deluge.preferences.removePage(this.prefsPage); }, - onEnable: function() { + onEnable: function () { this.prefsPage = deluge.preferences.addPage( new Deluge.ux.preferences.ExtractorPage() ); diff --git a/deluge/plugins/Label/deluge_label/data/label.js b/deluge/plugins/Label/deluge_label/data/label.js index ba7a7ac1d..b84ea6b69 100644 --- a/deluge/plugins/Label/deluge_label/data/label.js +++ b/deluge/plugins/Label/deluge_label/data/label.js @@ -20,7 +20,7 @@ Deluge.ux.preferences.LabelPage = Ext.extend(Ext.Panel, { layout: 'fit', border: false, - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.LabelPage.superclass.initComponent.call(this); fieldset = this.add({ xtype: 'fieldset', @@ -56,7 +56,7 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, { height: 100, closeAction: 'hide', - initComponent: function() { + initComponent: function () { Deluge.ux.AddLabelWindow.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Ok'), this.onOkClick, this); @@ -76,7 +76,7 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, { width: 220, listeners: { specialkey: { - fn: function(field, e) { + fn: function (field, e) { if (e.getKey() == 13) this.onOkClick(); }, scope: this, @@ -87,14 +87,14 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, { }); }, - onCancelClick: function() { + onCancelClick: function () { this.hide(); }, - onOkClick: function() { + onOkClick: function () { var label = this.form.getForm().getValues().name; deluge.client.label.add(label, { - success: function() { + success: function () { deluge.ui.update(); this.fireEvent('labeladded', label); }, @@ -103,17 +103,14 @@ Deluge.ux.AddLabelWindow = Ext.extend(Ext.Window, { this.hide(); }, - onHide: function(comp) { + onHide: function (comp) { Deluge.ux.AddLabelWindow.superclass.onHide.call(this, comp); this.form.getForm().reset(); }, - onShow: function(comp) { + onShow: function (comp) { Deluge.ux.AddLabelWindow.superclass.onShow.call(this, comp); - this.form - .getForm() - .findField('name') - .focus(false, 150); + this.form.getForm().findField('name').focus(false, 150); }, }); @@ -127,7 +124,7 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { height: 240, closeAction: 'hide', - initComponent: function() { + initComponent: function () { Deluge.ux.LabelOptionsWindow.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Ok'), this.onOkClick, this); @@ -385,18 +382,18 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { }); }, - getLabelOptions: function() { + getLabelOptions: function () { deluge.client.label.get_options(this.label, { success: this.gotOptions, scope: this, }); }, - gotOptions: function(options) { + gotOptions: function (options) { this.form.getForm().setValues(options); }, - show: function(label) { + show: function (label) { Deluge.ux.LabelOptionsWindow.superclass.show.call(this); this.label = label; this.setTitle(_('Label Options') + ': ' + this.label); @@ -404,11 +401,11 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { this.getLabelOptions(); }, - onCancelClick: function() { + onCancelClick: function () { this.hide(); }, - onOkClick: function() { + onOkClick: function () { var values = this.form.getForm().getFieldValues(); if (values['auto_add_trackers']) { values['auto_add_trackers'] = values['auto_add_trackers'].split( @@ -419,9 +416,9 @@ Deluge.ux.LabelOptionsWindow = Ext.extend(Ext.Window, { this.hide(); }, - onFieldChecked: function(field, checked) { + onFieldChecked: function (field, checked) { var fs = field.ownerCt.nextSibling(); - fs.items.each(function(field) { + fs.items.each(function (field) { field.setDisabled(!checked); }); }, @@ -436,7 +433,7 @@ Ext.ns('Deluge.plugins'); Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { name: 'Label', - createMenu: function() { + createMenu: function () { this.labelMenu = new Ext.menu.Menu({ items: [ { @@ -462,7 +459,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { }); }, - setFilter: function(filter) { + setFilter: function (filter) { filter.show_zero = true; filter.list.on('contextmenu', this.onLabelContextMenu, this); @@ -470,7 +467,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.filter = filter; }, - updateTorrentMenu: function(states) { + updateTorrentMenu: function (states) { this.torrentMenu.removeAll(true); this.torrentMenu.addMenuItem({ text: _('No Label'), @@ -489,7 +486,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { } }, - onDisable: function() { + onDisable: function () { deluge.sidebar.un('filtercreate', this.onFilterCreate); deluge.sidebar.un('afterfiltercreate', this.onAfterFilterCreate); delete Deluge.FilterPanel.templates.label; @@ -499,7 +496,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { deluge.preferences.removePage(this.prefsPage); }, - onEnable: function() { + onEnable: function () { this.prefsPage = deluge.preferences.addPage( new Deluge.ux.preferences.LabelPage() ); @@ -539,17 +536,17 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.registerTorrentStatus('label', _('Label')); }, - onAfterFilterCreate: function(sidebar, filter) { + onAfterFilterCreate: function (sidebar, filter) { if (filter.filter != 'label') return; this.updateTorrentMenu(filter.getStates()); }, - onFilterCreate: function(sidebar, filter) { + onFilterCreate: function (sidebar, filter) { if (filter.filter != 'label') return; this.setFilter(filter); }, - onLabelAddClick: function() { + onLabelAddClick: function () { if (!this.addWindow) { this.addWindow = new Deluge.ux.AddLabelWindow(); this.addWindow.on('labeladded', this.onLabelAdded, this); @@ -557,7 +554,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.addWindow.show(); }, - onLabelAdded: function(label) { + onLabelAdded: function (label) { var filter = deluge.sidebar.getFilter('label'); var states = filter.getStates(); var statesArray = []; @@ -582,7 +579,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.updateTorrentMenu(states); }, - onLabelContextMenu: function(dv, i, node, e) { + onLabelContextMenu: function (dv, i, node, e) { e.preventDefault(); if (!this.labelMenu) this.createMenu(); var r = dv.getRecord(node).get('filter'); @@ -597,7 +594,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.labelMenu.showAt(e.getXY()); }, - onLabelHeaderContextMenu: function(e, t) { + onLabelHeaderContextMenu: function (e, t) { e.preventDefault(); if (!this.labelMenu) this.createMenu(); this.labelMenu.items.get(1).setDisabled(true); @@ -605,18 +602,18 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { this.labelMenu.showAt(e.getXY()); }, - onLabelOptionsClick: function() { + onLabelOptionsClick: function () { if (!this.labelOpts) this.labelOpts = new Deluge.ux.LabelOptionsWindow(); this.labelOpts.show(this.filter.getState()); }, - onLabelRemoveClick: function() { + onLabelRemoveClick: function () { var state = this.filter.getState(); deluge.client.label.remove(state, { - success: function() { + success: function () { deluge.ui.update(); - this.torrentMenu.items.each(function(item) { + this.torrentMenu.items.each(function (item) { if (item.text != state) return; this.torrentMenu.remove(item); var i = item; @@ -626,12 +623,12 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { }); }, - onTorrentMenuClick: function(item, e) { + onTorrentMenuClick: function (item, e) { var ids = deluge.torrents.getSelectedIds(); - Ext.each(ids, function(id, i) { + Ext.each(ids, function (id, i) { if (ids.length == i + 1) { deluge.client.label.set_torrent(id, item.label, { - success: function() { + success: function () { deluge.ui.update(); }, }); diff --git a/deluge/plugins/Notifications/deluge_notifications/data/notifications.js b/deluge/plugins/Notifications/deluge_notifications/data/notifications.js index c9fb71fba..4b87e559f 100644 --- a/deluge/plugins/Notifications/deluge_notifications/data/notifications.js +++ b/deluge/plugins/Notifications/deluge_notifications/data/notifications.js @@ -21,7 +21,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { layout: 'fit', border: false, - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.NotificationsPage.superclass.initComponent.call( this ); @@ -44,7 +44,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { xtype: 'checkbox', boxLabel: _('Enabled'), listeners: { - check: function(object, checked) { + check: function (object, checked) { this.setSmtpDisabled(!checked); }, scope: this, @@ -227,11 +227,11 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { fields: [{ name: 'recipient' }], }), listeners: { - afteredit: function(e) { + afteredit: function (e) { e.record.commit(); }, }, - setEmptyText: function(text) { + setEmptyText: function (text) { if (this.viewReady) { this.getView().emptyText = text; this.getView().refresh(); @@ -239,7 +239,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { Ext.apply(this.viewConfig, { emptyText: text }); } }, - loadData: function(data) { + loadData: function (data) { this.getStore().loadData(data); if (this.viewReady) { this.getView().updateHeaders(); @@ -259,7 +259,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { }, colModel: new Ext.grid.ColumnModel({ defaults: { - renderer: function( + renderer: function ( value, meta, record, @@ -310,7 +310,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { ], }), listeners: { - cellclick: function(grid, rowIndex, colIndex, e) { + cellclick: function (grid, rowIndex, colIndex, e) { var record = grid.getStore().getAt(rowIndex); var field = grid.getColumnModel().getDataIndex(colIndex); var value = record.get(field); @@ -322,18 +322,18 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { } } }, - beforeedit: function(e) { + beforeedit: function (e) { if (Ext.isBoolean(e.value)) { return false; } return e.record.get('enabled'); }, - afteredit: function(e) { + afteredit: function (e) { e.record.commit(); }, }, - setEmptyText: function(text) { + setEmptyText: function (text) { if (this.viewReady) { this.getView().emptyText = text; this.getView().refresh(); @@ -341,13 +341,13 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { Ext.apply(this.viewConfig, { emptyText: text }); } }, - setSub: function(eventName) { + setSub: function (eventName) { var store = this.getStore(); var index = store.find('event', eventName); store.getAt(index).set('email', true); store.getAt(index).commit(); }, - loadData: function(data) { + loadData: function (data) { this.getStore().loadData(data); if (this.viewReady) { this.getView().updateHeaders(); @@ -374,9 +374,9 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { this.on('show', this.updateConfig, this); }, - updateConfig: function() { + updateConfig: function () { deluge.client.notifications.get_handled_events({ - success: function(events) { + success: function (events) { var data = []; var keys = Ext.keys(events); for (var i = 0; i < keys.length; i++) { @@ -388,7 +388,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { scope: this, }); deluge.client.notifications.get_config({ - success: function(config) { + success: function (config) { this.chkEnableEmail.setValue(config['smtp_enabled']); this.setSmtpDisabled(!config['smtp_enabled']); @@ -420,7 +420,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { }); }, - onApply: function() { + onApply: function () { var config = {}; config['smtp_enabled'] = this.chkEnableEmail.getValue(); @@ -461,11 +461,11 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { deluge.client.notifications.set_config(config); }, - onOk: function() { + onOk: function () { this.onApply(); }, - onAddClick: function() { + onAddClick: function () { var store = this.recipientsFset.getComponent(0).getStore(); var Recipient = store.recordType; var i = new Recipient({ @@ -476,7 +476,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { this.recipientsFset.getComponent(0).startEditing(0, 0); }, - onRemoveClick: function() { + onRemoveClick: function () { var selections = this.recipientsFset .getComponent(0) .getSelectionModel() @@ -488,7 +488,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { store.commitChanges(); }, - setSmtpDisabled: function(disable) { + setSmtpDisabled: function (disable) { this.hBoxHost.setDisabled(disable); this.hBoxPort.setDisabled(disable); this.hBoxUser.setDisabled(disable); @@ -498,7 +498,7 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { this.recipientsFset.getComponent(0).setDisabled(disable); }, - onDestroy: function() { + onDestroy: function () { deluge.preferences.un('show', this.updateConfig, this); Deluge.ux.preferences.NotificationsPage.superclass.onDestroy.call(this); @@ -508,11 +508,11 @@ Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, { name: 'Notifications', - onDisable: function() { + onDisable: function () { deluge.preferences.removePage(this.prefsPage); }, - onEnable: function() { + onEnable: function () { this.prefsPage = deluge.preferences.addPage( new Deluge.ux.preferences.NotificationsPage() ); diff --git a/deluge/plugins/Notifications/deluge_notifications/gtkui.py b/deluge/plugins/Notifications/deluge_notifications/gtkui.py index 486ee677a..cb26901a7 100644 --- a/deluge/plugins/Notifications/deluge_notifications/gtkui.py +++ b/deluge/plugins/Notifications/deluge_notifications/gtkui.py @@ -42,7 +42,7 @@ except ImportError: try: require_version('Notify', '0.7') - from gi.repository import Notify, GLib + from gi.repository import GLib, Notify except (ValueError, ImportError): POPUP_AVAILABLE = False else: diff --git a/deluge/plugins/Scheduler/deluge_scheduler/data/scheduler.js b/deluge/plugins/Scheduler/deluge_scheduler/data/scheduler.js index 13bec4605..f59068c5a 100644 --- a/deluge/plugins/Scheduler/deluge_scheduler/data/scheduler.js +++ b/deluge/plugins/Scheduler/deluge_scheduler/data/scheduler.js @@ -40,7 +40,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { ], daysOfWeek: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], - initComponent: function() { + initComponent: function () { Deluge.ux.ScheduleSelector.superclass.initComponent.call(this); // ExtJS' radiogroup implementation is very broken for styling. @@ -57,7 +57,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { });*/ }, - onRender: function(ct, position) { + onRender: function (ct, position) { Deluge.ux.ScheduleSelector.superclass.onRender.call(this, ct, position); var dom = this.body.dom; @@ -126,7 +126,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { Ext.each( this.daysOfWeek, - function(day) { + function (day) { var cells = []; var row = createEl(table, 'tr'); var label = createEl(row, 'th'); @@ -175,7 +175,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { ); }, - updateCell: function(cell) { + updateCell: function (cell) { // sanity check if (cell.currentValue == undefined) return; @@ -188,29 +188,29 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - getCurrentBrushValue: function() { + getCurrentBrushValue: function () { var v = null; var brushes = Ext.get(this.body.dom).findParent('form').elements[ this.stateBrushName ]; - Ext.each(brushes, function(b) { + Ext.each(brushes, function (b) { if (b.checked) v = b.value; }); return v; }, - onCellClick: function(event, cell) { + onCellClick: function (event, cell) { cell.oldValue = cell.currentValue; this.dragAnchor = null; }, - onCellMouseDown: function(event, cell) { + onCellMouseDown: function (event, cell) { this.dragAnchor = cell; }, - onCellMouseUp: function(event, cell) { + onCellMouseUp: function (event, cell) { // if we're dragging... if (this.dragAnchor) { // set all those between here and the anchor to the new values @@ -226,7 +226,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - onCellMouseOver: function(event, cell) { + onCellMouseOver: function (event, cell) { // LEFT TOOL TIP // if it isn't showing and we're dragging, show it. // otherwise if dragging, leave it alone unless we're dragging to the left. @@ -295,7 +295,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { // dragged into another day. Abort! Abort! Ext.each( this.daysOfWeek, - function(day) { + function (day) { this.revertCells(day, 0, 23); }, this @@ -323,7 +323,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - onCellMouseOut: function(event, cell) { + onCellMouseOut: function (event, cell) { if (!this.dragAnchor) this.hideCellLeftTooltip(); // revert state. If new state has been set, old and new will be equal. @@ -333,7 +333,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - previewCells: function(day, fromHour, toHour) { + previewCells: function (day, fromHour, toHour) { var cells = this.scheduleCells[day]; var curBrushValue = this.getCurrentBrushValue(); @@ -348,7 +348,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - revertCells: function(day, fromHour, toHour) { + revertCells: function (day, fromHour, toHour) { var cells = this.scheduleCells[day]; if (toHour > cells.length) toHour = cells.length; @@ -359,7 +359,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - confirmCells: function(day, fromHour, toHour) { + confirmCells: function (day, fromHour, toHour) { var cells = this.scheduleCells[day]; if (toHour > cells.length) toHour = cells.length; @@ -371,7 +371,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { } }, - showCellLeftTooltip: function(text, cell) { + showCellLeftTooltip: function (text, cell) { var tooltip = this.cellLeftTooltip; if (!tooltip) { @@ -400,19 +400,19 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { tooltip.style.visibility = 'visible'; }, - hideCellLeftTooltip: function() { + hideCellLeftTooltip: function () { if (this.cellLeftTooltip) { this.cellLeftTooltip.style.visibility = 'hidden'; } }, - isCellLeftTooltipHidden: function() { + isCellLeftTooltipHidden: function () { if (this.cellLeftTooltip) return this.cellLeftTooltip.style.visibility == 'hidden'; else return true; }, - showCellRightTooltip: function(text, cell) { + showCellRightTooltip: function (text, cell) { var tooltip = this.cellRightTooltip; if (!tooltip) { @@ -441,19 +441,19 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { tooltip.style.visibility = 'visible'; }, - hideCellRightTooltip: function() { + hideCellRightTooltip: function () { if (this.cellRightTooltip) { this.cellRightTooltip.style.visibility = 'hidden'; } }, - isCellRightTooltipHidden: function() { + isCellRightTooltipHidden: function () { if (this.cellRightTooltip) return this.cellRightTooltip.style.visibility == 'hidden'; else return true; }, - getConfig: function() { + getConfig: function () { var config = []; for (var i = 0; i < 24; i++) { @@ -471,7 +471,7 @@ Deluge.ux.ScheduleSelector = Ext.extend(Ext.form.FieldSet, { return config; }, - setConfig: function(config) { + setConfig: function (config) { for (var i = 0; i < 24; i++) { var hourConfig = config[i]; @@ -496,7 +496,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, { header: false, layout: 'fit', - initComponent: function() { + initComponent: function () { Deluge.ux.preferences.SchedulerPage.superclass.initComponent.call(this); this.form = this.add({ @@ -561,7 +561,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, { this.on('show', this.updateConfig, this); }, - onRender: function(ct, position) { + onRender: function (ct, position) { Deluge.ux.preferences.SchedulerPage.superclass.onRender.call( this, ct, @@ -572,7 +572,7 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, { this.form.doLayout(); }, - onApply: function() { + onApply: function () { // build settings object var config = {}; @@ -586,13 +586,13 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, { deluge.client.scheduler.set_config(config); }, - onOk: function() { + onOk: function () { this.onApply(); }, - updateConfig: function() { + updateConfig: function () { deluge.client.scheduler.get_config({ - success: function(config) { + success: function (config) { this.schedule.setConfig(config['button_state']); this.downloadLimit.setValue(config['low_down']); this.uploadLimit.setValue(config['low_up']); @@ -608,11 +608,11 @@ Deluge.ux.preferences.SchedulerPage = Ext.extend(Ext.Panel, { Deluge.plugins.SchedulerPlugin = Ext.extend(Deluge.Plugin, { name: 'Scheduler', - onDisable: function() { + onDisable: function () { deluge.preferences.removePage(this.prefsPage); }, - onEnable: function() { + onEnable: function () { this.prefsPage = deluge.preferences.addPage( new Deluge.ux.preferences.SchedulerPage() ); diff --git a/deluge/plugins/Stats/deluge_stats/data/stats.js b/deluge/plugins/Stats/deluge_stats/data/stats.js index 8f9e3f841..7ba3d272f 100644 --- a/deluge/plugins/Stats/deluge_stats/data/stats.js +++ b/deluge/plugins/Stats/deluge_stats/data/stats.js @@ -10,7 +10,7 @@ */ StatsPlugin = Ext.extend(Deluge.Plugin, { - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { name: 'Stats', @@ -20,8 +20,8 @@ StatsPlugin = Ext.extend(Deluge.Plugin, { StatsPlugin.superclass.constructor.call(this, config); }, - onDisable: function() {}, + onDisable: function () {}, - onEnable: function() {}, + onEnable: function () {}, }); new StatsPlugin(); diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py index 3b581be3e..07741cbf3 100644 --- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py @@ -72,14 +72,15 @@ class StatsTestCase(BaseTestCase): Not strictly a unit test, but tests if calls do not fail... """ + from deluge_stats import graph, gtkui + + from deluge.configmanager import ConfigManager from deluge.ui.gtkui.gtkui import DEFAULT_PREFS - from deluge.ui.gtkui.preferences import Preferences from deluge.ui.gtkui.mainwindow import MainWindow - from deluge.configmanager import ConfigManager from deluge.ui.gtkui.pluginmanager import PluginManager + from deluge.ui.gtkui.preferences import Preferences from deluge.ui.gtkui.torrentdetails import TorrentDetails from deluge.ui.gtkui.torrentview import TorrentView - from deluge_stats import graph, gtkui ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS) diff --git a/deluge/plugins/Toggle/deluge_toggle/data/toggle.js b/deluge/plugins/Toggle/deluge_toggle/data/toggle.js index 8e9a045ad..20fa4f445 100644 --- a/deluge/plugins/Toggle/deluge_toggle/data/toggle.js +++ b/deluge/plugins/Toggle/deluge_toggle/data/toggle.js @@ -10,7 +10,7 @@ */ TogglePlugin = Ext.extend(Deluge.Plugin, { - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { name: 'Toggle', @@ -20,8 +20,8 @@ TogglePlugin = Ext.extend(Deluge.Plugin, { TogglePlugin.superclass.constructor.call(this, config); }, - onDisable: function() {}, + onDisable: function () {}, - onEnable: function() {}, + onEnable: function () {}, }); new TogglePlugin(); diff --git a/deluge/ui/console/cmdline/commands/add.py b/deluge/ui/console/cmdline/commands/add.py index e063d488f..da42695b5 100644 --- a/deluge/ui/console/cmdline/commands/add.py +++ b/deluge/ui/console/cmdline/commands/add.py @@ -26,8 +26,8 @@ try: from urllib.request import url2pathname except ImportError: # PY2 fallback - from urlparse import urlparse # pylint: disable=ungrouped-imports from urllib import url2pathname # pylint: disable=ungrouped-imports + from urlparse import urlparse # pylint: disable=ungrouped-imports class Command(BaseCommand): diff --git a/deluge/ui/console/cmdline/commands/plugin.py b/deluge/ui/console/cmdline/commands/plugin.py index fafc77afd..72cecb40f 100644 --- a/deluge/ui/console/cmdline/commands/plugin.py +++ b/deluge/ui/console/cmdline/commands/plugin.py @@ -106,8 +106,8 @@ class Command(BaseCommand): elif options.install: import os.path - from base64 import b64encode import shutil + from base64 import b64encode filepath = options.install diff --git a/deluge/ui/console/console.py b/deluge/ui/console/console.py index 58d31d514..f683c749d 100644 --- a/deluge/ui/console/console.py +++ b/deluge/ui/console/console.py @@ -112,9 +112,9 @@ class Console(UI): ) # To properly print help message for the console commands ( e.g. deluge-console info -h), # we add a subparser for each command which will trigger the help/usage when given - from deluge.ui.console.parser import ( + from deluge.ui.console.parser import ( # import here because (see top) ConsoleCommandParser, - ) # import here because (see top) + ) self.console_parser = ConsoleCommandParser( parents=[self.parser], diff --git a/deluge/ui/console/modes/basemode.py b/deluge/ui/console/modes/basemode.py index dd3681f5b..5520b0b46 100644 --- a/deluge/ui/console/modes/basemode.py +++ b/deluge/ui/console/modes/basemode.py @@ -26,9 +26,9 @@ except ImportError: try: import signal - from fcntl import ioctl - import termios import struct + import termios + from fcntl import ioctl except ImportError: pass diff --git a/deluge/ui/console/modes/torrentdetail.py b/deluge/ui/console/modes/torrentdetail.py index d02a0d396..fbb4fa55f 100644 --- a/deluge/ui/console/modes/torrentdetail.py +++ b/deluge/ui/console/modes/torrentdetail.py @@ -220,7 +220,7 @@ class TorrentDetail(BaseMode, PopupsHandler): self.refresh() def build_file_list(self, torrent_files, progress, priority): - """ Split file list from torrent state into a directory tree. + """Split file list from torrent state into a directory tree. Returns: diff --git a/deluge/ui/console/parser.py b/deluge/ui/console/parser.py index 27f248564..1c0bd7009 100644 --- a/deluge/ui/console/parser.py +++ b/deluge/ui/console/parser.py @@ -60,14 +60,14 @@ class ConsoleCommandParser(ConsoleBaseParser): def parse_args(self, args=None): """Parse known UI args and handle common and process group options. - Notes: - If started by deluge entry script this has already been done. + Notes: + If started by deluge entry script this has already been done. - Args: - args (list, optional): The arguments to parse. + Args: + args (list, optional): The arguments to parse. - Returns: - argparse.Namespace: The parsed arguments. + Returns: + argparse.Namespace: The parsed arguments. """ from deluge.ui.ui_entry import AMBIGUOUS_CMD_ARGS @@ -118,9 +118,9 @@ class OptionParser(ConsoleBaseParser): def error(self, msg): """error(msg : string) - Print a usage message incorporating 'msg' to stderr and exit. - If you override this in a subclass, it should not return -- it - should either exit or raise an exception. + Print a usage message incorporating 'msg' to stderr and exit. + If you override this in a subclass, it should not return -- it + should either exit or raise an exception. """ raise OptionParserError(msg) diff --git a/deluge/ui/console/widgets/fields.py b/deluge/ui/console/widgets/fields.py index 1966c6685..021cab738 100644 --- a/deluge/ui/console/widgets/fields.py +++ b/deluge/ui/console/widgets/fields.py @@ -1061,9 +1061,9 @@ class ComboInput(InputField): # No match, so start at beginning select_in_range(0, selected) - from deluge.ui.console.widgets.popup import ( + from deluge.ui.console.widgets.popup import ( # Must import here SelectablePopup, - ) # Must import here + ) select_popup = SelectablePopup( self.parent, diff --git a/deluge/ui/gtk3/__init__.py b/deluge/ui/gtk3/__init__.py index 3b9d2b123..1d9b5b89d 100644 --- a/deluge/ui/gtk3/__init__.py +++ b/deluge/ui/gtk3/__init__.py @@ -40,9 +40,10 @@ class Gtk(UI): def start(self): super(Gtk, self).start() - from .gtkui import GtkUI import deluge.common + from .gtkui import GtkUI + def run(options): try: gtkui = GtkUI(options) diff --git a/deluge/ui/gtk3/dialogs.py b/deluge/ui/gtk3/dialogs.py index deea10515..4a2a60a7e 100644 --- a/deluge/ui/gtk3/dialogs.py +++ b/deluge/ui/gtk3/dialogs.py @@ -159,8 +159,8 @@ class ErrorDialog(BaseDialog): ) if traceback: - import traceback import sys + import traceback tb = sys.exc_info() tb = traceback.format_exc(tb[2]) diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py index 47e889c6e..d8d335866 100644 --- a/deluge/ui/gtk3/gtkui.py +++ b/deluge/ui/gtk3/gtkui.py @@ -75,7 +75,7 @@ set_prgname('deluge') log = logging.getLogger(__name__) try: - from setproctitle import setproctitle, getproctitle + from setproctitle import getproctitle, setproctitle except ImportError: def setproctitle(title): diff --git a/deluge/ui/gtk3/ipcinterface.py b/deluge/ui/gtk3/ipcinterface.py index dc51a8716..78858c443 100644 --- a/deluge/ui/gtk3/ipcinterface.py +++ b/deluge/ui/gtk3/ipcinterface.py @@ -31,8 +31,8 @@ try: from urllib.request import url2pathname except ImportError: # PY2 fallback - from urlparse import urlparse # pylint: disable=ungrouped-imports from urllib import url2pathname # pylint: disable=ungrouped-imports + from urlparse import urlparse # pylint: disable=ungrouped-imports log = logging.getLogger(__name__) @@ -84,8 +84,8 @@ class IPCInterface(component.Component): if windows_check(): # If we're on windows we need to check the global mutex to see if deluge is # already running. - import win32event import win32api + import win32event import winerror self.mutex = win32event.CreateMutex(None, False, 'deluge') diff --git a/deluge/ui/gtk3/listview.py b/deluge/ui/gtk3/listview.py index 666bb6731..7b1cba810 100644 --- a/deluge/ui/gtk3/listview.py +++ b/deluge/ui/gtk3/listview.py @@ -68,10 +68,10 @@ class ListView(object): class TreeviewColumn(Gtk.TreeViewColumn, object): """ - TreeViewColumn does not signal right-click events, and we need them - This subclass is equivalent to TreeViewColumn, but it signals these events + TreeViewColumn does not signal right-click events, and we need them + This subclass is equivalent to TreeViewColumn, but it signals these events - Most of the code of this class comes from Quod Libet (http://www.sacredchao.net/quodlibet) + Most of the code of this class comes from Quod Libet (http://www.sacredchao.net/quodlibet) """ __gsignals__ = { @@ -281,7 +281,7 @@ class ListView(object): def save_state(self, filename): """Saves the listview state (column positions and visibility) to - filename.""" + filename.""" # A list of ListViewColumnStates state = [] @@ -627,8 +627,7 @@ class ListView(object): unique=False, default_sort=False, ): - """Add a text column to the listview. Only the header name is required. - """ + """Add a text column to the listview. Only the header name is required.""" render = Gtk.CellRendererText() self.add_column( header, diff --git a/deluge/ui/gtk3/peers_tab.py b/deluge/ui/gtk3/peers_tab.py index fa79d84a1..e0282becf 100644 --- a/deluge/ui/gtk3/peers_tab.py +++ b/deluge/ui/gtk3/peers_tab.py @@ -305,8 +305,8 @@ class PeersTab(Tab): peer_ip = peer['ip'] else: # This is an IPv6 address - import socket import binascii + import socket # Split out the :port ip = ':'.join(peer['ip'].split(':')[:-1]) diff --git a/deluge/ui/gtk3/preferences.py b/deluge/ui/gtk3/preferences.py index b4d3f521c..a4d63aaa8 100644 --- a/deluge/ui/gtk3/preferences.py +++ b/deluge/ui/gtk3/preferences.py @@ -1180,8 +1180,8 @@ class Preferences(component.Component): chooser.destroy() return - from base64 import b64encode import shutil + from base64 import b64encode filename = os.path.split(filepath)[1] shutil.copyfile(filepath, os.path.join(get_config_dir(), 'plugins', filename)) diff --git a/deluge/ui/gtk3/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py index 29e019326..b2124b309 100644 --- a/deluge/ui/gtk3/torrentdetails.py +++ b/deluge/ui/gtk3/torrentdetails.py @@ -112,11 +112,11 @@ class TorrentDetails(component.Component): self.tabs = {} # Add the default tabs - from .status_tab import StatusTab from .details_tab import DetailsTab from .files_tab import FilesTab - from .peers_tab import PeersTab from .options_tab import OptionsTab + from .peers_tab import PeersTab + from .status_tab import StatusTab from .trackers_tab import TrackersTab default_tabs = { diff --git a/deluge/ui/web/js/deluge-all/AboutWindow.js b/deluge/ui/web/js/deluge-all/AboutWindow.js index 5376d05c0..15fede9b8 100644 --- a/deluge/ui/web/js/deluge-all/AboutWindow.js +++ b/deluge/ui/web/js/deluge-all/AboutWindow.js @@ -28,16 +28,16 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, { }, buttonAlign: 'center', - initComponent: function() { + initComponent: function () { Deluge.about.AboutWindow.superclass.initComponent.call(this); this.addEvents({ build_ready: true, }); var self = this; - var libtorrent = function() { + var libtorrent = function () { deluge.client.core.get_libtorrent_version({ - success: function(lt_version) { + success: function (lt_version) { comment += '
' + _('libtorrent:') + ' ' + lt_version; Ext.getCmp('about_comment').setText(comment, false); self.fireEvent('build_ready'); @@ -57,10 +57,10 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, { client_version + '
'; deluge.client.web.connected({ - success: function(connected) { + success: function (connected) { if (connected) { deluge.client.daemon.get_version({ - success: function(server_version) { + success: function (server_version) { comment += _('Server:') + ' ' + server_version + '
'; libtorrent(); @@ -70,7 +70,7 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, { this.fireEvent('build_ready'); } }, - failure: function() { + failure: function () { this.fireEvent('build_ready'); }, scope: this, @@ -111,19 +111,19 @@ Deluge.about.AboutWindow = Ext.extend(Ext.Window, { this.addButton(_('Close'), this.onCloseClick, this); }, - show: function() { - this.on('build_ready', function() { + show: function () { + this.on('build_ready', function () { Deluge.about.AboutWindow.superclass.show.call(this); }); }, - onCloseClick: function() { + onCloseClick: function () { this.close(); }, }); Ext.namespace('Deluge'); -Deluge.About = function() { +Deluge.About = function () { new Deluge.about.AboutWindow().show(); }; diff --git a/deluge/ui/web/js/deluge-all/AddConnectionWindow.js b/deluge/ui/web/js/deluge-all/AddConnectionWindow.js index 6d2637029..4d821f247 100644 --- a/deluge/ui/web/js/deluge-all/AddConnectionWindow.js +++ b/deluge/ui/web/js/deluge-all/AddConnectionWindow.js @@ -24,7 +24,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { bodyStyle: 'padding: 10px 5px;', closeAction: 'hide', - initComponent: function() { + initComponent: function () { Deluge.AddConnectionWindow.superclass.initComponent.call(this); this.addEvents('hostadded'); @@ -80,7 +80,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { }); }, - onAddClick: function() { + onAddClick: function () { var values = this.form.getForm().getValues(); deluge.client.web.add_host( values.host, @@ -88,7 +88,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { values.username, values.password, { - success: function(result) { + success: function (result) { if (!result[0]) { Ext.MessageBox.show({ title: _('Error'), @@ -111,7 +111,7 @@ Deluge.AddConnectionWindow = Ext.extend(Ext.Window, { ); }, - onHide: function() { + onHide: function () { this.form.getForm().reset(); }, }); diff --git a/deluge/ui/web/js/deluge-all/AddTrackerWindow.js b/deluge/ui/web/js/deluge-all/AddTrackerWindow.js index c9c835d47..8fbe0b221 100644 --- a/deluge/ui/web/js/deluge-all/AddTrackerWindow.js +++ b/deluge/ui/web/js/deluge-all/AddTrackerWindow.js @@ -12,7 +12,7 @@ Ext.ns('Deluge'); // Custom VType validator for tracker urls var trackerUrlTest = /(((^https?)|(^udp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i; Ext.apply(Ext.form.VTypes, { - trackerUrl: function(val, field) { + trackerUrl: function (val, field) { return trackerUrlTest.test(val); }, trackerUrlText: 'Not a valid tracker url', @@ -36,7 +36,7 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, { closeAction: 'hide', iconCls: 'x-deluge-edit-trackers', - initComponent: function() { + initComponent: function () { Deluge.AddTrackerWindow.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); @@ -59,17 +59,14 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, { }); }, - onAddClick: function() { - var trackers = this.form - .getForm() - .findField('trackers') - .getValue(); + onAddClick: function () { + var trackers = this.form.getForm().findField('trackers').getValue(); trackers = trackers.split('\n'); var cleaned = []; Ext.each( trackers, - function(tracker) { + function (tracker) { if (Ext.form.VTypes.trackerUrl(tracker)) { cleaned.push(tracker); } @@ -78,17 +75,11 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, { ); this.fireEvent('add', cleaned); this.hide(); - this.form - .getForm() - .findField('trackers') - .setValue(''); + this.form.getForm().findField('trackers').setValue(''); }, - onCancelClick: function() { - this.form - .getForm() - .findField('trackers') - .setValue(''); + onCancelClick: function () { + this.form.getForm().findField('trackers').setValue(''); this.hide(); }, }); diff --git a/deluge/ui/web/js/deluge-all/Client.js b/deluge/ui/web/js/deluge-all/Client.js index bcabbae5f..a06e863c0 100644 --- a/deluge/ui/web/js/deluge-all/Client.js +++ b/deluge/ui/web/js/deluge-all/Client.js @@ -31,7 +31,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { * Fires when the client has retrieved the list of methods from the server. * @param {Ext.ux.util.RpcClient} this */ - constructor: function(config) { + constructor: function (config) { Ext.ux.util.RpcClient.superclass.constructor.call(this, config); this._url = config.url || null; this._id = 0; @@ -44,14 +44,14 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { this.reloadMethods(); }, - reloadMethods: function() { + reloadMethods: function () { this._execute('system.listMethods', { success: this._setMethods, scope: this, }); }, - _execute: function(method, options) { + _execute: function (method, options) { options = options || {}; options.params = options.params || []; options.id = this._id; @@ -74,7 +74,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { }); }, - _onFailure: function(response, requestOptions) { + _onFailure: function (response, requestOptions) { var options = requestOptions.options; errorObj = { id: options.id, @@ -100,7 +100,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { } }, - _onSuccess: function(response, requestOptions) { + _onSuccess: function (response, requestOptions) { var responseObj = Ext.decode(response.responseText); var options = requestOptions.options; if (responseObj.error) { @@ -138,9 +138,9 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { } }, - _parseArgs: function(args) { + _parseArgs: function (args) { var params = []; - Ext.each(args, function(arg) { + Ext.each(args, function (arg) { params.push(arg); }); @@ -149,7 +149,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { var keys = Ext.keys(options), isOption = false; - Ext.each(this._optionKeys, function(key) { + Ext.each(this._optionKeys, function (key) { if (keys.indexOf(key) > -1) isOption = true; }); @@ -165,15 +165,15 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { return options; }, - _setMethods: function(methods) { + _setMethods: function (methods) { var components = {}, self = this; - Ext.each(methods, function(method) { + Ext.each(methods, function (method) { var parts = method.split('.'); var component = components[parts[0]] || {}; - var fn = function() { + var fn = function () { var options = self._parseArgs(arguments); return self._execute(method, options); }; @@ -186,7 +186,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, { } Ext.each( this._components, - function(component) { + function (component) { if (!component in components) { delete this[component]; } diff --git a/deluge/ui/web/js/deluge-all/ConnectionManager.js b/deluge/ui/web/js/deluge-all/ConnectionManager.js index 001e46bb1..5261726fb 100644 --- a/deluge/ui/web/js/deluge-all/ConnectionManager.js +++ b/deluge/ui/web/js/deluge-all/ConnectionManager.js @@ -21,7 +21,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { title: _('Connection Manager'), iconCls: 'x-deluge-connect-window-icon', - initComponent: function() { + initComponent: function () { Deluge.ConnectionManager.superclass.initComponent.call(this); this.on('hide', this.onHide, this); this.on('show', this.onShow, this); @@ -133,9 +133,9 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { * Check to see if the the web interface is currently connected * to a Deluge Daemon and show the Connection Manager if not. */ - checkConnected: function() { + checkConnected: function () { deluge.client.web.connected({ - success: function(connected) { + success: function (connected) { if (connected) { deluge.events.fire('connect'); } else { @@ -146,7 +146,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }); }, - disconnect: function(show) { + disconnect: function (show) { deluge.events.fire('disconnect'); if (show) { if (this.isVisible()) return; @@ -154,15 +154,15 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { } }, - loadHosts: function() { + loadHosts: function () { deluge.client.web.get_hosts({ success: this.onGetHosts, scope: this, }); }, - update: function() { - this.list.getStore().each(function(r) { + update: function () { + this.list.getStore().each(function (r) { deluge.client.web.get_host_status(r.id, { success: this.onGetHostStatus, scope: this, @@ -175,7 +175,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { * passed in records host state. * @param {Ext.data.Record} record The hosts record to update the UI for */ - updateButtons: function(record) { + updateButtons: function (record) { var button = this.buttons[1], status = record.get('status'); @@ -209,7 +209,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onAddClick: function(button, e) { + onAddClick: function (button, e) { if (!this.addWindow) { this.addWindow = new Deluge.AddConnectionWindow(); this.addWindow.on('hostadded', this.onHostChange, this); @@ -218,7 +218,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onEditClick: function(button, e) { + onEditClick: function (button, e) { var connection = this.list.getSelectedRecords()[0]; if (!connection) return; @@ -230,24 +230,24 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onHostChange: function() { + onHostChange: function () { this.loadHosts(); }, // private - onClose: function(e) { + onClose: function (e) { this.hide(); }, // private - onConnect: function(e) { + onConnect: function (e) { var selected = this.list.getSelectedRecords()[0]; if (!selected) return; var me = this; - var disconnect = function() { + var disconnect = function () { deluge.client.web.disconnect({ - success: function(result) { + success: function (result) { this.update(this); deluge.events.fire('disconnect'); }, @@ -268,11 +268,11 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { var id = selected.id; deluge.client.web.connect(id, { - success: function(methods) { + success: function (methods) { deluge.client.reloadMethods(); deluge.client.on( 'connected', - function(e) { + function (e) { deluge.events.fire('connect'); }, this, @@ -285,11 +285,11 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onGetHosts: function(hosts) { + onGetHosts: function (hosts) { this.list.getStore().loadData(hosts); Ext.each( hosts, - function(host) { + function (host) { deluge.client.web.get_host_status(host[0], { success: this.onGetHostStatus, scope: this, @@ -300,7 +300,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onGetHostStatus: function(host) { + onGetHostStatus: function (host) { var record = this.list.getStore().getById(host[0]); record.set('status', host[1]); record.set('version', host[2]); @@ -311,19 +311,19 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onHide: function() { + onHide: function () { if (this.running) window.clearInterval(this.running); }, // private - onLogin: function() { + onLogin: function () { if (deluge.config.first_login) { Ext.MessageBox.confirm( _('Change Default Password'), _( 'We recommend changing the default password.

Would you like to change it now?' ), - function(res) { + function (res) { this.checkConnected(); if (res == 'yes') { deluge.preferences.show(); @@ -339,7 +339,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onLogout: function() { + onLogout: function () { this.disconnect(); if (!this.hidden && this.rendered) { this.hide(); @@ -347,12 +347,12 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onRemoveClick: function(button) { + onRemoveClick: function (button) { var connection = this.list.getSelectedRecords()[0]; if (!connection) return; deluge.client.web.remove_host(connection.id, { - success: function(result) { + success: function (result) { if (!result) { Ext.MessageBox.show({ title: _('Error'), @@ -371,7 +371,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onSelectionChanged: function(list, selections) { + onSelectionChanged: function (list, selections) { if (selections[0]) { this.editHostButton.enable(); this.removeHostButton.enable(); @@ -387,7 +387,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { // FIXME: Find out why this is being fired twice // private - onShow: function() { + onShow: function () { if (!this.addHostButton) { var bbar = this.panel.getBottomToolbar(); this.addHostButton = bbar.items.get('cm-add'); @@ -401,7 +401,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, // private - onStopClick: function(button, e) { + onStopClick: function (button, e) { var connection = this.list.getSelectedRecords()[0]; if (!connection) return; @@ -411,7 +411,7 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { } else { // This means we need to stop the daemon deluge.client.web.stop_daemon(connection.id, { - success: function(result) { + success: function (result) { if (!result[0]) { Ext.MessageBox.show({ title: _('Error'), diff --git a/deluge/ui/web/js/deluge-all/Deluge.js b/deluge/ui/web/js/deluge-all/Deluge.js index 31b9947cc..86cae6d89 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.js +++ b/deluge/ui/web/js/deluge-all/Deluge.js @@ -25,21 +25,19 @@ Ext.state.Manager.setProvider( // Add some additional functions to ext and setup some of the // configurable parameters Ext.apply(Ext, { - escapeHTML: function(text) { - text = String(text) - .replace('<', '<') - .replace('>', '>'); + escapeHTML: function (text) { + text = String(text).replace('<', '<').replace('>', '>'); return text.replace('&', '&'); }, - isObjectEmpty: function(obj) { + isObjectEmpty: function (obj) { for (var i in obj) { return false; } return true; }, - areObjectsEqual: function(obj1, obj2) { + areObjectsEqual: function (obj1, obj2) { var equal = true; if (!obj1 || !obj2) return false; for (var i in obj1) { @@ -50,7 +48,7 @@ Ext.apply(Ext, { return equal; }, - keys: function(obj) { + keys: function (obj) { var keys = []; for (var i in obj) if (obj.hasOwnProperty(i)) { @@ -59,7 +57,7 @@ Ext.apply(Ext, { return keys; }, - values: function(obj) { + values: function (obj) { var values = []; for (var i in obj) { if (obj.hasOwnProperty(i)) { @@ -69,7 +67,7 @@ Ext.apply(Ext, { return values; }, - splat: function(obj) { + splat: function (obj) { var type = Ext.type(obj); return type ? (type != 'array' ? [obj] : obj) : []; }, @@ -106,7 +104,7 @@ Ext.apply(Deluge, { * @param {String} text The text to display on the bar * @param {Number} modified Amount to subtract from the width allowing for fixes */ - progressBar: function(progress, width, text, modifier) { + progressBar: function (progress, width, text, modifier) { modifier = Ext.value(modifier, 10); var progressWidth = ((width / 100.0) * progress).toFixed(0); var barWidth = progressWidth - 1; @@ -125,7 +123,7 @@ Ext.apply(Deluge, { * Constructs a new instance of the specified plugin. * @param {String} name The plugin name to create */ - createPlugin: function(name) { + createPlugin: function (name) { return new Deluge.pluginStore[name](); }, @@ -133,7 +131,7 @@ Ext.apply(Deluge, { * Check to see if a plugin has been registered. * @param {String} name The plugin name to check */ - hasPlugin: function(name) { + hasPlugin: function (name) { return Deluge.pluginStore[name] ? true : false; }, @@ -142,7 +140,7 @@ Ext.apply(Deluge, { * @param {String} name The plugin name to register * @param {Plugin} plugin The plugin to register */ - registerPlugin: function(name, plugin) { + registerPlugin: function (name, plugin) { Deluge.pluginStore[name] = plugin; }, }); diff --git a/deluge/ui/web/js/deluge-all/EditConnectionWindow.js b/deluge/ui/web/js/deluge-all/EditConnectionWindow.js index 63bd3054d..bfeb38f9d 100644 --- a/deluge/ui/web/js/deluge-all/EditConnectionWindow.js +++ b/deluge/ui/web/js/deluge-all/EditConnectionWindow.js @@ -24,7 +24,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, { bodyStyle: 'padding: 10px 5px;', closeAction: 'hide', - initComponent: function() { + initComponent: function () { Deluge.EditConnectionWindow.superclass.initComponent.call(this); this.addEvents('hostedited'); @@ -80,17 +80,11 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, { }); }, - show: function(connection) { + show: function (connection) { Deluge.EditConnectionWindow.superclass.show.call(this); - this.form - .getForm() - .findField('host') - .setValue(connection.get('host')); - this.form - .getForm() - .findField('port') - .setValue(connection.get('port')); + this.form.getForm().findField('host').setValue(connection.get('host')); + this.form.getForm().findField('port').setValue(connection.get('port')); this.form .getForm() .findField('username') @@ -98,7 +92,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, { this.host_id = connection.id; }, - onEditClick: function() { + onEditClick: function () { var values = this.form.getForm().getValues(); deluge.client.web.edit_host( this.host_id, @@ -107,7 +101,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, { values.username, values.password, { - success: function(result) { + success: function (result) { if (!result) { console.log(result); Ext.MessageBox.show({ @@ -128,7 +122,7 @@ Deluge.EditConnectionWindow = Ext.extend(Ext.Window, { ); }, - onHide: function() { + onHide: function () { this.form.getForm().reset(); }, }); diff --git a/deluge/ui/web/js/deluge-all/EditTrackerWindow.js b/deluge/ui/web/js/deluge-all/EditTrackerWindow.js index 82bc32c51..646b8de78 100644 --- a/deluge/ui/web/js/deluge-all/EditTrackerWindow.js +++ b/deluge/ui/web/js/deluge-all/EditTrackerWindow.js @@ -27,7 +27,7 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, { closeAction: 'hide', iconCls: 'x-deluge-edit-trackers', - initComponent: function() { + initComponent: function () { Deluge.EditTrackerWindow.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); @@ -50,32 +50,23 @@ Deluge.EditTrackerWindow = Ext.extend(Ext.Window, { }); }, - show: function(record) { + show: function (record) { Deluge.EditTrackerWindow.superclass.show.call(this); this.record = record; - this.form - .getForm() - .findField('tracker') - .setValue(record.data['url']); + this.form.getForm().findField('tracker').setValue(record.data['url']); }, - onCancelClick: function() { + onCancelClick: function () { this.hide(); }, - onHide: function() { - this.form - .getForm() - .findField('tracker') - .setValue(''); + onHide: function () { + this.form.getForm().findField('tracker').setValue(''); }, - onSaveClick: function() { - var url = this.form - .getForm() - .findField('tracker') - .getValue(); + onSaveClick: function () { + var url = this.form.getForm().findField('tracker').getValue(); this.record.set('url', url); this.record.commit(); this.hide(); diff --git a/deluge/ui/web/js/deluge-all/EditTrackersWindow.js b/deluge/ui/web/js/deluge-all/EditTrackersWindow.js index 5d2d9e8e1..f6733aaa6 100644 --- a/deluge/ui/web/js/deluge-all/EditTrackersWindow.js +++ b/deluge/ui/web/js/deluge-all/EditTrackersWindow.js @@ -28,7 +28,7 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { closeAction: 'hide', iconCls: 'x-deluge-edit-trackers', - initComponent: function() { + initComponent: function () { Deluge.EditTrackersWindow.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); @@ -111,18 +111,18 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { }); }, - onAddClick: function() { + onAddClick: function () { this.addWindow.show(); }, - onAddTrackers: function(trackers) { + onAddTrackers: function (trackers) { var store = this.list.getStore(); Ext.each( trackers, - function(tracker) { + function (tracker) { var duplicate = false, heightestTier = -1; - store.each(function(record) { + store.each(function (record) { if (record.get('tier') > heightestTier) { heightestTier = record.get('tier'); } @@ -143,27 +143,27 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { ); }, - onCancelClick: function() { + onCancelClick: function () { this.hide(); }, - onEditClick: function() { + onEditClick: function () { var selected = this.list.getSelectedRecords()[0]; if (!selected) return; this.editWindow.show(selected); }, - onHide: function() { + onHide: function () { this.list.getStore().removeAll(); }, - onListNodeDblClicked: function(list, index, node, e) { + onListNodeDblClicked: function (list, index, node, e) { this.editWindow.show(this.list.getRecord(node)); }, - onOkClick: function() { + onOkClick: function () { var trackers = []; - this.list.getStore().each(function(record) { + this.list.getStore().each(function (record) { trackers.push({ tier: record.get('tier'), url: record.get('url'), @@ -178,34 +178,28 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { this.hide(); }, - onRemoveClick: function() { + onRemoveClick: function () { // Remove from the grid var selected = this.list.getSelectedRecords()[0]; if (!selected) return; this.list.getStore().remove(selected); }, - onRequestComplete: function(status) { + onRequestComplete: function (status) { this.list.getStore().loadData(status); this.list.getStore().sort('tier', 'ASC'); }, - onSaveFail: function() {}, + onSaveFail: function () {}, - onSelect: function(list) { + onSelect: function (list) { if (list.getSelectionCount()) { - this.panel - .getBottomToolbar() - .items.get(4) - .enable(); + this.panel.getBottomToolbar().items.get(4).enable(); } }, - onShow: function() { - this.panel - .getBottomToolbar() - .items.get(4) - .disable(); + onShow: function () { + this.panel.getBottomToolbar().items.get(4).disable(); var r = deluge.torrents.getSelected(); this.torrentId = r.id; deluge.client.core.get_torrent_status(r.id, ['trackers'], { @@ -214,7 +208,7 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { }); }, - onDownClick: function() { + onDownClick: function () { var r = this.list.getSelectedRecords()[0]; if (!r) return; @@ -225,7 +219,7 @@ Deluge.EditTrackersWindow = Ext.extend(Ext.Window, { this.list.select(r.store.indexOf(r)); }, - onUpClick: function() { + onUpClick: function () { var r = this.list.getSelectedRecords()[0]; if (!r) return; diff --git a/deluge/ui/web/js/deluge-all/EventsManager.js b/deluge/ui/web/js/deluge-all/EventsManager.js index 1714339ad..89d8980fb 100644 --- a/deluge/ui/web/js/deluge-all/EventsManager.js +++ b/deluge/ui/web/js/deluge-all/EventsManager.js @@ -15,7 +15,7 @@ * Class for holding global events that occur within the UI. */ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { - constructor: function() { + constructor: function () { this.toRegister = []; this.on('login', this.onLogin, this); Deluge.EventsManager.superclass.constructor.call(this); @@ -24,7 +24,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { /** * Append an event handler to this object. */ - addListener: function(eventName, fn, scope, o) { + addListener: function (eventName, fn, scope, o) { this.addEvents(eventName); if (/[A-Z]/.test(eventName.substring(0, 1))) { if (!deluge.client) { @@ -42,7 +42,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { ); }, - getEvents: function() { + getEvents: function () { deluge.client.web.get_events({ success: this.onGetEventsSuccess, failure: this.onGetEventsFailure, @@ -53,8 +53,8 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { /** * Starts the EventsManagerManager checking for events. */ - start: function() { - Ext.each(this.toRegister, function(eventName) { + start: function () { + Ext.each(this.toRegister, function (eventName) { deluge.client.web.register_event_listener(eventName); }); this.running = true; @@ -65,21 +65,21 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { /** * Stops the EventsManagerManager checking for events. */ - stop: function() { + stop: function () { this.running = false; }, // private - onLogin: function() { + onLogin: function () { this.start(); }, - onGetEventsSuccess: function(events) { + onGetEventsSuccess: function (events) { if (!this.running) return; if (events) { Ext.each( events, - function(event) { + function (event) { var name = event[0], args = event[1]; args.splice(0, 0, name); @@ -92,7 +92,7 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, { }, // private - onGetEventsFailure: function(result, error) { + onGetEventsFailure: function (result, error) { // the request timed out or we had a communication failure if (!this.running) return; if (!error.isTimeout && this.errorCount++ >= 3) { diff --git a/deluge/ui/web/js/deluge-all/FileBrowser.js b/deluge/ui/web/js/deluge-all/FileBrowser.js index 72962a6b7..2afe1b1e6 100644 --- a/deluge/ui/web/js/deluge-all/FileBrowser.js +++ b/deluge/ui/web/js/deluge-all/FileBrowser.js @@ -15,7 +15,7 @@ Deluge.FileBrowser = Ext.extend(Ext.Window, { width: 500, height: 400, - initComponent: function() { + initComponent: function () { Deluge.FileBrowser.superclass.initComponent.call(this); this.add({ diff --git a/deluge/ui/web/js/deluge-all/FilterPanel.js b/deluge/ui/web/js/deluge-all/FilterPanel.js index 2362dbb4c..b6e5ec5ca 100644 --- a/deluge/ui/web/js/deluge-all/FilterPanel.js +++ b/deluge/ui/web/js/deluge-all/FilterPanel.js @@ -20,7 +20,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { show_zero: null, - initComponent: function() { + initComponent: function () { Deluge.FilterPanel.superclass.initComponent.call(this); this.filterType = this.initialConfig.filter; var title = ''; @@ -36,7 +36,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { (title = this.filterType.replace('_', ' ')), (parts = title.split(' ')), (title = ''); - Ext.each(parts, function(p) { + Ext.each(parts, function (p) { fl = p.substring(0, 1).toUpperCase(); title += fl + p.substring(1) + ' '; }); @@ -75,7 +75,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { * Return the currently selected filter state * @returns {String} the current filter state */ - getState: function() { + getState: function () { if (!this.list.getSelectionCount()) return; var state = this.list.getSelectedRecords()[0]; @@ -87,7 +87,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { /** * Return the current states in the filter */ - getStates: function() { + getStates: function () { return this.states; }, @@ -95,18 +95,18 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { * Return the Store for the ListView of the FilterPanel * @returns {Ext.data.Store} the ListView store */ - getStore: function() { + getStore: function () { return this.list.getStore(); }, /** * Update the states in the FilterPanel */ - updateStates: function(states) { + updateStates: function (states) { this.states = {}; Ext.each( states, - function(state) { + function (state) { this.states[state[0]] = state[1]; }, this @@ -118,7 +118,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { : this.show_zero; if (!show_zero) { var newStates = []; - Ext.each(states, function(state) { + Ext.each(states, function (state) { if (state[1] > 0 || state[0] == 'All') { newStates.push(state); } @@ -130,7 +130,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { var filters = {}; Ext.each( states, - function(s, i) { + function (s, i) { var record = store.getById(s[0]); if (!record) { record = new store.recordType({ @@ -149,7 +149,7 @@ Deluge.FilterPanel = Ext.extend(Ext.Panel, { this ); - store.each(function(record) { + store.each(function (record) { if (filters[record.id]) return; store.remove(record); var selected = this.list.getSelectedRecords()[0]; diff --git a/deluge/ui/web/js/deluge-all/Formatters.js b/deluge/ui/web/js/deluge-all/Formatters.js index a511f34a2..443bfdf56 100644 --- a/deluge/ui/web/js/deluge-all/Formatters.js +++ b/deluge/ui/web/js/deluge-all/Formatters.js @@ -24,7 +24,7 @@ Deluge.Formatters = { * @return {String} a string in the date representation of the current locale * or "" if seconds < 0. */ - date: function(timestamp) { + date: function (timestamp) { function zeroPad(num, count) { var numZeropad = num + ''; while (numZeropad.length < count) { @@ -52,7 +52,7 @@ Deluge.Formatters = { * @param {Boolean} showZero pass in true to displays 0 values * @return {String} formatted string with KiB, MiB or GiB units. */ - size: function(bytes, showZero) { + size: function (bytes, showZero) { if (!bytes && !showZero) return ''; bytes = bytes / 1024.0; @@ -78,7 +78,7 @@ Deluge.Formatters = { * @param {Boolean} showZero pass in true to displays 0 values * @return {String} formatted string with K, M or G units. */ - sizeShort: function(bytes, showZero) { + sizeShort: function (bytes, showZero) { if (!bytes && !showZero) return ''; bytes = bytes / 1024.0; @@ -104,7 +104,7 @@ Deluge.Formatters = { * @param {Boolean} showZero pass in true to displays 0 values * @return {String} formatted string with KiB, MiB or GiB units. */ - speed: function(bytes, showZero) { + speed: function (bytes, showZero) { return !bytes && !showZero ? '' : fsize(bytes, showZero) + '/s'; }, @@ -114,7 +114,7 @@ Deluge.Formatters = { * @param {Number} time the number of seconds * @return {String} a formatted time string. will return '' if seconds == 0 */ - timeRemaining: function(time) { + timeRemaining: function (time) { if (time <= 0) { return '∞'; } @@ -164,11 +164,11 @@ Deluge.Formatters = { * @param {Mixed} value the value to be displayed * @return the untouched value. */ - plain: function(value) { + plain: function (value) { return value; }, - cssClassEscape: function(value) { + cssClassEscape: function (value) { return value.toLowerCase().replace('.', '_'); }, }; diff --git a/deluge/ui/web/js/deluge-all/Keys.js b/deluge/ui/web/js/deluge-all/Keys.js index 25cf38bc3..7b3e3affc 100644 --- a/deluge/ui/web/js/deluge-all/Keys.js +++ b/deluge/ui/web/js/deluge-all/Keys.js @@ -133,6 +133,6 @@ Deluge.Keys = { // Merge the grid and status keys together as the status keys contain all the // grid ones. -Ext.each(Deluge.Keys.Grid, function(key) { +Ext.each(Deluge.Keys.Grid, function (key) { Deluge.Keys.Status.push(key); }); diff --git a/deluge/ui/web/js/deluge-all/LoginWindow.js b/deluge/ui/web/js/deluge-all/LoginWindow.js index 964f5ffb2..a055a6921 100644 --- a/deluge/ui/web/js/deluge-all/LoginWindow.js +++ b/deluge/ui/web/js/deluge-all/LoginWindow.js @@ -23,7 +23,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, { width: 300, height: 120, - initComponent: function() { + initComponent: function () { Deluge.LoginWindow.superclass.initComponent.call(this); this.on('show', this.onShow, this); @@ -56,17 +56,17 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, { this.passwordField.on('specialkey', this.onSpecialKey, this); }, - logout: function() { + logout: function () { deluge.events.fire('logout'); deluge.client.auth.delete_session({ - success: function(result) { + success: function (result) { this.show(true); }, scope: this, }); }, - show: function(skipCheck) { + show: function (skipCheck) { if (this.firstShow) { deluge.client.on('error', this.onClientError, this); this.firstShow = false; @@ -77,28 +77,28 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, { } deluge.client.auth.check_session({ - success: function(result) { + success: function (result) { if (result) { deluge.events.fire('login'); } else { this.show(true); } }, - failure: function(result) { + failure: function (result) { this.show(true); }, scope: this, }); }, - onSpecialKey: function(field, e) { + onSpecialKey: function (field, e) { if (e.getKey() == 13) this.onLogin(); }, - onLogin: function() { + onLogin: function () { var passwordField = this.passwordField; deluge.client.auth.login(passwordField.getValue(), { - success: function(result) { + success: function (result) { if (result) { deluge.events.fire('login'); this.hide(); @@ -109,7 +109,7 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, { msg: _('You entered an incorrect password'), buttons: Ext.MessageBox.OK, modal: false, - fn: function() { + fn: function () { passwordField.focus(true, 10); }, icon: Ext.MessageBox.WARNING, @@ -121,14 +121,14 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, { }); }, - onClientError: function(errorObj, response, requestOptions) { + onClientError: function (errorObj, response, requestOptions) { if (errorObj.error.code == 1) { deluge.events.fire('logout'); this.show(true); } }, - onShow: function() { + onShow: function () { this.passwordField.focus(true, 300); }, }); diff --git a/deluge/ui/web/js/deluge-all/Menus.js b/deluge/ui/web/js/deluge-all/Menus.js index 529c6cc66..d3b52019c 100644 --- a/deluge/ui/web/js/deluge-all/Menus.js +++ b/deluge/ui/web/js/deluge-all/Menus.js @@ -9,7 +9,7 @@ */ deluge.menus = { - onTorrentActionSetOpt: function(item, e) { + onTorrentActionSetOpt: function (item, e) { var ids = deluge.torrents.getSelectedIds(); var action = item.initialConfig.torrentAction; var opts = {}; @@ -17,17 +17,17 @@ deluge.menus = { deluge.client.core.set_torrent_options(ids, opts); }, - onTorrentActionMethod: function(item, e) { + onTorrentActionMethod: function (item, e) { var ids = deluge.torrents.getSelectedIds(); var action = item.initialConfig.torrentAction; deluge.client.core[action](ids, { - success: function() { + success: function () { deluge.ui.update(); }, }); }, - onTorrentActionShow: function(item, e) { + onTorrentActionShow: function (item, e) { var ids = deluge.torrents.getSelectedIds(); var action = item.initialConfig.torrentAction; switch (action) { diff --git a/deluge/ui/web/js/deluge-all/MoveStorage.js b/deluge/ui/web/js/deluge-all/MoveStorage.js index 208031fb6..9ba638ac6 100644 --- a/deluge/ui/web/js/deluge-all/MoveStorage.js +++ b/deluge/ui/web/js/deluge-all/MoveStorage.js @@ -10,7 +10,7 @@ Ext.namespace('Deluge'); Deluge.MoveStorage = Ext.extend(Ext.Window, { - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { title: _('Move Download Folder'), @@ -30,7 +30,7 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, { Deluge.MoveStorage.superclass.constructor.call(this, config); }, - initComponent: function() { + initComponent: function () { Deluge.MoveStorage.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancel, this); @@ -62,21 +62,21 @@ Deluge.MoveStorage = Ext.extend(Ext.Window, { //}); }, - hide: function() { + hide: function () { Deluge.MoveStorage.superclass.hide.call(this); this.torrentIds = null; }, - show: function(torrentIds) { + show: function (torrentIds) { Deluge.MoveStorage.superclass.show.call(this); this.torrentIds = torrentIds; }, - onCancel: function() { + onCancel: function () { this.hide(); }, - onMove: function() { + onMove: function () { var dest = this.moveLocation.getValue(); deluge.client.core.move_storage(this.torrentIds, dest); this.hide(); diff --git a/deluge/ui/web/js/deluge-all/MultiOptionsManager.js b/deluge/ui/web/js/deluge-all/MultiOptionsManager.js index 1cd7d193f..82f983897 100644 --- a/deluge/ui/web/js/deluge-all/MultiOptionsManager.js +++ b/deluge/ui/web/js/deluge-all/MultiOptionsManager.js @@ -15,7 +15,7 @@ * @extends Deluge.OptionsManager */ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { - constructor: function(config) { + constructor: function (config) { this.currentId = null; this.stored = {}; Deluge.MultiOptionsManager.superclass.constructor.call(this, config); @@ -25,7 +25,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * Changes bound fields to use the specified id. * @param {String} id */ - changeId: function(id, dontUpdateBinds) { + changeId: function (id, dontUpdateBinds) { var oldId = this.currentId; this.currentId = id; if (!dontUpdateBinds) { @@ -33,7 +33,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { if (!this.binds[option]) continue; Ext.each( this.binds[option], - function(bind) { + function (bind) { bind.setValue(this.get(option)); }, this @@ -47,7 +47,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * Changes all the changed values to be the default values * @param {String} id */ - commit: function() { + commit: function () { this.stored[this.currentId] = Ext.apply( this.stored[this.currentId], this.changed[this.currentId] @@ -60,7 +60,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * @param {String/Array} option A single option or an array of options to return. * @returns {Object} the options value. */ - get: function() { + get: function () { if (arguments.length == 1) { var option = arguments[0]; return this.isDirty(option) @@ -78,7 +78,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { var options = {}; Ext.each( arguments, - function(option) { + function (option) { options[option] = this.isDirty(option) ? this.changed[this.currentId][option] : this.getDefault(option); @@ -94,7 +94,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * @param {String} option A single option. * @returns {Object} the value of the option */ - getDefault: function(option) { + getDefault: function (option) { return this.has(option) ? this.stored[this.currentId][option] : this.options[option]; @@ -104,7 +104,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * Returns the dirty (changed) values. * @returns {Object} the changed options */ - getDirty: function() { + getDirty: function () { return this.changed[this.currentId] ? this.changed[this.currentId] : {}; }, @@ -113,7 +113,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * @param {String} option * @returns {Boolean} true if the option has been changed, else false. */ - isDirty: function(option) { + isDirty: function (option) { return ( this.changed[this.currentId] && !Ext.isEmpty(this.changed[this.currentId][option]) @@ -126,7 +126,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * @param {String} option * @returns {Boolean} true if the id has an option, else false. */ - has: function(option) { + has: function (option) { return ( this.stored[this.currentId] && !Ext.isEmpty(this.stored[this.currentId][option]) @@ -136,7 +136,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { /** * Reset the options back to the default values for the specified id. */ - reset: function() { + reset: function () { if (this.changed[this.currentId]) delete this.changed[this.currentId]; if (this.stored[this.currentId]) delete this.stored[this.currentId]; }, @@ -144,7 +144,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { /** * Reset the options back to their defaults for all ids. */ - resetAll: function() { + resetAll: function () { this.changed = {}; this.stored = {}; this.changeId(null); @@ -156,7 +156,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * @param {String} option * @param {Object} value The value for the option */ - setDefault: function(option, value) { + setDefault: function (option, value) { if (option === undefined) { return; } else if (value === undefined) { @@ -187,7 +187,7 @@ Deluge.MultiOptionsManager = Ext.extend(Deluge.OptionsManager, { * @param {String/Object} option or options to update * @param {Object} [value]; */ - update: function(option, value) { + update: function (option, value) { if (option === undefined) { return; } else if (value === undefined) { diff --git a/deluge/ui/web/js/deluge-all/OptionsManager.js b/deluge/ui/web/js/deluge-all/OptionsManager.js index a1c4e65a4..529f7afce 100644 --- a/deluge/ui/web/js/deluge-all/OptionsManager.js +++ b/deluge/ui/web/js/deluge-all/OptionsManager.js @@ -18,7 +18,7 @@ Ext.namespace('Deluge'); * @param {Object} config Configuration options */ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { - constructor: function(config) { + constructor: function (config) { config = config || {}; this.binds = {}; this.changed = {}; @@ -56,7 +56,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * Add a set of default options and values to the options manager * @param {Object} options The default options. */ - addOptions: function(options) { + addOptions: function (options) { this.options = Ext.applyIf(this.options, options); }, @@ -65,7 +65,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String} option * @param {Ext.form.Field} field */ - bind: function(option, field) { + bind: function (option, field) { this.binds[option] = this.binds[option] || []; this.binds[option].push(field); field._doption = option; @@ -81,7 +81,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { /** * Changes all the changed values to be the default values */ - commit: function() { + commit: function () { this.options = Ext.apply(this.options, this.changed); this.reset(); }, @@ -91,7 +91,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {Mixed} oldValue The original value * @param {Mixed} value The new value to convert */ - convertValueType: function(oldValue, value) { + convertValueType: function (oldValue, value) { if (Ext.type(oldValue) != Ext.type(value)) { switch (Ext.type(oldValue)) { case 'string': @@ -121,7 +121,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String} [option] A single option or an array of options to return. * @returns {Object} the options value. */ - get: function() { + get: function () { if (arguments.length == 1) { var option = arguments[0]; return this.isDirty(option) @@ -131,7 +131,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { var options = {}; Ext.each( arguments, - function(option) { + function (option) { if (!this.has(option)) return; options[option] = this.isDirty(option) ? this.changed[option] @@ -148,7 +148,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String|Array} [option] A single option or an array of options to return. * @returns {Object} the value of the option */ - getDefault: function(option) { + getDefault: function (option) { return this.options[option]; }, @@ -156,7 +156,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * Returns the dirty (changed) values. * @returns {Object} the changed options */ - getDirty: function() { + getDirty: function () { return this.changed; }, @@ -164,7 +164,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String} [option] The option to check * @returns {Boolean} true if the option has been changed from the default. */ - isDirty: function(option) { + isDirty: function (option) { return !Ext.isEmpty(this.changed[option]); }, @@ -173,14 +173,14 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String} option * @returns {Boolean} true if the option exists, else false. */ - has: function(option) { + has: function (option) { return this.options[option]; }, /** * Reset the options back to the default values. */ - reset: function() { + reset: function () { this.changed = {}; }, @@ -189,7 +189,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String} option * @param {Object} value The value for the option */ - set: function(option, value) { + set: function (option, value) { if (option === undefined) { return; } else if (typeof option == 'object') { @@ -209,7 +209,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {String/Object} option or options to update * @param {Object} [value]; */ - update: function(option, value) { + update: function (option, value) { if (option === undefined) { return; } else if (value === undefined) { @@ -238,7 +238,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * Lets the option manager know when a field is blurred so if a value * so value changing operations can continue on that field. */ - onFieldBlur: function(field, event) { + onFieldBlur: function (field, event) { if (this.focused == field) { this.focused = null; } @@ -249,7 +249,7 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * @param {Ext.form.Field} field * @private */ - onFieldChange: function(field, event) { + onFieldChange: function (field, event) { if (field.field) field = field.field; // fix for spinners this.update(field._doption, field.getValue()); }, @@ -258,16 +258,16 @@ Deluge.OptionsManager = Ext.extend(Ext.util.Observable, { * Lets the option manager know when a field is focused so if a value changing * operation is performed it will not change the value of the field. */ - onFieldFocus: function(field, event) { + onFieldFocus: function (field, event) { this.focused = field; }, - onChange: function(option, newValue, oldValue) { + onChange: function (option, newValue, oldValue) { // If we don't have a bind there's nothing to do. if (Ext.isEmpty(this.binds[option])) return; Ext.each( this.binds[option], - function(bind) { + function (bind) { // The field is currently focused so we do not want to change it. if (bind == this.focused) return; // Set the form field to the new value. diff --git a/deluge/ui/web/js/deluge-all/OtherLimitWindow.js b/deluge/ui/web/js/deluge-all/OtherLimitWindow.js index 3e5880fb0..0d53d4a4e 100644 --- a/deluge/ui/web/js/deluge-all/OtherLimitWindow.js +++ b/deluge/ui/web/js/deluge-all/OtherLimitWindow.js @@ -20,7 +20,7 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, { constrainHeader: true, closeAction: 'hide', - initComponent: function() { + initComponent: function () { Deluge.OtherLimitWindow.superclass.initComponent.call(this); this.form = this.add({ xtype: 'form', @@ -53,30 +53,27 @@ Deluge.OtherLimitWindow = Ext.extend(Ext.Window, { this.afterMethod('show', this.doFocusField, this); }, - setValue: function(value) { + setValue: function (value) { this.form.getForm().setValues({ limit: value }); }, - onCancelClick: function() { + onCancelClick: function () { this.form.getForm().reset(); this.hide(); }, - onOkClick: function() { + onOkClick: function () { var config = {}; config[this.group] = this.form.getForm().getValues().limit; deluge.client.core.set_config(config, { - success: function() { + success: function () { deluge.ui.update(); }, }); this.hide(); }, - doFocusField: function() { - this.form - .getForm() - .findField('limit') - .focus(true, 10); + doFocusField: function () { + this.form.getForm().findField('limit').focus(true, 10); }, }); diff --git a/deluge/ui/web/js/deluge-all/Plugin.js b/deluge/ui/web/js/deluge-all/Plugin.js index af2cda4e9..26971f762 100644 --- a/deluge/ui/web/js/deluge-all/Plugin.js +++ b/deluge/ui/web/js/deluge-all/Plugin.js @@ -21,7 +21,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, { */ name: null, - constructor: function(config) { + constructor: function (config) { this.isDelugePlugin = true; this.addEvents({ /** @@ -43,7 +43,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, { * Disables the plugin, firing the "{@link #disabled}" event and * then executing the plugins clean up method onDisabled. */ - disable: function() { + disable: function () { this.fireEvent('disabled', this); if (this.onDisable) this.onDisable(); }, @@ -52,13 +52,13 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, { * Enables the plugin, firing the "{@link #enabled}" event and * then executes the plugins setup method, onEnabled. */ - enable: function() { + enable: function () { deluge.client.reloadMethods(); this.fireEvent('enable', this); if (this.onEnable) this.onEnable(); }, - registerTorrentStatus: function(key, header, options) { + registerTorrentStatus: function (key, header, options) { options = options || {}; var cc = options.colCfg || {}, sc = options.storeCfg || {}; @@ -79,23 +79,23 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, { deluge.torrents.getView().refresh(true); }, - deregisterTorrentStatus: function(key) { + deregisterTorrentStatus: function (key) { var fields = []; - Ext.each(deluge.torrents.meta.fields, function(field) { + Ext.each(deluge.torrents.meta.fields, function (field) { if (field.name != key) fields.push(field); }); deluge.torrents.meta.fields = fields; deluge.torrents.getStore().reader.onMetaChange(deluge.torrents.meta); var cols = []; - Ext.each(deluge.torrents.columns, function(col) { + Ext.each(deluge.torrents.columns, function (col) { if (col.dataIndex != key) cols.push(col); }); deluge.torrents.colModel.setConfig(cols); deluge.torrents.columns = cols; var keys = []; - Ext.each(Deluge.Keys.Grid, function(k) { + Ext.each(Deluge.Keys.Grid, function (k) { if (k == key) keys.push(k); }); Deluge.Keys.Grid = keys; diff --git a/deluge/ui/web/js/deluge-all/RemoveWindow.js b/deluge/ui/web/js/deluge-all/RemoveWindow.js index a6290089d..ccac2ef99 100644 --- a/deluge/ui/web/js/deluge-all/RemoveWindow.js +++ b/deluge/ui/web/js/deluge-all/RemoveWindow.js @@ -27,16 +27,16 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, { bodyStyle: 'padding: 5px; padding-left: 10px;', html: 'Are you sure you wish to remove the torrent (s)?', - initComponent: function() { + 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); }, - remove: function(removeData) { + remove: function (removeData) { deluge.client.core.remove_torrents(this.torrentIds, removeData, { - success: function(result) { + success: function (result) { if (result == true) { console.log( 'Error(s) occured when trying to delete torrent(s).' @@ -49,25 +49,25 @@ Deluge.RemoveWindow = Ext.extend(Ext.Window, { }); }, - show: function(ids) { + show: function (ids) { Deluge.RemoveWindow.superclass.show.call(this); this.torrentIds = ids; }, - onCancel: function() { + onCancel: function () { this.hide(); this.torrentIds = null; }, - onRemove: function() { + onRemove: function () { this.remove(false); }, - onRemoveData: function() { + onRemoveData: function () { this.remove(true); }, - onRemoved: function(torrentIds) { + onRemoved: function (torrentIds) { deluge.events.fire('torrentsRemoved', torrentIds); this.hide(); deluge.ui.update(); diff --git a/deluge/ui/web/js/deluge-all/Sidebar.js b/deluge/ui/web/js/deluge-all/Sidebar.js index 74c3ecbcf..eb08a898f 100644 --- a/deluge/ui/web/js/deluge-all/Sidebar.js +++ b/deluge/ui/web/js/deluge-all/Sidebar.js @@ -24,7 +24,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { // private selected: null, - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { id: 'sidebar', @@ -43,16 +43,16 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { }, // private - initComponent: function() { + initComponent: function () { Deluge.Sidebar.superclass.initComponent.call(this); deluge.events.on('disconnect', this.onDisconnect, this); }, - createFilter: function(filter, states) { + createFilter: function (filter, states) { var panel = new Deluge.FilterPanel({ filter: filter, }); - panel.on('selectionchange', function(view, nodes) { + panel.on('selectionchange', function (view, nodes) { deluge.ui.update(); }); this.add(panel); @@ -60,7 +60,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { this.doLayout(); this.panels[filter] = panel; - panel.header.on('click', function(header) { + panel.header.on('click', function (header) { if (!deluge.config.sidebar_multiple_filters) { deluge.ui.update(); } @@ -74,16 +74,16 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { this.fireEvent('afterfiltercreate', this, panel); }, - getFilter: function(filter) { + getFilter: function (filter) { return this.panels[filter]; }, - getFilterStates: function() { + getFilterStates: function () { var states = {}; if (deluge.config.sidebar_multiple_filters) { // Grab the filters from each of the filter panels - this.items.each(function(panel) { + this.items.each(function (panel) { var state = panel.getState(); if (state == null) return; states[panel.filterType] = state; @@ -100,12 +100,12 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { return states; }, - hasFilter: function(filter) { + hasFilter: function (filter) { return this.panels[filter] ? true : false; }, // private - onDisconnect: function() { + onDisconnect: function () { for (var filter in this.panels) { this.remove(this.panels[filter]); } @@ -113,11 +113,11 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { this.selected = null; }, - onFilterSelect: function(selModel, rowIndex, record) { + onFilterSelect: function (selModel, rowIndex, record) { deluge.ui.update(); }, - update: function(filters) { + update: function (filters) { for (var filter in filters) { var states = filters[filter]; if (Ext.getKeys(this.panels).indexOf(filter) > -1) { @@ -130,7 +130,7 @@ Deluge.Sidebar = Ext.extend(Ext.Panel, { // Perform a cleanup of fitlers that are not enabled any more. Ext.each( Ext.keys(this.panels), - function(filter) { + function (filter) { if (Ext.keys(filters).indexOf(filter) == -1) { // We need to remove the panel this.remove(this.panels[filter]); diff --git a/deluge/ui/web/js/deluge-all/Statusbar.js b/deluge/ui/web/js/deluge-all/Statusbar.js index c2327bee9..00ad6b244 100644 --- a/deluge/ui/web/js/deluge-all/Statusbar.js +++ b/deluge/ui/web/js/deluge-all/Statusbar.js @@ -10,7 +10,7 @@ Ext.namespace('Deluge'); Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { id: 'deluge-statusbar', @@ -22,14 +22,14 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { Deluge.Statusbar.superclass.constructor.call(this, config); }, - initComponent: function() { + initComponent: function () { Deluge.Statusbar.superclass.initComponent.call(this); deluge.events.on('connect', this.onConnect, this); deluge.events.on('disconnect', this.onDisconnect, this); }, - createButtons: function() { + createButtons: function () { this.buttons = this.add( { id: 'statusbar-connections', @@ -213,7 +213,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { cls: 'x-btn-text-icon', iconCls: 'x-deluge-traffic', tooltip: _('Protocol Traffic Download/Upload'), - handler: function() { + handler: function () { deluge.preferences.show(); deluge.preferences.selectPage('Network'); }, @@ -240,7 +240,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { cls: 'x-btn-text-icon', iconCls: 'x-deluge-freespace', tooltip: _('Freespace in download folder'), - handler: function() { + handler: function () { deluge.preferences.show(); deluge.preferences.selectPage('Downloads'); }, @@ -249,7 +249,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { this.created = true; }, - onConnect: function() { + onConnect: function () { this.setStatus({ iconCls: 'x-connected', text: '', @@ -257,7 +257,7 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { if (!this.created) { this.createButtons(); } else { - Ext.each(this.buttons, function(item) { + Ext.each(this.buttons, function (item) { item.show(); item.enable(); }); @@ -265,23 +265,23 @@ Deluge.Statusbar = Ext.extend(Ext.ux.StatusBar, { this.doLayout(); }, - onDisconnect: function() { + onDisconnect: function () { this.clearStatus({ useDefaults: true }); - Ext.each(this.buttons, function(item) { + Ext.each(this.buttons, function (item) { item.hide(); item.disable(); }); this.doLayout(); }, - update: function(stats) { + update: function (stats) { if (!stats) return; function addSpeed(val) { return val + ' KiB/s'; } - var updateStat = function(name, config) { + var updateStat = function (name, config) { var item = this.items.get('statusbar-' + name); if (config.limit.value > 0) { var value = config.value.formatter diff --git a/deluge/ui/web/js/deluge-all/StatusbarMenu.js b/deluge/ui/web/js/deluge-all/StatusbarMenu.js index b9882539f..1365c9c98 100644 --- a/deluge/ui/web/js/deluge-all/StatusbarMenu.js +++ b/deluge/ui/web/js/deluge-all/StatusbarMenu.js @@ -15,13 +15,13 @@ Ext.ns('Deluge'); * @extends Ext.menu.Menu */ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { - initComponent: function() { + initComponent: function () { Deluge.StatusbarMenu.superclass.initComponent.call(this); this.otherWin = new Deluge.OtherLimitWindow( this.initialConfig.otherWin || {} ); - this.items.each(function(item) { + this.items.each(function (item) { if (item.getXType() != 'menucheckitem') return; if (item.value == 'other') { item.on('click', this.onOtherClicked, this); @@ -31,14 +31,14 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { }, this); }, - setValue: function(value) { + setValue: function (value) { var beenSet = false; // set the new value this.value = value = value == 0 ? -1 : value; var other = null; // uncheck all items - this.items.each(function(item) { + this.items.each(function (item) { if (item.setChecked) { item.suspendEvents(); if (item.value == value) { @@ -60,18 +60,18 @@ Deluge.StatusbarMenu = Ext.extend(Ext.menu.Menu, { other.resumeEvents(); }, - onLimitChanged: function(item, checked) { + onLimitChanged: function (item, checked) { if (!checked || item.value == 'other') return; // We do not care about unchecked or other. var config = {}; config[item.group] = item.value; deluge.client.core.set_config(config, { - success: function() { + success: function () { deluge.ui.update(); }, }); }, - onOtherClicked: function(item, e) { + onOtherClicked: function (item, e) { this.otherWin.group = item.group; this.otherWin.setValue(this.value); this.otherWin.show(); diff --git a/deluge/ui/web/js/deluge-all/Toolbar.js b/deluge/ui/web/js/deluge-all/Toolbar.js index d51818b4a..1ecdd75cf 100644 --- a/deluge/ui/web/js/deluge-all/Toolbar.js +++ b/deluge/ui/web/js/deluge-all/Toolbar.js @@ -14,7 +14,7 @@ * @extends Ext.Toolbar */ Deluge.Toolbar = Ext.extend(Ext.Toolbar, { - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { items: [ @@ -118,62 +118,62 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, { connectedButtons: ['add', 'remove', 'pause', 'resume', 'up', 'down'], - initComponent: function() { + initComponent: function () { Deluge.Toolbar.superclass.initComponent.call(this); deluge.events.on('connect', this.onConnect, this); deluge.events.on('login', this.onLogin, this); }, - onConnect: function() { + onConnect: function () { Ext.each( this.connectedButtons, - function(buttonId) { + function (buttonId) { this.items.get(buttonId).enable(); }, this ); }, - onDisconnect: function() { + onDisconnect: function () { Ext.each( this.connectedButtons, - function(buttonId) { + function (buttonId) { this.items.get(buttonId).disable(); }, this ); }, - onLogin: function() { + onLogin: function () { this.items.get('logout').enable(); }, - onLogout: function() { + onLogout: function () { this.items.get('logout').disable(); deluge.login.logout(); }, - onConnectionManagerClick: function() { + onConnectionManagerClick: function () { deluge.connectionManager.show(); }, - onHelpClick: function() { + onHelpClick: function () { window.open('http://dev.deluge-torrent.org/wiki/UserGuide'); }, - onAboutClick: function() { + onAboutClick: function () { var about = new Deluge.about.AboutWindow(); about.show(); }, - onPreferencesClick: function() { + onPreferencesClick: function () { deluge.preferences.show(); }, - onTorrentAction: function(item) { + onTorrentAction: function (item) { var selection = deluge.torrents.getSelections(); var ids = []; - Ext.each(selection, function(record) { + Ext.each(selection, function (record) { ids.push(record.id); }); @@ -184,7 +184,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, { case 'pause': case 'resume': deluge.client.core[item.id + '_torrent'](ids, { - success: function() { + success: function () { deluge.ui.update(); }, }); @@ -192,7 +192,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, { case 'up': case 'down': deluge.client.core['queue_' + item.id](ids, { - success: function() { + success: function () { deluge.ui.update(); }, }); @@ -200,7 +200,7 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, { } }, - onTorrentAdd: function() { + onTorrentAdd: function () { deluge.add.show(); }, }); diff --git a/deluge/ui/web/js/deluge-all/TorrentGrid.js b/deluge/ui/web/js/deluge-all/TorrentGrid.js index b0e0c5ec7..f664c765c 100644 --- a/deluge/ui/web/js/deluge-all/TorrentGrid.js +++ b/deluge/ui/web/js/deluge-all/TorrentGrid.js @@ -8,7 +8,7 @@ * See LICENSE for more details. */ -(function() { +(function () { /* Renderers for the Torrent Grid */ function queueRenderer(value) { return value == -1 ? '' : value + 1; @@ -337,21 +337,21 @@ key: 'a', ctrl: true, stopEvent: true, - handler: function() { + handler: function () { deluge.torrents.getSelectionModel().selectAll(); }, }, { key: [46], stopEvent: true, - handler: function() { + handler: function () { ids = deluge.torrents.getSelectedIds(); deluge.removeWindow.show(ids); }, }, ], - constructor: function(config) { + constructor: function (config) { config = Ext.apply( { id: 'torrentGrid', @@ -376,12 +376,12 @@ Deluge.TorrentGrid.superclass.constructor.call(this, config); }, - initComponent: function() { + initComponent: function () { Deluge.TorrentGrid.superclass.initComponent.call(this); deluge.events.on('torrentsRemoved', this.onTorrentsRemoved, this); deluge.events.on('disconnect', this.onDisconnect, this); - this.on('rowcontextmenu', function(grid, rowIndex, e) { + this.on('rowcontextmenu', function (grid, rowIndex, e) { e.stopEvent(); var selection = grid.getSelectionModel(); if (!selection.isSelected(rowIndex)) { @@ -397,7 +397,7 @@ * @param index {int} The row index of the torrent you wish to retrieve. * @return {Ext.data.Record} The record representing the torrent. */ - getTorrent: function(index) { + getTorrent: function (index) { return this.getStore().getAt(index); }, @@ -405,14 +405,14 @@ * Returns the currently selected record. * @ return {Array/Ext.data.Record} The record(s) representing the rows */ - getSelected: function() { + getSelected: function () { return this.getSelectionModel().getSelected(); }, /** * Returns the currently selected records. */ - getSelections: function() { + getSelections: function () { return this.getSelectionModel().getSelections(); }, @@ -420,7 +420,7 @@ * Return the currently selected torrent id. * @return {String} The currently selected id. */ - getSelectedId: function() { + getSelectedId: function () { return this.getSelectionModel().getSelected().id; }, @@ -428,15 +428,15 @@ * Return the currently selected torrent ids. * @return {Array} The currently selected ids. */ - getSelectedIds: function() { + getSelectedIds: function () { var ids = []; - Ext.each(this.getSelectionModel().getSelections(), function(r) { + Ext.each(this.getSelectionModel().getSelections(), function (r) { ids.push(r.id); }); return ids; }, - update: function(torrents, wipe) { + update: function (torrents, wipe) { var store = this.getStore(); // Need to perform a complete reload of the torrent grid. @@ -470,7 +470,7 @@ store.add(newTorrents); // Remove any torrents that should not be in the store. - store.each(function(record) { + store.each(function (record) { if (!torrents[record.id]) { store.remove(record); delete this.torrents[record.id]; @@ -484,17 +484,17 @@ }, // private - onDisconnect: function() { + onDisconnect: function () { this.getStore().removeAll(); this.torrents = {}; }, // private - onTorrentsRemoved: function(torrentIds) { + onTorrentsRemoved: function (torrentIds) { var selModel = this.getSelectionModel(); Ext.each( torrentIds, - function(torrentId) { + function (torrentId) { var record = this.getStore().getById(torrentId); if (selModel.isSelected(record)) { selModel.deselectRow(this.getStore().indexOf(record)); diff --git a/deluge/ui/web/js/deluge-all/UI.js b/deluge/ui/web/js/deluge-all/UI.js index dec4850fc..cc877d597 100644 --- a/deluge/ui/web/js/deluge-all/UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -42,7 +42,7 @@ deluge.ui = { * @description Create all the interface components, the json-rpc client * and set up various events that the UI will utilise. */ - initialize: function() { + initialize: function () { deluge.add = new Deluge.add.AddWindow(); deluge.details = new Deluge.details.DetailsPanel(); deluge.connectionManager = new Deluge.ConnectionManager(); @@ -100,7 +100,7 @@ deluge.ui = { deluge.client.on( 'connected', - function(e) { + function (e) { deluge.login.show(); }, this, @@ -113,7 +113,7 @@ deluge.ui = { this.originalTitle = document.title; }, - checkConnection: function() { + checkConnection: function () { deluge.client.web.connected({ success: this.onConnectionSuccess, failure: this.onConnectionError, @@ -121,7 +121,7 @@ deluge.ui = { }); }, - update: function() { + update: function () { var filters = deluge.sidebar.getFilterStates(); this.oldFilters = this.filters; this.filters = filters; @@ -134,9 +134,9 @@ deluge.ui = { deluge.details.update(); }, - onConnectionError: function(error) {}, + onConnectionError: function (error) {}, - onConnectionSuccess: function(result) { + onConnectionSuccess: function (result) { deluge.statusbar.setStatus({ iconCls: 'x-deluge-statusbar icon-ok', text: _('Connection restored'), @@ -147,7 +147,7 @@ deluge.ui = { } }, - onUpdateError: function(error) { + onUpdateError: function (error) { if (this.errorCount == 2) { Ext.MessageBox.show({ title: _('Lost Connection'), @@ -169,7 +169,7 @@ deluge.ui = { * @private * Updates the various components in the interface. */ - onUpdate: function(data) { + onUpdate: function (data) { if (!data['connected']) { deluge.connectionManager.disconnect(true); return; @@ -199,7 +199,7 @@ deluge.ui = { * @private * Start the Deluge UI polling the server and update the interface. */ - onConnect: function() { + onConnect: function () { if (!this.running) { this.running = setInterval(this.update, 2000); this.update(); @@ -214,14 +214,14 @@ deluge.ui = { * @static * @private */ - onDisconnect: function() { + onDisconnect: function () { this.stop(); }, - onGotPlugins: function(plugins) { + onGotPlugins: function (plugins) { Ext.each( plugins.enabled_plugins, - function(plugin) { + function (plugin) { if (deluge.plugins[plugin]) return; deluge.client.web.get_plugin_resources(plugin, { success: this.onGotPluginResources, @@ -232,7 +232,7 @@ deluge.ui = { ); }, - onPluginEnabled: function(pluginName) { + onPluginEnabled: function (pluginName) { if (deluge.plugins[pluginName]) { deluge.plugins[pluginName].enable(); } else { @@ -243,13 +243,13 @@ deluge.ui = { } }, - onGotPluginResources: function(resources) { + onGotPluginResources: function (resources) { var scripts = Deluge.debug ? resources.debug_scripts : resources.scripts; Ext.each( scripts, - function(script) { + function (script) { Ext.ux.JSLoader({ url: deluge.config.base + script, onLoad: this.onPluginLoaded, @@ -260,11 +260,11 @@ deluge.ui = { ); }, - onPluginDisabled: function(pluginName) { + onPluginDisabled: function (pluginName) { if (deluge.plugins[pluginName]) deluge.plugins[pluginName].disable(); }, - onPluginLoaded: function(options) { + onPluginLoaded: function (options) { // This could happen if the plugin has multiple scripts if (!Deluge.hasPlugin(options.pluginName)) return; @@ -278,7 +278,7 @@ deluge.ui = { * @static * Stop the Deluge UI polling the server and clear the interface. */ - stop: function() { + stop: function () { if (this.running) { clearInterval(this.running); this.running = false; @@ -287,6 +287,6 @@ deluge.ui = { }, }; -Ext.onReady(function(e) { +Ext.onReady(function (e) { deluge.ui.initialize(); }); diff --git a/deluge/ui/web/js/deluge-all/add/AddWindow.js b/deluge/ui/web/js/deluge-all/add/AddWindow.js index a9db791f1..fb89e479a 100644 --- a/deluge/ui/web/js/deluge-all/add/AddWindow.js +++ b/deluge/ui/web/js/deluge-all/add/AddWindow.js @@ -12,7 +12,7 @@ Ext.namespace('Deluge.add'); // This override allows file upload buttons to contain icons Ext.override(Ext.ux.form.FileUploadField, { - onRender: function(ct, position) { + onRender: function (ct, position) { Ext.ux.form.FileUploadField.superclass.onRender.call( this, ct, @@ -58,7 +58,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { plain: true, iconCls: 'x-deluge-add-window-icon', - initComponent: function() { + initComponent: function () { Deluge.add.AddWindow.superclass.initComponent.call(this); this.addButton(_('Cancel'), this.onCancelClick, this); @@ -168,17 +168,17 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { this.on('show', this.onShow, this); }, - clear: function() { + clear: function () { this.list.getStore().removeAll(); this.optionsPanel.clear(); // Reset upload form so handler fires when a canceled file is reselected this.fileUploadForm.reset(); }, - onAddClick: function() { + onAddClick: function () { var torrents = []; if (!this.list) return; - this.list.getStore().each(function(r) { + this.list.getStore().each(function (r) { var id = r.get('info_hash'); torrents.push({ path: this.optionsPanel.getFilename(id), @@ -187,29 +187,29 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { }, this); deluge.client.web.add_torrents(torrents, { - success: function(result) {}, + success: function (result) {}, }); this.clear(); this.hide(); }, - onCancelClick: function() { + onCancelClick: function () { this.clear(); this.hide(); }, - onFile: function() { + onFile: function () { if (!this.file) this.file = new Deluge.add.FileWindow(); this.file.show(); }, - onHide: function() { + onHide: function () { this.optionsPanel.setActiveTab(0); this.optionsPanel.files.setDisabled(true); this.optionsPanel.form.setDisabled(true); }, - onRemove: function() { + onRemove: function () { if (!this.list.getSelectionCount()) return; var torrent = this.list.getSelectedRecords()[0]; if (!torrent) return; @@ -220,7 +220,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { delete this.torrents[torrent.id]; }, - onSelect: function(list, selections) { + onSelect: function (list, selections) { if (selections.length) { var record = this.list.getRecord(selections[0]); this.optionsPanel.setTorrent(record.get('info_hash')); @@ -230,7 +230,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { } }, - onShow: function() { + onShow: function () { if (!this.url) { this.url = new Deluge.add.UrlWindow(); this.url.on('beforeadd', this.onTorrentBeforeAdd, this); @@ -241,14 +241,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { this.optionsPanel.form.getDefaults(); }, - onFileSelected: function() { + onFileSelected: function () { if (this.fileUploadForm.isValid()) { var torrentIds = []; var files = this.fileUploadForm.findField('torrentFile').value; var randomId = this.createTorrentId(); Array.prototype.forEach.call( files, - function(file, i) { + function (file, i) { // Append index for batch of unique torrentIds. var torrentId = randomId + i.toString(); torrentIds.push(torrentId); @@ -266,14 +266,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { } }, - onUploadSuccess: function(fp, upload) { + onUploadSuccess: function (fp, upload) { if (!upload.result.success) { this.clear(); return; } upload.result.files.forEach( - function(filename, i) { + function (filename, i) { deluge.client.web.get_torrent_info(filename, { success: this.onGotInfo, scope: this, @@ -285,7 +285,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { this.fileUploadForm.reset(); }, - onUploadFailure: function(form, action) { + onUploadFailure: function (form, action) { this.hide(); Ext.MessageBox.show({ title: _('Error'), @@ -298,18 +298,18 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { this.fireEvent('addfailed', this.torrentId); }, - onGotInfo: function(info, obj, response, request) { + onGotInfo: function (info, obj, response, request) { info.filename = request.options.filename; torrentId = request.options.torrentId; this.onTorrentAdd(torrentId, info); }, - onTorrentBeforeAdd: function(torrentId, text) { + onTorrentBeforeAdd: function (torrentId, text) { var store = this.list.getStore(); store.loadData([[torrentId, null, text]], true); }, - onTorrentAdd: function(torrentId, info) { + onTorrentAdd: function (torrentId, info) { var r = this.list.getStore().getById(torrentId); if (!info) { Ext.MessageBox.show({ @@ -330,7 +330,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { } }, - onTorrentAddFailed: function(torrentId) { + onTorrentAddFailed: function (torrentId) { var store = this.list.getStore(); var torrentRecord = store.getById(torrentId); if (torrentRecord) { @@ -338,7 +338,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { } }, - onUrl: function(button, event) { + onUrl: function (button, event) { this.url.show(); }, }); diff --git a/deluge/ui/web/js/deluge-all/add/FilesTab.js b/deluge/ui/web/js/deluge-all/add/FilesTab.js index a433ad6a6..fed52282d 100644 --- a/deluge/ui/web/js/deluge-all/add/FilesTab.js +++ b/deluge/ui/web/js/deluge-all/add/FilesTab.js @@ -34,7 +34,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { width: 60, dataIndex: 'size', tpl: new Ext.XTemplate('{size:this.fsize}', { - fsize: function(v) { + fsize: function (v) { return fsize(v); }, }), @@ -44,7 +44,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, { width: 65, dataIndex: 'download', tpl: new Ext.XTemplate('{download:this.format}', { - format: function(v) { + format: function (v) { return ( '
' @@ -72,7 +72,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, { width: 0.2, sortable: true, tpl: new Ext.XTemplate('{enabled:this.getCheckbox}', { - getCheckbox: function(v) { + getCheckbox: function (v) { return ( '