rem: reloadGrid(); 
context: function analizeAddNodeResponse(data) {		var str = '';	if(data.success) {		str = data.content;		var tmpStr=str.substring(0,ADDNODES_ACTION.length+2);		if(tmpStr==ADDNODES_ACTION+"OK"){			str=str.substring(ADDNODES_ACTION.length+2,str.length);			selectedMapElemInList=0;		} else {			tmpStr=str.substring(0,ADDRANGE_ACTION.length+2)			if(tmpStr==ADDRANGE_ACTION+"OK"){				str=str.substring(ADDRANGE_ACTION.length+2,str.length);			} else {				tmpStr=str.substring(0,ADDNODES_NEIG_ACTION.length+2)				if(tmpStr==ADDNODES_NEIG_ACTION+"OK"){					str=str.substring(ADDNODES_NEIG_ACTION.length+2,str.length);				} else {					tmpStr=str.substring(0,ADDNODES_WITH_NEIG_ACTION.length+2)					if(tmpStr==ADDNODES_WITH_NEIG_ACTION+"OK"){						str=str.substring(ADDNODES_WITH_NEIG_ACTION.length+2,str.length);						selectedMapElemInList=0;					} else {						tmpStr=str.substring(0,ADDMAPS_ACTION.length+2)						if(tmpStr==ADDMAPS_ACTION+"OK"){							str=str.substring(ADDMAPS_ACTION.length+2,str.length);						} else {				    	    alert('Adding Node/s failed!');							loading--;							assertLoading();							return;						}					}				}			}		}	} else {        alert('Adding Element/s failed!');		loading--;		assertLoading();		return;	}		var nodesAdded=false;	var nodesToAdd = new Array();	var linksToAdd = new Array();	var st = str.split("&");	for(var k=1;k<st.length;k++){		var nodeToken = st[k];		var nodeST = nodeToken.split("+");		var counter=0;		//Manage errors		if (nodeST.length == 1) {			var iderror;			while(counter< nodeST.length){				var tmp = nodeST[counter];				if(counter==0) 				{					iderror=tmp;				}				counter++;				// manage loop found error				//loopfound				var tmpStr=iderror.substring(0,9);				if(tmpStr=="loopfound"){					alert("Add Map As Node: Found Loop Adding SubMap with ID " + iderror.substring(9));				}			}					}		//MapElement		if (nodeST.length > 2) {			var id,iconName=DEFAULT_ICON,labelText="",avail=100,status=0,severity=0;						while(counter< nodeST.length){				var tmp = nodeST[counter];								//read the information of the map (id, name, ecc.)							if(counter==0) 				{					id=tmp;				}				if(counter==1)					{					if(tmp!="null")						iconName=tmp;					}				if(counter==2)					{					if(tmp!="null")						labelText=tmp;					}				if(counter==3)					{					if(tmp!="null")						avail=tmp;					}									if(counter==4)					{					if(tmp!="null")						status=tmp;					}								if(counter==5)					{					if(tmp!="null")						severity=tmp;					}									//alert(counter);					counter++;			}			var semaphoreColor=getSemaphoreColorForNode(severity,avail,status);			var semaphoreFlash = getSemaphoreFlash(severity,avail);			//alert("add element " + id);			var point = getFirstFreePoint();			newElem= new MapElement(id,iconName, labelText, semaphoreColor, semaphoreFlash, point.x, point.y, mapElemDimension, status, avail,severity)			nodesToAdd.push(newElem);			//reloadGrid();			// reloadgrid se non esiste lo spazio allora !!!!!!! tratto		}		// Links		if (nodeST.length == 2) { // when find links into server response...			var id1,id2;						while(counter< nodeST.length){				var tmp = nodeST[counter];								//read the information of the map (id, name, ecc.)							if(counter==0) 				{					id1=tmp;				}				if(counter==1)				{					id2=tmp;				}				counter++;			}			var linkId = id1+"-"+id2;			linksToAdd.push(linkId);			//map.addLink(id1,id2,"green",1);		}			}	if(!nodesAdded){		nodesAdded=true;		var freePoints = null;		var alerted = false;		do{     // try to add the elements		   reloadGrid();		   freePoints = getFreePoints();		   //alert("freePoints.length="+freePoints.length+"  nodesToAdd.length="+nodesToAdd.length);		   if(freePoints.length>=nodesToAdd.length){			break;		   }else{			if(!alerted)				alert('Not enough space for all elements, theirs dimension will be decreased.');			alerted=true;		   }		   var decrResult = decreaseMapElemDim();		   if(decrResult==false) // space problems			{			alert('No space available for elements.');			return;			}	   		}while(freePoints.length<nodesToAdd.length);				for(el in map.mapElements){			map.mapElements[el].setDimension(mapElemDimension);		}		map.render();				var index = 0;		for(nd in nodesToAdd){				var point = freePoints[index++];			//alert(point.x+" "+point.y);			var me = new MapElement(nodesToAdd[nd].id, nodesToAdd[nd].icon, nodesToAdd[nd].label.text, nodesToAdd[nd].semaphore.svgNode.getAttribute("fill"), getSemaphoreFlash(nodesToAdd[nd].severity,nodesToAdd[nd].avail), point.x, point.y, mapElemDimension, nodesToAdd[nd].status, nodesToAdd[nd].avail, nodesToAdd[nd].severity);			map.addMapElement(me);		}					}		var linkId;	for(ln in linksToAdd){			linkId = linksToAdd[ln];		var elemIds = linkId.split('-');		var id1=elemIds[0];		var id2=elemIds[1];		map.addLink(id1,id2,"green",1);	}			map.render();	reloadGrid();	loading--;	assertLoading();//	savedMapString=getMapString();	enableMenu();		}
meta: 2281	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/2281/d5b0121ba147eea97a444ae288f11e94118d5a54/ApplicationMap.js/buggy/opennms-webapp/src/main/webapp/map/ApplicationMap.js