Source
* @param string params.dialogueid (optional) Unique dialogue identifier to reuse existing overlay dialog
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
function check_target(e, type) {
// If type is expression.
if (type == 0) {
var targets = document.getElementsByName('expr_target_single');
}
// Type is recovery expression.
else {
var targets = document.getElementsByName('recovery_expr_target_single');
}
for (var i = 0; i < targets.length; ++i) {
targets[i].checked = targets[i] == e;
}
}
/**
* Remove part of expression.
*
* @param string id Expression temporary ID.
* @param number type Expression (type = 0) or recovery expression (type = 1).
*/
function delete_expression(id, type) {
// If type is expression.
if (type == 0) {
jQuery('#remove_expression').val(id);
}
// Type is recovery expression.
else {
jQuery('#remove_recovery_expression').val(id);
}
}
function testUserSound(idx) {
var element = document.getElementById(idx);
var sound = element.options[element.selectedIndex].value;
element = document.getElementById('messages_sounds.repeat');
var repeat = element.options[element.selectedIndex].value;
if (repeat == 1) {
AudioControl.playOnce(sound);
}
else if (repeat > 1) {
AudioControl.playLoop(sound, repeat);
}
else {
AudioControl.playLoop(sound, document.getElementById('messages_timeout').value);
}
}
function escapeHtml(string) {
return string
.replace(/&/g,'&')
.replace(/</g,'<')
.replace(/>/g,'>')
.replace(/\"/g,'"')
.replace(/\'/g,''');
}
function validateNumericBox(obj, allowempty, allownegative) {
if (obj != null) {
if (allowempty) {
if (obj.value.length == 0 || obj.value == null) {
obj.value = '';
}
else {
if (isNaN(parseInt(obj.value, 10))) {
obj.value = 0;
}
else {
obj.value = parseInt(obj.value, 10);
}
}
}
else {
if (isNaN(parseInt(obj.value, 10))) {
obj.value = 0;