writeContent.js
Esta función es capaz de generar el código HTML para 3 casos diferentes: el contenido principal de los elementos hoja, los elementos nodo que despliegan documentos al darles click, y los elementos nodo que no muestran nada (solo despliegan contenido).
Este código también se encarga de asignar el ícono especificado en la TOC a cada entrada generada, ya sean los archivos predeterminados "page.bmp", "epage.bmp" o "ipage.bmp" ("collbook.bmp"/"opbook.bmp" para los nodos); o una imagen *.ico personalizada en el directorio "favicons".
function writeContent(leveL, Line, ident)
{
idenc = ident;
maxL = CHM_nivel_mayor;
Ltmp = allTrim(CHM_toc[Line]);
toRet = "";
done1 = 0;
cc = 0;
favir = "favicons/";
cicon = ".bmp";
if(leveL==1)
{
idenc+="_leveler";
}
associate = idenc;
text = ""; ;//CParam(noLinea, 1);
documentt = ""; ;//CParam(noLinea, 2);
destiny = ""; ;//CParam(noLinea, 3);
icon = ""; ;//SParam(noLinea, 4);
toRet += "<tr>\n";
if(leveL > 1) ;//PADDING
{ ;//PADDING
for(cc=1; cc<=leveL-1; cc++) ;//PADDING
{ ;//PADDING
toRet += CHM_espaciador; ;//PADDING
} ;//PADDING
} ;//PADDING
if(leveL!=maxL) ;//any level; exept maximum one
{
//------Container Generation Code------:
//------Container Generation Code------:
//------Container Generation Code------:
//------Container Generation Code------:
//------Container Generation Code------:
//------Container Generation Code------:
if( ((CHM_struc_niveles[Line+1]>leveL) && (numPars(Line)==3)) || ((CHM_struc_niveles[Line]==1 && CHM_struc_niveles[Line+1]==1) && (numPars(Linea)==3)) ) ;//this is, a container
{
text = CParam(Line, 1);
documentt = CParam(Line, 2);
destiny = CParam(Line, 3);
toRet += "<td align=\"right\" width=\"20\">";
toRet += "<img src=\"" + img_rut + "collbook.bmp\" id=\"" + idenc + "_image\" />";
toRet += "</td>\n";
toRet += "<td>";
toRet += "<a ";
if(allTrim(documentt)!="")
{
toRet += "href=\"" + documentt + "\" ";
}
else
{
toRet += "href=\"javascript:try{jey;}catch(er){}\" ";
}
if(allTrim(documentt)!="") ;//container responsible to show a document (address parameter -- parameter #2 -- NOT empty)
{
toRet += " onkeypress=\"if(KeyboardCode==13){chmMenuEmule('onkeypress', '" + idenc + "', '" + associate + "', 'window.open(\\'" + documentt + "\\', \\'" + destiny + "\\', \\'\\')', '');}\" ";
toRet += " onmousedown=\"chmMenuEmule('onkeypress', '" + idenc + "', '" + associate + "', 'window.open(\\'" + documentt + "\\', \\'" + destiny + "\\', \\'\\')', '');\" ";
}
else ;//container that does NOT show anything (parameter #2 empty)
{
toRet += " onkeypress=\"if(KeyboardCode==13){chmMenuEmule('onkeypress', '" + idenc + "', '" + associate + "', '', '');}\" ";
toRet += " onmousedown=\"chmMenuEmule('onkeypress', '" + idenc + "', '" + associate + "', '', '')\" ";
}
if(allTrim(destiny)!="")
{
toRet += "target=\"" + destiny + "\">";
}
else
{
toRet += ">";
}
toRet += text + " </a><br />";
toRet += "</td>\n";
toRet += "</tr>\n";
done1 = 1;
}
}
if(!done1) ;//any level; whenever the previous processes have not been effectuated
{
text = allTrim(SParam(Line, 1));
documentt = allTrim(SParam(Line, 2));
destiny = allTrim(SParam(Line, 3));
icon = allTrim(SParam(Line, 4));
fic1 = icon.indexOf(".ico",icon.length-4);
fic2 = (fic1!=0 && fic1+4==icon.length);
if( (icon!="page" && icon!="epage" && icon!="ipage") && !fic2 )
{
icon = "page";
}
if( fic2 )
{
cicon = "";
}
else
{
favir = "";
cicon = ".bmp";
}
;//Attempt to make an advanced check, which will consist on testing through "try/catch"
;//and other functions, if in fact has been possible to load the image; otherwise
;//load the default image "page.bmp"
toRet += " <td align=\"right\" width=\"20\">";
toRet += "<img src=\"" + img_rut + favir + icon + cicon + "\" />";
toRet += "</td>\n";
toRet += " <td>";
toRet += " <a target=\"" + destiny + "\" href=\"" + documentt + "\">" + text + " </a><br />";
toRet += " </td>\n";
toRet += " </tr>\n";
}
return(toRet);
}