Author: damoxc

Revision: 4880

Log:
        partially implement adding torrents via url

Diff:
Modified: trunk/deluge/ui/web/css/deluge.css
===================================================================
--- trunk/deluge/ui/web/css/deluge.css  2009-03-17 01:03:09 UTC (rev 4879)
+++ trunk/deluge/ui/web/css/deluge.css  2009-03-17 01:03:38 UTC (rev 4880)
@@ -100,6 +100,11 @@
        background: url('/icons/16/add.png') no-repeat 2px;
 }
 
+/* Add Url Window */
+.x-deluge-add-url-window-icon {
+       background: url('/icons/16/add_url.png') no-repeat 2px;
+}
+
 /* Connect Window */
 .x-deluge-connect-window-icon {
        background: url('/icons/16/connection_manager.png') no-repeat 2px;

Modified: trunk/deluge/ui/web/js/deluge-add.js
===================================================================
--- trunk/deluge/ui/web/js/deluge-add.js        2009-03-17 01:03:09 UTC (rev 
4879)
+++ trunk/deluge/ui/web/js/deluge-add.js        2009-03-17 01:03:38 UTC (rev 
4880)
@@ -24,6 +24,14 @@
 Deluge.Add = {
        onRender: function(window) {
                
+       },
+       
+       onTorrentAdded: function(info) {
+               this.Store.loadData([[info['info_hash'], info['name']]], true);
+       },
+       
+       onUrl: function(button, event) {
+               this.Url.Window.show();
        }
 }
 
@@ -93,7 +101,9 @@
                                id: 'url',
                                cls: 'x-btn-text-icon',
                                text: _('Url'),
-                               icon: '/icons/16/add_url.png'
+                               icon: '/icons/16/add_url.png',
+                               handler: Deluge.Add.onUrl,
+                               scope: Deluge.Add
                        }, {
                                id: 'infohash',
                                cls: 'x-btn-text-icon',
@@ -124,6 +134,71 @@
        }]
 });
 
+Deluge.Add.Url = {
+       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, {
+                       onSuccess: this.onDownload.bindWithEvent(this)
+               });
+               this.Window.hide();
+       },
+       
+       onDownload: function(filename) {
+               Deluge.Client.web.get_torrent_info(filename, {
+                       onSuccess: this.onGotInfo.bindWithEvent(this)
+               });
+       },
+       
+       onGotInfo: function(info) {
+               var bound = Deluge.Add.onTorrentAdded.bind(Deluge.Add)
+               bound(info);
+       }
+}
+
+Deluge.Add.Url.Form = new Ext.form.FormPanel({
+    defaultType: 'textfield',
+    id: 'urlAddForm',
+    baseCls: 'x-plain',
+    labelWidth: 55,
+    items: [{
+        fieldLabel: _('Url'),
+        id: 'url',
+        name: 'url',
+        inputType: 'url',
+        anchor: '100%',
+        listeners: {
+            'specialkey': {
+                fn: Deluge.Add.Url.onAdd,
+                scope: Deluge.Add.Url
+            }
+        }
+    }]
+});
+
+Deluge.Add.Url.Window = new Ext.Window({
+       layout: 'fit',
+    width: 300,
+    height: 150,
+    bodyStyle: 'padding: 10px 5px;',
+    buttonAlign: 'center',
+    closeAction: 'hide',
+    closable: false,
+    modal: true,
+    plain: true,
+    title: _('Add from Url'),
+    iconCls: 'x-deluge-add-url-window-icon',
+    items: Deluge.Add.Url.Form,
+    buttons: [{
+        text: _('Add'),
+        handler: Deluge.Add.Url.onAdd,
+               scope: Deluge.Add.Url
+    }]
+});
+
 Deluge.Add.Window = new Ext.Window({
        layout: 'border',
     width: 400,



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to