<?xml version="1.0"?> <!-- -*- Mode: SGML -*- -->
<!--

  The contents of this file are subject to the Netscape Public License
  Version 1.0 (the "NPL"); you may not use this file except in
  compliance with the NPL.  You may obtain a copy of the NPL at
  http://www.mozilla.org/NPL/

  Software distributed under the NPL is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  for the specific language governing rights and limitations under the
  NPL.

  The Initial Developer of this code under the NPL is Netscape
  Communications Corporation.  Portions created by Netscape are
  Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  Reserved.

-->

<?xml-stylesheet href="chrome:/global/skin/" type="text/css"?>
<?xml-stylesheet href="history.css" type="text/css"?>

<!DOCTYPE window
[

<!ENTITY fileMenu.label "File">
<!ENTITY newWinCmd.label "New Window">
<!ENTITY closeCmd.label ".Close">
<!ENTITY editMenu.label "Edit">
<!ENTITY undoCmd.label "Undo">
<!ENTITY redoCmd.label "Redo">
<!ENTITY cutCmd.label "Cut">
<!ENTITY copyCmd.label "Copy">
<!ENTITY pasteCmd.label "Paste">
<!ENTITY deleteCmd.label "Delete">
<!ENTITY selAllCmd.label "Select All">
<!ENTITY findHisCmd.label "Find in History...">
<!ENTITY findAgainCmd.label "Find Again...">
<!ENTITY historyBySite.label "History By Site">
<!ENTITY historyByDate.label "History By Date">
<!ENTITY historyWindowTitle.label "History">
]>

<window title="&historyWindowTitle.label;"
  xmlns:html="http://www.w3.org/TR/REC-html40"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <html:script>

  function HistoryNewWindow()
  {
    var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
    if (!toolkitCore) {
      toolkitCore = new ToolkitCore();
      if (toolkitCore) {
        toolkitCore.Init("ToolkitCore");
      }
    }
    if (toolkitCore) {
      toolkitCore.ShowWindow("resource:/res/rdf/history.xul",
                             window);
    }
  }

  function OpenURL(event,node)
  {

    url = node.getAttribute('id');

    // Ignore "NC:" urls.
    if (url.substring(0, 3) == "NC:") {
      return false;
    }

    /*window.open(url,'bookmarks');*/
    var toolkitCore = XPAppCoresManager.Find("ToolkitCore");
    if (!toolkitCore) {
      toolkitCore = new ToolkitCore();
      if (toolkitCore) {
        toolkitCore.Init("ToolkitCore");
      }
    }
    if (toolkitCore) {
      toolkitCore.ShowWindow(url,window);
    }

    dump("OpenURL(" + url + ")\n");

    return true;
  }

function doSort(sortColName)
{
        var node = document.getElementById(sortColName);
	// determine column resource to sort on
	var sortResource = node.getAttribute('resource');
	if (!node)	return(false);

        var sortDirection="ascending";
        var isSortActive = node.getAttribute('sortActive');
        if (isSortActive == "true")
        {
                var currentDirection = node.getAttribute('sortDirection');
                if (currentDirection == "ascending")
                        sortDirection = "descending";
                else if (currentDirection == "descending")
                        sortDirection = "natural";
                else    sortDirection = "ascending";
        }

	// get RDF Core service
	var rdfCore = XPAppCoresManager.Find("RDFCore");
	if (!rdfCore)
	{
		rdfCore = new RDFCore();
		if (!rdfCore)
		{
			return(false);
		}
		rdfCore.Init("RDFCore");
	}
	// sort!!!
        rdfCore.doSort(node, sortResource, sortDirection);
        return(false);
}

  </html:script>

  <menubar>
    <menu name="&fileMenu.label;">
      <menuitem name="&newWinCmd.label;" onclick="HistoryNewWindow();"/>
      <separator/>
      <menuitem name="&closeCmd.label;"/>
    </menu>
    <menu name="&editMenu.label;">
      <menuitem name="&undoCmd.label;"/>
      <menuitem name="&redoCmd.label;"/>
      <separator/>
      <menuitem name="&cutCmd.label;"/>
      <menuitem name="&copyCmd.label;"/>
      <menuitem name="&pasteCmd.label;"/>
      <menuitem name="&deleteCmd.label;"/>
      <menuitem name="&selAllCmd.label;"/>
      <separator/>
      <menuitem name="&findHisCmd.label;"/>
      <menuitem name="&findAgainCmd.label;"/>
    </menu>
  </menubar>

<tree rdf:datasources="rdf:history"
      ondblclick="return OpenURL(event,event.target.parentNode.parentNode);">

  <template>
    <rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator"
          rootcontainment="treechildren" subcontainment="treechildren">
      <treeitem uri="...">
        <treerow>
          <treecell>
            <html:hr width="75%" align="center" size="1" />
          </treecell>
          <treecell></treecell>
          <treecell></treecell>
        </treerow>
      </treeitem>  		
    </rule>
  	
    <rule rootcontainment="treechildren" subcontainment="treechildren">
      <treeitem uri="...">
        <treerow>
          <treecell>
            <treeindentation />
            <titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name" align="right" />
          </treecell>

          <treecell>
            <titledbutton value="rdf:http://home.netscape.com/NC-rdf#URL" align="right"
                          style="list-style-image: none;" />
          </treecell>

          <treecell>
            <titledbutton value="rdf:http://home.netscape.com/NC-rdf#ShortcutURL" align="right"
                          style="list-style-image: none;" />
          </treecell>
        </treerow>
      </treeitem>
    </rule>
  </template>

  <treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
  <treecol id="URLColumn" rdf:resource="http://home.netscape.com/NC-rdf#URL"/>
  <treecol id="ShortcutURLColumn" rdf:resource="http://home.netscape.com/NC-rdf#ShortcutURL"/>

  <treehead>
    <treerow>
      <treecell onclick="return doSort('NameColumn');">
	<xul:observes element="NameColumn" attribute="sortActive"/>
	<xul:observes element="NameColumn" attribute="sortDirection"/>
      Name</treecell>
      <treecell onclick="return doSort('URLColumn');">
	<xul:observes element="URLColumn" attribute="sortActive"/>
	<xul:observes element="URLColumn" attribute="sortDirection"/>
      URL</treecell>
      <treecell onclick="return doSort('ShortcutURLColumn');">
	<xul:observes element="ShortcutURLColumn" attribute="sortActive"/>
	<xul:observes element="ShortcutURLColumn" attribute="sortDirection"/>
      Shortcut URL</treecell>
    </treerow>
  </treehead>

  <treechildren>
    <treeitem ref="NC:HistoryBySite" open="true">
      <treerow> 
        <treecell>&historyBySite.label;</treecell>
        <treecell></treecell>
        <treecell></treecell>
      </treerow>
    </treeitem>

    <treeitem ref="NC:HistoryByDate" open="true">
      <treerow>
        <treecell>&historyByDate.label;</treecell>
        <treecell></treecell>
        <treecell></treecell>
      </treerow>
    </treeitem>
  </treechildren>
</tree>

</window>
