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.

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

mercurial