1<?php
2/*
3** Zabbix
4** Copyright (C) 2001-2021 Zabbix SIA
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program; if not, write to the Free Software
18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19**/
20
21
22/**
23 * @var CView $this
24 */
25?>
26
27<script type="text/javascript">
28	jQuery(function($) {
29		var $tls_psk = $('.tls_psk', $('#autoreg-form'));
30
31		// Refresh field visibility on document load.
32		if (($('#tls_accept').val() & <?= HOST_ENCRYPTION_NONE ?>) == <?= HOST_ENCRYPTION_NONE ?>) {
33			$('#tls_in_none').prop('checked', true);
34		}
35		if (($('#tls_accept').val() & <?= HOST_ENCRYPTION_PSK ?>) == <?= HOST_ENCRYPTION_PSK ?>) {
36			$('#tls_in_psk').prop('checked', true);
37		}
38		else {
39			$tls_psk.hide();
40		}
41
42		// Show/hide PSK fields.
43		$('#tls_in_psk').on('click', function() {
44			$tls_psk.toggle($(this).is(':checked'));
45		});
46
47		// Depending on checkboxes, create a value for hidden field 'tls_accept'.
48		$('#autoreg-form').on('submit', function() {
49			var tls_accept = 0x00;
50
51			if ($('#tls_in_none').is(':checked')) {
52				tls_accept |= <?= HOST_ENCRYPTION_NONE ?>;
53			}
54			if ($('#tls_in_psk').is(':checked')) {
55				tls_accept |= <?= HOST_ENCRYPTION_PSK ?>;
56			}
57			else {
58				$('#tls_psk_identity, #tls_psk').val('');
59			}
60
61			$('#tls_accept').val(tls_accept);
62		});
63	});
64</script>
65