2 * (C) Copyright 2008 Eli Naeher
3 * (C) Copyright 2008 Jeremy Maitin-Shepard
5 * Use, modification, and distribution are subject to the terms specified in the
11 define_keywords("$use_webjumps", "$use_history", "$use_bookmarks",
13 function history_completer () {
15 var use_history = arguments.$use_history;
16 var use_bookmarks = arguments.$use_bookmarks;
17 let match_required = arguments.$match_required;
18 return function (input, pos, conservative) {
19 if (conservative && input.length == 0)
21 var query = nav_history_service.getNewQuery();
22 query.searchTerms = input;
24 query.onlyBookmarked = true;
25 var options = nav_history_service.getNewQueryOptions();
26 options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
27 if (use_bookmarks && !use_history)
28 options.queryType = options.QUERY_TYPE_BOOKMARKS;
29 else if (use_history && !use_bookmarks)
30 options.queryType = options.QUERY_TYPE_HISTORY;
32 options.queryType = options.QUERY_TYPE_UNIFIED; //WTF: not implemented yet?
33 var root = nav_history_service.executeQuery(query, options).root;
34 root.containerOpen = true;
35 var history_count = root.childCount;
36 return {count: history_count,
37 get_string: function (i) root.getChild(i).uri,
38 get_description: function (i) root.getChild(i).title,
39 get_input_state: function (i) [root.getChild(i).uri],
40 destroy: function () { root.containerOpen = false; },
41 get_match_required: function() match_required
46 function url_completer() {
48 var use_webjumps = arguments.$use_webjumps;
49 var use_history = arguments.$use_history;
50 var use_bookmarks = arguments.$use_bookmarks;
52 completers.push(file_path_completer());
54 completers.push(webjump_completer());
56 /* Do queries separately (which can lead to duplicates). The
57 * queries can be combined when QUERY_TYPE_UNIFIED is implemented. */
59 completers.push(history_completer($use_bookmarks = true));
61 completers.push(history_completer($use_history = true));
62 return merge_completers(completers);
66 function add_bookmark(url, title) {
67 nav_bookmarks_service.insertBookmark(nav_bookmarks_service.unfiledBookmarksFolder,
68 make_uri(url), -1, title);