<?php
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.
?>

<div id="howToConfigureExternalDns" style="display: none;">
    <p data-name="extDnsHowtoIntro"><?php echo $this->lmsg('smb.components.forms.mail-settings.howToConfigureExternalDnsAlways'); ?></p>
    <?php if ($this->enabled): ?>
        <span data-name="extDnsHowtoOn"><?php echo $this->lmsg('smb.components.forms.mail-settings.howToConfigureExternalDnsEnabled'); ?></span>
        <ul>
            <?php foreach ($this->dnsRecords as $dnsRecord): ?>
                <?php echo '<li data-name="extDnsHowtoRecord" style="overflow-wrap: break-word;  word-break: break-word;">' . $this->escape($dnsRecord) . '</li>'; ?>
            <?php endforeach; ?>
        </ul>
        <span data-name="extDnsHowtoAliases"><?php echo $this->lmsg('smb.components.forms.mail-settings.howToConfigureExternalDnsEnabledAliases'); ?></span>
    <?php else: ?>
        <p data-name="extDnsHowtoOff"><?php echo $this->lmsg('smb.components.forms.mail-settings.howToConfigureExternalDnsDisabled', ['option' => $this->lmsg('smb.components.forms.mail-settings.domainKeys')]); ?></p>
    <?php endif; ?>
</div>

<script type="text/javascript">
    //<![CDATA[
    Jsw.onReady(function () {
        var hintContainer = document.createElement('span');
        hintContainer.className = 'hint-inline hint-info';
        hintContainer.innerHTML = '&nbsp;&nbsp;';
        var hint = document.createElement('a');
        hint.className = 's-btn sb-help';
        hint.setAttribute('data-name', 'extDnsHowtoLink');
        hint.innerHTML = <?php echo $this->jsLmsg('smb.components.forms.mail-settings.howToConfigureExternalDns'); ?>;
        Jsw.render(hintContainer, hint);

        Jsw.render(document.querySelector('#domainKeys-form-row label'), hintContainer, 'after');
        new Jsw.DynamicPopupHint.Instance({
            title: <?php echo $this->jsLmsg('smb.components.forms.mail-settings.howToConfigureExternalDns'); ?>,
            placement: 'top',
            target: hint,
            content: document.getElementById('howToConfigureExternalDns').innerHTML
        });
        document.getElementById('howToConfigureExternalDns').innerHTML = '';
    });
    //]]>
</script>
