<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>
<?php
echo $this->form;
$typeElementId = $this->form->getElement('type')->getId();
?>
<script type="text/javascript">
//<![CDATA[
Jsw.namespace('Smb.Views.SslCertificate');
Smb.Views.SslCertificate.setType = function (type) {
    document.getElementById('<?php echo $typeElementId ?>').value = type;
};

Smb.Views.SslCertificate.removeCaCertificate = function (button) {
    Jsw.messageBox.show({
        type: Jsw.messageBox.TYPE_YESNO,
        subtype: Jsw.messageBox.SUBTYPE_DELETE,
        text: <?php echo $this->jsLmsg('components.forms.ssl-certificate.add.removeCaCertificateConfirmation') ?>,
        onYesClick: function () {
            Smb.Views.SslCertificate.setType('removeCa');
            Jsw.submit(button);
        },
    });
};

Smb.Views.SslCertificate.submitFilesForm = function (context) {
    if ('' === document.getElementById('name').value) {
        alert(<?php echo $this->jsLmsg('enterCertificateName'); ?>);
        document.getElementById('name').focus();
        return;
    }

    Smb.Views.SslCertificate.setType('sendFiles');
    Jsw.submit(context);
};
//]]>
</script>
