~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to frontends/php/js/tree.js

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-06-04 09:22:37 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080604092237-zgwq7kmraj1oohoz
Tags: 1:1.4.5-1ubuntu1
* Merge from debian unstable, remaining changes: 
  + fixing missing pid directory in /var/run
* Added the same patch to debian/zabbix-server-{mysql,pgsql}.zabbix-server.init
  (LP: #172775)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
** ZABBIX
3
 
** Copyright (C) 2000-2005 SIA Zabbix
4
 
**
5
 
** This program is free software; you can redistribute it and/or modify
6
 
** it under the terms of the GNU General Public License as published by
7
 
** the Free Software Foundation; either version 2 of the License, or
8
 
** (at your option) any later version.
9
 
**
10
 
** This program is distributed in the hope that it will be useful,
11
 
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
** GNU General Public License for more details.
14
 
**
15
 
** You should have received a copy of the GNU General Public License
16
 
** along with this program; if not, write to the Free Software
17
 
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 
**/
19
 
// JavaScript Document
20
 
var IE = document.all?true:false;
21
 
var OP = window.opera?true:false;
22
 
 
23
 
 
24
 
var tree ={
25
 
init : function(){
26
 
        if((tree_init = cookie.read(tree_name)) != null){
27
 
                var nodes = tree_init.split('.');
28
 
                var c = nodes.length-1;
29
 
                for(var i=0; i<c;i++){
30
 
                        this.onStartSetStatus(nodes[i]);
31
 
                }
32
 
                this.onStartOpen(nodes);
33
 
        }
34
 
},
35
 
 
36
 
getNodeStatus : function(id){
37
 
        try{
38
 
                if(treenode[id].status == 'close'){
39
 
                        return 'close';
40
 
                } else {
41
 
                        return 'open';
42
 
                }
43
 
        } catch(e){
44
 
                return 'close';
45
 
        }
46
 
},
47
 
 
48
 
ChangeNodeStatus : function(id){
49
 
        try{
50
 
                if(treenode[id].status == 'close'){
51
 
                        treenode[id].status = 'open';
52
 
                } else {
53
 
                        treenode[id].status = 'close';
54
 
                }
55
 
                var cookie_str='';
56
 
                for(var i = 1; i < treenode.length; i++){
57
 
                        if(typeof(treenode[i]) != 'undefined'){
58
 
                                if(treenode[i].status == 'open'){
59
 
                                        cookie_str+=i+'.';
60
 
                                }
61
 
                        }
62
 
                }
63
 
                cookie.create(tree_name,cookie_str);
64
 
        } catch(e){
65
 
                IE?(alert(e.description)):(alert(e));
66
 
        }
67
 
},
68
 
 
69
 
 
70
 
closeSNodeX : function(id,img){
71
 
        try{
72
 
                nodelist = treenode[id].nodelist.split('.');
73
 
                if(this.getNodeStatus(id) == 'close'){
74
 
                        this.OpenNode(nodelist);
75
 
                        img.src = 'images/general/tree/'+img.name.toUpperCase()+'.gif';
76
 
                } else {
77
 
                        this.CloseNode(nodelist);
78
 
                        img.src = 'images/general/tree/'+img.name.toUpperCase()+'c.gif';
79
 
                }
80
 
                this.ChangeNodeStatus(id);
81
 
        } catch(e){
82
 
//              alert('closeSNodeX: '+e);
83
 
                return;
84
 
        }
85
 
},
86
 
 
87
 
OpenNode : function(nodelist){
88
 
        try{
89
 
                var c = nodelist.length-1;
90
 
                for(var i=0; i<c; i++){
91
 
                        document.getElementById(nodelist[i]).style.display = (!IE || OP)?("table-row"):('block');
92
 
                        if(this.getNodeStatus(nodelist[i]) == 'open'){
93
 
                                this.OpenNode(treenode[nodelist[i]].nodelist.split('.'));
94
 
                        }
95
 
                }
96
 
        } catch(e){
97
 
//              alert('OpenNode: '+e);
98
 
        }
99
 
},
100
 
        
101
 
CloseNode : function(nodelist){
102
 
        try{
103
 
                var c = nodelist.length-1;
104
 
                for(var i=0; i<c; i++){
105
 
                        document.getElementById(nodelist[i]).style.display = 'none';
106
 
                        if(this.getNodeStatus(nodelist[i]) == 'open'){
107
 
                                this.CloseNode(treenode[nodelist[i]].nodelist.split('.'));
108
 
                        }
109
 
                }
110
 
        } catch(e){ 
111
 
//              alert('CloseNode: '+e);
112
 
        }
113
 
},
114
 
 
115
 
onStartOpen : function(nodes){
116
 
        var nodes = tree_init.split('.');
117
 
        var c = nodes.length-1;
118
 
        for(var i=0; i<c;i++){
119
 
                if(typeof(nodes[i]) != 'undefined'){
120
 
                        try{
121
 
//                              alert(nodes[i]+' : '+this.checkParent(nodes[i]));
122
 
                                if(this.checkParent(nodes[i])){
123
 
                                        var nodelist = treenode[nodes[i]].nodelist.split('.');
124
 
                                        this.OpenNode(nodelist);
125
 
                                }
126
 
                        } catch(e){
127
 
                                cookie.erase(tree_name);
128
 
//                              alert('OnStartOpen: '+e);
129
 
                        }
130
 
                }
131
 
        }
132
 
},
133
 
 
134
 
onStartSetStatus : function(id){
135
 
        try{
136
 
                if(typeof(treenode[id]) == 'undefined') return;
137
 
                var img_id=id+'I';;
138
 
                var img = document.getElementById(img_id);
139
 
                img.src = 'images/general/tree/'+img.name.toUpperCase()+'.gif';
140
 
                
141
 
                treenode[id].status = 'open';
142
 
        } catch(e){
143
 
//              alert('OnStartSetStatus: '+e);
144
 
        }
145
 
},
146
 
 
147
 
checkParent : function(id){
148
 
        try{
149
 
                
150
 
                if(id == '0'){
151
 
                        return true;
152
 
                } else if(typeof(treenode[id]) == 'undefined'){
153
 
                        return false;
154
 
                } else if(treenode[id].status != 'open'){
155
 
                        return false;
156
 
                } else {
157
 
                        return this.checkParent(treenode[id].parentid);
158
 
                }
159
 
        } catch(e){
160
 
//              alert('checkPparent: '+e);
161
 
        }
162
 
}
163
 
}
 
1
/*
 
2
** ZABBIX
 
3
** Copyright (C) 2000-2005 SIA Zabbix
 
4
**
 
5
** This program is free software; you can redistribute it and/or modify
 
6
** it under the terms of the GNU General Public License as published by
 
7
** the Free Software Foundation; either version 2 of the License, or
 
8
** (at your option) any later version.
 
9
**
 
10
** This program is distributed in the hope that it will be useful,
 
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
** GNU General Public License for more details.
 
14
**
 
15
** You should have received a copy of the GNU General Public License
 
16
** along with this program; if not, write to the Free Software
 
17
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
**/
 
19
// JavaScript Document
 
20
var IE = document.all?true:false;
 
21
var OP = window.opera?true:false;
 
22
 
 
23
 
 
24
var tree ={
 
25
init : function(){
 
26
        if((tree_init = cookie.read(tree_name)) != null){
 
27
                var nodes = tree_init.split('.');
 
28
                var c = nodes.length-1;
 
29
                for(var i=0; i<c;i++){
 
30
                        this.onStartSetStatus(nodes[i]);
 
31
                }
 
32
                this.onStartOpen(nodes);
 
33
        }
 
34
},
 
35
 
 
36
getNodeStatus : function(id){
 
37
        try{
 
38
                if(treenode[id].status == 'close'){
 
39
                        return 'close';
 
40
                } else {
 
41
                        return 'open';
 
42
                }
 
43
        } catch(e){
 
44
                return 'close';
 
45
        }
 
46
},
 
47
 
 
48
ChangeNodeStatus : function(id){
 
49
        try{
 
50
                if(treenode[id].status == 'close'){
 
51
                        treenode[id].status = 'open';
 
52
                } else {
 
53
                        treenode[id].status = 'close';
 
54
                }
 
55
                var cookie_str='';
 
56
                for(var i = 1; i < nodeid_list.length; i++){
 
57
                        if(typeof(treenode[nodeid_list[i]]) != 'undefined'){
 
58
                                if(treenode[nodeid_list[i]].status == 'open'){
 
59
                                        cookie_str+=nodeid_list[i]+'.';
 
60
                                }
 
61
                        }
 
62
                }
 
63
                cookie.create(tree_name,cookie_str);
 
64
        } catch(e){
 
65
//              IE?(alert(e.description)):(alert(e));
 
66
        }
 
67
},
 
68
 
 
69
 
 
70
closeSNodeX : function(id,img){
 
71
        try{
 
72
                nodelist = treenode[id].nodelist.split('.');
 
73
                if(this.getNodeStatus(id) == 'close'){
 
74
                        this.OpenNode(nodelist);
 
75
                        img.src = 'images/general/tree/'+img.name.toUpperCase()+'.gif';
 
76
                } else {
 
77
                        this.CloseNode(nodelist);
 
78
                        img.src = 'images/general/tree/'+img.name.toUpperCase()+'c.gif';
 
79
                }
 
80
                this.ChangeNodeStatus(id);
 
81
        } catch(e){
 
82
//              alert('closeSNodeX: '+e);
 
83
                return;
 
84
        }
 
85
},
 
86
 
 
87
OpenNode : function(nodelist){
 
88
        try{
 
89
                var c = nodelist.length-1;
 
90
                for(var i=0; i<c; i++){
 
91
                        document.getElementById(nodelist[i]).style.display = (!IE || OP)?("table-row"):('block');
 
92
                        if(this.getNodeStatus(nodelist[i]) == 'open'){
 
93
                                this.OpenNode(treenode[nodelist[i]].nodelist.split('.'));
 
94
                        }
 
95
                }
 
96
        } catch(e){
 
97
//              alert('OpenNode: '+e);
 
98
        }
 
99
},
 
100
        
 
101
CloseNode : function(nodelist){
 
102
        try{
 
103
                var c = nodelist.length-1;
 
104
                for(var i=0; i<c; i++){
 
105
                        document.getElementById(nodelist[i]).style.display = 'none';
 
106
                        if(this.getNodeStatus(nodelist[i]) == 'open'){
 
107
                                this.CloseNode(treenode[nodelist[i]].nodelist.split('.'));
 
108
                        }
 
109
                }
 
110
        } catch(e){ 
 
111
//              alert('CloseNode: '+e);
 
112
        }
 
113
},
 
114
 
 
115
onStartOpen : function(nodes){
 
116
        var nodes = tree_init.split('.');
 
117
        var c = nodes.length-1;
 
118
        for(var i=0; i<c;i++){
 
119
                if(typeof(nodes[i]) != 'undefined'){
 
120
                        try{
 
121
//                              alert(nodes[i]+' : '+this.checkParent(nodes[i]));
 
122
                                if(this.checkParent(nodes[i])){
 
123
                                        var nodelist = treenode[nodes[i]].nodelist.split('.');
 
124
                                        this.OpenNode(nodelist);
 
125
                                }
 
126
                        } catch(e){
 
127
                                cookie.erase(tree_name);
 
128
//                              alert('OnStartOpen: '+e);
 
129
                        }
 
130
                }
 
131
        }
 
132
},
 
133
 
 
134
onStartSetStatus : function(id){
 
135
        try{
 
136
                if(typeof(treenode[id]) == 'undefined') return;
 
137
                var img_id=id+'I';;
 
138
                var img = document.getElementById(img_id);
 
139
                img.src = 'images/general/tree/'+img.name.toUpperCase()+'.gif';
 
140
                
 
141
                treenode[id].status = 'open';
 
142
        } catch(e){
 
143
//              alert('OnStartSetStatus: '+e);
 
144
        }
 
145
},
 
146
 
 
147
checkParent : function(id){
 
148
        try{
 
149
                
 
150
                if(id == '0'){
 
151
                        return true;
 
152
                } else if(typeof(treenode[id]) == 'undefined'){
 
153
                        return false;
 
154
                } else if(treenode[id].status != 'open'){
 
155
                        return false;
 
156
                } else {
 
157
                        return this.checkParent(treenode[id].parentid);
 
158
                }
 
159
        } catch(e){
 
160
//              alert('checkPparent: '+e);
 
161
        }
 
162
}
 
163
}