1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-03 19:23:37 +02:00

fixed favicons in :hs and :bmarks output (:bmarks filter still broken)

This commit is contained in:
Martin Stubenschrott
2008-11-20 21:55:41 +00:00
parent 7032d4ec38
commit aa13986142
2 changed files with 19 additions and 12 deletions

View File

@@ -26,6 +26,9 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
// TODO: with the new subscript loader, is there really no way to keep variable in per-file scope?
const DEFAULT_FAVICON = "chrome://mozapps/skin/places/defaultFavicon.png";
// also includes methods for dealing with keywords and search engines // also includes methods for dealing with keywords and search engines
function Bookmarks() //{{{ function Bookmarks() //{{{
{ {
@@ -74,7 +77,7 @@ function Bookmarks() //{{{
let keyword = bookmarksService.getKeywordForBookmark(node.itemId); let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
let tags = taggingService.getTagsForURI(uri, {}) || []; let tags = taggingService.getTagsForURI(uri, {}) || [];
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId)); //return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
return bookmarks.push({url: node.uri, title: node.title, icon: null, keyword: keyword, tags: tags, id: node.itemId}); return bookmarks.push({ url: node.uri, title: node.title, get icon() getFavicon(node.uri), keyword: keyword, tags: tags, id: node.itemId});
} }
function readBookmark(id) function readBookmark(id)
@@ -715,7 +718,7 @@ function History() //{{{
{ {
let node = root.getChild(i); let node = root.getChild(i);
if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark if (node.type == node.RESULT_TYPE_URI) // just make sure it's a bookmark
items.push({ url: node.uri, title: node.title, get icon() function() bookmarks.getFavicon(node.uri) }); items.push({ url: node.uri, title: node.title, icon: node.icon ? node.icon.spec : DEFAULT_FAVICON });
} }
root.containerOpen = false; // close a container after using it! root.containerOpen = false; // close a container after using it!
@@ -942,6 +945,7 @@ function QuickMarks() //{{{
} }
let items = ({ title: String(mark), url: qmarks.get(mark) } for each (mark in marks)); 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 list = template.bookmarks("QuickMark", items);
commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE); commandline.echo(list, commandline.HL_NORMAL, commandline.FORCE_MULTILINE);
} }

View File

@@ -1324,31 +1324,34 @@ function ItemList(id) //{{{
} }
// TODO: move to completions? // TODO: move to completions?
function createDefaultRow([b, c, a], dom) function createDefaultRow(item, dom)
{ {
if (item instanceof Array)
item = { text: item[0], description: item[1], icon: item[2] };
/* Kludge until we have completion contexts. */ /* Kludge until we have completion contexts. */
let map = completion.filterMap; let map = completion.filterMap;
if (map) if (map)
{ {
b = map[0] ? map[0](b) : b; item.text = map[0] ? map[0](item.text) : item.text;
c = map[1] ? map[1](c) : c; item.description = map[1] ? map[1](item.description) : item.description;
} }
/* Obviously, ItemList shouldn't know or care about this. */ /* Obviously, ItemList shouldn't know or care about this. */
let filter = completion.filterString; let filter = completion.filterString;
if (filter) if (filter)
{ {
b = template.highlightFilter(b, filter); item.text = template.highlightFilter(item.text, filter);
c = template.highlightFilter(c, filter); item.description = template.highlightFilter(item.description, filter);
} }
if (typeof a == "function") if (typeof item.icon == "function")
a = a(); item.icon = item.icon();
let row = let row =
<ul class="hl-CompItem"> <ul class="hl-CompItem">
<li class="hl-CompIcon">{a ? <img src={a}/> : <></>}</li> <li class="hl-CompIcon">{item.icon ? <img src={item.icon}/> : <></>}</li>
<li class="hl-CompResult">{b}</li> <li class="hl-CompResult">{item.text}</li>
<li class="hl-CompDesc">{c}</li> <li class="hl-CompDesc">{item.description}</li>
</ul>; </ul>;
if (dom) if (dom)