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

Merge branch 'master' of kmaglione@git.vimperator.org:/git/vimperator/liberator

This commit is contained in:
Kris Maglione
2008-12-09 22:05:03 -05:00
5 changed files with 52 additions and 55 deletions

View File

@@ -1169,10 +1169,10 @@ function Completion() //{{{
let styles = {}; let styles = {};
buffer.alternateStyleSheets.forEach(function (style) { buffer.alternateStyleSheets.forEach(function (style) {
if (style.title in styles) if (!(style.title in styles))
styles[style.title].push(style.href); styles[style.title] = [];
else
styles[style.title] = [style.href]; styles[style.title].push(style.href || "inline");
}); });
context.completions = [[s, styles[s].join(", ")] for (s in styles)]; context.completions = [[s, styles[s].join(", ")] for (s in styles)];
@@ -1606,9 +1606,9 @@ function Completion() //{{{
// if the 'complete' argument is passed like "h", it temporarily overrides the complete option // if the 'complete' argument is passed like "h", it temporarily overrides the complete option
url: function url(context, complete) url: function url(context, complete)
{ {
var numLocationCompletions = 0; // how many async completions did we already return to the caller? let numLocationCompletions = 0; // how many async completions did we already return to the caller?
var start = 0; let start = 0;
var skip = context.filter.match("^.*" + options["urlseparator"]); // start after the last 'urlseparator' let skip = context.filter.match("^.*" + options["urlseparator"]); // start after the last 'urlseparator'
if (skip) if (skip)
context.advance(skip[0].length); context.advance(skip[0].length);

View File

@@ -207,7 +207,7 @@ function AutoCommands() //{{{
} }
}); });
var list = template.commandOutput( let list = template.commandOutput(
<table> <table>
<tr highlight="Title"> <tr highlight="Title">
<td colspan="2">----- Auto Commands -----</td> <td colspan="2">----- Auto Commands -----</td>
@@ -282,7 +282,7 @@ function Events() //{{{
try // not every extension has a getBrowser() method try // not every extension has a getBrowser() method
{ {
var tabcontainer = getBrowser().mTabContainer; let tabcontainer = getBrowser().mTabContainer;
if (tabcontainer) // not every VIM-like extension has a tab container if (tabcontainer) // not every VIM-like extension has a tab container
{ {
tabcontainer.addEventListener("TabMove", function (event) tabcontainer.addEventListener("TabMove", function (event)
@@ -434,14 +434,14 @@ function Events() //{{{
function isFormElemFocused() function isFormElemFocused()
{ {
var elt = window.document.commandDispatcher.focusedElement; let elt = window.document.commandDispatcher.focusedElement;
if (elt == null) if (elt == null)
return false; return false;
try try
{ // sometimes the elt doesn't have .localName { // sometimes the elt doesn't have .localName
var tagname = elt.localName.toLowerCase(); let tagname = elt.localName.toLowerCase();
var type = elt.type.toLowerCase(); let type = elt.type.toLowerCase();
if ((tagname == "input" && (type != "image")) || if ((tagname == "input" && (type != "image")) ||
tagname == "textarea" || tagname == "textarea" ||
@@ -524,7 +524,7 @@ function Events() //{{{
if (options["focuscontent"]) if (options["focuscontent"])
{ {
setTimeout(function () { setTimeout(function () {
var focused = document.commandDispatcher.focusedElement; let focused = document.commandDispatcher.focusedElement;
if (focused && (focused.value !== undefined) && focused.value.length == 0) if (focused && (focused.value !== undefined) && focused.value.length == 0)
focused.blur(); focused.blur();
}, 100); }, 100);
@@ -741,7 +741,7 @@ function Events() //{{{
playMacro: function (macro) playMacro: function (macro)
{ {
var res = false; let res = false;
if (!/[a-zA-Z0-9@]/.test(macro) && macro.length == 1) if (!/[a-zA-Z0-9@]/.test(macro) && macro.length == 1)
{ {
liberator.echoerr("E354: Invalid register name: '" + macro + "'"); liberator.echoerr("E354: Invalid register name: '" + macro + "'");
@@ -794,13 +794,13 @@ function Events() //{{{
if (!filter) if (!filter)
return macros; return macros;
var re = new RegExp(filter); let re = new RegExp(filter);
return ([macro, keys] for ([macro, keys] in macros) if (re.test(macro))); return ([macro, keys] for ([macro, keys] in macros) if (re.test(macro)));
}, },
deleteMacros: function (filter) deleteMacros: function (filter)
{ {
var re = new RegExp(filter); let re = new RegExp(filter);
for (let [item,] in macros) for (let [item,] in macros)
{ {
@@ -817,13 +817,13 @@ function Events() //{{{
// if you want < to be taken literally, prepend it with a \\ // if you want < to be taken literally, prepend it with a \\
feedkeys: function (keys, noremap, silent) feedkeys: function (keys, noremap, silent)
{ {
var doc = window.document; let doc = window.document;
var view = window.document.defaultView; let view = window.document.defaultView;
var escapeKey = false; // \ to escape some special keys let escapeKey = false; // \ to escape some special keys
var wasFeeding = this.feedingKeys; let wasFeeding = this.feedingKeys;
this.feedingKeys = true; this.feedingKeys = true;
var wasSilent = commandline.silent; let wasSilent = commandline.silent;
if (silent) if (silent)
commandline.silent = silent; commandline.silent = silent;
@@ -1041,7 +1041,7 @@ function Events() //{{{
modes.show(); modes.show();
// TODO: allow macros to be continued when page does not fully load with an option // TODO: allow macros to be continued when page does not fully load with an option
var ret = (buffer.loaded == 1); let ret = (buffer.loaded == 1);
if (!ret) if (!ret)
liberator.echoerr("Page did not load completely in " + ms + " milliseconds. Macro stopped."); liberator.echoerr("Page did not load completely in " + ms + " milliseconds. Macro stopped.");
liberator.dump("done waiting: " + ret); liberator.dump("done waiting: " + ret);
@@ -1066,8 +1066,8 @@ function Events() //{{{
function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument function hasHTMLDocument(win) win && win.document && win.document instanceof HTMLDocument
var win = window.document.commandDispatcher.focusedWindow; let win = window.document.commandDispatcher.focusedWindow;
var elem = window.document.commandDispatcher.focusedElement; let elem = window.document.commandDispatcher.focusedElement;
if (win && win.top == content && liberator.has("tabs")) if (win && win.top == content && liberator.has("tabs"))
tabs.localStore.focusedFrame = win; tabs.localStore.focusedFrame = win;
@@ -1136,8 +1136,8 @@ function Events() //{{{
onSelectionChange: function (event) onSelectionChange: function (event)
{ {
var couldCopy = false; let couldCopy = false;
var controller = document.commandDispatcher.getControllerForCommand("cmd_copy"); let controller = document.commandDispatcher.getControllerForCommand("cmd_copy");
if (controller && controller.isCommandEnabled("cmd_copy")) if (controller && controller.isCommandEnabled("cmd_copy"))
couldCopy = true; couldCopy = true;
@@ -1176,7 +1176,7 @@ function Events() //{{{
{ {
case modes.NORMAL: case modes.NORMAL:
// clear any selection made // clear any selection made
var selection = window.content.getSelection(); let selection = window.content.getSelection();
try try
{ // a simple if (selection) does not seem to work { // a simple if (selection) does not seem to work
selection.collapseToStart(); selection.collapseToStart();
@@ -1606,7 +1606,7 @@ function Events() //{{{
}, },
setOverLink : function (link, b) setOverLink : function (link, b)
{ {
var ssli = options["showstatuslinks"]; let ssli = options["showstatuslinks"];
if (link && ssli) if (link && ssli)
{ {
if (ssli == 1) if (ssli == 1)
@@ -1635,8 +1635,8 @@ function Events() //{{{
prefObserver: { prefObserver: {
register: function () register: function ()
{ {
var prefService = Components.classes["@mozilla.org/preferences-service;1"] const prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService); .getService(Components.interfaces.nsIPrefService);
this._branch = prefService.getBranch(""); // better way to monitor all changes? this._branch = prefService.getBranch(""); // better way to monitor all changes?
this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2); this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
this._branch.addObserver("", this, false); this._branch.addObserver("", this, false);
@@ -1658,7 +1658,7 @@ function Events() //{{{
switch (aData) switch (aData)
{ {
case "accessibility.browsewithcaret": case "accessibility.browsewithcaret":
var value = options.getPref("accessibility.browsewithcaret", false); let value = options.getPref("accessibility.browsewithcaret", false);
liberator.mode = value ? modes.CARET : modes.NORMAL; liberator.mode = value ? modes.CARET : modes.NORMAL;
break; break;
} }

View File

@@ -337,7 +337,7 @@ function Search() //{{{
// TODO: backwards seems impossible i fear :( // TODO: backwards seems impossible i fear :(
find: function (str, backwards) find: function (str, backwards)
{ {
var fastFind = getBrowser().fastFind; let fastFind = getBrowser().fastFind;
processUserPattern(str); processUserPattern(str);
@@ -359,8 +359,8 @@ function Search() //{{{
if (getBrowser().fastFind.searchString != lastSearchString) if (getBrowser().fastFind.searchString != lastSearchString)
this.find(lastSearchString, false); this.find(lastSearchString, false);
var up = reverse ? !lastSearchBackwards : lastSearchBackwards; let up = reverse ? !lastSearchBackwards : lastSearchBackwards;
var result = getBrowser().fastFind.findAgain(up, linksOnly); let result = getBrowser().fastFind.findAgain(up, linksOnly);
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND) if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND)
{ {

View File

@@ -1846,7 +1846,7 @@ function StatusLine() //{{{
// tab numbers set // tab numbers set
if (options.get("guioptions").has("n", "N")) if (options.get("guioptions").has("n", "N"))
{ {
for (let [i, tab] in Iterator(getBrowser().mTabs)) for (let [i, tab] in util.Array.iterator2(getBrowser().mTabs))
tab.setAttribute("ordinal", i + 1); tab.setAttribute("ordinal", i + 1);
} }

View File

@@ -220,7 +220,7 @@ const config = { //{{{
"Open homepage in a new tab", "Open homepage in a new tab",
function () function ()
{ {
var homepages = gHomeButton.getHomePage(); let homepages = gHomeButton.getHomePage();
liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ? liberator.open(homepages, /\bhomepage\b/.test(options["activate"]) ?
liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB); liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB);
}); });
@@ -233,22 +233,21 @@ const config = { //{{{
{ {
if (/^file:\/|^\//.test(url)) if (/^file:\/|^\//.test(url))
{ {
//var strippedFilename = url.replace(/^(file:\/\/)?(.*)/, "$2"); let file = io.getFile(url);
var file = io.getFile(url); return file.exists() && file.isDirectory();
if (!file.exists() || !file.isDirectory()) }
return false; else
else {
return true; // for all other locations just check if the URL ends with /
return /\/$/.test(url);
} }
// for all other locations just check if the URL ends with /
return /\/$/.test(url);
} }
if (count < 1) if (count < 1)
count = 1; count = 1;
var url = buffer.URL; // XXX
let url = buffer.URL;
for (let i = 0; i < count; i++) for (let i = 0; i < count; i++)
{ {
if (isDirectory(url)) if (isDirectory(url))
@@ -259,11 +258,9 @@ const config = { //{{{
url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end url = url.replace(/^(.*:\/+.*?)\/+$/, "$1/"); // get rid of more than 1 / at the end
if (url == buffer.URL) if (url == buffer.URL)
{
liberator.beep(); liberator.beep();
return; else
} liberator.open(url);
liberator.open(url);
}, },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
@@ -271,7 +268,7 @@ const config = { //{{{
"Go to the root of the website", "Go to the root of the website",
function () function ()
{ {
var uri = content.document.location; let uri = content.document.location;
if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now if (/(about|mailto):/.test(uri.protocol)) // exclude these special protocols for now
{ {
liberator.beep(); liberator.beep();
@@ -321,7 +318,7 @@ const config = { //{{{
"Redraw the screen", "Redraw the screen",
function () function ()
{ {
var wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). let wu = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
getInterface(Components.interfaces.nsIDOMWindowUtils); getInterface(Components.interfaces.nsIDOMWindowUtils);
wu.redraw(); wu.redraw();
modes.show(); modes.show();
@@ -401,8 +398,8 @@ const config = { //{{{
{ {
setter: function (value) setter: function (value)
{ {
var ioService = Components.classes['@mozilla.org/network/io-service;1'] const ioService = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService2); .getService(Components.interfaces.nsIIOService2);
ioService.offline = !value; ioService.offline = !value;
gPrefService.setBoolPref("browser.offline", ioService.offline); gPrefService.setBoolPref("browser.offline", ioService.offline);
@@ -424,7 +421,7 @@ const config = { //{{{
{ {
try try
{ {
var id = config.mainWindowID || "main-window"; let id = config.mainWindowID || "main-window";
document.getElementById(id).setAttribute("titlemodifier", value); document.getElementById(id).setAttribute("titlemodifier", value);
if (window.content.document.title.length > 0) if (window.content.document.title.length > 0)
document.title = window.content.document.title + " - " + value; document.title = window.content.document.title + " - " + value;