From 7521ef4bf1155469fd2fa3198d0e9345825a688d Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Fri, 3 Oct 2008 16:50:21 +0000 Subject: [PATCH] Fix :pageinfo spacing, and stuff. --- content/buffer.js | 26 ++++++++++++++------------ content/completion.js | 2 +- content/io.js | 6 +++--- content/ui.js | 33 +++++---------------------------- content/util.js | 21 ++++++++++++++++++++- 5 files changed, 43 insertions(+), 45 deletions(-) diff --git a/content/buffer.js b/content/buffer.js index 961b40f1..0a10becd 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -682,7 +682,7 @@ liberator.Buffer = function () //{{{ nFeed++; var type = feedTypes[feed.type] || feedTypes["application/rss+xml"]; if (verbose) - yield [" " + feed.title, liberator.util.highlightURL(feed.href, true) +  ({type})]; + yield [feed.title, liberator.util.highlightURL(feed.href, true) +  ({type})]; } } } @@ -736,22 +736,22 @@ liberator.Buffer = function () //{{{ return; } - yield [" Title", doc.title]; - yield [" URL", liberator.util.highlightURL(doc.location.toString(), true)]; + yield ["Title", doc.title]; + yield ["URL", liberator.util.highlightURL(doc.location.toString(), true)]; var ref = "referrer" in doc && doc.referrer; if (ref) - yield [" Referrer", liberator.util.highlightURL(ref, true)]; + yield ["Referrer", liberator.util.highlightURL(ref, true)]; if (pageSize[0]) - yield [" File Size", pageSize[1] ? pageSize[1] + " (" + pageSize[0] + ")" + yield ["File Size", pageSize[1] ? pageSize[1] + " (" + pageSize[0] + ")" : pageSize[0]]; - yield [" Mime-Type", doc.contentType]; - yield [" Encoding", doc.characterSet]; - yield [" Compatibility", doc.compatMode == "BackCompat" ? "Quirks Mode" : "Full/Almost Standards Mode"]; + yield ["Mime-Type", doc.contentType]; + yield ["Encoding", doc.characterSet]; + yield ["Compatibility", doc.compatMode == "BackCompat" ? "Quirks Mode" : "Full/Almost Standards Mode"]; if (lastModVerbose) - yield [" Last Modified", lastModVerbose]; + yield ["Last Modified", lastModVerbose]; }); addPageInfoSection("m", "Meta Tags", function (verbose) @@ -761,7 +761,7 @@ liberator.Buffer = function () //{{{ let nodes = Array.map(metaNodes, function (node) [(node.name || node.httpEquiv), node.content]) .sort(function (a, b) String.localeCompare(a[0].toLowerCase(), b[0].toLowerCase())); - return ([" " + node[0], liberator.util.highlightURL(node[1], false)] + return ([node[0], liberator.util.highlightURL(node[1], false)] for each (node in arrayIter(nodes))); }); @@ -1840,16 +1840,18 @@ liberator.template = { ); }, - table: function (title, data) + table: function (title, data, indent) { let table = + - + { this.map(data, function (datum) + ) diff --git a/content/completion.js b/content/completion.js index d65cb40a..31097bd4 100644 --- a/content/completion.js +++ b/content/completion.js @@ -475,7 +475,7 @@ liberator.Completion = function () //{{{ historyResult = result; historyTimer.tell(); if (result.searchResult <= result.RESULT_SUCCESS) - historyTimer.force(); + historyTimer.flush(); } }); } diff --git a/content/io.js b/content/io.js index 5c072e31..6d6d4e1d 100644 --- a/content/io.js +++ b/content/io.js @@ -323,12 +323,12 @@ liberator.IO = function () //{{{ XML.prettyPrinting = false; var list =
{title}{title}
{datum[0]} {liberator.template.maybeXML(datum[1])}
- {[ + { + liberator.template.map2(scriptNames, function (i, name) - - for ([i, name] in Iterator(striptNames))].reduce(liberator.buffer.template.add, <>) + ) }
{i+1} {name}
.toXMLString(); liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); diff --git a/content/ui.js b/content/ui.js index 7b6ef29f..a1f6b749 100644 --- a/content/ui.js +++ b/content/ui.js @@ -121,23 +121,8 @@ liberator.CommandLine = function () //{{{ // the widget used for multiline output var multilineOutputWidget = document.getElementById("liberator-multiline-output"); - - var stylesheet = - ; - - stylesheet = liberator.util.xmlToDom(stylesheet, multilineOutputWidget.contentDocument); - multilineOutputWidget.contentDocument.getElementsByTagName("head")[0] - .appendChild(stylesheet); - - multilineOutputWidget.contentDocument.body.id = "liberator-multiline-output-content"; - - // TODO: is there a better way to determine and set the UI font, 'guifont' perhaps? - var mainWindowID = liberator.config.mainWindowID || "main-window"; - var fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null).getPropertyValue("font-size"); - multilineOutputWidget.contentDocument.body.setAttribute("style", "font-size: " + fontSize); - - multilineOutputWidget.contentDocument.body.innerHTML = ""; + multilineOutputWidget.setAttribute("src", + liberator.util.blankDocument("liberator-multiline-output-content")); var outputContainer = multilineOutputWidget.parentNode; @@ -1203,19 +1188,10 @@ liberator.ItemList = function (id) //{{{ return; } - var doc = iframe.contentDocument; + var doc; var container = iframe.parentNode; - var stylesheet = liberator.util.xmlToDom( - , doc); - doc.getElementsByTagName("head")[0].appendChild(stylesheet); - - doc.body.id = id + "-content"; - - var mainWindowID = liberator.config.mainWindowID || "main-window"; - var fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null).getPropertyValue("font-size"); - doc.body.setAttribute("style", "font-size: " + fontSize); + iframe.setAttribute("src", liberator.util.blankDocument(id + "-content")); var completions = []; // a reference to the Array of completions var listOffset = -1; // how many items is the displayed list shifted from the internal tab index @@ -1349,6 +1325,7 @@ liberator.ItemList = function (id) //{{{ // if @param selectedItem is given, show the list and select that item setItems: function (items, selectedItem) { + doc = iframe.contentDocument; listOffset = listIndex = -1; completions = items || []; if (typeof(selectedItem) == "number") diff --git a/content/util.js b/content/util.js index dd8404d5..fd2de41f 100644 --- a/content/util.js +++ b/content/util.js @@ -77,6 +77,24 @@ liberator.util = { //{{{ yield ary[i]; }, + blankDocument: function (bodyId) + { + let mainWindowID = liberator.config.mainWindowID || "main-window"; + let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null) + .getPropertyValue("font-size"); + + return 'data:application/xhtml+xml,' + encodeURI('' + + '' + + + + + <link rel="stylesheet" type="text/css" + href={"chrome://" + liberator.config.name.toLowerCase() + "/skin/vimperator.css"}/> + </head> + <body id={bodyId} style={"font-size: " + fontSize}/> + </html>) + }, + clip: function (str, length) { return str.length <= length ? str : str.substr(0, length - 3) + "..."; @@ -404,7 +422,8 @@ liberator.util = { //{{{ case "text": return doc.createTextNode(node); case "element": - let domnode = doc.createElement(node.name()); + // Should use the node's namespace, in the future. + let domnode = doc.createElementNS("http://www.w3.org/1999/xhtml", node.localName()); for each (let attr in node.@*) domnode.setAttribute(attr.name(), String(attr)); for each (let child in node.*)