1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-29 03:25:48 +01:00

prefer let over var in Events and AutoCommands

This commit is contained in:
Doug Kearns
2008-12-10 02:46:06 +11:00
parent 2376da165d
commit f2a2e9dc55

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;
} }