Search UI tweaks.

This commit is contained in:
rjc%netscape.com 1999-08-19 19:58:26 +00:00
parent e02585cd7d
commit 6cc3e0e601
8 changed files with 376 additions and 25 deletions

View File

@ -1,5 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
<?xml-stylesheet href="internet.css" type="text/css"?>
<?xml-stylesheet href="internetresults.css" type="text/css"?>
@ -8,6 +9,8 @@
<!ENTITY window.title.label "Search Internet Results">
<!ENTITY results.title.label "Results:">
<!ENTITY resultsites.title.label "Search Sites:">
<!ENTITY name.column.label "Name">
<!ENTITY relevance.column.label "Relevance">
<!ENTITY site.column.label "Internet Site">
@ -26,6 +29,43 @@
<titledbutton style="width: 100%;" id="internetresultssummary" value="&results.title.label;" />
</box>
<box align="horizontal" style="width: 100%;" >
<tree id="NC:SearchResultsSitesRoot" style="height: 64;" flex="100%" datasources="rdf:internetsearch">
<template>
<treechildren>
<treeitem>
<treerow>
<treecell uri="...">
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name" align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</template>
<treecol id="SiteNameColumn" rdf:resource="http://home.netscape.com/NC-rdf#SiteNameColumn"/>
<treehead>
<treerow>
<treecell resource="http://home.netscape.com/NC-rdf#SiteNameColumn" onclick="return doSort('SiteNameColumn');">
<observes element="SiteNameColumn" attribute="sortActive"/>
<observes element="SiteNameColumn" attribute="sortDirection"/>
&resultsites.title.label;
</treecell>
</treerow>
</treehead>
<treechildren>
<treeitem>
<treerow>
<treecell>
<titledbutton value="All Search Results" align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</tree>
</box>
<tree id="internetresultstree" style="height: 100%; width: 100%;" flex="100%" datasources="rdf:internetsearch" ondblclick="return OpenURL(event, event.target.parentNode.parentNode);">
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
<treecol id="RelevanceColumn" rdf:resource="http://home.netscape.com/NC-rdf#Relevance" sortActive="true" sortDirection="descending" />
@ -61,7 +101,7 @@
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Site" align="left" style="list-style-image: none;" />
</treecell>
<treecell>
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Engine" align="left" style="list-style-image: none;" />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Engine" align="left" />
</treecell>
</treerow>
</treeitem>

View File

@ -27,6 +27,10 @@ titledbutton {
background-image: inherit;
}
treeitem[loading="true"] > treerow > treecell > titledbutton {
list-style-image: url("resource:/res/rdf/loading.gif") ! important ;
}
treeitem > treerow > treecell > titledbutton[value="AOL Netfind"] {
list-style-image: url("resource:/res/rdf/datasets/AOL_NetFind.gif");
}

View File

@ -2,6 +2,166 @@
var gText = "";
var gSites = "";
function loadPage()
{
try
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var localStore = rdf.GetDataSource("rdf:local-store");
if (localStore)
{
// XXX activate last selected list of search engines
var treeNode = document.getElementById("NC:SearchEngineRoot");
var treeChildrenNode = null;
var numChildren = treeNode.childNodes.length;
for (var x = 0; x<numChildren; x++)
{
if (treeNode.childNodes[x].tagName == "treechildren")
{
treeChildrenNode = treeNode.childNodes[x];
break;
}
}
if (treeChildrenNode != null)
{
var numEngines = treeChildrenNode.childNodes.length;
dump("LoadPage(): " + numEngines + " engines.\n");
var checkedProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#checked", true);
for (var x = 0; x<numEngines; x++)
{
var treeItem = treeChildrenNode.childNodes[x];
if (!treeItem) continue;
var engineURI = treeItem.getAttribute("id");
var src = rdf.GetResource(engineURI, true);
var target = localStore.GetTarget(src, checkedProperty, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target == "true")
{
dump("loadPage(): Checking '" + engineURI + "\n");
treeItem.childNodes[0].childNodes[0].childNodes[0].checked = true;
treeItem.childNodes[0].childNodes[0].childNodes[0].setAttribute("checked", "1");
}
}
}
}
}
}
catch(ex)
{
dump("\nloadPage(): Exception.\n");
}
// check and see if we need to do an automatic search
if (window.parent)
{
var searchText = window.parent.getSearchText();
if (searchText)
{
var textNode = document.getElementById("searchtext");
if (textNode)
{
textNode.setAttribute("value", searchText);
doSearch();
}
}
}
}
function unloadPage()
{
try
{
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var localStore = rdf.GetDataSource("rdf:local-store");
if (localStore)
{
// remember last selected list of search engines
var treeNode = document.getElementById("NC:SearchEngineRoot");
var treeChildrenNode = null;
var numChildren = treeNode.childNodes.length;
for (var x = 0; x<numChildren; x++)
{
if (treeNode.childNodes[x].tagName == "treechildren")
{
treeChildrenNode = treeNode.childNodes[x];
break;
}
}
if (treeChildrenNode != null)
{
var numEngines = treeChildrenNode.childNodes.length;
dump("unloadPage(): " + numEngines + " engines.\n");
var checkedProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#checked", true);
var trueLiteral = rdf.GetLiteral("true");
var checkedFlag = false;
for (var x = 0; x<numEngines; x++)
{
var treeItem = treeChildrenNode.childNodes[x];
if (!treeItem)
{
dump("unloadPage(): Huh? treeitem is null.\n");
continue;
}
checkedFlag = false;
if (treeItem.childNodes[0].childNodes[0].childNodes[0].checked == true)
{
checkedFlag = true;
}
else if (treeItem.childNodes[0].childNodes[0].childNodes[0].getAttribute("checked") == "1")
{
checkedFlag = true;
}
var engineURI = treeItem.getAttribute("id");
var src = rdf.GetResource(engineURI, true);
if (checkedFlag == true)
{
dump("unloadPage(): Saving '" + engineURI + "'\n");
localStore.Assert(src, checkedProperty, trueLiteral, true);
}
else
{
// unassert it just in case its in the localstore, as we don't want to remember it
localStore.Unassert(src, checkedProperty, trueLiteral, true);
}
}
// XXX for now, need to force a flush
flushableStore = localStore.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
if (flushableStore)
{
flushableStore.Flush();
}
}
}
}
}
catch(ex)
{
dump("\nunloadPage(): Exception.\n");
}
}
function doSearch()
{
gText = "";
@ -35,18 +195,36 @@ function doSearch()
var foundEngine = false;
var numEngines = treeChildrenNode.childNodes.length;
dump("Found treebody, it has " + numEngines + " kids\n");
dump("doSearch(): " + numEngines + " engines.\n");
for (var x = 0; x<numEngines; x++)
{
dump("Engine: #" + x + "\n");
var treeItem = treeChildrenNode.childNodes[x];
if (!treeItem) continue;
// XXX when its fully implemented, instead use
// var engines = document.getElementsByTagName("checkbox");
if (treeItem.childNodes[0].childNodes[0].childNodes[0].getAttribute("value") == "1")
if (!treeItem)
{
dump("doSearch(): huh? treeitem is null.\n");
continue;
}
var checkedFlag = false;
if (treeItem.childNodes[0].childNodes[0].childNodes[0].checked == true)
{
checkedFlag = true;
}
else if (treeItem.childNodes[0].childNodes[0].childNodes[0].getAttribute("checked") == "1")
{
checkedFlag = true;
}
if (checkedFlag == true)
{
var engineURI = treeItem.getAttribute("id");
if (!engineURI) continue;
dump ("# " + x + ": " + engineURI + "\n");
dump ("doSearch(): Checked: # " + x + ": " + engineURI + "\n");
var searchEngineName = treeItem.childNodes[0].childNodes[1].childNodes[0].getAttribute("value");
if (searchEngineName != "")
@ -73,7 +251,7 @@ function doSearch()
if (foundEngine == false) return(false);
searchURL += "&text=" + escape(text);
dump("Internet Search URL: " + searchURL + "\n");
dump("\nInternet Search URL: " + searchURL + "\n");
// set text in results pane
var summaryNode = parent.frames[1].document.getElementById("internetresultssummary");
@ -87,7 +265,7 @@ function doSearch()
// load find URL into results pane
var resultsTree = parent.frames[1].document.getElementById("internetresultstree");
if (!resultsTree) return(false);
resultsTree.setAttribute("ref", searchURL);
resultsTree.setAttribute("ref", searchURL);
// enable "Save Search" button
var searchButton = document.getElementById("SaveSearch");
@ -101,7 +279,28 @@ function doSearch()
return(true);
}
function doUncheckAll()
function doCheck(node)
{
/* XXX due to a bug, on a mouse-click we also set the
checked attribute in the DOM so that it persists */
if (node.checked == true)
{
node.setAttribute("checked", "1");
}
else
{
node.removeAttribute("checked");
// node.setAttribute("checked", "0");
}
return(false);
}
function doCheckAll(activeFlag)
{
// get selected search engines
var treeNode = document.getElementById("NC:SearchEngineRoot");
@ -119,20 +318,44 @@ function doUncheckAll()
if (treeChildrenNode == null) return(false);
var numEngines = treeChildrenNode.childNodes.length;
dump("Found treebody, it has " + numEngines + " kids\n");
dump("doCheckAll(): " + numEngines + " engines.\n");
for (var x = 0; x<numEngines; x++)
{
var treeItem = treeChildrenNode.childNodes[x];
if (!treeItem) continue;
// XXX when its fully implemented, instead use
// var engines = document.getElementsByTagName("checkbox");
if (treeItem.childNodes[0].childNodes[0].childNodes[0].getAttribute("value") == "1")
if (!treeItem)
{
treeItem.childNodes[0].childNodes[0].childNodes[0].setAttribute("value", "0");
dump("doCheckAll(): huh? treeItem is null.\n");
continue;
}
var checkedFlag = false;
if (treeItem.childNodes[0].childNodes[0].childNodes[0].checked == true)
{
checkedFlag = true;
}
else if (treeItem.childNodes[0].childNodes[0].childNodes[0].getAttribute("checked") == "1")
{
checkedFlag = true;
}
if (checkedFlag != activeFlag)
{
treeItem.childNodes[0].childNodes[0].childNodes[0].checked = activeFlag;
if (activeFlag)
{
treeItem.childNodes[0].childNodes[0].childNodes[0].setAttribute("checked", "1");
}
else
{
treeItem.childNodes[0].childNodes[0].childNodes[0].removeAttribute("checked");
// treeItem.childNodes[0].childNodes[0].childNodes[0].setAttribute("checked", "0");
}
}
}
dump("doUncheckAll() done.\n");
dump("doCheckAll() done.\n");
return(true);
}

View File

@ -11,6 +11,7 @@
<!ENTITY checkbox.column.label "On">
<!ENTITY engine.column.label "Search Engines">
<!ENTITY checkall.button.label "Check All">
<!ENTITY uncheckall.button.label "Uncheck All">
<!ENTITY savesearch.button.label "Save Search in Bookmarks">
]>
@ -19,7 +20,7 @@
<window title="&window.title.label;" style="width:100%; height:100%; background-color:white" align="vertical"
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">
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="loadPage()" onunload="unloadPage()">
<html:script src="internet.js" />
<html:script src="shared.js" />
@ -40,10 +41,10 @@
<template>
<treechildren>
<treeitem uri="...">
<treeitem uri="..." loading="rdf:http://home.netscape.com/NC-rdf#loading" >
<treerow>
<treecell treeallowevents="true">
<checkbox value="0" />
<html:input type="checkbox" onclick="doCheck(this)" />
</treecell>
<treecell>
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name" align="left" />
@ -70,7 +71,8 @@
<box align="horizontal" style="width: 100%;" >
<spring align="horizontal" flex="100%" />
<html:input type="button" value="&uncheckall.button.label;" onclick="return doUncheckAll();" />
<html:input type="button" value="&checkall.button.label;" onclick="return doCheckAll(true);" />
<html:input type="button" value="&uncheckall.button.label;" onclick="return doCheckAll(false);" />
<html:input id="SaveSearch" type="button" disabled="true" value="&savesearch.button.label;" onclick="return saveSearch();" />
<spring align="horizontal" flex="100%" />
</box>

View File

@ -20,7 +20,7 @@ treecol[sortActive="true"] {
background-color: lightgray;
}
treeitem[container="true"][open="true"][loading="true"] > treerow > treecell > titledbutton {
treeitem[loading="true"] > treerow > treecell > titledbutton {
list-style-image: url("resource:/res/rdf/loading.gif") ! important ;
}
@ -79,3 +79,29 @@ treeitem > treerow > treecell > titledbutton {
titledbutton#bookmarks {
list-style-image:url("chrome://bookmarks/skin/bookmark-item.gif");
}
/* Icons */
treeitem > treerow > treecell > titledbutton[value="AOL Netfind"] {
list-style-image: url("resource:/res/rdf/datasets/AOL_NetFind.gif");
}
treeitem > treerow > treecell > titledbutton[value="Google"] {
list-style-image: url("resource:/res/rdf/datasets/Google.gif");
}
treeitem > treerow > treecell > titledbutton[value="GoTo.com"] {
list-style-image: url("resource:/res/rdf/datasets/GoTo.com.gif");
}
treeitem > treerow > treecell > titledbutton[value="Netscape Open Directory"] {
list-style-image: url("resource:/res/rdf/datasets/Netscape_Open_Directory.gif");
}
treeitem > treerow > treecell > titledbutton[value="Snap.com"] {
list-style-image: url("resource:/res/rdf/datasets/Snap.com.gif");
}
treeitem > treerow > treecell > titledbutton {
list-style-image: url("resource:/res/rdf/document.gif");
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
<?xml-stylesheet href="internet.css" type="text/css"?>
<?xml-stylesheet href="internetresults.css" type="text/css"?>
@ -8,6 +9,8 @@
<!ENTITY window.title.label "Search Internet Results">
<!ENTITY results.title.label "Results:">
<!ENTITY resultsites.title.label "Search Sites:">
<!ENTITY name.column.label "Name">
<!ENTITY relevance.column.label "Relevance">
<!ENTITY site.column.label "Internet Site">
@ -26,6 +29,43 @@
<titledbutton style="width: 100%;" id="internetresultssummary" value="&results.title.label;" />
</box>
<box align="horizontal" style="width: 100%;" >
<tree id="NC:SearchResultsSitesRoot" style="height: 64;" flex="100%" datasources="rdf:internetsearch">
<template>
<treechildren>
<treeitem>
<treerow>
<treecell uri="...">
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Name" align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</template>
<treecol id="SiteNameColumn" rdf:resource="http://home.netscape.com/NC-rdf#SiteNameColumn"/>
<treehead>
<treerow>
<treecell resource="http://home.netscape.com/NC-rdf#SiteNameColumn" onclick="return doSort('SiteNameColumn');">
<observes element="SiteNameColumn" attribute="sortActive"/>
<observes element="SiteNameColumn" attribute="sortDirection"/>
&resultsites.title.label;
</treecell>
</treerow>
</treehead>
<treechildren>
<treeitem>
<treerow>
<treecell>
<titledbutton value="All Search Results" align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
</tree>
</box>
<tree id="internetresultstree" style="height: 100%; width: 100%;" flex="100%" datasources="rdf:internetsearch" ondblclick="return OpenURL(event, event.target.parentNode.parentNode);">
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
<treecol id="RelevanceColumn" rdf:resource="http://home.netscape.com/NC-rdf#Relevance" sortActive="true" sortDirection="descending" />
@ -61,7 +101,7 @@
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Site" align="left" style="list-style-image: none;" />
</treecell>
<treecell>
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Engine" align="left" style="list-style-image: none;" />
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Engine" align="left" />
</treecell>
</treerow>
</treeitem>

View File

@ -1,8 +1,12 @@
function loadPage(thePage)
var gSearchStr = "";
function loadPage(thePage, searchStr)
{
var content="", results="";
gSearchStr = "";
if (thePage == "find")
{
content="find.xul";
@ -12,6 +16,11 @@ function loadPage(thePage)
{
content="internet.xul";
results="internetresults.xul";
if ((searchStr) && (searchStr != null))
{
gSearchStr = searchStr;
}
}
else if (thePage == "mail")
{
@ -39,3 +48,10 @@ function loadPage(thePage)
}
return(true);
}
function getSearchText()
{
return(gSearchStr);
}

View File

@ -17,7 +17,7 @@
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"
onload="loadPage(window.arguments[0])" >
onload="loadPage(window.arguments[0], window.arguments[1])" >
<html:script src="search.js" />