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

Prefer let over var in Highlights and Bookmarks.

This commit is contained in:
Doug Kearns
2008-12-23 01:30:33 +11:00
parent feeccb23d2
commit dba08286e8
2 changed files with 38 additions and 38 deletions

View File

@@ -76,8 +76,8 @@ function Bookmarks() //{{{
const rootFolders = [bookmarksService.toolbarFolder, bookmarksService.bookmarksMenuFolder, bookmarksService.unfiledBookmarksFolder];
const sleep = liberator.sleep;
var bookmarks = [];
var self = this;
let bookmarks = [];
let self = this;
this.__defineGetter__("name", function () name);
this.__defineGetter__("store", function () store);
@@ -108,7 +108,7 @@ function Bookmarks() //{{{
function deleteBookmark(id)
{
var length = bookmarks.length;
let length = bookmarks.length;
bookmarks = bookmarks.filter(function (item) item.id != id);
return bookmarks.length < length;
}
@@ -194,7 +194,7 @@ function Bookmarks() //{{{
if (isAnnotation)
return;
// liberator.dump("onItemChanged(" + itemId + ", " + property + ", " + value + ")\n");
var bookmark = bookmarks.filter(function (item) item.id == itemId)[0];
let bookmark = bookmarks.filter(function (item) item.id == itemId)[0];
if (bookmark)
{
if (property == "tags")
@@ -276,7 +276,7 @@ function Bookmarks() //{{{
"Open a prompt to bookmark the current URL",
function ()
{
var title = "";
let title = "";
if (buffer.title != buffer.URL)
title = " -title=\"" + buffer.title + "\"";
commandline.open(":", "bmark " + buffer.URL + title, modes.EX);
@@ -294,7 +294,7 @@ function Bookmarks() //{{{
"Show jumplist",
function ()
{
var sh = window.getWebNavigation().sessionHistory;
let sh = window.getWebNavigation().sessionHistory;
let entries = [sh.getEntryAtIndex(i, false) for (i in util.range(0, sh.count))];
let list = template.jumps(sh.index, entries);
@@ -337,10 +337,10 @@ function Bookmarks() //{{{
"Add a bookmark",
function (args)
{
var url = args.length == 0 ? buffer.URL : args[0];
var title = args["-title"] || (args.length == 0 ? buffer.title : null);
var keyword = args["-keyword"] || null;
var tags = args["-tags"] || [];
let url = args.length == 0 ? buffer.URL : args[0];
let title = args["-title"] || (args.length == 0 ? buffer.title : null);
let keyword = args["-keyword"] || null;
let tags = args["-tags"] || [];
if (bookmarks.add(false, title, url, keyword, tags, args.bang))
{
@@ -426,7 +426,7 @@ function Bookmarks() //{{{
{
try
{
var uri = util.createURI(url);
let uri = util.createURI(url);
if (!force)
{
for (let bmark in cache)
@@ -466,15 +466,15 @@ function Bookmarks() //{{{
if (!url)
return;
var count = this.remove(url);
let count = this.remove(url);
if (count > 0)
{
commandline.echo("Removed bookmark: " + url, commandline.HL_NORMAL, commandline.FORCE_SINGLELINE);
}
else
{
var title = buffer.title || url;
var extra = "";
let title = buffer.title || url;
let extra = "";
if (title != url)
extra = " (" + title + ")";
this.add(true, title, url);
@@ -486,7 +486,7 @@ function Bookmarks() //{{{
{
try
{
var uri = util.newURI(url);
let uri = util.newURI(url);
return (bookmarksService.getBookmarkedURIFor(uri) != null);
}
catch (e)
@@ -501,12 +501,12 @@ function Bookmarks() //{{{
if (!url)
return 0;
var i = 0;
let i = 0;
try
{
var uri = util.newURI(url);
let uri = util.newURI(url);
var count = {};
var bmarks = bookmarksService.getBookmarkIdsForURI(uri, count);
let bmarks = bookmarksService.getBookmarkIdsForURI(uri, count);
for (; i < bmarks.length; i++)
bookmarksService.removeItem(bmarks[i]);
@@ -529,18 +529,18 @@ function Bookmarks() //{{{
// also ensures that each search engine has a Vimperator-friendly alias
getSearchEngines: function getSearchEngines()
{
var searchEngines = [];
var firefoxEngines = searchService.getVisibleEngines({});
let searchEngines = [];
let firefoxEngines = searchService.getVisibleEngines({});
for (let [,engine] in Iterator(firefoxEngines))
{
var alias = engine.alias;
let alias = engine.alias;
if (!alias || !/^[a-z0-9_-]+$/.test(alias))
alias = engine.name.replace(/^\W*([a-zA-Z_-]+).*/, "$1").toLowerCase();
if (!alias)
alias = "search"; // for search engines which we can't find a suitable alias
// make sure we can use search engines which would have the same alias (add numbers at the end)
var newAlias = alias;
let newAlias = alias;
for (let j = 1; j <= 10; j++) // <=10 is intentional
{
if (!searchEngines.some(function (item) item[0] == newAlias))
@@ -603,9 +603,9 @@ function Bookmarks() //{{{
// if the search also requires a postData, [url, postData] is returned
getSearchURL: function getSearchURL(text, useDefsearch)
{
var url = null;
var aPostDataRef = {};
var searchString = (useDefsearch ? options["defsearch"] + " " : "") + text;
let url = null;
let aPostDataRef = {};
let searchString = (useDefsearch ? options["defsearch"] + " " : "") + text;
// we need to make sure our custom alias have been set, even if the user
// did not :open <tab> once before
@@ -702,7 +702,7 @@ function History() //{{{
{
if (args)
{
var sh = window.getWebNavigation().sessionHistory;
let sh = window.getWebNavigation().sessionHistory;
for (let i = sh.index - 1; i >= 0; i--)
{
if (sh.getEntryAtIndex(i, false).URI.spec == args)
@@ -748,7 +748,7 @@ function History() //{{{
{
if (args)
{
var sh = window.getWebNavigation().sessionHistory;
let sh = window.getWebNavigation().sessionHistory;
for (let i in util.range(sh.index + 1, sh.count))
{
if (sh.getEntryAtIndex(i, false).URI.spec == args)
@@ -961,7 +961,7 @@ function QuickMarks() //{{{
"Mark a URL with a letter for quick access",
function (args)
{
var matches = args.string.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/);
let matches = args.string.match(/^([a-zA-Z0-9])(?:\s+(.+))?$/);
if (!matches)
liberator.echoerr("E488: Trailing characters");
else if (!matches[2])
@@ -984,7 +984,7 @@ function QuickMarks() //{{{
return;
}
var filter = args.replace(/[^a-zA-Z0-9]/g, "");
let filter = args.replace(/[^a-zA-Z0-9]/g, "");
quickmarks.list(filter);
});
@@ -1002,7 +1002,7 @@ function QuickMarks() //{{{
remove: function remove(filter)
{
var pattern = RegExp("[" + filter.replace(/\s+/g, "") + "]");
let pattern = RegExp("[" + filter.replace(/\s+/g, "") + "]");
for (let [qmark,] in qmarks)
{
@@ -1018,7 +1018,7 @@ function QuickMarks() //{{{
jumpTo: function jumpTo(qmark, where)
{
var url = qmarks.get(qmark);
let url = qmarks.get(qmark);
if (url)
liberator.open(url, where);
@@ -1028,11 +1028,11 @@ function QuickMarks() //{{{
list: function list(filter)
{
var marks = [key for ([key, val] in qmarks)];
let marks = [key for ([key, val] in qmarks)];
// This was a lot nicer without the lambda...
var lowercaseMarks = marks.filter(function (x) /[a-z]/.test(x)).sort();
var uppercaseMarks = marks.filter(function (x) /[A-Z]/.test(x)).sort();
var numberMarks = marks.filter(function (x) /[0-9]/.test(x)).sort();
let lowercaseMarks = marks.filter(function (x) /[a-z]/.test(x)).sort();
let uppercaseMarks = marks.filter(function (x) /[A-Z]/.test(x)).sort();
let numberMarks = marks.filter(function (x) /[0-9]/.test(x)).sort();
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);