Source
/*
** 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/>.
**/
/**
* CMacroValue element control.
*/
(function($) {
'use strict';
const ZBX_MACRO_TYPE_TEXT = 0;
const ZBX_MACRO_TYPE_SECRET = 1;
const ZBX_MACRO_TYPE_VAULT = 2;
const ZBX_STYLE_MACRO_VALUE_TEXT = 'macro-value-text';
const ZBX_STYLE_MACRO_VALUE_SECRET = 'macro-value-secret';
const ZBX_STYLE_MACRO_VALUE_VAULT = 'macro-value-vault';
const ZBX_STYLE_ICON_SECRET = 'icon-secret';
function btnUndoFocusEventHandle() {
$(this)
.closest('.macro-input-group')
.find('.btn-undo')
.toggleClass('is-focused');
}
function btnUndoClickEventHandle() {
var $this = $(this),
$container = $this.closest('.macro-input-group'),
$input_container = $('.input-secret, .textarea-flexible', $container),
$input = $('.input-secret input[type=password], .textarea-flexible', $container),
$dropdown_value = $('.dropdown-value', $container);
$input_container.replaceWith(
$('<div>')
.addClass('input-secret')
.append(
$('<input>')
.attr({
id: $input.attr('id'),
name: $input.attr('name'),
type: 'password',
value: '******',
placeholder: $input.attr('placeholder'),
maxlength: $input.attr('maxlength'),
disabled: true
})
.on('focus blur', btnUndoFocusEventHandle)
)
.append($('<button>').attr({
type: 'button',