Convertir un conjunto de objetos Puntos Libres a un objeto Lista de Puntos y borrar los Puntos Libres en JavaScript - Versión dejar solo una lista

Autor:
JP MathPR

JavaScript

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