2006-07-27 18:54:23 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2006-07-27 18:50:16 +04:00
|
|
|
*
|
2006-07-27 18:54:23 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
2006-07-27 18:50:16 +04:00
|
|
|
*
|
2006-07-27 18:54:23 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2006-07-27 18:50:16 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2006-07-27 18:54:23 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2006-07-27 18:50:16 +04:00
|
|
|
*
|
2006-07-27 18:50:24 +04:00
|
|
|
* Contributor(s):
|
|
|
|
* Alec Flett <alecf@netscape.com>
|
2006-07-27 18:54:23 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-07-27 18:50:16 +04:00
|
|
|
// The history window uses JavaScript in bookmarks.js too.
|
1999-08-05 09:11:42 +04:00
|
|
|
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
var gHistoryOutliner;
|
2006-07-27 18:52:30 +04:00
|
|
|
var gLastHostname;
|
|
|
|
var gLastDomain;
|
|
|
|
var gGlobalHistory;
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
var gPrefService;
|
2006-07-27 18:52:30 +04:00
|
|
|
var gDeleteByHostname;
|
|
|
|
var gDeleteByDomain;
|
|
|
|
var gHistoryBundle;
|
2006-07-27 18:53:50 +04:00
|
|
|
var gHistoryStatus;
|
2006-07-27 18:54:12 +04:00
|
|
|
var gWindowManager = null;
|
2006-07-27 18:52:30 +04:00
|
|
|
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
function HistoryInit()
|
|
|
|
{
|
|
|
|
gHistoryOutliner = document.getElementById("historyOutliner");
|
2006-07-27 18:53:49 +04:00
|
|
|
gDeleteByHostname = document.getElementById("menu_deleteByHostname");
|
|
|
|
gDeleteByDomain = document.getElementById("menu_deleteByDomain");
|
2006-07-27 18:52:30 +04:00
|
|
|
gHistoryBundle = document.getElementById("historyBundle");
|
2006-07-27 18:53:50 +04:00
|
|
|
gHistoryStatus = document.getElementById("statusbar-display");
|
2006-07-27 18:53:34 +04:00
|
|
|
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
var outlinerController = new nsOutlinerController(gHistoryOutliner, document.getElementById('historyOutlinerBody'));
|
2006-07-27 18:52:30 +04:00
|
|
|
var historyController = new nsHistoryController;
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
gHistoryOutliner.controllers.appendController(historyController);
|
2006-07-27 18:53:34 +04:00
|
|
|
|
2006-07-27 18:54:06 +04:00
|
|
|
if ("arguments" in window && window.arguments[0] && window.arguments.length >= 1) {
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
// We have been supplied a resource URI to root the tree on
|
|
|
|
var uri = window.arguments[0];
|
|
|
|
setRoot(uri);
|
|
|
|
if (uri.substring(0,5) == "find:") {
|
|
|
|
// Update the windowtype so that future searches are directed
|
|
|
|
// there and the window is not re-used for bookmarks.
|
|
|
|
var windowNode = document.getElementById("history-window");
|
|
|
|
windowNode.setAttribute("windowtype", "history:searchresults");
|
|
|
|
}
|
2006-07-27 18:54:11 +04:00
|
|
|
document.getElementById("groupingMenu").setAttribute("hidden", "true");
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
}
|
2006-07-27 18:54:11 +04:00
|
|
|
else {
|
|
|
|
gPrefService = Components.classes["@mozilla.org/preferences;1"]
|
|
|
|
.getService(Components.interfaces.nsIPref);
|
|
|
|
try {
|
|
|
|
var grouping = gPrefService.GetCharPref("browser.history.grouping");
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
grouping = "";
|
|
|
|
}
|
|
|
|
GroupBy(grouping);
|
|
|
|
if (gHistoryStatus) { // must be the window
|
|
|
|
switch(grouping) {
|
|
|
|
case "site":
|
|
|
|
document.getElementById("groupBySite").setAttribute("checked", "true");
|
|
|
|
break;
|
|
|
|
case "none":
|
|
|
|
document.getElementById("groupByNone").setAttribute("checked", "true");
|
|
|
|
break;
|
|
|
|
case "day":
|
|
|
|
default:
|
|
|
|
document.getElementById("groupByDay").setAttribute("checked", "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
gHistoryOutliner.focus();
|
|
|
|
gHistoryOutliner.outlinerBoxObject.view.selection.select(0);
|
1999-08-05 09:11:42 +04:00
|
|
|
}
|
1999-08-20 02:02:40 +04:00
|
|
|
|
2006-07-27 18:52:30 +04:00
|
|
|
function updateHistoryCommands()
|
|
|
|
{
|
|
|
|
goUpdateCommand("cmd_deleteByHostname");
|
|
|
|
goUpdateCommand("cmd_deleteByDomain");
|
|
|
|
}
|
|
|
|
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
function historyOnSelect()
|
2006-07-27 18:52:30 +04:00
|
|
|
{
|
|
|
|
// every time selection changes, save the last hostname
|
|
|
|
gLastHostname = "";
|
|
|
|
gLastDomain = "";
|
2006-07-27 18:52:31 +04:00
|
|
|
var match;
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
var currentIndex = gHistoryOutliner.currentIndex;
|
|
|
|
var rowIsContainer = isContainer(gHistoryOutliner, currentIndex);
|
|
|
|
var url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
|
|
|
|
|
|
|
|
if (url && !rowIsContainer) {
|
2006-07-27 18:52:30 +04:00
|
|
|
// matches scheme://(hostname)...
|
2006-07-27 18:52:31 +04:00
|
|
|
match = url.match(/.*:\/\/([^\/:]*)/);
|
2006-07-27 18:53:34 +04:00
|
|
|
|
2006-07-27 18:52:30 +04:00
|
|
|
if (match && match.length>1)
|
|
|
|
gLastHostname = match[1];
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
|
2006-07-27 18:53:51 +04:00
|
|
|
if (gHistoryStatus)
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
gHistoryStatus.label = url;
|
|
|
|
}
|
|
|
|
else {
|
2006-07-27 18:53:51 +04:00
|
|
|
if (gHistoryStatus)
|
|
|
|
gHistoryStatus.label = "";
|
2006-07-27 18:52:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gLastHostname) {
|
|
|
|
// matches the last foo.bar in foo.bar or baz.foo.bar
|
2006-07-27 18:52:31 +04:00
|
|
|
match = gLastHostname.match(/([^.]+\.[^.]+$)/);
|
2006-07-27 18:52:30 +04:00
|
|
|
if (match)
|
|
|
|
gLastDomain = match[1];
|
|
|
|
}
|
|
|
|
document.commandDispatcher.updateCommands("select");
|
|
|
|
}
|
|
|
|
|
|
|
|
function nsHistoryController()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsHistoryController.prototype =
|
|
|
|
{
|
|
|
|
supportsCommand: function(command)
|
|
|
|
{
|
|
|
|
switch(command) {
|
|
|
|
case "cmd_deleteByHostname":
|
|
|
|
case "cmd_deleteByDomain":
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
isCommandEnabled: function(command)
|
|
|
|
{
|
|
|
|
var enabled = false;
|
|
|
|
var stringId;
|
|
|
|
var text;
|
|
|
|
switch(command) {
|
|
|
|
case "cmd_deleteByHostname":
|
|
|
|
if (gLastHostname) {
|
|
|
|
stringId = "deleteHost";
|
|
|
|
enabled = true;
|
|
|
|
} else {
|
|
|
|
stringId = "deleteHostNoSelection";
|
|
|
|
}
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
text = gHistoryBundle.stringBundle.formatStringFromName(stringId,
|
|
|
|
[ gLastHostname ], 1);
|
2006-07-27 18:53:34 +04:00
|
|
|
gDeleteByHostname.setAttribute("label", text);
|
2006-07-27 18:52:30 +04:00
|
|
|
break;
|
|
|
|
case "cmd_deleteByDomain":
|
|
|
|
if (gLastDomain) {
|
|
|
|
stringId = "deleteDomain";
|
|
|
|
enabled = true;
|
|
|
|
} else {
|
|
|
|
stringId = "deleteDomainNoSelection";
|
|
|
|
}
|
|
|
|
text = gHistoryBundle.stringBundle.formatStringFromName(stringId,
|
|
|
|
[ gLastDomain ], 1);
|
2006-07-27 18:53:34 +04:00
|
|
|
gDeleteByDomain.setAttribute("label", text);
|
2006-07-27 18:52:30 +04:00
|
|
|
}
|
|
|
|
return enabled;
|
|
|
|
},
|
|
|
|
|
|
|
|
doCommand: function(command)
|
|
|
|
{
|
|
|
|
switch(command) {
|
|
|
|
case "cmd_deleteByHostname":
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
if (!gGlobalHistory)
|
|
|
|
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIBrowserHistory);
|
2006-07-27 18:53:25 +04:00
|
|
|
gGlobalHistory.removePagesFromHost(gLastHostname, false)
|
2006-07-27 18:52:30 +04:00
|
|
|
return true;
|
2006-07-27 18:53:34 +04:00
|
|
|
|
2006-07-27 18:52:30 +04:00
|
|
|
case "cmd_deleteByDomain":
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
if (!gGlobalHistory)
|
|
|
|
gGlobalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIBrowserHistory);
|
2006-07-27 18:53:25 +04:00
|
|
|
gGlobalHistory.removePagesFromHost(gLastDomain, true)
|
2006-07-27 18:52:30 +04:00
|
|
|
return true;
|
2006-07-27 18:53:34 +04:00
|
|
|
|
2006-07-27 18:52:30 +04:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-27 18:50:17 +04:00
|
|
|
var historyDNDObserver = {
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
onDragStart: function (aEvent, aXferData, aDragAction)
|
|
|
|
{
|
|
|
|
var currentIndex = gHistoryOutliner.currentIndex;
|
|
|
|
if (isContainer(gHistoryOutliner, currentIndex))
|
|
|
|
return false;
|
|
|
|
var url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
|
|
|
|
var title = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "Name");
|
|
|
|
|
|
|
|
var htmlString = "<A HREF='" + url + "'>" + title + "</A>";
|
|
|
|
aXferData.data = new TransferData();
|
|
|
|
aXferData.data.addDataForFlavour("text/unicode", url);
|
|
|
|
aXferData.data.addDataForFlavour("text/html", htmlString);
|
|
|
|
aXferData.data.addDataForFlavour("text/x-moz-url", url + "\n" + title);
|
|
|
|
}
|
2006-07-27 18:50:22 +04:00
|
|
|
};
|
2006-07-27 18:50:25 +04:00
|
|
|
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
function OpenURL(aInNewWindow)
|
2006-07-27 18:50:25 +04:00
|
|
|
{
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
var currentIndex = gHistoryOutliner.currentIndex;
|
|
|
|
if (isContainer(gHistoryOutliner, currentIndex))
|
2006-07-27 18:50:25 +04:00
|
|
|
return false;
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
|
|
|
|
var url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
|
2006-07-27 18:50:25 +04:00
|
|
|
|
2006-07-27 18:54:12 +04:00
|
|
|
if (aInNewWindow) {
|
|
|
|
var count = gHistoryOutliner.outlinerBoxObject.view.selection.count;
|
|
|
|
if (count == 1)
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );
|
2006-07-27 18:54:12 +04:00
|
|
|
else {
|
|
|
|
var min = new Object();
|
|
|
|
var max = new Object();
|
|
|
|
var rangeCount = gHistoryOutliner.outlinerBoxObject.view.selection.getRangeCount();
|
|
|
|
for (var i = 0; i < rangeCount; ++i) {
|
|
|
|
gHistoryOutliner.outlinerBoxObject.view.selection.getRangeAt(i, min, max);
|
|
|
|
for (var k = max.value; k >= min.value; --k) {
|
|
|
|
url = gHistoryOutliner.outlinerBoxObject.view.getCellText(k, "URL");
|
|
|
|
window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-27 18:53:34 +04:00
|
|
|
else
|
2006-07-27 18:53:24 +04:00
|
|
|
openTopWin(url);
|
2006-07-27 18:50:26 +04:00
|
|
|
return true;
|
2006-07-27 18:50:25 +04:00
|
|
|
}
|
2006-07-27 18:54:05 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Root the tree on a given URI (used for displaying search results)
|
|
|
|
*/
|
|
|
|
function setRoot(root)
|
|
|
|
{
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
var windowNode = document.getElementById("history-window");
|
|
|
|
windowNode.setAttribute("title", gHistoryBundle.getString("search_results_title"));
|
|
|
|
document.getElementById("historyOutlinerBody").setAttribute("ref", root);
|
2006-07-27 18:54:05 +04:00
|
|
|
}
|
|
|
|
|
History should use outliner, provide a way to sort/view history the old way, win32 classic should use +/- twisties (73857, 71947, 80846, also fixes 66907, 59814, 71029, 48864, 69260, others). r=alecf sr=ben
2006-07-27 18:54:10 +04:00
|
|
|
function GroupBy(groupingType)
|
|
|
|
{
|
|
|
|
var outlinerBody = document.getElementById("historyOutlinerBody");
|
|
|
|
switch(groupingType) {
|
|
|
|
case "day":
|
|
|
|
outlinerBody.setAttribute("ref", "NC:HistoryByDate");
|
|
|
|
break;
|
|
|
|
case "site":
|
|
|
|
outlinerBody.setAttribute("ref", "find:groupby=hostname");
|
|
|
|
break;
|
|
|
|
case "none":
|
|
|
|
outlinerBody.setAttribute("ref", "NC:HistoryRoot");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
gPrefService.SetCharPref("browser.history.grouping", groupingType);
|
|
|
|
}
|
2006-07-27 18:54:12 +04:00
|
|
|
|
|
|
|
function historyAddBookmarks()
|
|
|
|
{
|
|
|
|
var count = gHistoryOutliner.outlinerBoxObject.view.selection.count;
|
|
|
|
var url;
|
|
|
|
var title;
|
|
|
|
if (count == 1) {
|
|
|
|
var currentIndex = gHistoryOutliner.currentIndex;
|
|
|
|
url = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "URL");
|
|
|
|
title = gHistoryOutliner.outlinerBoxObject.view.getCellText(currentIndex, "Name");
|
|
|
|
BookmarksUtils.addBookmark(url, title, undefined, true);
|
|
|
|
}
|
|
|
|
else if (count > 1) {
|
|
|
|
var min = new Object();
|
|
|
|
var max = new Object();
|
|
|
|
var rangeCount = gHistoryOutliner.outlinerBoxObject.view.selection.getRangeCount();
|
|
|
|
for (var i = 0; i < rangeCount; ++i) {
|
|
|
|
gHistoryOutliner.outlinerBoxObject.view.selection.getRangeAt(i, min, max);
|
|
|
|
for (var k = max.value; k >= min.value; --k) {
|
|
|
|
url = gHistoryOutliner.outlinerBoxObject.view.getCellText(k, "URL");
|
|
|
|
title = gHistoryOutliner.outlinerBoxObject.view.getCellText(k, "Name");
|
|
|
|
BookmarksUtils.addBookmark(url, title, undefined, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function updateItems()
|
|
|
|
{
|
|
|
|
var count = gHistoryOutliner.outlinerBoxObject.view.selection.count;
|
|
|
|
var openItem = document.getElementById("miOpen");
|
|
|
|
var openItemInNewWindow = document.getElementById("miOpenInNewWindow");
|
|
|
|
if (count > 1) {
|
|
|
|
document.getElementById("miAddBookmark").setAttribute("label", document.getElementById('multipleBookmarks').getAttribute("label"));
|
|
|
|
var min = new Object();
|
|
|
|
var max = new Object();
|
|
|
|
var rangeCount = gHistoryOutliner.outlinerBoxObject.view.selection.getRangeCount();
|
|
|
|
for (var i = 0; i < rangeCount; ++i) {
|
|
|
|
gHistoryOutliner.outlinerBoxObject.view.selection.getRangeAt(i, min, max);
|
|
|
|
for (var k = max.value; k >= min.value; --k) {
|
|
|
|
if (isContainer(gHistoryOutliner, k))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
openItem.setAttribute("hidden", "true");
|
|
|
|
openItem.removeAttribute("default");
|
|
|
|
openItemInNewWindow.setAttribute("default", "true");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.getElementById("miAddBookmark").removeAttribute("disabled");
|
|
|
|
document.getElementById("miAddBookmark").setAttribute("label", document.getElementById('oneBookmark').getAttribute("label"));
|
|
|
|
var currentIndex = gHistoryOutliner.currentIndex;
|
|
|
|
if (isContainer(gHistoryOutliner, currentIndex))
|
|
|
|
return false;
|
|
|
|
if (!gWindowManager) {
|
|
|
|
gWindowManager = Components.classes['@mozilla.org/rdf/datasource;1?name=window-mediator'].getService();
|
|
|
|
gWindowManager = gWindowManager.QueryInterface( Components.interfaces.nsIWindowMediator);
|
|
|
|
}
|
|
|
|
var topWindowOfType = gWindowManager.getMostRecentWindow("navigator:browser");
|
|
|
|
if (!topWindowOfType) {
|
|
|
|
openItem.setAttribute("hidden", "true");
|
|
|
|
openItem.removeAttribute("default");
|
|
|
|
openItemInNewWindow.setAttribute("default", "true");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
openItem.removeAttribute("hidden");
|
|
|
|
if (!openItem.getAttribute("default"))
|
|
|
|
openItem.setAttribute("default", "true");
|
|
|
|
openItemInNewWindow.removeAttribute("default");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|