1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-19 15:33:35 +02:00

Add filtering to :addons and :downloads. Add -type flag to :addons.

--HG--
extra : transplant_source : %06i65%11-C%E7b%12%C0%8E%8C%8Ed%C9%ED8I%13
This commit is contained in:
Kris Maglione
2011-01-24 05:05:57 -05:00
parent fb4aafc21e
commit 74b6710484
6 changed files with 70 additions and 14 deletions

View File

@@ -178,9 +178,10 @@ var DownloadList = Class("DownloadList",
XPCOM([Ci.nsIDownloadProgressListener,
Ci.nsIObserver,
Ci.nsISupportsWeakReference]), {
init: function init(modules) {
init: function init(modules, filter) {
this.modules = modules;
this.nodes = {};
this.filter = filter && filter.toLowerCase();
this.downloads = {};
},
cleanup: function cleanup() {
@@ -213,12 +214,15 @@ var DownloadList = Class("DownloadList",
addDownload: function addDownload(id) {
if (!(id in this.downloads)) {
this.downloads[id] = Download(id, this);
let download = Download(id, this);
if (this.filter && download.displayName.indexOf(this.filter) === -1)
return;
this.downloads[id] = download;
let index = values(this.downloads).sort(function (a, b) a.compare(b))
.indexOf(this.downloads[id]);
.indexOf(download);
this.nodes.list.insertBefore(this.downloads[id].nodes.row,
this.nodes.list.insertBefore(download.nodes.row,
this.nodes.list.childNodes[index + 1]);
}
},
@@ -283,8 +287,11 @@ var Downloads = Module("downloads", {
commands.add(["downl[oads]", "dl"],
"Display the downloads list",
function (args) {
let downloads = DownloadList(modules);
let downloads = DownloadList(modules, args[0]);
modules.commandline.echo(downloads);
},
{
argCount: "?"
});
},
dactyl: function (dactyl, modules, window) {