Changeset 0d665d7
- Timestamp:
- 05/06/2011 06:02:54 PM (14 years ago)
- Children:
- 871d9ac
- Parents:
- aef2a8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/ui/web/js/deluge-all/add/UrlWindow.js
raef2a8 r0d665d7 1 1 /*! 2 2 * Deluge.add.UrlWindow.js 3 * 3 * 4 4 * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> 5 5 * … … 34 34 Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, { 35 35 36 37 38 39 40 41 36 title: _('Add from Url'), 37 modal: true, 38 plain: true, 39 layout: 'fit', 40 width: 350, 41 height: 155, 42 42 43 buttonAlign: 'center', 44 closeAction: 'hide', 45 bodyStyle: 'padding: 10px 5px;', 46 iconCls: 'x-deluge-add-url-window-icon', 47 48 initComponent: function() { 49 Deluge.add.UrlWindow.superclass.initComponent.call(this); 50 this.addButton(_('Add'), this.onAddClick, this); 51 52 var form = this.add({ 53 xtype: 'form', 54 defaultType: 'textfield', 55 baseCls: 'x-plain', 56 labelWidth: 55 57 }); 58 59 this.urlField = form.add({ 60 fieldLabel: _('Url'), 61 id: 'url', 62 name: 'url', 63 anchor: '100%' 64 }); 65 this.urlField.on('specialkey', this.onAdd, this); 66 67 this.cookieField = form.add({ 68 fieldLabel: _('Cookies'), 69 id: 'cookies', 70 name: 'cookies', 71 anchor: '100%' 72 }); 73 this.cookieField.on('specialkey', this.onAdd, this); 74 }, 75 76 onAddClick: function(field, e) { 77 if ((field.id == 'url' || field.id == 'cookies') && e.getKey() != e.ENTER) return; 43 buttonAlign: 'center', 44 closeAction: 'hide', 45 bodyStyle: 'padding: 10px 5px;', 46 iconCls: 'x-deluge-add-url-window-icon', 78 47 79 var field = this.urlField; 80 var url = field.getValue(); 81 var cookies = this.cookieField.getValue(); 82 var torrentId = this.createTorrentId(); 83 84 deluge.client.web.download_torrent_from_url(url, cookies, { 85 success: this.onDownload, 86 scope: this, 87 torrentId: torrentId 88 }); 89 this.hide(); 90 this.fireEvent('beforeadd', torrentId, url); 91 }, 92 93 onDownload: function(filename, obj, resp, req) { 94 this.urlField.setValue(''); 95 deluge.client.web.get_torrent_info(filename, { 96 success: this.onGotInfo, 97 scope: this, 98 filename: filename, 99 torrentId: req.options.torrentId 100 }); 101 }, 102 103 onGotInfo: function(info, obj, response, request) { 104 info['filename'] = request.options.filename; 105 this.fireEvent('add', request.options.torrentId, info); 106 } 48 initComponent: function() { 49 Deluge.add.UrlWindow.superclass.initComponent.call(this); 50 this.addButton(_('Add'), this.onAddClick, this); 51 52 var form = this.add({ 53 xtype: 'form', 54 defaultType: 'textfield', 55 baseCls: 'x-plain', 56 labelWidth: 55 57 }); 58 59 this.urlField = form.add({ 60 fieldLabel: _('Url'), 61 id: 'url', 62 name: 'url', 63 width: '97%' 64 }); 65 this.urlField.on('specialkey', this.onAdd, this); 66 67 this.cookieField = form.add({ 68 fieldLabel: _('Cookies'), 69 id: 'cookies', 70 name: 'cookies', 71 width: '97%' 72 }); 73 this.cookieField.on('specialkey', this.onAdd, this); 74 }, 75 76 onAddClick: function(field, e) { 77 if ((field.id == 'url' || field.id == 'cookies') && e.getKey() != e.ENTER) return; 78 79 var field = this.urlField; 80 var url = field.getValue(); 81 var cookies = this.cookieField.getValue(); 82 var torrentId = this.createTorrentId(); 83 84 deluge.client.web.download_torrent_from_url(url, cookies, { 85 success: this.onDownload, 86 scope: this, 87 torrentId: torrentId 88 }); 89 this.hide(); 90 this.fireEvent('beforeadd', torrentId, url); 91 }, 92 93 onDownload: function(filename, obj, resp, req) { 94 this.urlField.setValue(''); 95 deluge.client.web.get_torrent_info(filename, { 96 success: this.onGotInfo, 97 scope: this, 98 filename: filename, 99 torrentId: req.options.torrentId 100 }); 101 }, 102 103 onGotInfo: function(info, obj, response, request) { 104 info['filename'] = request.options.filename; 105 this.fireEvent('add', request.options.torrentId, info); 106 } 107 107 });
Note:
See TracChangeset
for help on using the changeset viewer.