rem: var promptStr = bundle.GetStringFromName("NewBookmarkURLPrompt"); urlVal = prompt(promptStr, ""); if (!urlVal || urlVal=="")	return(false); 
add: while (true) { var promptStr = bundle.GetStringFromName("NewBookmarkURLPrompt"); urlVal = prompt(promptStr, ""); if (!urlVal || urlVal=="")	return(false);   var colonOffset = urlVal.indexOf(":"); if (colonOffset > 0)	break; alert(bundle.GetStringFromName("NeedValidURL")); } 
context: function doContextCmd(cmdName){	debug("doContextCmd start: cmd='" + cmdName + "'");	var bundle = srGetStrBundle("chrome://bookmarks/locale/bookmark.properties");	// do some prompting/confirmation for various bookmark commands that we know about;	// if we have values to pass it, they are added to the arguments array	var	nameVal = "", urlVal = "";	if (cmdName == "http://home.netscape.com/NC-rdf#command?cmd=newbookmark")	{		var promptStr = bundle.GetStringFromName("NewBookmarkURLPrompt");		urlVal = prompt(promptStr, "");		if (!urlVal || urlVal=="")	return(false);		promptStr = bundle.GetStringFromName("NewBookmarkNamePrompt");		nameVal = prompt(promptStr, "");		if (!nameVal || nameVal=="")	return(false);	}	else if (cmdName == "http://home.netscape.com/NC-rdf#command?cmd=newfolder")	{		var promptStr = bundle.GetStringFromName("NewFolderNamePrompt");		nameVal = prompt(promptStr, "");		if (!nameVal || nameVal=="")	return(false);	}	else if ((cmdName == "http://home.netscape.com/NC-rdf#command?cmd=deletebookmark") ||		 (cmdName == "http://home.netscape.com/NC-rdf#command?cmd=deletebookmarkfolder") ||		 (cmdName == "http://home.netscape.com/NC-rdf#command?cmd=deletebookmarkseparator"))	{		var promptStr = bundle.GetStringFromName("DeleteItems");		if (!confirm(promptStr))	return(false);	}	var treeNode = document.getElementById("bookmarksTree");	if (!treeNode)    return(false);	var db = treeNode.database;	if (!db)    return(false);	var compositeDB = db.QueryInterface(Components.interfaces.nsIRDFDataSource);	if (!compositeDB)    return(false);	var isupports = Components.classes["component://netscape/rdf/rdf-service"].getService();	if (!isupports)    return(false);	var rdf = isupports.QueryInterface(Components.interfaces.nsIRDFService);	if (!rdf)    return(false);	// need a resource for the command	var cmdResource = rdf.GetResource(cmdName);	if (!cmdResource)        return(false);	cmdResource = cmdResource.QueryInterface(Components.interfaces.nsIRDFResource);	if (!cmdResource)        return(false);	// set up selection nsISupportsArray	var selectionInstance = Components.classes["component://netscape/supports-array"].createInstance();	var selectionArray = selectionInstance.QueryInterface(Components.interfaces.nsISupportsArray);	// set up arguments nsISupportsArray	var argumentsInstance = Components.classes["component://netscape/supports-array"].createInstance();	var argumentsArray = argumentsInstance.QueryInterface(Components.interfaces.nsISupportsArray);	// get various arguments (parent, name)	var parentArc = rdf.GetResource("http://home.netscape.com/NC-rdf#parent");	if (!parentArc)	return(false);	var nameArc = rdf.GetResource("http://home.netscape.com/NC-rdf#Name");	if (!nameArc)	return(false);	var urlArc = rdf.GetResource("http://home.netscape.com/NC-rdf#URL");	if (!urlArc)	return(false);	var select_list = treeNode.selectedItems;	debug("# of Nodes selected: " + select_list.length);	if (select_list.length < 1)	{		// if nothing is selected, default to using the "ref" on the root of the tree		var	uri = treeNode.getAttribute("ref");		if (!uri || uri=="")    return(false);		var rdfNode = rdf.GetResource(uri);		// add node into selection array		if (rdfNode)		{			selectionArray.AppendElement(rdfNode);		}		// add singular arguments into arguments array		if ((nameVal) && (nameVal != ""))		{			var nameLiteral = rdf.GetLiteral(nameVal);			if (!nameLiteral)	return(false);			argumentsArray.AppendElement(nameArc);			argumentsArray.AppendElement(nameLiteral);		}		if ((urlVal) && (urlVal != ""))		{			var urlLiteral = rdf.GetLiteral(urlVal);			if (!urlLiteral)	return(false);			argumentsArray.AppendElement(urlArc);			argumentsArray.AppendElement(urlLiteral);		}	}	else for (var nodeIndex=0; nodeIndex<select_list.length; nodeIndex++)	{		var node = select_list[nodeIndex];		if (!node)    break;		var	uri = node.getAttribute("ref");		if ((uri) || (uri == ""))		{			uri = node.getAttribute("id");		}		if (!uri)    return(false);		var rdfNode = rdf.GetResource(uri);		if (!rdfNode)    break;		// add node into selection array		selectionArray.AppendElement(rdfNode);		// get the parent's URI		var parentURI="";		var	theParent = node;		while (theParent)		{			theParent = theParent.parentNode;			parentURI = theParent.getAttribute("ref");			if ((!parentURI) || (parentURI == ""))			{				parentURI = theParent.getAttribute("id");			}			if (parentURI != "")	break;		}		if (parentURI == "")    return(false);		var parentNode = rdf.GetResource(parentURI, true);		if (!parentNode)	return(false);		// add multiple arguments into arguments array		argumentsArray.AppendElement(parentArc);		argumentsArray.AppendElement(parentNode);		if ((nameVal) && (nameVal != ""))		{			var nameLiteral = rdf.GetLiteral(nameVal);			if (!nameLiteral)	return(false);			argumentsArray.AppendElement(nameArc);			argumentsArray.AppendElement(nameLiteral);		}		if ((urlVal) && (urlVal != ""))		{			var urlLiteral = rdf.GetLiteral(urlVal);			if (!urlLiteral)	return(false);			argumentsArray.AppendElement(urlArc);			argumentsArray.AppendElement(urlLiteral);		}	}	// do the command	compositeDB.DoCommand( selectionArray, cmdResource, argumentsArray );	debug("doContextCmd ends.");	return(true);}
meta: 9421	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/9421/03d3b65f7ae94f4df15a98681d9aecbd3bf05013/bookmarks.js/clean/suite/common/bookmarks/bookmarks.js