1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 21:28:00 +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) alternateStylesheet: function alternateStylesheet(context)
{ {
context.title = ["Stylesheet", "Location"]; context.title = ["Stylesheet", "Location"];
context.keys = { text: "title", description: function (item) item.href };
// unify split style sheets // unify split style sheets
let completions = buffer.alternateStyleSheets; let styles = {};
completions.forEach(function (stylesheet) {
stylesheet.href = stylesheet.href || "inline"; buffer.alternateStyleSheets.forEach(function (style) {
completions = completions.filter(function (sheet) { if (style.title in styles)
if (stylesheet.title == sheet.title && stylesheet != sheet) styles[style.title].push(style.href);
{ else
stylesheet.href += ", " + sheet.href; styles[style.title] = [style.href];
return false;
}
return true;
});
}); });
context.completions = completions;
context.completions = [[s, styles[s].join(", ")] for (s in styles)];
}, },
// filter a list of urls // filter a list of urls