diff --git a/content/buffer.js b/content/buffer.js index 94a408e1..d4cdb129 100644 --- a/content/buffer.js +++ b/content/buffer.js @@ -34,10 +34,10 @@ liberator.Buffer = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - const highlightClasses = ["Boolean", "ErrorMsg", "InfoMsg", "Keyword", "LineNr", - "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Question", "StatusLine", - "StatusLineBroken", "StatusLineSecure", "String", "Tag", "Title", "URL", - "WarningMsg"]; + const highlightClasses = ["Boolean", "ErrorMsg", "Function", "InfoMsg", "Keyword", + "LineNr", "ModeMsg", "MoreMsg", "Normal", "Null", "Number", "Question", + "StatusLine", "StatusLineBroken", "StatusLineSecure", "String", "Tag", + "Title", "URL", "WarningMsg"]; let name = liberator.config.name.toLowerCase(); const highlightDocs = "chrome://" + name + "/content/buffer.xhtml,chrome://browser/content/browser.xul"; @@ -927,7 +927,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.template.highlightURL(feed.href, true) +  ({type})]; } } } @@ -982,11 +982,11 @@ liberator.Buffer = function () //{{{ } yield ["Title", doc.title]; - yield ["URL", liberator.util.highlightURL(doc.location.toString(), true)]; + yield ["URL", liberator.template.highlightURL(doc.location.toString(), true)]; var ref = "referrer" in doc && doc.referrer; if (ref) - yield ["Referrer", liberator.util.highlightURL(ref, true)]; + yield ["Referrer", liberator.template.highlightURL(ref, true)]; if (pageSize[0]) yield ["File Size", pageSize[1] ? pageSize[1] + " (" + pageSize[0] + ")" @@ -1004,7 +1004,7 @@ liberator.Buffer = function () //{{{ // get meta tag data, sort and put into pageMeta[] var metaNodes = window.content.document.getElementsByTagName("meta"); - return Array.map(metaNodes, function (node) [(node.name || node.httpEquiv), liberator.util.highlightURL(node.content)]) + return Array.map(metaNodes, function (node) [(node.name || node.httpEquiv), liberator.template.highlightURL(node.content)]) .sort(function (a, b) String.localeCompare(a[0].toLowerCase(), b[0].toLowerCase())); }); @@ -1977,158 +1977,4 @@ liberator.Marks = function () //{{{ //}}} }; //}}} -liberator.template = { - add: function (a, b) a + b, - join: function (c) function (a, b) a + c + b, - - map: function (iter, fn, sep) - { - if (iter.length) /* Kludge? */ - iter = liberator.util.arrayIter(iter); - let ret = <>; - let n = 0; - for each (let i in iter) - { - let val = fn(i); - if (val == undefined) - continue; - if (sep && n++) - ret += sep; - ret += val; - } - return ret; - }, - map2: function (iter, fn, sep) - { - // Could cause performance problems. - return this.map(Iterator(iter), function (x) fn.apply(null, x), sep); - }, - - maybeXML: function (xml) - { - if (typeof xml == "xml") - return xml; - try - { - return new XMLList(xml); - } - catch (e) {} - return <>{xml}; - }, - - generic: function (xml) - { - return <>:{liberator.commandline.getCommand()}
+ xml; - }, - - bookmarks: function (header, items) - { - return this.generic( - - - - - { - this.map(items, function (item) - - - - ) - } -
{header}URL
{liberator.util.clip(item.title, 50)} - {item.url}  - { - !(item.extra && item.extra.length) ? "" : - - ({ - liberator.template.map(item.extra, function (e) - <>{e[0]}: {e[1]}, - /* Non-breaking space */) - }) - - } -
); - }, - - jumps: function (index, elems) - { - return this.generic( - - - - - { - this.map2(elems, function (idx, val) - - - - - - ) - } -
jumptitleURI
{idx == index ? ">" : ""}{Math.abs(idx - index)}{val.title}{val.URI.spec}
); - }, - - options: function (title, opts) - { - return this.generic( - - - - - { - this.map(opts, function (opt) - - - ) - } -
--- {title} ---
- {opt.pre}{opt.name}{opt.value} - {opt.isDefault || opt.default == null ? "" : (default: {opt.default})} -
); - }, - - table: function (title, data, indent) - { - let table = - - - - - { - this.map(data, function (datum) - - - - ) - } -
{title}
{datum[0]}{liberator.template.maybeXML(datum[1])}
; - if (table.tr.length() > 1) - return table; - }, - - tabular: function (headings, style, iter) - { - /* This might be mind-bogglingly slow. We'll see. */ - return this.generic( - - - { - this.map(headings, function (h) - ) - } - - { - this.map(iter, function (row) - - { - liberator.template.map2(row, function (i, d) - ) - } - ) - } -
{h}
{d}
); - }, -}; - // vim: set fdm=marker sw=4 ts=4 et: diff --git a/content/completion.js b/content/completion.js index 4def5823..5b4cfe73 100644 --- a/content/completion.js +++ b/content/completion.js @@ -489,10 +489,12 @@ liberator.Completion = function () //{{{ if (!filter) return [[a[0], a[1], favicon ? a[2] : null] for each (a in array)]; + let result; if (matchFromBeginning) - return buildLongestStartingSubstring(array, filter, favicon); + result = buildLongestStartingSubstring(array, filter, favicon); else - return buildLongestCommonSubstring(array, filter, favicon); + result = buildLongestCommonSubstring(array, filter, favicon); + return result; }, cached: function (key, filter, generate, method) diff --git a/content/liberator.xul b/content/liberator.xul index 5b751250..e5bb92d5 100644 --- a/content/liberator.xul +++ b/content/liberator.xul @@ -49,9 +49,10 @@ the terms of any one of the MPL, the GPL or the LGPL.