just some whitespace changes
This commit is contained in:
parent
3f8abf1e34
commit
fd9bf112c4
|
@ -1,35 +1,35 @@
|
||||||
/*
|
/*
|
||||||
Script: deluge-bars.js
|
Script: deluge-bars.js
|
||||||
Contains all objects and functions related to the statusbar, toolbar and
|
Contains all objects and functions related to the statusbar, toolbar and
|
||||||
sidebar.
|
sidebar.
|
||||||
|
|
||||||
Copyright:
|
Copyright:
|
||||||
(C) Damien Churchill 2009 <damoxc@gmail.com>
|
(C) Damien Churchill 2009 <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
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 3, or (at your option)
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, write to:
|
along with this program. If not, write to:
|
||||||
The Free Software Foundation, Inc.,
|
The Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor
|
51 Franklin Street, Fifth Floor
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
In addition, as a special exception, the copyright holders give
|
In addition, as a special exception, the copyright holders give
|
||||||
permission to link the code of portions of this program with the OpenSSL
|
permission to link the code of portions of this program with the OpenSSL
|
||||||
library.
|
library.
|
||||||
You must obey the GNU General Public License in all respects for all of
|
You must obey the GNU General Public License in all respects for all of
|
||||||
the code used other than OpenSSL. If you modify file(s) with this
|
the code used other than OpenSSL. If you modify file(s) with this
|
||||||
exception, you may extend this exception to your version of the file(s),
|
exception, you may extend this exception to your version of the file(s),
|
||||||
but you are not obligated to do so. If you do not wish to do so, delete
|
but you are not obligated to do so. If you do not wish to do so, delete
|
||||||
this exception statement from your version. If you delete this exception
|
this exception statement from your version. If you delete this exception
|
||||||
statement from all source files in the program, then also delete it here.
|
statement from all source files in the program, then also delete it here.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -38,199 +38,199 @@ Copyright:
|
||||||
// _('Tracker Host')
|
// _('Tracker Host')
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// Renderer for the items in the filter grids.
|
// Renderer for the items in the filter grids.
|
||||||
function filterRenderer(value, p, r) {
|
function filterRenderer(value, p, r) {
|
||||||
var lname = value.toLowerCase().replace('.', '_');
|
var lname = value.toLowerCase().replace('.', '_');
|
||||||
|
|
||||||
var image = '';
|
var image = '';
|
||||||
if (r.store.id == 'tracker_host') {
|
if (r.store.id == 'tracker_host') {
|
||||||
if (value != 'Error') {
|
if (value != 'Error') {
|
||||||
image = String.format('url(/tracker/{0})', value);
|
image = String.format('url(/tracker/{0})', value);
|
||||||
} else {
|
} else {
|
||||||
lname = null;
|
lname = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (image) {
|
if (image) {
|
||||||
return String.format('<div class="x-deluge-filter" style="background-image: {2};">{0} ({1})</div>', value, r.data['count'], image);
|
return String.format('<div class="x-deluge-filter" style="background-image: {2};">{0} ({1})</div>', value, r.data['count'], image);
|
||||||
} else if (lname) {
|
} else if (lname) {
|
||||||
return String.format('<div class="x-deluge-filter x-deluge-{2}">{0} ({1})</div>', value, r.data['count'], lname);
|
return String.format('<div class="x-deluge-filter x-deluge-{2}">{0} ({1})</div>', value, r.data['count'], lname);
|
||||||
} else {
|
} else {
|
||||||
return String.format('<div class="x-deluge-filter">{0} ({1})</div>', value, r.data['count']);
|
return String.format('<div class="x-deluge-filter">{0} ({1})</div>', value, r.data['count']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ext.deluge.Sidebar = Ext.extend(Ext.Panel, {
|
Ext.deluge.Sidebar = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
// private
|
// private
|
||||||
panels: {},
|
panels: {},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
selected: null,
|
selected: null,
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
id: 'sidebar',
|
id: 'sidebar',
|
||||||
region: 'west',
|
region: 'west',
|
||||||
cls: 'deluge-sidebar',
|
cls: 'deluge-sidebar',
|
||||||
title: _('Filters'),
|
title: _('Filters'),
|
||||||
layout: 'accordion',
|
layout: 'accordion',
|
||||||
split: true,
|
split: true,
|
||||||
width: 200,
|
width: 200,
|
||||||
minSize: 175,
|
minSize: 175,
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
margins: '5 0 0 5',
|
margins: '5 0 0 5',
|
||||||
cmargins: '5 0 0 5'
|
cmargins: '5 0 0 5'
|
||||||
}, config);
|
}, config);
|
||||||
Ext.deluge.Sidebar.superclass.constructor.call(this, config);
|
Ext.deluge.Sidebar.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
initComponent: function() {
|
initComponent: function() {
|
||||||
Ext.deluge.Sidebar.superclass.initComponent.call(this);
|
Ext.deluge.Sidebar.superclass.initComponent.call(this);
|
||||||
Deluge.Events.on("disconnect", this.onDisconnect, this);
|
Deluge.Events.on("disconnect", this.onDisconnect, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
createFilter: function(filter, states) {
|
createFilter: function(filter, states) {
|
||||||
var store = new Ext.data.SimpleStore({
|
var store = new Ext.data.SimpleStore({
|
||||||
id: filter,
|
id: filter,
|
||||||
fields: [
|
fields: [
|
||||||
{name: 'filter'},
|
{name: 'filter'},
|
||||||
{name: 'count'}
|
{name: 'count'}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var title = filter.replace('_', ' ');
|
var title = filter.replace('_', ' ');
|
||||||
var parts = title.split(' ');
|
var parts = title.split(' ');
|
||||||
title = '';
|
title = '';
|
||||||
Ext.each(parts, function(part) {
|
Ext.each(parts, function(part) {
|
||||||
firstLetter = part.substring(0, 1);
|
firstLetter = part.substring(0, 1);
|
||||||
firstLetter = firstLetter.toUpperCase();
|
firstLetter = firstLetter.toUpperCase();
|
||||||
part = firstLetter + part.substring(1);
|
part = firstLetter + part.substring(1);
|
||||||
title += part + ' ';
|
title += part + ' ';
|
||||||
});
|
});
|
||||||
|
|
||||||
var panel = new Ext.grid.GridPanel({
|
var panel = new Ext.grid.GridPanel({
|
||||||
id: filter + '-panel',
|
id: filter + '-panel',
|
||||||
border: false,
|
border: false,
|
||||||
store: store,
|
store: store,
|
||||||
title: _(title),
|
title: _(title),
|
||||||
columns: [
|
columns: [
|
||||||
{id: 'filter', sortable: false, renderer: filterRenderer, dataIndex: 'filter'}
|
{id: 'filter', sortable: false, renderer: filterRenderer, dataIndex: 'filter'}
|
||||||
],
|
],
|
||||||
stripeRows: false,
|
stripeRows: false,
|
||||||
selModel: new Ext.grid.RowSelectionModel({
|
selModel: new Ext.grid.RowSelectionModel({
|
||||||
singleSelect: true,
|
singleSelect: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
'rowselect': {fn: this.onFilterSelect, scope: this}
|
'rowselect': {fn: this.onFilterSelect, scope: this}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
hideHeaders: true,
|
hideHeaders: true,
|
||||||
autoExpandColumn: 'filter',
|
autoExpandColumn: 'filter',
|
||||||
deferredRender: false,
|
deferredRender: false,
|
||||||
autoScroll: true
|
autoScroll: true
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Deluge.config['sidebar_show_zero'] == false) {
|
if (Deluge.config['sidebar_show_zero'] == false) {
|
||||||
states = this.removeZero(states);
|
states = this.removeZero(states);
|
||||||
}
|
}
|
||||||
|
|
||||||
store.loadData(states);
|
store.loadData(states);
|
||||||
this.add(panel);
|
this.add(panel);
|
||||||
|
|
||||||
this.doLayout();
|
this.doLayout();
|
||||||
this.panels[filter] = panel;
|
this.panels[filter] = panel;
|
||||||
|
|
||||||
if (!this.selected) {
|
if (!this.selected) {
|
||||||
panel.getSelectionModel().selectFirstRow();
|
panel.getSelectionModel().selectFirstRow();
|
||||||
this.selected = {
|
this.selected = {
|
||||||
row: 0,
|
row: 0,
|
||||||
filter: states[0][0],
|
filter: states[0][0],
|
||||||
panel: panel
|
panel: panel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getFilters: function() {
|
getFilters: function() {
|
||||||
var filters = {}
|
var filters = {}
|
||||||
if (!this.selected) {
|
if (!this.selected) {
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
if (!this.selected.filter || !this.selected.panel) {
|
if (!this.selected.filter || !this.selected.panel) {
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
var filterType = this.selected.panel.store.id;
|
var filterType = this.selected.panel.store.id;
|
||||||
if (filterType == "state" && this.selected.filter == "All") {
|
if (filterType == "state" && this.selected.filter == "All") {
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
filters[filterType] = this.selected.filter;
|
filters[filterType] = this.selected.filter;
|
||||||
return filters;
|
return filters;
|
||||||
},
|
},
|
||||||
|
|
||||||
// private
|
// private
|
||||||
onDisconnect: function() {
|
onDisconnect: function() {
|
||||||
Ext.each(Ext.getKeys(this.panels), function(filter) {
|
Ext.each(Ext.getKeys(this.panels), function(filter) {
|
||||||
this.remove(filter + '-panel');
|
this.remove(filter + '-panel');
|
||||||
}, this);
|
}, this);
|
||||||
this.panels = {};
|
this.panels = {};
|
||||||
this.selected = null;
|
this.selected = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
onFilterSelect: function(selModel, rowIndex, record) {
|
onFilterSelect: function(selModel, rowIndex, record) {
|
||||||
if (!this.selected) needsUpdate = true;
|
if (!this.selected) needsUpdate = true;
|
||||||
else if (this.selected.row != rowIndex) needsUpdate = true;
|
else if (this.selected.row != rowIndex) needsUpdate = true;
|
||||||
else needsUpdate = false;
|
else needsUpdate = false;
|
||||||
this.selected = {
|
this.selected = {
|
||||||
row: rowIndex,
|
row: rowIndex,
|
||||||
filter: record.get('filter'),
|
filter: record.get('filter'),
|
||||||
panel: this.panels[record.store.id]
|
panel: this.panels[record.store.id]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsUpdate) Deluge.UI.update();
|
if (needsUpdate) Deluge.UI.update();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the states with zero torrents in them.
|
* Remove the states with zero torrents in them.
|
||||||
*/
|
*/
|
||||||
removeZero: function(states) {
|
removeZero: function(states) {
|
||||||
var newStates = [];
|
var newStates = [];
|
||||||
Ext.each(states, function(state) {
|
Ext.each(states, function(state) {
|
||||||
if (state[1] > 0 || state[0] == _('All')) {
|
if (state[1] > 0 || state[0] == _('All')) {
|
||||||
newStates.push(state);
|
newStates.push(state);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return newStates;
|
return newStates;
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(filters) {
|
update: function(filters) {
|
||||||
for (var filter in filters) {
|
for (var filter in filters) {
|
||||||
var states = filters[filter];
|
var states = filters[filter];
|
||||||
if (Ext.getKeys(this.panels).indexOf(filter) > -1) {
|
if (Ext.getKeys(this.panels).indexOf(filter) > -1) {
|
||||||
this.updateFilter(filter, states);
|
this.updateFilter(filter, states);
|
||||||
} else {
|
} else {
|
||||||
this.createFilter(filter, states);
|
this.createFilter(filter, states);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform a cleanup of fitlers that aren't enabled any more
|
// Perform a cleanup of fitlers that aren't enabled any more
|
||||||
Ext.each(Ext.keys(this.panels), function(filter) {
|
Ext.each(Ext.keys(this.panels), function(filter) {
|
||||||
if (Ext.keys(filters).indexOf(filter) == -1) {
|
if (Ext.keys(filters).indexOf(filter) == -1) {
|
||||||
// We need to remove the panel
|
// We need to remove the panel
|
||||||
this.panels[filter]
|
this.panels[filter]
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
updateFilter: function(filter, states) {
|
updateFilter: function(filter, states) {
|
||||||
if (Deluge.config['sidebar_show_zero'] == false) {
|
if (Deluge.config['sidebar_show_zero'] == false) {
|
||||||
states = this.removeZero(states);
|
states = this.removeZero(states);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.panels[filter].store.loadData(states);
|
this.panels[filter].store.loadData(states);
|
||||||
if (this.selected && this.selected.panel == this.panels[filter]) {
|
if (this.selected && this.selected.panel == this.panels[filter]) {
|
||||||
this.panels[filter].getSelectionModel().selectRow(this.selected.row);
|
this.panels[filter].getSelectionModel().selectRow(this.selected.row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Deluge.Sidebar = new Ext.deluge.Sidebar();
|
Deluge.Sidebar = new Ext.deluge.Sidebar();
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
Script: deluge-torrents.js
|
Script: Deluge.Torrents.js
|
||||||
Contains all objects and functions related to the torrent grid.
|
Contains all objects and functions related to the torrent grid.
|
||||||
|
|
||||||
Copyright:
|
Copyright:
|
||||||
(C) Damien Churchill 2009 <damoxc@gmail.com>
|
(C) Damien Churchill 2009 <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
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 3, or (at your option)
|
the Free Software Foundation; either version 3, or (at your option)
|
||||||
any later version.
|
any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, write to:
|
along with this program. If not, write to:
|
||||||
The Free Software Foundation, Inc.,
|
The Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor
|
51 Franklin Street, Fifth Floor
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
In addition, as a special exception, the copyright holders give
|
In addition, as a special exception, the copyright holders give
|
||||||
permission to link the code of portions of this program with the OpenSSL
|
permission to link the code of portions of this program with the OpenSSL
|
||||||
|
@ -33,274 +33,275 @@ Copyright:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
/* Renderers for the Torrent Grid */
|
/* Renderers for the Torrent Grid */
|
||||||
function queueRenderer(value) {
|
function queueRenderer(value) {
|
||||||
return (value == -1) ? '' : value + 1;
|
return (value == -1) ? '' : value + 1;
|
||||||
}
|
}
|
||||||
function torrentNameRenderer(value, p, r) {
|
function torrentNameRenderer(value, p, r) {
|
||||||
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value);
|
return String.format('<div class="torrent-name x-deluge-{0}">{1}</div>', r.data['state'].toLowerCase(), value);
|
||||||
}
|
}
|
||||||
function torrentSpeedRenderer(value) {
|
function torrentSpeedRenderer(value) {
|
||||||
if (!value) return;
|
if (!value) return;
|
||||||
return fspeed(value);
|
return fspeed(value);
|
||||||
}
|
}
|
||||||
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(this.style.match(/\w+:\s*(\d+)\w+/)[1]) - 8;
|
var width = new Number(this.style.match(/\w+:\s*(\d+)\w+/)[1]) - 8;
|
||||||
return Deluge.progressBar(value, width, text);
|
return Deluge.progressBar(value, width, text);
|
||||||
}
|
}
|
||||||
function seedsRenderer(value, p, r) {
|
function seedsRenderer(value, p, r) {
|
||||||
if (r.data['total_seeds'] > -1) {
|
if (r.data['total_seeds'] > -1) {
|
||||||
return String.format('{0} ({1})', value, r.data['total_seeds']);
|
return String.format('{0} ({1})', value, r.data['total_seeds']);
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function peersRenderer(value, p, r) {
|
function peersRenderer(value, p, r) {
|
||||||
if (r.data['total_peers'] > -1) {
|
if (r.data['total_peers'] > -1) {
|
||||||
return String.format('{0} ({1})', value, r.data['total_peers']);
|
return String.format('{0} ({1})', value, r.data['total_peers']);
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function availRenderer(value, p, r) {
|
function availRenderer(value, p, r) {
|
||||||
return new Number(value).toFixed(3);
|
return new Number(value).toFixed(3);
|
||||||
}
|
}
|
||||||
function trackerRenderer(value, p, r) {
|
function trackerRenderer(value, p, r) {
|
||||||
return String.format('<div style="background: url(/tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
|
return String.format('<div style="background: url(/tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Ext.deluge.TorrentGrid Class
|
|
||||||
*
|
|
||||||
* @author Damien Churchill <damoxc@gmail.com>
|
|
||||||
* @version 1.2
|
|
||||||
*
|
|
||||||
* @class Ext.deluge.TorrentGrid
|
|
||||||
* @extends Ext.grid.GridPanel
|
|
||||||
* @constructor
|
|
||||||
* @param {Object} config Configuration options
|
|
||||||
*/
|
|
||||||
Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
|
|
||||||
constructor: function(config) {
|
|
||||||
config = Ext.apply({
|
|
||||||
id: 'torrentGrid',
|
|
||||||
store: new Ext.data.SimpleStore({
|
|
||||||
fields: [
|
|
||||||
{name: 'queue'},
|
|
||||||
{name: 'name'},
|
|
||||||
{name: 'size', type: 'int'},
|
|
||||||
{name: 'state'},
|
|
||||||
{name: 'progress', type: 'float'},
|
|
||||||
{name: 'seeds', type: 'int'},
|
|
||||||
{name: 'total_seeds', type: 'int'},
|
|
||||||
{name: 'peers', type: 'int'},
|
|
||||||
{name: 'total_peers', type: 'int'},
|
|
||||||
{name: 'downspeed', type: 'int'},
|
|
||||||
{name: 'upspeed', type: 'int'},
|
|
||||||
{name: 'eta', type: 'int'},
|
|
||||||
{name: 'ratio', type: 'float'},
|
|
||||||
{name: 'avail', type: 'float'},
|
|
||||||
{name: 'added', type: 'int'},
|
|
||||||
{name: 'tracker'}
|
|
||||||
],
|
|
||||||
id: 16
|
|
||||||
}),
|
|
||||||
columns: [{
|
|
||||||
id:'queue',
|
|
||||||
header: _('#'),
|
|
||||||
width: 30,
|
|
||||||
sortable: true,
|
|
||||||
renderer: queueRenderer,
|
|
||||||
dataIndex: 'queue'
|
|
||||||
}, {
|
|
||||||
id:'name',
|
|
||||||
header: _('Name'),
|
|
||||||
width: 150,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentNameRenderer,
|
|
||||||
dataIndex: 'name'
|
|
||||||
}, {
|
|
||||||
header: _('Size'),
|
|
||||||
width: 75,
|
|
||||||
sortable: true,
|
|
||||||
renderer: fsize,
|
|
||||||
dataIndex: 'size'
|
|
||||||
}, {
|
|
||||||
header: _('Progress'),
|
|
||||||
width: 150,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentProgressRenderer,
|
|
||||||
dataIndex: 'progress'
|
|
||||||
}, {
|
|
||||||
header: _('Seeders'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: seedsRenderer,
|
|
||||||
dataIndex: 'seeds'
|
|
||||||
}, {
|
|
||||||
header: _('Peers'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: peersRenderer,
|
|
||||||
dataIndex: 'peers'
|
|
||||||
}, {
|
|
||||||
header: _('Down Speed'),
|
|
||||||
width: 80,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentSpeedRenderer,
|
|
||||||
dataIndex: 'downspeed'
|
|
||||||
}, {
|
|
||||||
header: _('Up Speed'),
|
|
||||||
width: 80,
|
|
||||||
sortable: true,
|
|
||||||
renderer: torrentSpeedRenderer,
|
|
||||||
dataIndex: 'upspeed'
|
|
||||||
}, {
|
|
||||||
header: _('ETA'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: ftime,
|
|
||||||
dataIndex: 'eta'
|
|
||||||
}, {
|
|
||||||
header: _('Ratio'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: availRenderer,
|
|
||||||
dataIndex: 'ratio'
|
|
||||||
}, {
|
|
||||||
header: _('Avail'),
|
|
||||||
width: 60,
|
|
||||||
sortable: true,
|
|
||||||
renderer: availRenderer,
|
|
||||||
dataIndex: 'avail'
|
|
||||||
}, {
|
|
||||||
header: _('Added'),
|
|
||||||
width: 80,
|
|
||||||
sortable: true,
|
|
||||||
renderer: fdate,
|
|
||||||
dataIndex: 'added'
|
|
||||||
}, {
|
|
||||||
header: _('Tracker'),
|
|
||||||
width: 120,
|
|
||||||
sortable: true,
|
|
||||||
renderer: trackerRenderer,
|
|
||||||
dataIndex: 'tracker'
|
|
||||||
}],
|
|
||||||
region: 'center',
|
|
||||||
cls: 'deluge-torrents',
|
|
||||||
stripeRows: true,
|
|
||||||
autoExpandColumn: 'name',
|
|
||||||
deferredRender:false,
|
|
||||||
autoScroll:true,
|
|
||||||
margins: '5 5 0 0'
|
|
||||||
}, config);
|
|
||||||
Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
|
|
||||||
},
|
|
||||||
|
|
||||||
initComponent: function() {
|
/**
|
||||||
Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
|
* Ext.deluge.TorrentGrid Class
|
||||||
Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
|
*
|
||||||
this.on('rowcontextmenu', function(grid, rowIndex, e) {
|
* @author Damien Churchill <damoxc@gmail.com>
|
||||||
e.stopEvent();
|
* @version 1.2
|
||||||
var selection = grid.getSelectionModel();
|
*
|
||||||
if (!selection.hasSelection()) {
|
* @class Ext.deluge.TorrentGrid
|
||||||
selection.selectRow(rowIndex);
|
* @extends Ext.grid.GridPanel
|
||||||
}
|
* @constructor
|
||||||
Deluge.Menus.Torrent.showAt(e.getPoint());
|
* @param {Object} config Configuration options
|
||||||
});
|
*/
|
||||||
},
|
Ext.deluge.TorrentGrid = Ext.extend(Ext.grid.GridPanel, {
|
||||||
|
constructor: function(config) {
|
||||||
/**
|
config = Ext.apply({
|
||||||
* Returns the record representing the torrent at the specified index.
|
id: 'torrentGrid',
|
||||||
*
|
store: new Ext.data.SimpleStore({
|
||||||
* @param {int} The row index of the torrent you wish to retrieve.
|
fields: [
|
||||||
* @return {Ext.data.Record} The record representing the torrent.
|
{name: 'queue'},
|
||||||
*/
|
{name: 'name'},
|
||||||
getTorrent: function(rowIndex) {
|
{name: 'size', type: 'int'},
|
||||||
return this.getStore().getAt(rowIndex);
|
{name: 'state'},
|
||||||
},
|
{name: 'progress', type: 'float'},
|
||||||
|
{name: 'seeds', type: 'int'},
|
||||||
getSelected: function() {
|
{name: 'total_seeds', type: 'int'},
|
||||||
return this.getSelectionModel().getSelected();
|
{name: 'peers', type: 'int'},
|
||||||
},
|
{name: 'total_peers', type: 'int'},
|
||||||
|
{name: 'downspeed', type: 'int'},
|
||||||
getSelections: function() {
|
{name: 'upspeed', type: 'int'},
|
||||||
return this.getSelectionModel().getSelections();
|
{name: 'eta', type: 'int'},
|
||||||
},
|
{name: 'ratio', type: 'float'},
|
||||||
|
{name: 'avail', type: 'float'},
|
||||||
update: function(torrents) {
|
{name: 'added', type: 'int'},
|
||||||
//var torrents = [];
|
{name: 'tracker'}
|
||||||
var store = this.getStore();
|
],
|
||||||
for (var torrentId in torrents) {
|
id: 16
|
||||||
var record = store.getById(torrentId);
|
}),
|
||||||
var torrent = torrents[torrentId];
|
columns: [{
|
||||||
if (!record) {
|
id:'queue',
|
||||||
// We need to create a new record
|
header: _('#'),
|
||||||
var data = [
|
width: 30,
|
||||||
torrent.queue,
|
sortable: true,
|
||||||
torrent.name,
|
renderer: queueRenderer,
|
||||||
torrent.total_size,
|
dataIndex: 'queue'
|
||||||
torrent.state,
|
}, {
|
||||||
torrent.progress,
|
id:'name',
|
||||||
torrent.num_seeds,
|
header: _('Name'),
|
||||||
torrent.total_seeds,
|
width: 150,
|
||||||
torrent.num_peers,
|
sortable: true,
|
||||||
torrent.total_peers,
|
renderer: torrentNameRenderer,
|
||||||
torrent.download_payload_rate,
|
dataIndex: 'name'
|
||||||
torrent.upload_payload_rate,
|
}, {
|
||||||
torrent.eta,
|
header: _('Size'),
|
||||||
torrent.ratio,
|
width: 75,
|
||||||
torrent.distributed_copies,
|
sortable: true,
|
||||||
torrent.time_added,
|
renderer: fsize,
|
||||||
torrent.tracker_host,
|
dataIndex: 'size'
|
||||||
torrentId
|
}, {
|
||||||
];
|
header: _('Progress'),
|
||||||
store.loadData([data], true);
|
width: 150,
|
||||||
} else {
|
sortable: true,
|
||||||
// We just need to do an update
|
renderer: torrentProgressRenderer,
|
||||||
record.set('queue', torrent.queue);
|
dataIndex: 'progress'
|
||||||
record.set('name', torrent.name);
|
}, {
|
||||||
record.set('size', torrent.total_size);
|
header: _('Seeders'),
|
||||||
record.set('state', torrent.state);
|
width: 60,
|
||||||
record.set('progress', torrent.progress);
|
sortable: true,
|
||||||
record.set('seeds', torrent.num_seeds);
|
renderer: seedsRenderer,
|
||||||
record.set('total_seeds', torrent.total_seeds);
|
dataIndex: 'seeds'
|
||||||
record.set('peers', torrent.num_peers);
|
}, {
|
||||||
record.set('total_peers', torrent.total_peers);
|
header: _('Peers'),
|
||||||
record.set('downspeed', torrent.download_payload_rate);
|
width: 60,
|
||||||
record.set('upspeed', torrent.upload_payload_rate);
|
sortable: true,
|
||||||
record.set('eta', torrent.eta);
|
renderer: peersRenderer,
|
||||||
record.set('ratio', torrent.ratio);
|
dataIndex: 'peers'
|
||||||
record.set('avail', torrent.distributed_copies);
|
}, {
|
||||||
record.set('added', torrent.time_added);
|
header: _('Down Speed'),
|
||||||
record.set('tracker', torrent.tracker_host);
|
width: 80,
|
||||||
record.commit();
|
sortable: true,
|
||||||
}
|
renderer: torrentSpeedRenderer,
|
||||||
}
|
dataIndex: 'downspeed'
|
||||||
|
}, {
|
||||||
var torrentIds = Ext.keys(torrents);
|
header: _('Up Speed'),
|
||||||
store.each(function(record) {
|
width: 80,
|
||||||
if (torrentIds.indexOf(record.id) == -1) {
|
sortable: true,
|
||||||
// Torrent is no longer in the grid so we must remove it.
|
renderer: torrentSpeedRenderer,
|
||||||
store.remove(record);
|
dataIndex: 'upspeed'
|
||||||
}
|
}, {
|
||||||
}, this);
|
header: _('ETA'),
|
||||||
},
|
width: 60,
|
||||||
|
sortable: true,
|
||||||
// private
|
renderer: ftime,
|
||||||
onTorrentRemoved: function(torrentIds) {
|
dataIndex: 'eta'
|
||||||
var selModel = this.getSelectionModel();
|
}, {
|
||||||
Ext.each(torrentIds, function(torrentId) {
|
header: _('Ratio'),
|
||||||
var record = this.getStore().getById(torrentId);
|
width: 60,
|
||||||
if (selModel.isSelected(record)) {
|
sortable: true,
|
||||||
selModel.deselectRow(this.getStore().indexOf(record));
|
renderer: availRenderer,
|
||||||
}
|
dataIndex: 'ratio'
|
||||||
this.getStore().remove(record);
|
}, {
|
||||||
}, this);
|
header: _('Avail'),
|
||||||
}
|
width: 60,
|
||||||
});
|
sortable: true,
|
||||||
Deluge.Torrents = new Ext.deluge.TorrentGrid();
|
renderer: availRenderer,
|
||||||
|
dataIndex: 'avail'
|
||||||
|
}, {
|
||||||
|
header: _('Added'),
|
||||||
|
width: 80,
|
||||||
|
sortable: true,
|
||||||
|
renderer: fdate,
|
||||||
|
dataIndex: 'added'
|
||||||
|
}, {
|
||||||
|
header: _('Tracker'),
|
||||||
|
width: 120,
|
||||||
|
sortable: true,
|
||||||
|
renderer: trackerRenderer,
|
||||||
|
dataIndex: 'tracker'
|
||||||
|
}],
|
||||||
|
region: 'center',
|
||||||
|
cls: 'deluge-torrents',
|
||||||
|
stripeRows: true,
|
||||||
|
autoExpandColumn: 'name',
|
||||||
|
deferredRender:false,
|
||||||
|
autoScroll:true,
|
||||||
|
margins: '5 5 0 0',
|
||||||
|
stateful: true
|
||||||
|
}, config);
|
||||||
|
Ext.deluge.TorrentGrid.superclass.constructor.call(this, config);
|
||||||
|
},
|
||||||
|
|
||||||
|
initComponent: function() {
|
||||||
|
Ext.deluge.TorrentGrid.superclass.initComponent.call(this);
|
||||||
|
Deluge.Events.on('torrentRemoved', this.onTorrentRemoved, this);
|
||||||
|
this.on('rowcontextmenu', function(grid, rowIndex, e) {
|
||||||
|
e.stopEvent();
|
||||||
|
var selection = grid.getSelectionModel();
|
||||||
|
if (!selection.hasSelection()) {
|
||||||
|
selection.selectRow(rowIndex);
|
||||||
|
}
|
||||||
|
Deluge.Menus.Torrent.showAt(e.getPoint());
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the record representing the torrent at the specified index.
|
||||||
|
*
|
||||||
|
* @param {int} The row index of the torrent you wish to retrieve.
|
||||||
|
* @return {Ext.data.Record} The record representing the torrent.
|
||||||
|
*/
|
||||||
|
getTorrent: function(rowIndex) {
|
||||||
|
return this.getStore().getAt(rowIndex);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSelected: function() {
|
||||||
|
return this.getSelectionModel().getSelected();
|
||||||
|
},
|
||||||
|
|
||||||
|
getSelections: function() {
|
||||||
|
return this.getSelectionModel().getSelections();
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function(torrents) {
|
||||||
|
//var torrents = [];
|
||||||
|
var store = this.getStore();
|
||||||
|
for (var torrentId in torrents) {
|
||||||
|
var record = store.getById(torrentId);
|
||||||
|
var torrent = torrents[torrentId];
|
||||||
|
if (!record) {
|
||||||
|
// We need to create a new record
|
||||||
|
var data = [
|
||||||
|
torrent.queue,
|
||||||
|
torrent.name,
|
||||||
|
torrent.total_size,
|
||||||
|
torrent.state,
|
||||||
|
torrent.progress,
|
||||||
|
torrent.num_seeds,
|
||||||
|
torrent.total_seeds,
|
||||||
|
torrent.num_peers,
|
||||||
|
torrent.total_peers,
|
||||||
|
torrent.download_payload_rate,
|
||||||
|
torrent.upload_payload_rate,
|
||||||
|
torrent.eta,
|
||||||
|
torrent.ratio,
|
||||||
|
torrent.distributed_copies,
|
||||||
|
torrent.time_added,
|
||||||
|
torrent.tracker_host,
|
||||||
|
torrentId
|
||||||
|
];
|
||||||
|
store.loadData([data], true);
|
||||||
|
} else {
|
||||||
|
// We just need to do an update
|
||||||
|
record.set('queue', torrent.queue);
|
||||||
|
record.set('name', torrent.name);
|
||||||
|
record.set('size', torrent.total_size);
|
||||||
|
record.set('state', torrent.state);
|
||||||
|
record.set('progress', torrent.progress);
|
||||||
|
record.set('seeds', torrent.num_seeds);
|
||||||
|
record.set('total_seeds', torrent.total_seeds);
|
||||||
|
record.set('peers', torrent.num_peers);
|
||||||
|
record.set('total_peers', torrent.total_peers);
|
||||||
|
record.set('downspeed', torrent.download_payload_rate);
|
||||||
|
record.set('upspeed', torrent.upload_payload_rate);
|
||||||
|
record.set('eta', torrent.eta);
|
||||||
|
record.set('ratio', torrent.ratio);
|
||||||
|
record.set('avail', torrent.distributed_copies);
|
||||||
|
record.set('added', torrent.time_added);
|
||||||
|
record.set('tracker', torrent.tracker_host);
|
||||||
|
record.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var torrentIds = Ext.keys(torrents);
|
||||||
|
store.each(function(record) {
|
||||||
|
if (torrentIds.indexOf(record.id) == -1) {
|
||||||
|
// Torrent is no longer in the grid so we must remove it.
|
||||||
|
store.remove(record);
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
// private
|
||||||
|
onTorrentRemoved: function(torrentIds) {
|
||||||
|
var selModel = this.getSelectionModel();
|
||||||
|
Ext.each(torrentIds, function(torrentId) {
|
||||||
|
var record = this.getStore().getById(torrentId);
|
||||||
|
if (selModel.isSelected(record)) {
|
||||||
|
selModel.deselectRow(this.getStore().indexOf(record));
|
||||||
|
}
|
||||||
|
this.getStore().remove(record);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Deluge.Torrents = new Ext.deluge.TorrentGrid();
|
||||||
})();
|
})();
|
Loading…
Reference in New Issue