1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-24 02:22:26 +01:00

unify the presentation of split style sheets when completing :pagestyle

This commit is contained in:
Doug Kearns
2008-08-31 05:55:48 +00:00
parent 6353b76f6d
commit 509a2cf75c
2 changed files with 16 additions and 8 deletions

View File

@@ -571,9 +571,8 @@ liberator.Buffer = function () //{{{
{ {
var stylesheets = getAllStyleSheets(window.content); var stylesheets = getAllStyleSheets(window.content);
// TODO: how should we handle duplicate titles?
stylesheets = stylesheets.filter(function (stylesheet) { stylesheets = stylesheets.filter(function (stylesheet) {
return !(!/^(screen|all|)$/i.test(stylesheet.media.mediaText) || /^\s*$/.test(stylesheet.title)); return /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title);
}); });
return stylesheets; return stylesheets;

View File

@@ -164,7 +164,7 @@ liberator.Completion = function () //{{{
else else
return buildLongestCommonSubstring(array, filter); return buildLongestCommonSubstring(array, filter);
}, },
// FIXME: items shouldn't be [[[a], b]], but [[a, b]] and only mapped if at all for bLCS --mst // FIXME: items shouldn't be [[[a], b]], but [[a, b]] and only mapped if at all for bLCS --mst
buffer: function (filter) buffer: function (filter)
{ {
@@ -338,7 +338,7 @@ liberator.Completion = function () //{{{
var tmp = liberator.events.getMacros(); var tmp = liberator.events.getMacros();
for (var item in tmp) for (var item in tmp)
macros.push([item, tmp[item]]); macros.push([item, tmp[item]]);
return [0, liberator.completion.filter(macros, filter)]; return [0, liberator.completion.filter(macros, filter)];
}, },
@@ -402,13 +402,22 @@ liberator.Completion = function () //{{{
stylesheet: function (filter) stylesheet: function (filter)
{ {
var stylesheets = getAllStyleSheets(window.content); var completions = liberator.buffer.alternateStyleSheets.map(function (stylesheet) {
stylesheets = liberator.buffer.alternateStyleSheets.map(function (stylesheet) {
return [stylesheet.title, stylesheet.href || "inline"]; return [stylesheet.title, stylesheet.href || "inline"];
}); });
return [0, this.filter(stylesheets, filter)]; // unify split style sheets
completions.forEach(function (stylesheet) {
for (let i = 0; i < completions.length; i++) {
if (stylesheet[0] == completions[i][0] && stylesheet[1] != completions[i][1])
{
stylesheet[1] += ", " + completions[i][1];
completions.splice(i, 1);
}
}
});
return [0, this.filter(completions, filter)];
}, },
// filter a list of urls // filter a list of urls