gecko-dev/xpfe/components/search/resources/internet.js

103 lines
2.4 KiB
JavaScript
Raw Normal View History

1999-06-15 05:14:37 +00:00
var gText = "";
var gSites = "";
1999-08-19 19:58:26 +00:00
function loadPage()
{
// 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 doCheckAll(activeFlag)
1999-06-15 05:14:37 +00:00
{
// get selected search engines
1999-10-06 03:33:28 +00:00
var treeNode = document.getElementById("searchengines");
1999-08-05 23:05:19 +00:00
if (!treeNode) return(false);
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) return(false);
1999-06-15 05:14:37 +00:00
1999-08-05 23:05:19 +00:00
var numEngines = treeChildrenNode.childNodes.length;
1999-08-19 19:58:26 +00:00
dump("doCheckAll(): " + numEngines + " engines.\n");
1999-06-15 05:14:37 +00:00
for (var x = 0; x<numEngines; x++)
{
1999-08-05 23:05:19 +00:00
var treeItem = treeChildrenNode.childNodes[x];
1999-08-19 19:58:26 +00:00
if (!treeItem)
{
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)
1999-08-05 23:05:19 +00:00
{
1999-08-19 19:58:26 +00:00
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");
}
1999-08-05 23:05:19 +00:00
}
1999-06-15 05:14:37 +00:00
}
1999-08-19 19:58:26 +00:00
dump("doCheckAll() done.\n");
1999-06-15 05:14:37 +00:00
return(true);
}
1999-06-16 01:47:02 +00:00
function saveSearch()
{
var resultsTree = parent.frames[1].document.getElementById("internetresultstree");
if (!resultsTree) return(false);
var searchURL = resultsTree.getAttribute("ref");
if ((!searchURL) || (searchURL == "")) return(false);
1999-06-16 01:47:02 +00:00
dump("Bookmark search URL: " + searchURL + "\n");
var bmks = Components.classes["component://netscape/browser/bookmarks-service"].getService();
if (bmks) bmks = bmks.QueryInterface(Components.interfaces.nsIBookmarksService);
var searchTitle = "Search: '" + gText + "' using " + gSites;
if (bmks) bmks.AddBookmark(searchURL, searchTitle, bmks.BOOKMARK_SEARCH_TYPE, null);
1999-06-16 01:47:02 +00:00
return(true);
2000-02-16 03:40:47 +00:00
}