// also includes methods for dealing with keywords and search engines
var Bookmarks = Module("bookmarks", {
init: function () {
+ this.timer = Timer(0, 100, function () {
+ this.checkBookmarked(buffer.uri);
+ }, this);
+
storage.addObserver("bookmark-cache", function (key, event, arg) {
if (["add", "change", "remove"].indexOf(event) >= 0)
autocommands.trigger("Bookmark" + event[0].toUpperCase() + event.substr(1),
valueOf: function () arg
}
}, arg));
- statusline.updateStatus();
+ bookmarks.timer.tell();
}, window);
},
+ signals: {
+ "browser.locationChange": function (webProgress, request, uri) {
+ statusline.bookmarked = false;
+ this.checkBookmarked(uri);
+ }
+ },
+
get format() ({
anchored: false,
title: ["URL", "Info"],
*
* @param {Element} elem A form element for which to add a keyword.
*/
- addSearchKeyword: function (elem) {
+ addSearchKeyword: function addSearchKeyword(elem) {
if (elem instanceof HTMLFormElement || elem.form)
var [url, post, charset] = util.parseForm(elem);
else
commands.commandToString({ command: "bmark", options: options, arguments: [url] }) + " -keyword ");
},
+ checkBookmarked: function checkBookmarked(uri) {
+ if (PlacesUtils.asyncGetBookmarkIds)
+ PlacesUtils.asyncGetBookmarkIds(uri, function (ids) {
+ statusline.bookmarked = ids.length;
+ });
+ else
+ this.timeout(function () {
+ statusline.bookmarked = bookmarkcache.isBookmarked(uri);
+ });
+ },
+
/**
* Toggles the bookmarked state of the given URL. If the URL is
* bookmarked, all bookmarks for said URL are removed.
if (!alias)
alias = "search"; // for search engines which we can't find a suitable alias
- if (set.has(aliases, alias))
+ if (Set.has(aliases, alias))
alias += ++aliases[alias];
else
aliases[alias] = 0;
getSuggestions: function getSuggestions(engineName, query, callback) {
const responseType = "application/x-suggestions+json";
- let engine = set.has(this.searchEngines, engineName) && this.searchEngines[engineName];
+ let engine = Set.has(this.searchEngines, engineName) && this.searchEngines[engineName];
if (engine && engine.supportsResponseType(responseType))
var queryURI = engine.getSubmission(query, responseType).uri.spec;
if (!queryURI)
param = query.substr(offset + 1);
}
- var engine = set.has(bookmarks.searchEngines, keyword) && bookmarks.searchEngines[keyword];
+ var engine = Set.has(bookmarks.searchEngines, keyword) && bookmarks.searchEngines[keyword];
if (engine) {
if (engine.searchForm && !param)
return engine.searchForm;
completer: function title(context, args) {
let frames = buffer.allFrames();
if (!args.bang)
- return [
- [win.document.title, frames.length == 1 ? "Current Location" : "Frame: " + win.location.href]
+ return [
+ [win.document.title, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.location.href]
for ([, win] in Iterator(frames))];
context.keys.text = "title";
context.keys.description = "url";
context.title = ["Page URL"];
let frames = buffer.allFrames();
context.completions = [
- [win.document.documentURI, frames.length == 1 ? "Current Location" : "Frame: " + win.document.title]
+ [win.document.documentURI, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.document.title]
for ([, win] in Iterator(frames))];
return;
}
"Delete a bookmark",
function (args) {
if (args.bang)
- commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
+ commandline.input(_("bookmark.prompt.deleteAll") + " ",
function (resp) {
if (resp && resp.match(/^y(es)?$/i)) {
bookmarks.remove(Object.keys(bookmarkcache.bookmarks));
- dactyl.echomsg(_("bookmark.allGone"));
+ dactyl.echomsg(_("bookmark.allDeleted"));
}
});
else {
let context = CompletionContext(args.join(" "));
context.fork("bookmark", 0, completion, "bookmark",
args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
- var deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
+ deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
}
dactyl.echomsg({ message: _("bookmark.deleted", deletedCount) });
if (item && item.url.indexOf("%s") > -1)
context.fork("keyword/" + keyword, keyword.length + space.length, null, function (context) {
context.format = history.format;
- context.title = [keyword + " Quick Search"];
+ context.title = [/*L*/keyword + " Quick Search"];
// context.background = true;
context.compare = CompletionContext.Sort.unsorted;
context.generate = function () {
return;
let ctxt = context.fork(name, 0);
- ctxt.title = [engine.description + " Suggestions"];
+ ctxt.title = [/*L*/engine.description + " Suggestions"];
ctxt.keys = { text: util.identity, description: function () "" };
ctxt.compare = CompletionContext.Sort.unsorted;
ctxt.filterFunc = null;