home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 May / maximum-cd-2009-05.iso / DiscContents / Firefox Setup 3.0.6.exe / nonlocalized / chrome / browser.jar / content / browser / places / history-panel.js < prev    next >
Encoding:
JavaScript  |  2008-04-20  |  3.2 KB  |  107 lines

  1. //@line 40 "/e/fx19rel/WINNT_5.2_Depend/mozilla/browser/components/places/content/history-panel.js"
  2.  
  3. var gHistoryTree;
  4. var gSearchBox;
  5. var gHistoryGrouping = "";
  6. var gSearching = false;
  7.  
  8. function HistorySidebarInit()
  9. {
  10.   gHistoryTree = document.getElementById("historyTree");
  11.   gSearchBox = document.getElementById("search-box");
  12.  
  13.   gHistoryGrouping = document.getElementById("viewButton").
  14.                               getAttribute("selectedsort");
  15.  
  16.   if (gHistoryGrouping == "site")
  17.     document.getElementById("bysite").setAttribute("checked", "true");
  18.   else if (gHistoryGrouping == "visited") 
  19.     document.getElementById("byvisited").setAttribute("checked", "true");
  20.   else if (gHistoryGrouping == "lastvisited")
  21.     document.getElementById("bylastvisited").setAttribute("checked", "true");
  22.   else if (gHistoryGrouping == "dayandsite")
  23.     document.getElementById("bydayandsite").setAttribute("checked", "true");
  24.   else
  25.     document.getElementById("byday").setAttribute("checked", "true");
  26.  
  27.   initContextMenu();
  28.   
  29.   searchHistory("");
  30. }
  31.  
  32. function initContextMenu() {
  33.   // Insert "Bookmark This Link" right before the copy item
  34.   document.getElementById("placesContext")
  35.           .insertBefore(document.getElementById("addBookmarkContextItem"),
  36.                         document.getElementById("placesContext_copy"));
  37. }
  38.  
  39. function GroupBy(groupingType)
  40. {
  41.   gHistoryGrouping = groupingType;
  42.   gSearchBox.value = "";
  43.   searchHistory("");
  44. }
  45.  
  46. function historyAddBookmarks()
  47.   // no need to check gHistoryTree.view.selection.count
  48.   // node will be null if there is a multiple selection 
  49.   // or if the selected item is not a URI node
  50.   var node = gHistoryTree.selectedNode;
  51.   if (node && PlacesUtils.nodeIsURI(node))
  52.     PlacesUIUtils.showMinimalAddBookmarkUI(PlacesUtils._uri(node.uri), node.title);
  53. }
  54.  
  55. function searchHistory(aInput)
  56. {
  57.   var query = PlacesUtils.history.getNewQuery();
  58.   var options = PlacesUtils.history.getNewQueryOptions();
  59.  
  60.   const NHQO = Ci.nsINavHistoryQueryOptions;
  61.   var sortingMode;
  62.   var resultType;
  63.  
  64.   if (aInput) {
  65.     query.searchTerms = aInput;
  66.     sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
  67.     resultType = NHQO.RESULTS_AS_URI;
  68.   }
  69.   else {
  70.     switch (gHistoryGrouping) {
  71.       case "visited":
  72.         resultType = NHQO.RESULTS_AS_URI;
  73.         sortingMode = NHQO.SORT_BY_VISITCOUNT_DESCENDING;
  74.         break; 
  75.       case "lastvisited":
  76.         resultType = NHQO.RESULTS_AS_URI;
  77.         sortingMode = NHQO.SORT_BY_DATE_DESCENDING;
  78.         break; 
  79.       case "dayandsite":
  80.         resultType = NHQO.RESULTS_AS_DATE_SITE_QUERY;
  81.         break;
  82.       case "site":
  83.         resultType = NHQO.RESULTS_AS_SITE_QUERY;
  84.         sortingMode = NHQO.SORT_BY_TITLE_ASCENDING;
  85.         break;
  86.       case "day":
  87.       default:
  88.         resultType = NHQO.RESULTS_AS_DATE_QUERY;
  89.         break;
  90.     }
  91.   }
  92.  
  93.   options.sortingMode = sortingMode;
  94.   options.resultType = resultType;
  95.  
  96.   // call load() on the tree manually
  97.   // instead of setting the place attribute in history-panel.xul
  98.   // otherwise, we will end up calling load() twice
  99.   gHistoryTree.load([query], options);
  100. }
  101.  
  102. window.addEventListener("SidebarFocused",
  103.                         function()
  104.                           gSearchBox.focus(),
  105.                         false);
  106.