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
9 define_keywords("$use_webjumps", "$use_history", "$use_bookmarks",
11 function history_completer () {
13 var use_history = arguments.$use_history;
14 var use_bookmarks = arguments.$use_bookmarks;
15 let match_required = arguments.$match_required;
16 return function (input, pos, conservative) {
17 if (conservative && input.length == 0)
19 var query = nav_history_service.getNewQuery();
20 query.searchTerms = input;
22 query.onlyBookmarked = true;
23 var options = nav_history_service.getNewQueryOptions();
24 options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
25 if (use_bookmarks && !use_history)
26 options.queryType = options.QUERY_TYPE_BOOKMARKS;
27 else if (use_history && !use_bookmarks)
28 options.queryType = options.QUERY_TYPE_HISTORY;
30 options.queryType = options.QUERY_TYPE_UNIFIED; //WTF: not implemented yet?
31 var root = nav_history_service.executeQuery(query, options).root;
32 root.containerOpen = true;
33 var history_count = root.childCount;
34 return {count: history_count,
35 get_string: function (i) root.getChild(i).uri,
36 get_description: function (i) root.getChild(i).title,
37 get_input_state: function (i) [root.getChild(i).uri],
38 destroy: function () { root.containerOpen = false; },
39 get_match_required: function() match_required
44 function url_completer() {
46 var use_webjumps = arguments.$use_webjumps;
47 var use_history = arguments.$use_history;
48 var use_bookmarks = arguments.$use_bookmarks;
50 completers.push(file_path_completer());
52 completers.push(webjump_completer());
54 if(use_history || use_bookmarks) {
55 completers.push(history_completer($use_history = use_history,
56 $use_bookmarks = use_bookmarks));
58 return merge_completers(completers);
62 function add_bookmark(url, title) {
63 nav_bookmarks_service.insertBookmark(nav_bookmarks_service.unfiledBookmarksFolder,
64 make_uri(url), -1, title);