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