},
- onTorrentChanged: function(tor)
+ onTorrentChanged: function(ev, tor)
{
// update our dirty fields
this.dirtyTorrents[ tor.getId() ] = true;
needinfo.push(id);
}
else {
- var tr = this;
t = tr._torrents[id] = new Torrent(o);
this.dirtyTorrents[id] = true;
- $(t).bind('dataChanged',function(ev,tor) {tr.onTorrentChanged(tor);});
+ $(t).bind('dataChanged',$.proxy(this.onTorrentChanged,this));
if(!('name' in t.fields) || !('status' in t.fields)) // missing some fields...
needinfo.push(id);
}
this.updateTorrents(null, ['id'].concat(Torrent.Fields.Metadata, Torrent.Fields.Stats));
},
- onRowClicked: function(ev, row)
+ onRowClicked: function(ev)
{
+ var row = ev.currentTarget.row;
+
// handle the per-row "torrent_resume" button
if (ev.target.className === 'torrent_resume') {
this.startTorrent(row.getTorrent());
}
// remove the dirty rows from the dom
- e = $.map(dirty_rows.slice(0), function(r) {
- return r.getElement();
- });
+ e = [];
+ for (i=0; row=dirty_rows[i]; ++i)
+ e.push (row.getElement());
$(e).detach();
// drop any dirty rows that don't pass the filter test
e = row.getElement();
e.row = row;
dirty_rows.push(row);
- var tr = this;
- $(e).click(function(ev){tr.onRowClicked(ev,ev.currentTarget.row);});
- $(e).dblclick(function(ev){tr.toggleInspector();});
+ $(e).click($.proxy(this.onRowClicked,this));
+ $(e).dblclick($.proxy(this.toggleInspector,this));
}
}
this.dirtyTorrents = { };
// jquery's even/odd starts with 1 not 0, so invert its logic
- e = $.map(rows.slice(0), function(r){return r.getElement();});
- $(e).filter(":odd").addClass('even');
- $(e).filter(":even").removeClass('even');
+ for (i=0; row=rows[i]; ++i)
+ $(row.getElement()).toggleClass('even',(i%2)!==0);
// sync gui
this.updateStatusbar();