diff --git a/content/bookmarks.js b/content/bookmarks.js
index 247c8609..c7d98bbf 100644
--- a/content/bookmarks.js
+++ b/content/bookmarks.js
@@ -77,7 +77,14 @@ function Bookmarks() //{{{
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
let tags = taggingService.getTagsForURI(uri, {}) || [];
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
- return bookmarks.push({ url: node.uri, title: node.title, get icon() getFavicon(node.uri), keyword: keyword, tags: tags, id: node.itemId});
+
+ return bookmarks.push({ url: node.uri,
+ title: node.title,
+ get icon() getFavicon(node.uri), // TODO; must be a direct way to get the icon
+ keyword: keyword,
+ tags: tags,
+ id: node.itemId,
+ get xml() template.bookmarkItem(this)});
}
function readBookmark(id)
@@ -537,7 +544,7 @@ function Bookmarks() //{{{
if (openItems)
return liberator.open([i.url for each (i in items)], liberator.NEW_TAB);
- let list = template.bookmarks("title", items);
+ let list = template.genericTable(["", "title", "URL"], items);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
}
};
@@ -718,7 +725,10 @@ function History() //{{{
{
let node = root.getChild(i);
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
- items.push({ url: node.uri, title: node.title, icon: node.icon ? node.icon.spec : DEFAULT_FAVICON });
+ items.push({ url: node.uri,
+ title: node.title,
+ icon: node.icon ? node.icon.spec : DEFAULT_FAVICON,
+ get xml() template.bookmarkItem(this)});
}
root.containerOpen = false; // close a container after using it!
@@ -770,7 +780,7 @@ function History() //{{{
if (openItems)
return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB);
- let list = template.bookmarks("title", items);
+ let list = template.genericTable(["", "title", "URL"], items);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
}
};
@@ -944,9 +954,12 @@ function QuickMarks() //{{{
}
}
- let items = ({ title: String(mark), url: qmarks.get(mark) } for each (mark in marks));
- // TODO: template.bookmarks is not the best for quickmarks
- let list = template.bookmarks("QuickMark", items);
+ let items = ({ title: String(mark),
+ url: qmarks.get(mark),
+ get xml()
| {this.title} | {this.url} |
+ } for each (mark in marks));
+
+ let list = template.genericTable(["QuickMark", "URL"], items);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
}
};
diff --git a/content/completion.js b/content/completion.js
index 2e8d4620..585bc394 100644
--- a/content/completion.js
+++ b/content/completion.js
@@ -809,34 +809,6 @@ function Completion() //{{{
bookmark: function (filter)
{
- // TODO: move to template.js?
- function createHtml(item)
- {
- var extra = [];
- if (item.keyword)
- extra.push(['keyword', item.keyword, "hl-Keyword"]);
- if (item.tags.length > 0)
- extra.push(["tags", item.tags.join(","), "hl-Tag"]); // no space, otherwise it looks strange, since we just have spaces to seperate tags from keywords
-
- return
- 
- - {util.clip(item.title || "", 50)}
- -
- {item.url}
- {
- !(extra.length) ? "" :
-
- }
-
-
- }
-
return {
start: 0,
get items() {
@@ -846,28 +818,9 @@ function Completion() //{{{
bmark[1] = bmark.title;
bmark.text = bmark.url;
- bmark.__defineGetter__("html", function () createHtml(bmark));
return bmark;
});
},
- createRow: function (item)
-
- 
- - {util.clip(item.title || "", 50)}
- -
- {item.url}
- {
- !(item.extra && item.extra.length) ? "" :
-
- }
-
-
};
},
diff --git a/content/mail.js b/content/mail.js
index 6140d097..b7f5234b 100644
--- a/content/mail.js
+++ b/content/mail.js
@@ -616,8 +616,8 @@ function Mail() //{{{
"Toggle HTML message display",
function ()
{
- var want_html = (gPrefBranch.getIntPref("mailnews.display.html_as", 1) == 1);
- mail.setHTML(want_html ? 1 : 0);
+ let wantHtml = (gPrefBranch.getIntPref("mailnews.display.html_as", 1) == 1);
+ mail.setHTML(wantHtml ? 1 : 0);
});
// YANKING TEXT
diff --git a/content/template.js b/content/template.js
index 44e8fc19..2e5af4a0 100644
--- a/content/template.js
+++ b/content/template.js
@@ -138,20 +138,51 @@ const template = {
return <>:{commandline.getCommand()}
> + xml;
},
- bookmarks: function (header, items)
+ // every item must have a .xml property which defines how to draw itself
+ // @param headers is an array of strings, the text for the header columns
+ genericTable: function (headers, items)
{
- let createRow = completion.bookmark("").createRow;
return this.generic(
- | {header} | URL |
+ {
+ headers.reduce(function (prev, cur) prev + {cur} | , <>>)
+ }
{
- this.map(items, function (item) createRow(item))
+ this.map(items, function (item) item.xml)
}
);
},
+ // returns a single row for a bookmark or history item
+ bookmarkItem: function (item)
+ {
+ var extra = [];
+ if (item.keyword)
+ extra.push(['keyword', item.keyword, "hl-Keyword"]);
+ if (item.tags && item.tags.length > 0)
+ extra.push(["tags", item.tags.join(","), "hl-Tag"]); // no space, otherwise it looks strange, since we just have spaces to seperate tags from keywords
+
+ return
+ 
+ - {util.clip(item.title || "", 50)}
+ -
+ {item.url}
+ {
+ !(extra.length) ? "" :
+
+ }
+
+
+ },
+
jumps: function (index, elems)
{
return this.generic(
diff --git a/content/ui.js b/content/ui.js
index a9756ec1..f0662c97 100644
--- a/content/ui.js
+++ b/content/ui.js
@@ -1381,14 +1381,14 @@ function ItemList(id) //{{{
if (diff == 1) /* Scroll down */
{
let item = items[endIndex - 1];
- let row = "html" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
+ let row = "xml" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
tbody.removeChild(tbody.firstChild);
tbody.appendChild(row);
}
else /* Scroll up */
{
let item = items[offset];
- let row = "html" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
+ let row = "xml" in item ? util.xmlToDom(item.html, doc) : createDefaultRow(item, true);
tbody.removeChild(tbody.lastChild);
tbody.insertBefore(row, tbody.firstChild);
}
@@ -1402,7 +1402,7 @@ function ItemList(id) //{{{
{
template.map(util.range(offset, endIndex), function (i)
- "html" in items[i] ? items[i].html : createDefaultRow(items[i]))
+ "xml" in items[i] ? items[i].html : createDefaultRow(items[i]))
}