Bug 227053 history sidebar issues: gHistoryStatus has no properties; correctly extract the hostname from a url; don't leak observers r=timeless sr=alecf

This commit is contained in:
neil%parkwaycc.co.uk 2004-01-13 16:25:03 +00:00
Родитель fc11e70a19
Коммит c17702b3da
3 изменённых файлов: 28 добавлений и 24 удалений

Просмотреть файл

@ -30,7 +30,9 @@
<page id="history-panel" orient="vertical"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="HistoryCommonInit();" elementtofocus="historyTree">
onload="HistoryCommonInit();"
onunload="HistoryPanelUnload();"
elementtofocus="historyTree">
<stringbundle id="historyBundle"
src="chrome://communicator/locale/history/history.properties"/>
<commandset id="selectEditMenuItems">

Просмотреть файл

@ -42,6 +42,7 @@ var gLastHostname;
var gLastDomain;
var gGlobalHistory;
var gPrefService;
var gIOService;
var gDeleteByHostname;
var gDeleteByDomain;
var gHistoryBundle;
@ -49,12 +50,6 @@ var gHistoryStatus;
var gHistoryGrouping = "";
var gWindowManager = null;
function HistoryWindowInit()
{
HistoryCommonInit();
gHistoryTree.focus();
}
function HistoryCommonInit()
{
gHistoryTree = document.getElementById("historyTree");
@ -113,9 +108,19 @@ function HistoryCommonInit()
}
SortInNewDirection(find_sort_direction(find_sort_column()));
if (gHistoryStatus)
gHistoryTree.focus();
gHistoryTree.treeBoxObject.view.selection.select(0);
}
function HistoryPanelUnload()
{
var pb = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var pbi = pb.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
pbi.removeObserver("browser.history.grouping", groupObserver, false);
}
function updateHistoryCommands()
{
goUpdateCommand("cmd_deleteByHostname");
@ -149,27 +154,24 @@ function historyOnSelect()
var match;
var currentIndex = gHistoryTree.currentIndex;
var rowIsContainer = gHistoryGrouping != "none" && currentIndex >= 0 && isContainer(gHistoryTree, currentIndex);
var url = rowIsContainer ? gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL") : null;
var url = rowIsContainer ? "" : gHistoryTree.treeBoxObject.view.getCellText(currentIndex, "URL");
if (url) {
// matches scheme://(hostname)...
match = url.match(/^.*?:\/\/(?:([^\/:]*)(?::([^\/:]*))?@)?([^\/:]*)(?::([^\/:]*))?(.*)$/);
if (!gIOService)
gIOService = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);
try {
gLastHostname = gIOService.newURI(url, null, null).host;
// matches the last foo.bar in foo.bar or baz.foo.bar
match = gLastHostname.match(/([^.]+\.[^.]+$)/);
if (match)
gLastDomain = match[1];
} catch (e) {}
}
if (match && match.length>1)
gLastHostname = match[3];
if (gHistoryStatus)
gHistoryStatus.label = url;
}
else {
gHistoryStatus.label = "";
}
if (gLastHostname) {
// matches the last foo.bar in foo.bar or baz.foo.bar
match = gLastHostname.match(/([^.]+\.[^.]+$)/);
if (match)
gLastDomain = match[1];
}
document.commandDispatcher.updateCommands("select");
}

Просмотреть файл

@ -32,7 +32,7 @@
<!DOCTYPE window SYSTEM "chrome://communicator/locale/history/history.dtd" >
<window title="&historyWindowTitle.label;" id="history-window"
onload="HistoryWindowInit();"
onload="HistoryCommonInit();"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
width="500" height="400"
persist="width height screenX screenY sizemode"