Build compressed javascript for deluge-all

This commit is contained in:
Calum Lind 2012-02-18 18:26:04 +00:00
parent ea75828f25
commit 3744bdad69
2 changed files with 237 additions and 134 deletions

View File

@ -1438,7 +1438,7 @@ Deluge.add.Window = Ext.extend(Ext.Window, {
}); });
/*! /*!
* Deluge.add.AddWindow.js * Deluge.add.AddWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -1488,7 +1488,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Add'), this.onAddClick, this); this.addButton(_('Add'), this.onAddClick, this);
function torrentRenderer(value, p, r) { function torrentRenderer(value, p, r) {
if (r.data['info_hash']) { if (r.data['info_hash']) {
return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value); return String.format('<div class="x-deluge-add-torrent-name">{0}</div>', value);
@ -1511,7 +1511,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
sortable: true, sortable: true,
renderer: torrentRenderer, renderer: torrentRenderer,
dataIndex: 'text' dataIndex: 'text'
}], }],
stripeRows: true, stripeRows: true,
singleSelect: true, singleSelect: true,
listeners: { listeners: {
@ -1552,7 +1552,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
}] }]
}) })
}); });
this.optionsPanel = this.add(new Deluge.add.OptionsPanel()); this.optionsPanel = this.add(new Deluge.add.OptionsPanel());
this.on('hide', this.onHide, this); this.on('hide', this.onHide, this);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
@ -1603,16 +1603,14 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
var torrent = this.list.getSelectedRecords()[0]; var torrent = this.list.getSelectedRecords()[0];
this.list.getStore().remove(torrent); this.list.getStore().remove(torrent);
this.optionsPanel.clear(); this.optionsPanel.clear();
if (this.torrents && this.torrents[torrent.id]) delete this.torrents[torrent.id]; if (this.torrents && this.torrents[torrent.id]) delete this.torrents[torrent.id];
}, },
onSelect: function(list, selections) { onSelect: function(list, selections) {
if (selections.length) { if (selections.length) {
var record = this.list.getRecord(selections[0]); var record = this.list.getRecord(selections[0]);
this.optionsPanel.setTorrent(record.get('info_hash')); this.optionsPanel.setTorrent(record.get('info_hash'));
this.optionsPanel.files.setDisabled(false);
this.optionsPanel.form.setDisabled(false);
} else { } else {
this.optionsPanel.files.setDisabled(true); this.optionsPanel.files.setDisabled(true);
this.optionsPanel.form.setDisabled(true); this.optionsPanel.form.setDisabled(true);
@ -1631,7 +1629,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
this.file.on('beforeadd', this.onTorrentBeforeAdd, this); this.file.on('beforeadd', this.onTorrentBeforeAdd, this);
this.file.on('add', this.onTorrentAdd, this); this.file.on('add', this.onTorrentAdd, this);
} }
this.optionsPanel.form.getDefaults(); this.optionsPanel.form.getDefaults();
}, },
@ -1657,6 +1655,7 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, {
r.set('text', info['name']); r.set('text', info['name']);
this.list.getStore().commitChanges(); this.list.getStore().commitChanges();
this.optionsPanel.addTorrent(info); this.optionsPanel.addTorrent(info);
this.list.select(r);
} }
}, },
@ -1929,7 +1928,7 @@ Deluge.add.FilesTab = Ext.extend(Ext.ux.tree.TreeGrid, {
Ext.namespace('Ext.deluge.add'); Ext.namespace('Ext.deluge.add');
/*! /*!
* Deluge.add.OptionsPanel.js * Deluge.add.OptionsPanel.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -1990,7 +1989,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
Ext.each(Ext.keys(fileIndexes), function(index) { Ext.each(Ext.keys(fileIndexes), function(index) {
priorities[index] = fileIndexes[index]; priorities[index] = fileIndexes[index];
}); });
var oldId = this.form.optionsManager.changeId(torrent['info_hash'], true); var oldId = this.form.optionsManager.changeId(torrent['info_hash'], true);
this.form.optionsManager.setDefault('file_priorities', priorities); this.form.optionsManager.setDefault('file_priorities', priorities);
this.form.optionsManager.changeId(oldId, true); this.form.optionsManager.changeId(oldId, true);
@ -2020,23 +2019,34 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
this.torrentId = torrentId; this.torrentId = torrentId;
this.form.optionsManager.changeId(torrentId); this.form.optionsManager.changeId(torrentId);
this.files.clearFiles(); this.files.clearFiles();
var root = this.files.getRootNode(); var root = this.files.getRootNode();
var priorities = this.form.optionsManager.get('file_priorities'); var priorities = this.form.optionsManager.get('file_priorities');
this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) { this.form.setDisabled(false);
var node = new Ext.tree.TreeNode({
download: (entry.index) ? priorities[entry.index] : true, if (this.torrents[torrentId]['files_tree']) {
filename: filename, this.walkFileTree(this.torrents[torrentId]['files_tree'], function(filename, type, entry, parentNode) {
fileindex: entry.index, var node = new Ext.tree.TreeNode({
leaf: type != 'dir', download: (entry.index) ? priorities[entry.index] : true,
size: entry.length filename: filename,
}); fileindex: entry.index,
parentNode.appendChild(node); leaf: type != 'dir',
if (type == 'dir') return node; size: entry.length
}, this, root); });
root.firstChild.expand(); parentNode.appendChild(node);
if (type == 'dir') return node;
}, this, root);
root.firstChild.expand();
this.files.setDisabled(false);
this.files.show();
} else {
// Files tab is empty so show options tab
this.form.show();
this.files.setDisabled(true);
}
}, },
walkFileTree: function(files, callback, scope, parentNode) { walkFileTree: function(files, callback, scope, parentNode) {
@ -2049,7 +2059,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
} else { } else {
var ret = callback(filename, type, entry, parentNode); var ret = callback(filename, type, entry, parentNode);
} }
if (type == 'dir') this.walkFileTree(entry, callback, scope, ret); if (type == 'dir') this.walkFileTree(entry, callback, scope, ret);
} }
}, },
@ -2071,7 +2081,7 @@ Deluge.add.OptionsPanel = Ext.extend(Ext.TabPanel, {
}, this); }, this);
} else { } else {
this.files.setDownload(nodes[0], oldValue, true); this.files.setDownload(nodes[0], oldValue, true);
} }
}, },
scope: this, scope: this,
icon: Ext.MessageBox.QUESTION icon: Ext.MessageBox.QUESTION
@ -2353,17 +2363,27 @@ Deluge.add.UrlWindow = Ext.extend(Deluge.add.Window, {
var cookies = this.cookieField.getValue(); var cookies = this.cookieField.getValue();
var torrentId = this.createTorrentId(); var torrentId = this.createTorrentId();
deluge.client.web.download_torrent_from_url(url, cookies, { if (url.substring(0,20) == 'magnet:?xt=urn:btih:') {
success: this.onDownload, deluge.client.web.get_magnet_info(url, {
scope: this, success: this.onGotInfo,
torrentId: torrentId scope: this,
}); filename: url,
torrentId: torrentId
});
} else {
deluge.client.web.download_torrent_from_url(url, cookies, {
success: this.onDownload,
scope: this,
torrentId: torrentId
});
}
this.hide(); this.hide();
this.urlField.setValue('');
this.fireEvent('beforeadd', torrentId, url); this.fireEvent('beforeadd', torrentId, url);
}, },
onDownload: function(filename, obj, resp, req) { onDownload: function(filename, obj, resp, req) {
this.urlField.setValue('');
deluge.client.web.get_torrent_info(filename, { deluge.client.web.get_torrent_info(filename, {
success: this.onGotInfo, success: this.onGotInfo,
scope: this, scope: this,
@ -3954,7 +3974,7 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, {
}); });
/*! /*!
* Deluge.preferences.PreferencesWindow.js * Deluge.preferences.PreferencesWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -4060,7 +4080,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
this.addButton(_('Close'), this.onClose, this); this.addButton(_('Close'), this.onClose, this);
this.addButton(_('Apply'), this.onApply, this); this.addButton(_('Apply'), this.onApply, this);
this.addButton(_('Ok'), this.onOk, this); this.addButton(_('Ok'), this.onOk, this);
this.optionsManager = new Deluge.OptionsManager(); this.optionsManager = new Deluge.OptionsManager();
this.on('afterrender', this.onAfterRender, this); this.on('afterrender', this.onAfterRender, this);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
@ -4082,7 +4102,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
this.addPage(new Deluge.preferences.Cache()); this.addPage(new Deluge.preferences.Cache());
this.addPage(new Deluge.preferences.Plugins()); this.addPage(new Deluge.preferences.Plugins());
}, },
onApply: function(e) { onApply: function(e) {
var changed = this.optionsManager.getDirty(); var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) { if (!Ext.isObjectEmpty(changed)) {
@ -4091,13 +4111,13 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
scope: this scope: this
}); });
} }
for (var page in this.pages) { for (var page in this.pages) {
if (this.pages[page].onApply) this.pages[page].onApply(); if (this.pages[page].onApply) this.pages[page].onApply();
} }
}, },
/** /**
* Return the options manager for the preferences window. * Return the options manager for the preferences window.
* @returns {Deluge.OptionsManager} the options manager * @returns {Deluge.OptionsManager} the options manager
@ -4105,7 +4125,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
getOptionsManager: function() { getOptionsManager: function() {
return this.optionsManager; return this.optionsManager;
}, },
/** /**
* Adds a page to the preferences window. * Adds a page to the preferences window.
* @param {Mixed} page * @param {Mixed} page
@ -4120,7 +4140,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
this.pages[name].index = -1; this.pages[name].index = -1;
return this.pages[name]; return this.pages[name];
}, },
/** /**
* Removes a preferences page from the window. * Removes a preferences page from the window.
* @param {mixed} name * @param {mixed} name
@ -4133,12 +4153,12 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
delete this.pages[page.title]; delete this.pages[page.title];
}, },
/** /**
* Select which preferences page is displayed. * Select which preferences page is displayed.
* @param {String} page The page name to change to * @param {String} page The page name to change to
*/ */
selectPage: function(page) { selectPage: function(page) {
if (this.pages[page].index < 0) { if (this.pages[page].index < 0) {
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]); this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
} }
this.list.select(this.pages[page].index); this.list.select(this.pages[page].index);
@ -4146,24 +4166,24 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
// private // private
doSelectPage: function(page) { doSelectPage: function(page) {
if (this.pages[page].index < 0) { if (this.pages[page].index < 0) {
this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]); this.pages[page].index = this.configPanel.items.indexOf(this.pages[page]);
} }
this.configPanel.getLayout().setActiveItem(this.pages[page].index); this.configPanel.getLayout().setActiveItem(this.pages[page].index);
this.currentPage = page; this.currentPage = page;
}, },
// private // private
onGotConfig: function(config) { onGotConfig: function(config) {
this.getOptionsManager().set(config); this.getOptionsManager().set(config);
}, },
// private // private
onPageSelect: function(list, selections) { onPageSelect: function(list, selections) {
var r = list.getRecord(selections[0]); var r = list.getRecord(selections[0]);
this.doSelectPage(r.get('name')); this.doSelectPage(r.get('name'));
}, },
// private // private
onSetConfig: function() { onSetConfig: function() {
this.getOptionsManager().commit(); this.getOptionsManager().commit();
@ -4176,7 +4196,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
} }
this.configPanel.getLayout().setActiveItem(0); this.configPanel.getLayout().setActiveItem(0);
}, },
// private // private
onShow: function() { onShow: function() {
if (!deluge.client.core) return; if (!deluge.client.core) return;
@ -4193,7 +4213,18 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, {
// private // private
onOk: function() { onOk: function() {
deluge.client.core.set_config(this.optionsManager.getDirty()); var changed = this.optionsManager.getDirty();
if (!Ext.isObjectEmpty(changed)) {
deluge.client.core.set_config(changed, {
success: this.onSetConfig,
scope: this
});
}
for (var page in this.pages) {
if (this.pages[page].onOk) this.pages[page].onOk();
}
this.hide(); this.hide();
} }
}); });
@ -6927,13 +6958,17 @@ Deluge.Keys = {
* <pre>['queue', 'name', 'total_size', 'state', 'progress', 'num_seeds', * <pre>['queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
* 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate', * 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
* 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', * 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies',
* 'is_auto_managed', 'time_added', 'tracker_host']</pre> * 'is_auto_managed', 'time_added', 'tracker_host', 'save_path',
* 'total_done', 'total_uploaded', 'max_download_speed', 'max_upload_speed',
* 'seeds_peers_ratio']</pre>
*/ */
Grid: [ Grid: [
'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds', 'queue', 'name', 'total_size', 'state', 'progress', 'num_seeds',
'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate', 'total_seeds', 'num_peers', 'total_peers', 'download_payload_rate',
'upload_payload_rate', 'eta', 'ratio', 'distributed_copies', 'upload_payload_rate', 'eta', 'ratio', 'distributed_copies',
'is_auto_managed', 'time_added', 'tracker_host', 'save_path' 'is_auto_managed', 'time_added', 'tracker_host', 'save_path',
'total_done', 'total_uploaded', 'max_download_speed', 'max_upload_speed',
'seeds_peers_ratio'
], ],
/** /**
@ -8736,8 +8771,6 @@ Deluge.Toolbar = Ext.extend(Ext.Toolbar, {
deluge.add.show(); deluge.add.show();
} }
}); });
deluge.toolbar = new Deluge.Toolbar();
/*! /*!
* Deluge.TorrentGrid.js * Deluge.TorrentGrid.js
* *
@ -8783,11 +8816,15 @@ deluge.toolbar = new Deluge.Toolbar();
if (!value) return; if (!value) return;
return fspeed(value); return fspeed(value);
} }
function torrentLimitRenderer(value) {
if (value == -1) return '';
return fspeed(value * 1024.0);
}
function torrentProgressRenderer(value, p, r) { function torrentProgressRenderer(value, p, r) {
value = new Number(value); value = new Number(value);
var progress = value; var progress = value;
var text = r.data['state'] + ' ' + value.toFixed(2) + '%'; var text = r.data['state'] + ' ' + value.toFixed(2) + '%';
var width = new Number(p.style.match(/\w+:\s*(\d+)\w+/)[1]); var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]);
return Deluge.progressBar(value, width - 8, text); return Deluge.progressBar(value, width - 8, text);
} }
function seedsRenderer(value, p, r) { function seedsRenderer(value, p, r) {
@ -8805,7 +8842,7 @@ deluge.toolbar = new Deluge.Toolbar();
} }
} }
function availRenderer(value, p, r) { function availRenderer(value, p, r) {
return (value < 0) ? '&infin;' : new Number(value).toFixed(3); return (value < 0) ? '&infin;' : parseFloat(new Number(value).toFixed(3));
} }
function trackerRenderer(value, p, r) { function trackerRenderer(value, p, r) {
return String.format('<div style="background: url(' + deluge.config.base + 'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value); return String.format('<div style="background: url(' + deluge.config.base + 'tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
@ -8857,18 +8894,6 @@ deluge.toolbar = new Deluge.Toolbar();
sortable: true, sortable: true,
renderer: torrentProgressRenderer, renderer: torrentProgressRenderer,
dataIndex: 'progress' dataIndex: 'progress'
}, {
header: _('Seeders'),
width: 60,
sortable: true,
renderer: seedsRenderer,
dataIndex: 'num_seeds'
}, {
header: _('Peers'),
width: 60,
sortable: true,
renderer: peersRenderer,
dataIndex: 'num_peers'
}, { }, {
header: _('Down Speed'), header: _('Down Speed'),
width: 80, width: 80,
@ -8887,36 +8912,90 @@ deluge.toolbar = new Deluge.Toolbar();
sortable: true, sortable: true,
renderer: ftime, renderer: ftime,
dataIndex: 'eta' dataIndex: 'eta'
}, {
header: _('Seeders'),
hidden: true,
width: 60,
sortable: true,
renderer: seedsRenderer,
dataIndex: 'num_seeds'
}, {
header: _('Peers'),
hidden: true,
width: 60,
sortable: true,
renderer: peersRenderer,
dataIndex: 'num_peers'
}, { }, {
header: _('Ratio'), header: _('Ratio'),
hidden: true,
width: 60, width: 60,
sortable: true, sortable: true,
renderer: availRenderer, renderer: availRenderer,
dataIndex: 'ratio' dataIndex: 'ratio'
}, { }, {
header: _('Avail'), header: _('Avail'),
hidden: true,
width: 60, width: 60,
sortable: true, sortable: true,
renderer: availRenderer, renderer: availRenderer,
dataIndex: 'distributed_copies' dataIndex: 'distributed_copies'
}, { }, {
header: _('Added'), header: _('Added'),
hidden: true,
width: 80, width: 80,
sortable: true, sortable: true,
renderer: fdate, renderer: fdate,
dataIndex: 'time_added' dataIndex: 'time_added'
}, { }, {
header: _('Tracker'), header: _('Tracker'),
hidden: true,
width: 120, width: 120,
sortable: true, sortable: true,
renderer: trackerRenderer, renderer: trackerRenderer,
dataIndex: 'tracker_host' dataIndex: 'tracker_host'
}, { }, {
header: _('Save Path'), header: _('Save Path'),
hidden: true,
width: 120, width: 120,
sortable: true, sortable: true,
renderer: fplain, renderer: fplain,
dataIndex: 'save_path' dataIndex: 'save_path'
}, {
header: _('Downloaded'),
hidden: true,
width: 75,
sortable: true,
renderer: fsize,
dataIndex: 'total_done'
}, {
header: _('Uploaded'),
hidden: true,
width: 75,
sortable: true,
renderer: fsize,
dataIndex: 'total_uploaded'
}, {
header: _('Down Limit'),
hidden: true,
width: 75,
sortable: true,
renderer: torrentLimitRenderer,
dataIndex: 'max_download_speed'
}, {
header: _('Up Limit'),
hidden: true,
width: 75,
sortable: true,
renderer: torrentLimitRenderer,
dataIndex: 'max_upload_speed'
}, {
header: _('Seeders') + '/' + _('Peers'),
hidden: true,
width: 75,
sortable: true,
renderer: availRenderer,
dataIndex: 'seeds_peers_ratio'
}], }],
meta: { meta: {
@ -8939,19 +9018,42 @@ deluge.toolbar = new Deluge.Toolbar();
{name: 'distributed_copies', type: 'float'}, {name: 'distributed_copies', type: 'float'},
{name: 'time_added', type: 'int'}, {name: 'time_added', type: 'int'},
{name: 'tracker_host'}, {name: 'tracker_host'},
{name: 'save_path'} {name: 'save_path'},
{name: 'total_done', type: 'int'},
{name: 'total_uploaded', type: 'int'},
{name: 'max_download_speed', type: 'int'},
{name: 'max_upload_speed', type: 'int'},
{name: 'seeds_peers_ratio', type: 'float'}
] ]
}, },
keys: [{
key: 'a',
ctrl: true,
stopEvent: true,
handler: function() {
deluge.torrents.getSelectionModel().selectAll();
}
}, {
key: [46],
stopEvent: true,
handler: function() {
ids = deluge.torrents.getSelectedIds();
deluge.removeWindow.show(ids);
}
}],
constructor: function(config) { constructor: function(config) {
config = Ext.apply({ config = Ext.apply({
id: 'torrentGrid', id: 'torrentGrid',
store: new Ext.data.JsonStore(this.meta), store: new Ext.data.JsonStore(this.meta),
columns: this.columns, columns: this.columns,
keys: this.keys,
region: 'center', region: 'center',
cls: 'deluge-torrents', cls: 'deluge-torrents',
stripeRows: true, stripeRows: true,
autoExpandColumn: 'name', autoExpandColumn: 'name',
autoExpandMin: 150,
deferredRender:false, deferredRender:false,
autoScroll:true, autoScroll:true,
margins: '5 5 0 0', margins: '5 5 0 0',
@ -9149,6 +9251,7 @@ deluge.ui = {
deluge.preferences = new Deluge.preferences.PreferencesWindow(); deluge.preferences = new Deluge.preferences.PreferencesWindow();
deluge.sidebar = new Deluge.Sidebar(); deluge.sidebar = new Deluge.Sidebar();
deluge.statusbar = new Deluge.Statusbar(); deluge.statusbar = new Deluge.Statusbar();
deluge.toolbar = new Deluge.Toolbar();
this.detailsPanel = new Ext.Panel({ this.detailsPanel = new Ext.Panel({
id: 'detailsPanel', id: 'detailsPanel',

File diff suppressed because one or more lines are too long