source: branches/2.2/workflow/js/orgchart/utils.js @ 3167

Revision 3167, 1.8 KB checked in by viani, 14 years ago (diff)

Ticket #1135 - Merged r1990:3166 from /trunk/workflow into /branches/2.2/workflow

  • Property svn:executable set to *
Line 
1function constructTable(header, content, atributes)
2{
3        /*** constrói a tabela ***/
4        var table = document.createElement("TABLE");
5
6        table.style.marginTop = "10px";
7
8        /* configura a tabela */
9        if (atributes)
10                for (i in atributes)
11                        if (typeof atributes[i] != "function")
12                                table.setAttribute(i, atributes[i]);
13
14        var tbody = document.createElement("TBODY");
15        var tr;
16        var td;
17
18        /* cabeçalho */
19        tr = document.createElement("TR");
20        tr.className = 'message_header';
21        for (i in header)
22        {
23                if (typeof header[i] != "function")
24                {
25                        td = document.createElement("TH");
26                        td.innerHTML = header[i];
27                        td.className = 'message_header';
28                        tr.appendChild(td);
29                }
30        }
31        tbody.appendChild(tr);
32
33        /* elementos da tabela */
34        for (var i = 0; i < content.length; i++)
35        {
36                /* atributos da linha (TR) */
37                tr = document.createElement("TR");
38                if (content[i]['tr_attributes'])
39                        for (j in content[i]['tr_attributes'])
40                                if (typeof content[i]['tr_attributes'][j] != "function")
41                                        tr.setAttribute(j, content[i]['tr_attributes'][j]);
42
43                /* dados da tabela */
44                for (j in header)
45                {
46                        if (typeof header[j] != "function")
47                        {
48                                td = document.createElement("TD");
49                                td.innerHTML = content[i][j];
50                                tr.appendChild(td);
51                        }
52                }
53                tbody.appendChild(tr);
54        }
55        table.appendChild(tbody);
56
57        return table;
58}
59
60/* constrói select boxes */
61function constructSelectBox(name, items, selected)
62{
63        var output = '';
64
65        output = '<select name="' + name + '" id="' + name  + '">';
66        for (i in items)
67                if (typeof items[i] != "function")
68                        output += '<option value="' + i + '"' +  ((i == selected) ? ' selected' : '') + '>' + items[i] + '</option>';
69        output += '</select>';
70
71        return output;
72}
73
74/* gerencia possíveis erros oriundos do método chamado via Ajax */
75function handleError(data)
76{
77        if (typeof(data) == "string")
78        {
79                write_errors(data);
80                return false;
81        }
82        else
83                return true;
84}
Note: See TracBrowser for help on using the repository browser.