context: function saveSearch(){	var resultsTree = document.getElementById("Tree");	if( !resultsTree)	return(false);	var ds = resultsTree.database;	if (!ds)		return(false);	var	lastSearchURI="";	var	lastSearchText="";	var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();	if (rdf)   rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);	if (rdf)	{		var source = rdf.GetResource( "NC:LastSearchRoot", true);		var childProperty;		var target;		// look for last search URI		childProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#ref", true);		target = ds.GetTarget(source, childProperty, true);		if (target)	target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);		if (target)	target = target.Value;		if (target && target != "")		{			lastSearchURI = target;			debug("Bookmark search  URL: '" + lastSearchURI + "'\n");		}		// look for last search text		childProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#LastText", true);		target = ds.GetTarget(source, childProperty, true);		if (target)	target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);		if (target)	target = target.Value;		if (target && target != "")		{			// convert pluses (+) back to spaces			target = target.replace(/+/i, " ");			lastSearchText = unescape(target);			debug("Bookmark search Name: '" + lastSearchText + "'\n");		}	}	if ((lastSearchURI == null) || (lastSearchURI == ""))	return(false);// 	rjc says: if lastSearchText is empty/null, that's still OK, synthesize the text	if ((lastSearchText == null) || (lastSearchText == ""))	{		lastSearchText = lastSearchURI;		var siteOffset = lastSearchText.indexOf("://");		if (siteOffset > 0)		{			siteOffset += 3;			var endOffset = lastSearchText.indexOf("/", siteOffset);			if (endOffset > 0)			{				lastSearchText = lastSearchText.substr(0, endOffset+1);			}		}	}	var bmks = Components.classes["component://netscape/browser/bookmarks-service"].getService();	if (bmks)	bmks = bmks.QueryInterface(Components.interfaces.nsIBookmarksService);	var textNode = document.getElementById("sidebar-search-text");	if( !textNode )		return(false);	var searchTitle = "Search: '" + lastSearchText + "'";	// using " + gSites;	if (bmks)	bmks.AddBookmark(lastSearchURI, searchTitle, bmks.BOOKMARK_SEARCH_TYPE, null);	return(true);}
meta: 5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5459/d3e0de7b06190a2b947be90b94d6aff63487e60c/search-panel.js/clean/xpfe/components/search/resources/search-panel.js