mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-01 12:02:28 +01:00
make further refinements to the output of :pageinfo
This commit is contained in:
@@ -32,7 +32,7 @@ vimperator.Buffer = function() //{{{
|
||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////{{{
|
||||
// used for the "B" mapping to remember the last :buffer[!] command
|
||||
var lastBufferSwitchArgs = "";
|
||||
var lastBufferSwitchArgs = "";
|
||||
var lastBufferSwitchSpecial = true;
|
||||
|
||||
var zoom_levels = [ 1, 10, 25, 50, 75, 90, 100,
|
||||
@@ -190,9 +190,9 @@ vimperator.Buffer = function() //{{{
|
||||
return result;
|
||||
}
|
||||
|
||||
// in contrast to vim, returns the selection if one is made,
|
||||
// in contrast to vim, returns the selection if one is made,
|
||||
// otherwise tries to guess the current word unter the text cursor
|
||||
// NOTE: might change the selection
|
||||
// NOTE: might change the selection
|
||||
this.getCurrentWord = function()
|
||||
{
|
||||
var selection = window.content.getSelection().toString();
|
||||
@@ -493,8 +493,8 @@ vimperator.Buffer = function() //{{{
|
||||
bumpZoomLevel(-steps, full_zoom);
|
||||
};
|
||||
|
||||
this.pageInfo = function(verbose)
|
||||
{
|
||||
this.pageInfo = function(verbose)
|
||||
{
|
||||
// to get the file size later (from pageInfo.js) (setup cacheEntryDescriptor)
|
||||
const nsICacheService = Components.interfaces.nsICacheService;
|
||||
const ACCESS_READ = Components.interfaces.nsICache.ACCESS_READ;
|
||||
@@ -517,23 +517,21 @@ vimperator.Buffer = function() //{{{
|
||||
catch (ex2) { }
|
||||
}
|
||||
|
||||
if (!verbose)
|
||||
if (!verbose)
|
||||
{
|
||||
// TODO: strip off any component after &
|
||||
var file = window.content.document.location.pathname.split('/').pop();
|
||||
if (!file)
|
||||
file = "[No Name]";
|
||||
|
||||
var title = window.content.document.title;
|
||||
if (title.length > 60)
|
||||
title = title.substr(0,57) + "... ";
|
||||
else if (!title.length)
|
||||
title = "[No Title]";
|
||||
var title = window.content.document.title || "[No Title]";
|
||||
|
||||
if (cacheEntryDescriptor)
|
||||
if (cacheEntryDescriptor)
|
||||
var pageSize = Math.round(cacheEntryDescriptor.dataSize / 1024 * 100) / 100 + "KB";
|
||||
|
||||
var pageInfoText = "" + file + ": " + title + " (" + pageSize + ", other cool things)";
|
||||
var lastmod = window.content.document.lastModified.slice(0, -3);
|
||||
|
||||
var pageInfoText = '"' + file + '" (' + pageSize + ", " + lastmod + ") " + title;
|
||||
|
||||
vimperator.echo(pageInfoText, vimperator.commandline.FORCE_SINGLELINE);
|
||||
return;
|
||||
@@ -543,42 +541,46 @@ vimperator.Buffer = function() //{{{
|
||||
var pageMeta = []; // keeps meta infos
|
||||
|
||||
// get general infos
|
||||
pageGeneral.push(["Title", window.content.document.title]);
|
||||
pageGeneral.push(["URL", '<a class="hl-URL" href="' + window.content.document.location.toString() + '">' +
|
||||
pageGeneral.push(["Title", window.content.document.title]);
|
||||
pageGeneral.push(["URL", '<a class="hl-URL" href="' + window.content.document.location.toString() + '">' +
|
||||
window.content.document.location.toString() + '</a>']);
|
||||
pageGeneral.push(["Referrer", ("referrer" in window.content.document && window.content.document.referrer)]);
|
||||
pageGeneral.push(["Mime-Type", window.content.document.contentType]);
|
||||
pageGeneral.push(["Encoding", window.content.document.characterSet]);
|
||||
|
||||
|
||||
|
||||
if (cacheEntryDescriptor) {
|
||||
var pageSize = cacheEntryDescriptor.dataSize;
|
||||
pageGeneral.push(["File Size", (Math.round(pageSize / 1024 * 100) / 100) + "KB (" + pageSize + " bytes)"]);
|
||||
var bytes = pageSize + '';
|
||||
for (var u = bytes.length - 3; u > 0; u -= 3) // make a 1400 -> 1'400
|
||||
bytes = bytes.slice(0, u) + "'" + bytes.slice(u, bytes.length);
|
||||
pageGeneral.push(["File Size", (Math.round(pageSize / 1024 * 100) / 100) + "KB (" + bytes + " bytes)"]);
|
||||
}
|
||||
|
||||
pageGeneral.push(["Compatibility", content.document.compatMode == "BackCompat" ?
|
||||
pageGeneral.push(["Compatibility", content.document.compatMode == "BackCompat" ?
|
||||
"Quirks Mode" : "Full/Almost Standard Mode"]);
|
||||
pageGeneral.push(["Last Modified", window.content.document.lastModified]);
|
||||
|
||||
// get meta tag infos info and sort and put into pageMeta[]
|
||||
// get meta tag data, sort and put into pageMeta[]
|
||||
var metaNodes = window.content.document.getElementsByTagName("meta");
|
||||
var length = metaNodes.length;
|
||||
if (length)
|
||||
{
|
||||
if (length)
|
||||
{
|
||||
var tmpSort = [];
|
||||
var tmpDict = [];
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
var tmpTag = metaNodes[i].name || metaNodes[i].httpEquiv;// +
|
||||
var tmpTag = metaNodes[i].name || metaNodes[i].httpEquiv;// +
|
||||
//'<span style="font-weight: normal; font-size: 90%;">-eq</span>'; // XXX: really important?
|
||||
var tmpTagNr = tmpTag + "-" + i; // allows multiple (identical) meta names
|
||||
tmpDict[tmpTagNr] = [tmpTag, metaNodes[i].content];
|
||||
tmpSort.push(tmpTagNr); // array for sorting
|
||||
}
|
||||
|
||||
// sort: ignore-case
|
||||
tmpSort.sort(function (a,b){return a.toLowerCase() > b.toLowerCase() ? 1 : -1;});
|
||||
// sort: ignore-case
|
||||
tmpSort.sort(function (a,b){return a.toLowerCase() > b.toLowerCase() ? 1 : -1;});
|
||||
|
||||
for (var i=0; i < tmpSort.length; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user