<?php
// Copyright 1999-2022. Plesk International GmbH. All rights reserved.
?>
<?php echo $this->form ?>

<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function () {
    var restoreDefaultButton = Jsw.getComponent('btn-restoreDefaultButton');

    var updateSessionOptions = function () {
        if (document.getElementById('disableCheckSessionIp').checked ||
            document.getElementById('loginTimeout').value !== '<?php echo \Plesk\Session\Helper::DEFAULT_LOGIN_TIMEOUT; ?>'
        ) {
            restoreDefaultButton.enable();
            restoreDefaultButton._tooltip.setText('<?php echo $this->form->lmsg('restoreDefaultButtonDescription');?>');
        } else {
            restoreDefaultButton.disable();
            restoreDefaultButton._tooltip.setText('<?php echo $this->form->lmsg('restoreDefaultButtonDescriptionDisable');?>');
        }
    };

    document.getElementById('disableCheckSessionIp').addEventListener('click', updateSessionOptions);
    document.getElementById('loginTimeout').addEventListener('keyup', updateSessionOptions);
    restoreDefaultButton.addEventObserver('click', function () {
        document.getElementById('loginTimeout').value = '<?php echo \Plesk\Session\Helper::DEFAULT_LOGIN_TIMEOUT; ?>';
        document.getElementById('disableCheckSessionIp').checked = false;
        updateSessionOptions();
    });
    updateSessionOptions();
});
//]]>
</script>
