1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 12:27:58 +01:00

fix completion.alternateStylesheet

This commit is contained in:
Doug Kearns
2008-12-10 01:10:12 +11:00
parent 6ec66f253f
commit e93a17e13f

View File

@@ -1583,22 +1583,18 @@ function Completion() //{{{
alternateStylesheet: function alternateStylesheet(context)
{
context.title = ["Stylesheet", "Location"];
context.keys = { text: "title", description: function (item) item.href };
// unify split style sheets
let completions = buffer.alternateStyleSheets;
completions.forEach(function (stylesheet) {
stylesheet.href = stylesheet.href || "inline";
completions = completions.filter(function (sheet) {
if (stylesheet.title == sheet.title && stylesheet != sheet)
{
stylesheet.href += ", " + sheet.href;
return false;
}
return true;
});
let styles = {};
buffer.alternateStyleSheets.forEach(function (style) {
if (style.title in styles)
styles[style.title].push(style.href);
else
styles[style.title] = [style.href];
});
context.completions = completions;
context.completions = [[s, styles[s].join(", ")] for (s in styles)];
},
// filter a list of urls