//JavaScript[br]//Convertir un conjunto de objetos Puntos Libres [br]//a un objeto Lista de Puntos y borrar los Puntos Libres[br]//en JavaScript[br]//////////////////////////////////////////[br]//Declare variables[br]var no = ggbApplet.getObjectNumber();[br]var xV, yV;[br]var j = 1;[br]var axV = new Array();[br]var ayV = new Array();[br]var aIndex = new Array();[br]/////////////////////////////////////////////// [br]// Enlista el nombre de los objetos del mismo tipo en un arreglo [br]ggbApplet.evalCommand("LxV={ }");[br]ggbApplet.evalCommand("LyV={ }");[br]for (var i = 0; i < no; i++) {[br] if (ggbApplet.getObjectType(ggbApplet.getObjectName(i)) == "point") {[br] ggbApplet.evalCommand("xV=x(" + ggbApplet.getObjectName(i) + ")");[br] ggbApplet.evalCommand("yV=y(" + ggbApplet.getObjectName(i) + ")");[br] xV = ggbApplet.getValue("xV");[br] yV = ggbApplet.getValue("yV");[br] //alert(i + " xV=" + xV + " yV=" + yV);[br] ggbApplet.setListValue("LxV", j, xV);[br] ggbApplet.setListValue("LyV", j, yV);[br] j++;[br] } // si[br]} // para[br]ggbApplet.evalCommand("LP=Sequence((Element(LxV,i),Element(LyV,i)),i,1,Length(LxV),1)");[br]ggbApplet.evalCommand("index=Sequence(IndexOf(Element(Sort(LxV),i),LxV),i,1,Length(LxV),1)");[br]var nE = j;[br]/////////////////////////////////////////////////////////////////////////////////////[br]//Extract points free from Geogebra to JavaScript[br]for (i = 1; i < nE; i++) {[br] ggbApplet.evalCommand("xV=Element(LxV," + i + ")");[br] ggbApplet.evalCommand("yV=Element(LyV," + i + ")");[br] ggbApplet.evalCommand("Iindex=Element(index," + i + ")");[br] axV.push(Number(ggbApplet.getValue("xV")));[br] ayV.push(Number(ggbApplet.getValue("yV")));[br] aIndex.push(Number.parseInt(ggbApplet.getValue("Iindex")));[br] //alert("axV="+axV[i-1]+ " ayV="+ayV[i-1]+" index="+aIndex[i-1]);[br]}[br]///////////////////////////////////////////////////////////////////////////////[br]// Send array points to Geogebra[br]var ListP = "LP2={"[br]for (i = 1; i < aIndex.length; i++) {[br] if (i == 1) {[br] ListP = ListP + "(" + axV[aIndex[i - 1] - 1] + "," + ayV[aIndex[i - 1] - 1] + ")";[br] // alert("("+axV[aIndex[i-1]-1]+","+ayV[aIndex[i-1]-1]+")");[br] } else {[br] ListP = ListP + ",(" + axV[aIndex[i - 1] - 1] + "," + ayV[aIndex[i - 1] - 1] + ")";[br] //alert("("+axV[aIndex[i-1]-1]+","+ayV[aIndex[i-1]-1]+")");[br] }[br]}[br]ListP = ListP + "}";[br]ggbApplet.evalCommand(ListP);[br]///////////////////////////////////////////////////////[br]// Set Visible Points[br]for(var i = 0; i < no; i++){[br] if (ggbApplet.getObjectType(ggbApplet.getObjectName(i)) == "point") {[br] ggbApplet.setVisible(ggbApplet.getObjectName(i),false);[br] } // si[br]} // para[br]ggbApplet.evalCommand("SetVisibleInView(LP2,1,true)");[br]////////////////////////////////////////////////////////[br]// Delete objects[br]ggbApplet.setVisible("LP", false);[br]ggbApplet.setVisible("LP2", true);[br]ggbApplet.deleteObject("xV");[br]ggbApplet.deleteObject("yV");[br]ggbApplet.deleteObject("Iindex");[br]ggbApplet.deleteObject("LyV");[br]ggbApplet.deleteObject("LxV");[br]ggbApplet.deleteObject("index");[br]var opt = prompt("Deseas borrar las coordenadas de los puntos? (Y/N)", "N");[br]var dno = no;[br]if (opt == 'Y' || opt == 'y') {[br] for (var i = dno; 0 < i; i--) {[br] if (ggbApplet.getObjectType(ggbApplet.getObjectName(i)) == "point") {[br] ggbApplet.deleteObject(ggbApplet.getObjectName(i));[br] //dno--;[br] } // si[br] } // para[br]} //if opt