source: branches/2.2/workflow/js/jscode/common_functions.js @ 3167

Revision 3167, 2.9 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 Element(element){
2        return document.getElementById(element);
3}
4
5function killElement(param){
6        var elem = document.getElementById(param);
7        if (elem)
8                elem.parentNode.removeChild(elem);
9}
10
11function load_lang(){
12
13        var handler_load_lang = function(data){
14                array_lang = data;
15        };
16        cExecute("$this.bo_userinterface.getLang",handler_load_lang);
17}
18
19function write_msg(msg) {
20        var msg = '<table width=100% class="msg_erro_table"><tr><th width="40%"></th><th noWrap class="msg_erro_th">'+msg+'</th><th width="40%"></th></tr><tbody></tbody><table>';
21        var divAppboxHeader = document.getElementById("divAppboxHeader");
22        divAppboxHeader.innerHTML = msg;
23        setTimeout("Element('divAppboxHeader').innerHTML = '<table align=center border=0 width=100%><tr><td align=center><span class=msg_erro_text>Workflow</span></td></tr></table>'", 5000);
24}
25
26function write_errors(msg_errors) {
27        alert(msg_errors.replace(/<br \/>/gi, "\n"));
28}
29
30function activity_icon(type, is_interactive) {
31
32        switch(type)
33        {
34                case 'activity':
35                        ic = "mini_" + ((is_interactive == 'y') ? 'blue_' : '') + "rectangle.gif";
36                        break;
37                case 'switch':
38                        ic = "mini_" + ((is_interactive == 'y')? 'blue_':'') + "diamond.gif";
39                        break;
40                case 'start':
41                        ic = "mini_" + ((is_interactive == 'y')? 'blue_':'') + "circle.gif";
42                        break;
43                case 'end':
44                        ic = "mini_" + ((is_interactive == 'y')? 'blue_':'') + "dbl_circle.gif";
45                        break;
46                case 'split':
47                        ic = "mini_" + ((is_interactive == 'y')? 'blue_':'') + "triangle.gif";
48                        break;
49                case 'join':
50                        ic = "mini_" + ((is_interactive == 'y')? 'blue_':'') + "inv_triangle.gif";
51                        break;
52                case 'standalone':
53                        ic = "mini_" + ((is_interactive == 'y')? 'blue_':'') + "hexagon.gif";
54                        break;
55                default:
56                        ic = "no-activity.gif";
57        }
58
59        var result = '<img src="' + _icon_dir + 'activities/' + ic + '" alt="' + type + '" title="' + type + '" />';
60        return result;
61}
62
63function get_icon(img_name, title, attributes)
64{
65        if (attributes == null) {
66                attributes = '';
67        }
68        return "<img " + attributes  + " src='" + _icon_dir + img_name + "' alt='" + title + "' title='" + title + "'>";
69}
70
71function get_link(link,text,attributes)
72{
73        if (attributes == null) {
74                attributes = '';
75        }
76
77        return "<a href=" + link + " " + attributes  + ">" + text + "</a>";
78}
79
80function _checkError(data)
81{
82        if (data['error'])
83        {
84                alert(data['error'].replace(/<br \/>/gi, "\n"));
85                if (data['url'])
86                        window.location = data['url'];
87                return true;
88        }
89
90        return false;
91}
92
93function formatDateField(e, obj)
94{
95        // assuring it works on IE
96        var e = window.event || e;
97        var code = e.charCode || e.keyCode;
98       
99        switch (code) {
100                case (8): // backspace
101                case (9): // tab
102                case (35): // end
103                case (36): // home
104                case (37): // left arrow
105                case (39): // right arrow
106                case (46): // delete
107                        return true;
108        }
109
110        if (obj.value.length == 2)
111                obj.value += '/';
112        else if (obj.value.length == 5)
113                obj.value += '/';
114        else if (obj.value.length >= 10)
115                return false;
116
117        // just numbers!
118        return ((code >= 48) && (code <= 57))? true : false;
119}
Note: See TracBrowser for help on using the repository browser.