1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
<script type="text/javascript">
function add_var_to_opener_obj(obj, name, value) {
new_variable = window.opener.document.createElement('input');
new_variable.type = 'hidden';
new_variable.name = name;
new_variable.value = value;
obj.appendChild(new_variable);
}
function insertText(obj, value) {
<?php if ($this->data['dstfld1'] == 'expression') { ?>
if (IE) {
obj.focus();
var s = window.opener.document.selection.createRange();
s.text = value;
}
else if (obj.selectionStart || obj.selectionStart == '0') {
var s = obj.selectionStart,
e = obj.selectionEnd,
objValue = jQuery(obj).val();
jQuery(obj).val(objValue.substring(0, s) + value + objValue.substring(e, objValue.length));
}
else {
jQuery(obj).val(jQuery(obj).val() + value);
}
<?php } else { ?>
jQuery(obj).val(value);
<?php } ?>
}
jQuery(document).ready(function() {
'use strict';
jQuery('#paramtype').change(function() {
if (jQuery('#expr_type option:selected').val().substr(0, 4) == 'last'
|| jQuery('#expr_type option:selected').val().substr(0, 6) == 'strlen'
|| jQuery('#expr_type option:selected').val().substr(0, 4) == 'band') {
if (jQuery('#paramtype option:selected').val() == <?php echo PARAM_TYPE_COUNTS; ?>) {
jQuery('#param_0').removeAttr('readonly');
}
else {
jQuery('#param_0').attr('readonly', 'readonly');
}
}
});
jQuery(document).ready(function() {
if (jQuery('#expr_type option:selected').val().substr(0, 4) == 'last'
|| jQuery('#expr_type option:selected').val().substr(0, 6) == 'strlen'
|| jQuery('#expr_type option:selected').val().substr(0, 4) == 'band') {
if (jQuery('#paramtype option:selected').val() == <?php echo PARAM_TYPE_COUNTS; ?>) {
jQuery('#param_0').removeAttr('readonly');
}
else {
jQuery('#param_0').attr('readonly', 'readonly');
}
}
});
});
</script>
<?php
if (!empty($this->data['insert'])) { ?>
<script type="text/javascript">
insertText(jQuery('#<?php echo $this->data['dstfld1']; ?>', window.opener.document), <?php echo zbx_jsvalue($this->data['expression']); ?>);
close_window();
</script>
<?php
}
if (!empty($this->data['cancel'])) {?>
<script type="text/javascript">
close_window();
</script>
<?php
}
|