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

merge improvements to :pageinfo

This commit is contained in:
Doug Kearns
2007-11-22 12:01:35 +00:00
parent d15c85be04
commit 0eeeec421e
2 changed files with 21 additions and 21 deletions

View File

@@ -147,7 +147,7 @@ vimperator.Buffer = function () //{{{
}, },
// returns an XPathResult object // returns an XPathResult object
evaluateXPath: function (expression, doc, elem, ordered) evaluateXPath: function (expression, doc, elem, asIterator)
{ {
if (!doc) if (!doc)
doc = window.content.document; doc = window.content.document;
@@ -165,7 +165,7 @@ vimperator.Buffer = function () //{{{
return null; return null;
} }
}, },
ordered ? XPathResult.ORDERED_NODE_SNAPSHOT_TYPE : XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, asIterator ? XPathResult.UNORDERED_NODE_ITERATOR_TYPE : XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null null
); );
@@ -459,43 +459,43 @@ vimperator.Buffer = function () //{{{
"application/rdf+xml": "XML" "application/rdf+xml": "XML"
}; };
function isValidFeed(aData, aPrincipal, aIsFeed) function isValidFeed(data, principal, isFeed)
{ {
if (!aData || !aPrincipal) if (!data || !principal)
return false; return false;
if (!aIsFeed) if (!isFeed)
{ {
var type = aData.type && aData.type.toLowerCase(); var type = data.type && data.type.toLowerCase();
type = type.replace(/^\s+|\s*(?:;.*)?$/g, ""); type = type.replace(/^\s+|\s*(?:;.*)?$/g, "");
aIsFeed = (type == "application/rss+xml" || type == "application/atom+xml"); isFeed = (type == "application/rss+xml" || type == "application/atom+xml");
if (!aIsFeed) if (!isFeed)
{ {
// really slimy: general XML types with magic letters in the title // really slimy: general XML types with magic letters in the title
const titleRegex = /(^|\s)rss($|\s)/i; const titleRegex = /(^|\s)rss($|\s)/i;
aIsFeed = ((type == "text/xml" || type == "application/rdf+xml" || isFeed = ((type == "text/xml" || type == "application/rdf+xml" ||
type == "application/xml") && titleRegex.test(aData.title)); type == "application/xml") && titleRegex.test(data.title));
} }
} }
if (aIsFeed) if (isFeed)
{ {
try try
{ {
urlSecurityCheck(aData.href, aPrincipal, urlSecurityCheck(data.href, principal,
Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
} }
catch (ex) catch (ex)
{ {
aIsFeed = false; isFeed = false;
} }
} }
if (type) if (type)
aData.type = type; data.type = type;
return aIsFeed; return isFeed;
} }
// TODO: could this be useful for other commands? // TODO: could this be useful for other commands?
@@ -506,7 +506,7 @@ vimperator.Buffer = function () //{{{
if (data.length - 1) if (data.length - 1)
{ {
for (var i = 0; i < data.length - 1 ; i++) for (var i = 0; i < data.length - 1; i++)
ret += "<tr><td style='font-weight: bold; min-width: 150px'> " + data[i][0] + ": </td><td>" + data[i][1] + "</td></tr>"; ret += "<tr><td style='font-weight: bold; min-width: 150px'> " + data[i][0] + ": </td><td>" + data[i][1] + "</td></tr>";
} }
else else
@@ -575,7 +575,7 @@ vimperator.Buffer = function () //{{{
if (isValidFeed(feed, window.content.document.nodePrincipal, rels.feed)) if (isValidFeed(feed, window.content.document.nodePrincipal, rels.feed))
{ {
var type = feedTypes[feed.type] || feedTypes["application/rss+xml"]; var type = feedTypes[feed.type] || feedTypes["application/rss+xml"];
pageFeeds.push([feed.title, vimperator.util.highlightURL(feed.href, true) + " (" + type + ")"]); pageFeeds.push([feed.title, vimperator.util.highlightURL(feed.href, true) + " <span style='color: gray;'>(" + type + ")</span>"]);
} }
} }
} }
@@ -583,7 +583,7 @@ vimperator.Buffer = function () //{{{
var lastModVerbose = new Date(window.content.document.lastModified).toLocaleString(); var lastModVerbose = new Date(window.content.document.lastModified).toLocaleString();
var lastMod = new Date(window.content.document.lastModified).toLocaleFormat("%x %X"); var lastMod = new Date(window.content.document.lastModified).toLocaleFormat("%x %X");
// FIXME: probably unportable across differnet language versions // FIXME: probably unportable across differnet language versions
if (lastModVerbose == "Invalid Date") if (lastModVerbose == "Invalid Date" || new Date(window.content.document.lastModified).getFullYear() == 1970)
lastModVerbose = lastMod = null; lastModVerbose = lastMod = null;
// Ctrl-g single line output // Ctrl-g single line output
@@ -650,7 +650,7 @@ vimperator.Buffer = function () //{{{
} }
// sort: ignore-case // sort: ignore-case
tmpSort.sort(function (a,b){return a.toLowerCase() > b.toLowerCase() ? 1 : -1;}); tmpSort.sort(function (a, b) { return a.toLowerCase() > b.toLowerCase() ? 1 : -1; });
for (var i = 0; i < tmpSort.length; i++) for (var i = 0; i < tmpSort.length; i++)
pageMeta.push([tmpDict[tmpSort[i]][0], vimperator.util.highlightURL(tmpDict[tmpSort[i]][1], false)]); pageMeta.push([tmpDict[tmpSort[i]][0], vimperator.util.highlightURL(tmpDict[tmpSort[i]][1], false)]);
} }

View File

@@ -1016,8 +1016,8 @@ vimperator.Commands = function () //{{{
commandManager.add(new vimperator.Command(["pa[geinfo]"], commandManager.add(new vimperator.Command(["pa[geinfo]"],
function () { vimperator.buffer.pageInfo(true); }, function () { vimperator.buffer.pageInfo(true); },
{ {
shortHelp: "Show general and/or meta-content site informations", shortHelp: "Show various page information",
help: "Show general and/or meta-content site informations" help: "See :help 'pageinfo' for available options",
} }
)); ));
commandManager.add(new vimperator.Command(["pc[lose]"], commandManager.add(new vimperator.Command(["pc[lose]"],