1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 12:27:59 +01:00

prefer let over var in Tabs

This commit is contained in:
Doug Kearns
2008-12-08 19:36:50 +11:00
parent b921abb6a3
commit c4ba7444c2

View File

@@ -69,9 +69,9 @@ function Tabs() //{{{
// - "$" for the last tab // - "$" for the last tab
function indexFromSpec(spec, wrap) function indexFromSpec(spec, wrap)
{ {
var position = getBrowser().mTabContainer.selectedIndex; let position = getBrowser().mTabContainer.selectedIndex;
var length = getBrowser().mTabs.length; let length = getBrowser().mTabs.length;
var last = length - 1; let last = length - 1;
if (spec === undefined || spec === "") if (spec === undefined || spec === "")
return position; return position;
@@ -97,13 +97,13 @@ function Tabs() //{{{
function copyTab(to, from) function copyTab(to, from)
{ {
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"] const ss = Components.classes["@mozilla.org/browser/sessionstore;1"]
.getService(Components.interfaces.nsISessionStore); .getService(Components.interfaces.nsISessionStore);
if (!from) if (!from)
from = getBrowser().mTabContainer.selectedItem; from = getBrowser().mTabContainer.selectedItem;
var tabState = ss.getTabState(from); let tabState = ss.getTabState(from);
ss.setTabState(to, tabState); ss.setTabState(to, tabState);
} }
@@ -194,7 +194,7 @@ function Tabs() //{{{
{ {
setter: function (value) setter: function (value)
{ {
var values = [[0, 1], // always in current tab let values = [[0, 1], // always in current tab
[0, 3], // in a new tab [0, 3], // in a new tab
[2, 3], // in a new window if it has specified sizes [2, 3], // in a new window if it has specified sizes
[1, 2], // always in new window [1, 2], // always in new window
@@ -405,7 +405,7 @@ function Tabs() //{{{
if (args || count > 0) if (args || count > 0)
{ {
var index; let index;
// count is ignored if an arg is specified, as per Vim // count is ignored if an arg is specified, as per Vim
if (args) if (args)
@@ -537,7 +537,7 @@ function Tabs() //{{{
let special = args.bang; let special = args.bang;
args = args.string; args = args.string;
var where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB; let where = special ? liberator.NEW_TAB : liberator.NEW_BACKGROUND_TAB;
if (/\btabopen\b/.test(options["activate"])) if (/\btabopen\b/.test(options["activate"]))
where = special ? liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB; where = special ? liberator.NEW_BACKGROUND_TAB : liberator.NEW_TAB;
@@ -561,9 +561,9 @@ function Tabs() //{{{
"Duplicate current tab", "Duplicate current tab",
function (args) function (args)
{ {
var tab = tabs.getTab(); let tab = tabs.getTab();
var activate = args.bang ? true : false; let activate = args.bang ? true : false;
if (/\btabopen\b/.test(options["activate"])) if (/\btabopen\b/.test(options["activate"]))
activate = !activate; activate = !activate;
@@ -692,12 +692,12 @@ function Tabs() //{{{
// @returns an array of tabs which match filter // @returns an array of tabs which match filter
get: function (filter) get: function (filter)
{ {
var buffers = []; let buffers = [];
for (let [i, browser] in this.browsers) for (let [i, browser] in this.browsers)
{ {
var title = browser.contentTitle || "(Untitled)"; let title = browser.contentTitle || "(Untitled)";
var uri = browser.currentURI.spec; let uri = browser.currentURI.spec;
var number = i + 1; let number = i + 1;
buffers.push([number, title, uri]); buffers.push([number, title, uri]);
} }
return buffers; return buffers;
@@ -739,7 +739,7 @@ function Tabs() //{{{
// NOTE: position is a 0 based index // NOTE: position is a 0 based index
move: function (tab, spec, wrap) move: function (tab, spec, wrap)
{ {
var index = indexFromSpec(spec, wrap); let index = indexFromSpec(spec, wrap);
getBrowser().moveTabTo(tab, index); getBrowser().moveTabTo(tab, index);
}, },
@@ -747,7 +747,7 @@ function Tabs() //{{{
// quitOnLastTab = 2: quit and save session // quitOnLastTab = 2: quit and save session
remove: function (tab, count, focusLeftTab, quitOnLastTab) remove: function (tab, count, focusLeftTab, quitOnLastTab)
{ {
var removeOrBlankTab = { let removeOrBlankTab = {
Firefox: function (tab) Firefox: function (tab)
{ {
if (getBrowser().mTabs.length > 1) if (getBrowser().mTabs.length > 1)
@@ -816,9 +816,9 @@ function Tabs() //{{{
select: function (spec, wrap) select: function (spec, wrap)
{ {
var index = indexFromSpec(spec, wrap); let index = indexFromSpec(spec, wrap);
// FIXME: // FIXME:
if (index === -1) if (index == -1)
{ {
liberator.beep(); // XXX: move to ex-handling? liberator.beep(); // XXX: move to ex-handling?
return; return;
@@ -940,7 +940,7 @@ function Tabs() //{{{
cloneTab: function (tab, activate) cloneTab: function (tab, activate)
{ {
var newTab = getBrowser().addTab(); let newTab = getBrowser().addTab();
copyTab(newTab, tab); copyTab(newTab, tab);
if (activate) if (activate)
@@ -955,9 +955,9 @@ function Tabs() //{{{
tab = getBrowser().mTabContainer.selectedItem; tab = getBrowser().mTabContainer.selectedItem;
window.open(); window.open();
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser"); let win = wm.getMostRecentWindow("navigator:browser");
copyTab(win.getBrowser().mCurrentTab, tab); copyTab(win.getBrowser().mCurrentTab, tab);
this.remove(tab, 1, false, 1); this.remove(tab, 1, false, 1);
@@ -973,7 +973,7 @@ function Tabs() //{{{
// NOTE: this currently relies on v.tabs.index() returning the // NOTE: this currently relies on v.tabs.index() returning the
// currently selected tab index when passed null // currently selected tab index when passed null
var index = tabs.index(tabs.alternate); let index = tabs.index(tabs.alternate);
// TODO: since a tab close is more like a bdelete for us we // TODO: since a tab close is more like a bdelete for us we
// should probably reopen the closed tab when a 'deleted' // should probably reopen the closed tab when a 'deleted'