browser/components/places/content/history-panel.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 var gHistoryTree;
michael@0 7 var gSearchBox;
michael@0 8 var gHistoryGrouping = "";
michael@0 9 var gSearching = false;
michael@0 10
michael@0 11 function HistorySidebarInit()
michael@0 12 {
michael@0 13 gHistoryTree = document.getElementById("historyTree");
michael@0 14 gSearchBox = document.getElementById("search-box");
michael@0 15
michael@0 16 gHistoryGrouping = document.getElementById("viewButton").
michael@0 17 getAttribute("selectedsort");
michael@0 18
michael@0 19 if (gHistoryGrouping == "site")
michael@0 20 document.getElementById("bysite").setAttribute("checked", "true");
michael@0 21 else if (gHistoryGrouping == "visited")
michael@0 22 document.getElementById("byvisited").setAttribute("checked", "true");
michael@0 23 else if (gHistoryGrouping == "lastvisited")
michael@0 24 document.getElementById("bylastvisited").setAttribute("checked", "true");
michael@0 25 else if (gHistoryGrouping == "dayandsite")
michael@0 26 document.getElementById("bydayandsite").setAttribute("checked", "true");
michael@0 27 else
michael@0 28 document.getElementById("byday").setAttribute("checked", "true");
michael@0 29
michael@0 30 searchHistory("");
michael@0 31 }
michael@0 32
michael@0 33 function GroupBy(groupingType)
michael@0 34 {
michael@0 35 gHistoryGrouping = groupingType;
michael@0 36 searchHistory(gSearchBox.value);
michael@0 37 }
michael@0 38
michael@0 39 function searchHistory(aInput)
michael@0 40 {
michael@0 41 var query = PlacesUtils.history.getNewQuery();
michael@0 42 var options = PlacesUtils.history.getNewQueryOptions();
michael@0 43
michael@0 44 const NHQO = Ci.nsINavHistoryQueryOptions;
michael@0 45 var sortingMode;
michael@0 46 var resultType;
michael@0 47
michael@0 48 switch (gHistoryGrouping) {
michael@0 49 case "visited":
michael@0 50 resultType = NHQO.RESULTS_AS_URI;
michael@0 51 sortingMode = NHQO.SORT_BY_VISITCOUNT_DESCENDING;
michael@0 52 break;
michael@0 53 case "lastvisited":
michael@0 54 resultType = NHQO.RESULTS_AS_URI;
michael@0 55 sortingMode = NHQO.SORT_BY_DATE_DESCENDING;
michael@0 56 break;
michael@0 57 case "dayandsite":
michael@0 58 resultType = NHQO.RESULTS_AS_DATE_SITE_QUERY;
michael@0 59 break;
michael@0 60 case "site":
michael@0 61 resultType = NHQO.RESULTS_AS_SITE_QUERY;
michael@0 62 sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
michael@0 63 break;
michael@0 64 case "day":
michael@0 65 default:
michael@0 66 resultType = NHQO.RESULTS_AS_DATE_QUERY;
michael@0 67 break;
michael@0 68 }
michael@0 69
michael@0 70 if (aInput) {
michael@0 71 query.searchTerms = aInput;
michael@0 72 if (gHistoryGrouping != "visited" && gHistoryGrouping != "lastvisited") {
michael@0 73 sortingMode = NHQO.SORT_BY_FRECENCY_DESCENDING;
michael@0 74 resultType = NHQO.RESULTS_AS_URI;
michael@0 75 }
michael@0 76 }
michael@0 77
michael@0 78 options.sortingMode = sortingMode;
michael@0 79 options.resultType = resultType;
michael@0 80 options.includeHidden = !!aInput;
michael@0 81
michael@0 82 // call load() on the tree manually
michael@0 83 // instead of setting the place attribute in history-panel.xul
michael@0 84 // otherwise, we will end up calling load() twice
michael@0 85 gHistoryTree.load([query], options);
michael@0 86 }
michael@0 87
michael@0 88 window.addEventListener("SidebarFocused",
michael@0 89 function()
michael@0 90 gSearchBox.focus(),
michael@0 91 false);

mercurial