3
** Copyright (C) 2000-2005 SIA Zabbix
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.
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.
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.
19
var IE = document.all?true:false;
20
var OP = window.opera?true:false;
25
alert("DEBUG INFO: " + msg);
28
function close_window()
30
window.setTimeout("window.close()", 500); /* Solve bug for Internet Explorer */
34
function add_variable(o_el, s_name, x_value, s_formname, o_document)
38
if(!o_document) o_document = document;
42
if( !(form = o_document.forms[s_formname]) )
43
throw "Missed form with name '"+s_formname+"'.";
48
if( !(form = o_el.form) )
49
throw "Missed form in 'o_el' object";
53
if( !(form = this.form) )
54
throw "Missed form in 'this' object";
57
var o_variable = o_document.createElement('input');
59
if( !o_variable ) throw "Can't create element";
61
o_variable.type = 'hidden';
62
o_variable.name = s_name;
63
o_variable.value = x_value;
65
form.appendChild(o_variable);
70
function get_scroll_pos()
72
var scrOfX = 0, scrOfY = 0;
73
if( typeof( window.pageYOffset ) == 'number' )
74
{ //Netscape compliant
75
scrOfY = window.pageYOffset;
76
scrOfX = window.pageXOffset;
78
else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
80
scrOfY = document.body.scrollTop;
81
scrOfX = document.body.scrollLeft;
83
else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
84
{ //IE6 standards compliant mode
85
scrOfY = document.documentElement.scrollTop;
86
scrOfX = document.documentElement.scrollLeft;
88
return [ scrOfX, scrOfY ];
90
function get_cursor_position(e)
92
e = e || window.event;
93
var cursor = {x:0, y:0};
94
if (e.pageX || e.pageY) {
99
var de = document.documentElement;
100
var b = document.body;
101
cursor.x = e.clientX +
102
(de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
103
cursor.y = e.clientY +
104
(de.scrollTop || b.scrollTop) - (de.clientTop || 0);
109
function Redirect(url) {
110
window.location = url;
114
function create_var(form_name, var_name, var_val, submit)
116
var frmForm = document.forms[form_name];
118
if(!frmForm) return false;
120
var objVar = document.createElement('input');
122
if(!objVar) return false;
124
objVar.setAttribute('type', 'hidden');
125
objVar.setAttribute('name', var_name);
126
objVar.setAttribute('value', var_val);
128
frmForm.appendChild(objVar);
135
function Confirm(msg){
136
if(confirm(msg,'title'))
142
function PopUp(url,width,height,form_name){
143
if(!width) width = 600;
144
if(!height) height = 450;
145
if(!form_name) form_name = 'zbx_popup';
147
var left = (screen.width-(width+150))/2;
148
var top = (screen.height-(height+150))/2;
150
var popup = window.open(url,form_name,'width=' + width +',height=' + height + ',top='+ top +',left='+ left +
151
',resizable=yes,scrollbars=yes,location=no,menubar=no');
158
function CheckAll(form_name, chkMain, shkName){
159
var frmForm = document.forms[form_name];
160
var value = frmForm.elements[chkMain].checked;
161
for (var i=0; i < frmForm.length; i++)
163
name = frmForm.elements[i].name.split('[')[0];
164
if(frmForm.elements[i].type != 'checkbox') continue;
165
if(name == chkMain) continue;
166
if(shkName && shkName != name) continue;
167
if(frmForm.elements[i].disabled == true) continue;
168
frmForm.elements[i].checked = value;
172
function GetSelectedText(obj)
174
if (navigator.appName == "Microsoft Internet Explorer")
177
return document.selection.createRange().text;
179
else (obj.selectionStart)
181
if(obj.selectionStart != obj.selectionEnd) {
182
var s = obj.selectionStart;
183
var e = obj.selectionEnd;
184
return obj.value.substring(s, e);
190
function ScaleChartToParenElement(obj_name)
192
var obj = document.getElementsByName(obj_name);
194
if(obj.length <= 0) throw "Can't find objects with name [" + obj_name +"]";
196
for(i = obj.length-1; i>=0; i--)
198
obj[i].src += "&width=" + (obj[i].parentNode.offsetWidth - obj[i].parentNode.offsetLeft - 10);
202
function insert_sizeable_graph(url)
206
if(document.body.clientWidth)
207
width = document.body.clientWidth;
208
else if(document.width)
209
width = document.width;
211
if(width) url += "&width=" + (width - 108);
213
document.write("<IMG SRC=\"" + url + "\">");