Well.... it's plenty of stuff.
I'm making an LDAP browsing application for our enterprise (web enabled).
It's made on PHP. I have already displayed the directory and can collapse / expand nodes. I have implemented node expansion with ajax (via sajax). In the PHP function that is called to get the information of the nodes I'm going to display I pass some information, like:
Node's Plain Name
Node's DN
Node's GUID
If the node has children among others. I separate each line by a \n and each node by an empty line (\n).
The JS code "parses" that input that's coming from sajax and creates the nodes and so on. It works flawlessly..... on firefox.
Not that it fails on IE, it works there too... but it fails when I have a html entity in my code (that I'm not decoding on php).
Things like "Enfermería" make the script fail from that point on.
Here's one output that the browser is supposed to handle (through my script that gets its input from sajax):
Code:
+:var res = 'a9d6d489976453488534e1188af6c956\n17\norganizationalunit \nAdiestramiento y Soporte\nOU=Adiestramiento y Soporte,OU=AIT,DC=FHEP,DC=ORG\n79560207a9c609438c5ad54d5cd641ff\ntrue\n\ngroup \nAnalista Web\nCN=Analista Web,OU=AIT,DC=FHEP,DC=ORG\n74cabd037763dc46a14ee777c25d4716\nfalse\n\norganizationalunit \nAnalista Web y Movil\nOU=Analista Web y Movil,OU=AIT,DC=FHEP,DC=ORG\nd0171519e267974095ce80065c80e430\nfalse\n\ngroup \nAplicacion Evaluaciones\nCN=Aplicacion Evaluaciones,OU=AIT,DC=FHEP,DC=ORG\n4c37585469b6c44598c8391be0dd7634\nfalse\n\ngroup \nAsesores\nCN=Asesores,OU=AIT,DC=FHEP,DC=ORG\nb6724ee1757bbc4d946713e457bba72c\nfalse\n\norganizationalunit \nAsesores SMILE\nOU=Asesores SMILE,OU=AIT,DC=FHEP,DC=ORG\n10bd2391ffb09f4f81e0d9914f605de8\ntrue\n\norganizationalunit \nCoordinacion de AIT\nOU=Coordinacion de AIT,OU=AIT,DC=FHEP,DC=ORG\n453e3eec097c7749bd5c9d036f799d51\ntrue\n\ngroup \nCoordinador de Sistemas\nCN=Coordinador de Sistemas,OU=AIT,DC=FHEP,DC=ORG\n4e9f8a768873eb47b8ffb76ecf680564\nfalse\n\norganizationalunit \nDigitalizaci�\nOU=Digitalizaci�,OU=AIT,DC=FHEP,DC=ORG\nef0d3df10db09f43ba76860f23e7e5b4\ntrue\n\norganizationalunit \nHardware\nOU=Hardware,OU=AIT,DC=FHEP,DC=ORG\n44606e18a8e7fe4db253b76b297ca433\ntrue\n\ngroup \nInforme de Errores SMILE\nCN=Informe de Errores SMILE,OU=AIT,DC=FHEP,DC=ORG\ne151e7eb1e6eb0489161\nfalse\n\ngroup \nPasante de Sistemas\nCN=Pasante de Sistemas,OU=AIT,DC=FHEP,DC=ORG\nb58bcb05975e6c4da0b92c028d543fc7\nfalse\n\ngroup \nSistemas Global\nCN=Sistemas Global,OU=AIT,DC=FHEP,DC=ORG\n25d1b4547518ed4abd65fa9a0dc72950\nfalse\n\norganizationalunit \nSoftware\nOU=Software,OU=AIT,DC=FHEP,DC=ORG\ne782dc21e66d0a4f9fd20d5ee508a852\ntrue\n\ngroup \nSoporte Administrativo\nCN=Soporte Administrativo,OU=AIT,DC=FHEP,DC=ORG\n80ab950ee499f74b8814e59a861e32fb\nfalse\n\norganizationalunit \nSoporte ASYS\nOU=Soporte ASYS,OU=AIT,DC=FHEP,DC=ORG\n9a612d71fe89314e9e04285f72e7a59e\ntrue\n\ngroup \nSoporte SMILE\nCN=Soporte SMILE,OU=AIT,DC=FHEP,DC=ORG\n3451e868f980ec47b316c2789432c58e\nfalse\n\n'; res;
The characters � are the special one that aren't being displayed well, but that they are being well transmitted. Checking with hexedit:
That would be "ción" from "Digitalización".
This is the JS code I use to parse the input and create the nodes:
Code:
function agregarNodos(resultado) {
// en la primera linea esta el nombre de la tabla sobre la que estoy trabajando
var posicion1 = resultado.indexOf("\n");
var guid = resultado.substring(0, posicion1);
posicion1++;
var posicion2 = resultado.indexOf("\n", posicion1);
var cantidad = parseInt(resultado.substring(posicion1, posicion2));
// ahora pasamos a los nodos
posicion1 = posicion2+1;
var clase = "";
var nombre = "";
var dn = "";
var guid2 = "";
var hijos = false;
var cadena = ""; // temporal
var lista = document.getElementById(guid);
var forma = document.forms["peticion"];
for (var i = 0; i < cantidad; i++) {
for (var j = 0; j < 6; j++) {
posicion2 = resultado.indexOf("\n", posicion1);
cadena = resultado.substring(posicion1, posicion2);
switch (j) {
case 0:
clase = cadena;
break;
case 1:
nombre = cadena;
break;
case 2:
dn = cadena;
break;
case 3:
guid2 = cadena;
break;
case 4:
hijos = cadena == "true" ? true : false;
break;
default:
}
posicion1 = posicion2+1;
}
var nodeLI = document.createElement("LI");
var nodeText = document.createTextNode(nombre);
if (hijos) {
//
var field = forma.elements[guid2];
// tiene hijos... hay que hacerlo expandible
nodeA.href="javascript:toggle(\'" + guid2 + "\');"
var nodeCruz = document.createTextNode(field ? "-" : "+"); // expandido?
nodeA.appendChild(nodeCruz);
nodeLI.appendChild(nodeA);
// le agregamos un espacio al texto del nodo de texto
nodeText.data = ' ' + nodeText.data;
nodeLI.appendChild(nodeText);
// agregamos la nueva lista
var nodeUL = document.createElement("UL");
nodeUL.id = guid2;
nodeLI.appendChild(nodeUL);
if (field) {
// hay que expandir este campo tambien
x_getNodes(guid2, agregarNodos);
}
} else {
nodeLI.appendChild(nodeText);
}
lista.appendChild(nodeLI);
}
}
As you can see, I parse the input by looking for the new lines in the input string.
Any ideas how I can overcome the problem?