mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-23 16:48:21 +00:00
split out Deluge.Add into seperate smaller files
add back adding torrents via file
This commit is contained in:
parent
cb14a2dd22
commit
993c654917
93
deluge/ui/web/js/Deluge.Add.File.js
Normal file
93
deluge/ui/web/js/Deluge.Add.File.js
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
Script: Deluge.Add.File.js
|
||||||
|
Contains the Add Torrent by file window.
|
||||||
|
|
||||||
|
Copyright:
|
||||||
|
(C) Damien Churchill 2009 <damoxc@gmail.com>
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, write to:
|
||||||
|
The Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Ext.deluge.add.FileWindow = Ext.extend(Ext.deluge.add.Window, {
|
||||||
|
constructor: function(config) {
|
||||||
|
config = Ext.apply({
|
||||||
|
layout: 'fit',
|
||||||
|
width: 350,
|
||||||
|
height: 115,
|
||||||
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
|
buttonAlign: 'center',
|
||||||
|
closeAction: 'hide',
|
||||||
|
modal: true,
|
||||||
|
plain: true,
|
||||||
|
title: _('Add from File'),
|
||||||
|
iconCls: 'x-deluge-add-file',
|
||||||
|
buttons: [{
|
||||||
|
text: _('Add'),
|
||||||
|
handler: this.onAdd,
|
||||||
|
scope: this
|
||||||
|
}]
|
||||||
|
}, config);
|
||||||
|
Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
|
||||||
|
},
|
||||||
|
|
||||||
|
initComponent: function() {
|
||||||
|
Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
|
||||||
|
this.form = this.add(new Ext.form.FormPanel({
|
||||||
|
baseCls: 'x-plain',
|
||||||
|
labelWidth: 55,
|
||||||
|
autoHeight: true,
|
||||||
|
fileUpload: true,
|
||||||
|
items: [{
|
||||||
|
xtype: 'fileuploadfield',
|
||||||
|
id: 'torrentFile',
|
||||||
|
emptyText: _('Select a torrent'),
|
||||||
|
fieldLabel: _('File'),
|
||||||
|
name: 'file',
|
||||||
|
buttonCfg: {
|
||||||
|
text: _('Browse') + '...'
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
onAdd: function(field, e) {
|
||||||
|
if (this.form.getForm().isValid()) {
|
||||||
|
this.form.getForm().submit({
|
||||||
|
url: '/upload',
|
||||||
|
waitMsg: _('Uploading your torrent...'),
|
||||||
|
success: this.onUploadSuccess,
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.fireEvent('beforeadd', null);
|
||||||
|
},
|
||||||
|
|
||||||
|
onUploadSuccess: function(fp, upload) {
|
||||||
|
this.hide();
|
||||||
|
var filename = upload.result.toString();
|
||||||
|
this.form.getForm().findField('torrentFile').setValue('');
|
||||||
|
Deluge.Client.web.get_torrent_info(filename, {
|
||||||
|
success: this.onGotInfo,
|
||||||
|
scope: this,
|
||||||
|
filename: filename
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onGotInfo: function(info, obj, response, request) {
|
||||||
|
info['filename'] = request.options.filename;
|
||||||
|
this.fireEvent('add', info);
|
||||||
|
}
|
||||||
|
});
|
95
deluge/ui/web/js/Deluge.Add.Url.js
Normal file
95
deluge/ui/web/js/Deluge.Add.Url.js
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
Script: Deluge.Add.Url.js
|
||||||
|
Contains the Add Torrent by url window.
|
||||||
|
|
||||||
|
Copyright:
|
||||||
|
(C) Damien Churchill 2009 <damoxc@gmail.com>
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
|
any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, write to:
|
||||||
|
The Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor
|
||||||
|
Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
|
||||||
|
constructor: function(config) {
|
||||||
|
config = Ext.apply({
|
||||||
|
layout: 'fit',
|
||||||
|
width: 350,
|
||||||
|
height: 115,
|
||||||
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
|
buttonAlign: 'center',
|
||||||
|
closeAction: 'hide',
|
||||||
|
modal: true,
|
||||||
|
plain: true,
|
||||||
|
title: _('Add from Url'),
|
||||||
|
iconCls: 'x-deluge-add-url-window-icon',
|
||||||
|
buttons: [{
|
||||||
|
text: _('Add'),
|
||||||
|
handler: this.onAdd,
|
||||||
|
scope: this
|
||||||
|
}]
|
||||||
|
}, config);
|
||||||
|
Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
|
||||||
|
},
|
||||||
|
|
||||||
|
initComponent: function() {
|
||||||
|
Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
|
||||||
|
this.form = this.add(new Ext.form.FormPanel({
|
||||||
|
defaultType: 'textfield',
|
||||||
|
baseCls: 'x-plain',
|
||||||
|
labelWidth: 55,
|
||||||
|
items: [{
|
||||||
|
fieldLabel: _('Url'),
|
||||||
|
id: 'url',
|
||||||
|
name: 'url',
|
||||||
|
inputType: 'url',
|
||||||
|
anchor: '100%',
|
||||||
|
listeners: {
|
||||||
|
'specialkey': {
|
||||||
|
fn: this.onAdd,
|
||||||
|
scope: this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
onAdd: function(field, e) {
|
||||||
|
if (field.id == 'url' && e.getKey() != e.ENTER) return;
|
||||||
|
|
||||||
|
var field = this.form.items.get('url');
|
||||||
|
var url = field.getValue();
|
||||||
|
|
||||||
|
Deluge.Client.web.download_torrent_from_url(url, {
|
||||||
|
success: this.onDownload,
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
this.hide();
|
||||||
|
this.fireEvent('beforeadd', url);
|
||||||
|
},
|
||||||
|
|
||||||
|
onDownload: function(filename) {
|
||||||
|
this.form.items.get('url').setValue('');
|
||||||
|
Deluge.Client.web.get_torrent_info(filename, {
|
||||||
|
success: this.onGotInfo,
|
||||||
|
scope: this,
|
||||||
|
filename: filename
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onGotInfo: function(info, obj, response, request) {
|
||||||
|
info['filename'] = request.options.filename;
|
||||||
|
this.fireEvent('add', info);
|
||||||
|
}
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Script: deluge-add.js
|
Script: Deluge.Add.js
|
||||||
Contains the Add Torrent window.
|
Contains the Add Torrent window.
|
||||||
|
|
||||||
Copyright:
|
Copyright:
|
||||||
@ -119,79 +119,6 @@ Ext.deluge.add.Window = Ext.extend(Ext.Window, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.deluge.add.UrlWindow = Ext.extend(Ext.deluge.add.Window, {
|
|
||||||
constructor: function(config) {
|
|
||||||
config = Ext.apply({
|
|
||||||
layout: 'fit',
|
|
||||||
width: 350,
|
|
||||||
height: 115,
|
|
||||||
bodyStyle: 'padding: 10px 5px;',
|
|
||||||
buttonAlign: 'center',
|
|
||||||
closeAction: 'hide',
|
|
||||||
modal: true,
|
|
||||||
plain: true,
|
|
||||||
title: _('Add from Url'),
|
|
||||||
iconCls: 'x-deluge-add-url-window-icon',
|
|
||||||
buttons: [{
|
|
||||||
text: _('Add'),
|
|
||||||
handler: this.onAdd,
|
|
||||||
scope: this
|
|
||||||
}]
|
|
||||||
}, config);
|
|
||||||
Ext.deluge.add.UrlWindow.superclass.constructor.call(this, config);
|
|
||||||
},
|
|
||||||
|
|
||||||
initComponent: function() {
|
|
||||||
Ext.deluge.add.UrlWindow.superclass.initComponent.call(this);
|
|
||||||
this.form = this.add(new Ext.form.FormPanel({
|
|
||||||
defaultType: 'textfield',
|
|
||||||
baseCls: 'x-plain',
|
|
||||||
labelWidth: 55,
|
|
||||||
items: [{
|
|
||||||
fieldLabel: _('Url'),
|
|
||||||
id: 'url',
|
|
||||||
name: 'url',
|
|
||||||
inputType: 'url',
|
|
||||||
anchor: '100%',
|
|
||||||
listeners: {
|
|
||||||
'specialkey': {
|
|
||||||
fn: this.onAdd,
|
|
||||||
scope: this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
onAdd: function(field, e) {
|
|
||||||
if (field.id == 'url' && e.getKey() != e.ENTER) return;
|
|
||||||
|
|
||||||
var field = this.form.items.get('url');
|
|
||||||
var url = field.getValue();
|
|
||||||
|
|
||||||
Deluge.Client.web.download_torrent_from_url(url, {
|
|
||||||
success: this.onDownload,
|
|
||||||
scope: this
|
|
||||||
});
|
|
||||||
this.hide();
|
|
||||||
this.fireEvent('beforeadd', url);
|
|
||||||
},
|
|
||||||
|
|
||||||
onDownload: function(filename) {
|
|
||||||
this.form.items.get('url').setValue('');
|
|
||||||
Deluge.Client.web.get_torrent_info(filename, {
|
|
||||||
success: this.onGotInfo,
|
|
||||||
scope: this,
|
|
||||||
filename: filename
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
onGotInfo: function(info, obj, response, request) {
|
|
||||||
info['filename'] = request.options.filename;
|
|
||||||
this.fireEvent('add', info);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
||||||
|
|
||||||
torrents: {},
|
torrents: {},
|
||||||
@ -280,10 +207,7 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.options = this.add(new Ext.deluge.add.OptionsPanel());
|
this.options = this.add(new Ext.deluge.add.OptionsPanel());
|
||||||
|
this.on('show', this.onShow, this);
|
||||||
this.url = new Ext.deluge.add.UrlWindow();
|
|
||||||
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
|
||||||
this.url.on('add', this.onTorrentAdd, this);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
@ -361,6 +285,20 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
|||||||
root.firstChild.expand();
|
root.firstChild.expand();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onShow: function() {
|
||||||
|
if (!this.url) {
|
||||||
|
this.url = new Ext.deluge.add.UrlWindow();
|
||||||
|
this.url.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
|
this.url.on('add', this.onTorrentAdd, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.file) {
|
||||||
|
this.file = new Ext.deluge.add.FileWindow();
|
||||||
|
this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
|
||||||
|
this.file.on('add', this.onTorrentAdd, this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onTorrentBeforeAdd: function(temptext) {
|
onTorrentBeforeAdd: function(temptext) {
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -387,9 +325,6 @@ Ext.deluge.add.AddWindow = Ext.extend(Ext.deluge.add.Window, {
|
|||||||
Deluge.Add = new Ext.deluge.add.AddWindow();
|
Deluge.Add = new Ext.deluge.add.AddWindow();
|
||||||
|
|
||||||
/*Deluge.Add = {
|
/*Deluge.Add = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onFile: function() {
|
onFile: function() {
|
||||||
this.File.Window.show();
|
this.File.Window.show();
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
DELUGE_FILES="Deluge.js Deluge.Formatters.js Deluge.Menus.js Deluge.Events.js Deluge.Add.js Deluge.Client.js Deluge.ConnectionManager.js Deluge.Details.js Deluge.Details.Status.js Deluge.Details.Details.js Deluge.Details.Files.js Deluge.Details.Peers.js Deluge.Details.Options.js Deluge.Keys.js Deluge.Login.js Deluge.Preferences.js Deluge.Preferences.Downloads.js Deluge.Preferences.Network.js Deluge.Preferences.Bandwidth.js Deluge.Preferences.Interface.js Deluge.Preferences.Other.js Deluge.Preferences.Daemon.js Deluge.Preferences.Queue.js Deluge.Preferences.Proxy.js Deluge.Preferences.Notification.js Deluge.Preferences.Plugins.js Deluge.Sidebar.js Deluge.Statusbar.js Deluge.Toolbar.js Deluge.Torrents.js Deluge.UI.js"
|
DELUGE_FILES="Deluge.js Deluge.Formatters.js Deluge.Menus.js Deluge.Events.js Deluge.Add.js Deluge.Add.File.js Deluge.Add.Url.js Deluge.Client.js Deluge.ConnectionManager.js Deluge.Details.js Deluge.Details.Status.js Deluge.Details.Details.js Deluge.Details.Files.js Deluge.Details.Peers.js Deluge.Details.Options.js Deluge.Keys.js Deluge.Login.js Deluge.Preferences.js Deluge.Preferences.Downloads.js Deluge.Preferences.Network.js Deluge.Preferences.Bandwidth.js Deluge.Preferences.Interface.js Deluge.Preferences.Other.js Deluge.Preferences.Daemon.js Deluge.Preferences.Queue.js Deluge.Preferences.Proxy.js Deluge.Preferences.Notification.js Deluge.Preferences.Plugins.js Deluge.Sidebar.js Deluge.Statusbar.js Deluge.Toolbar.js Deluge.Torrents.js Deluge.UI.js"
|
||||||
ALL_FILES="ext-extensions-debug.js $DELUGE_FILES"
|
ALL_FILES="ext-extensions-debug.js $DELUGE_FILES"
|
||||||
|
|
||||||
scan() {
|
scan() {
|
||||||
|
File diff suppressed because one or more lines are too long
@ -257,6 +257,9 @@ class TopLevel(resource.Resource):
|
|||||||
"/js/Deluge.Menus.js",
|
"/js/Deluge.Menus.js",
|
||||||
"/js/Deluge.Events.js",
|
"/js/Deluge.Events.js",
|
||||||
"/js/Deluge.Add.js",
|
"/js/Deluge.Add.js",
|
||||||
|
"/js/Deluge.Add.File.js",
|
||||||
|
"/js/Deluge.Add.Url.js",
|
||||||
|
"/js/Deluge.Add.Infohash.js",
|
||||||
"/js/Deluge.Client.js",
|
"/js/Deluge.Client.js",
|
||||||
"/js/Deluge.ConnectionManager.js",
|
"/js/Deluge.ConnectionManager.js",
|
||||||
"/js/Deluge.Details.js",
|
"/js/Deluge.Details.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user