var externals = function(data)
{
if (_checkError(data))
return;
var content_id_3 = document.getElementById("content_id_3");
if (data.length == 0)
{
var parag = document.createElement("P");
parag.className = "text_dsp";
parag.innerHTML = "Não existem aplicações externas";
content_id_3.appendChild(parag);
}
else
{
elem = document.getElementById("table_ext");
if (elem) {
elem.parentNode.removeChild(elem);
}
draw_externals_grid(data, 3);
}
};
function draw_externals_folder()
{
cExecute ("$this.bo_userinterface.externals", externals, "");
}
function draw_externals_grid(data, page)
{
var content_id_3 = document.getElementById("content_id_3");
var available_width = screen.availWidth - 200;
var max_columns = Math.floor(available_width / 120);
var max_lines = Math.max(2, Math.ceil(data.length / max_columns));
var table_element = document.createElement("TABLE");
var tbody_element = document.createElement("TBODY");
table_element.setAttribute("id", "table_ext");
table_element.setAttribute("cellSpacing", "10");
table_element.setAttribute("width", "auto");
tr_element = document.createElement("TR");
for (i=1; i <= max_lines * max_columns; i++)
{
td_element = document.createElement("TD");
td_element.setAttribute("id", "td_ext_" + (i -1) );
td_element.className = "proc_td_bg";
td_element.align = "left";
tr_element.appendChild(td_element);
if ((i % max_columns) == 0)
{
tbody_element.appendChild(tr_element);
tr_element = document.createElement("TR");
}
}
tbody_element.appendChild(tr_element);
table_element.appendChild(tbody_element);
content_id_3.appendChild(table_element);
/* this loop is required because if a regular "for" is used, the variables will be shared among the iterations */
(function loop(i)
{
if (i <= data.length)
{
ind = i - 1;
var external_link = data[ind].wf_ext_link;
ext = data[ind];
ext_name_dsp = ext.name;
if (ext_name_dsp.length > 40)
{
ext_name_dsp = ext_name_dsp.substr(0,40) + "...";
}
table_element = document.createElement("TABLE");
table_element.onclick = function() { var external_window = window.open(external_link,'extwindow'); external_window.opener = null;};
tbody_element = document.createElement("TBODY");
tr_element = document.createElement("TR");
td_element = document.createElement("TD");
td_element.setAttribute("vAlign", "top");
td_element.setAttribute("align", "center");
td_element.setAttribute("height", "40");
td_element.innerHTML = "";
tr_element.appendChild(td_element);
tbody_element.appendChild(tr_element);
tr_element = document.createElement("TR");
td_element = document.createElement("TD");
td_element.setAttribute("width", "106");
if (is_ie) {
td_element.setAttribute("height", "60");
} else {
td_element.setAttribute("height", "47");
}
td_element.setAttribute("vAlign", "top");
td_element.setAttribute("align", "center");
td_element.innerHTML = ext_name_dsp;
td_element.innerHTML += "
";
tr_element.appendChild(td_element);
tbody_element.appendChild(tr_element);
tbody_element.style.cursor = 'pointer';
table_element.appendChild(tbody_element);
td_ext = document.getElementById("td_ext_" + ind);
td_ext.appendChild(table_element);
td_ext.className = "proc_td";
loop(i+1);
}
})(1);
for (ix = data.length; ix < max_lines * max_columns; ix++) {
elem = document.getElementById("td_ext_" + ix);
elem.setAttribute("width", "120");
if (is_ie) {
elem.setAttribute("height", "119");
} else {
elem.setAttribute("height", "106");
}
elem.innerHTML = " ";
}
}