add a tracker renderer

This commit is contained in:
Damien Churchill 2009-04-06 18:17:04 +00:00
parent 1719ece036
commit 0501537045
1 changed files with 12 additions and 8 deletions

View File

@ -34,6 +34,13 @@ function torrent_speed(value) {
return fspeed(value);
}
function progress(value, p, r) {
var progress = value.toInt();
var text = r.data['state'] + ' ' + value.toFixed(2) + '%'
var width = this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt() - 8;
return progressBar(value.toInt(), width, text);
}
var tpl = '<div class="x-progress-wrap x-progress-renderered">' +
'<div class="x-progress-inner">' +
'<div style="width: {2}px" class="x-progress-bar">' +
@ -47,13 +54,6 @@ var tpl = '<div class="x-progress-wrap x-progress-renderered">' +
'</div>' +
'</div>';
function progress(value, p, r) {
var progress = value.toInt();
var text = r.data['state'] + ' ' + value.toFixed(2) + '%'
var width = this.style.match(/\w+:\s*(\d+)\w+/)[1].toInt() - 8;
return progressBar(value.toInt(), width, text);
}
function progressBar(progress, width, text) {
var progressWidth = (width / 100.0) * progress;
var barWidth = progressWidth.toInt() - 1;
@ -81,6 +81,10 @@ function avail(value) {
return value.toFixed(3);
}
function tracker(value) {
return String.format('<div style="background: url(/tracker/{0}) no-repeat; padding-left: 20px;">{0}</div>', value);
}
Deluge.Torrents = {
Store: new Ext.data.SimpleStore({
fields: [
@ -151,7 +155,7 @@ Deluge.Torrents.Grid = new Ext.grid.GridPanel({
{header: "Ratio", width: 60, sortable: true, renderer: avail, dataIndex: 'ratio'},
{header: "Avail.", width: 60, sortable: true, renderer: avail, dataIndex: 'avail'},
{header: "Added", width: 80, sortable: true, renderer: fdate, dataIndex: 'added'},
{header: "Tracker", width: 120, sortable: true, renderer: Deluge.Formatters.plain, dataIndex: 'tracker'}
{header: "Tracker", width: 120, sortable: true, renderer: tracker, dataIndex: 'tracker'}
],
stripeRows: true,
autoExpandColumn: 'name',