<?php
// Copyright 1999-2021. Plesk International GmbH. All rights reserved.
?>
<script type="text/javascript">
//<![CDATA[
Jsw.onReady(function() {

    new Jsw.Hint({
        renderTo: 'main',
        hint: <?php echo $this->jsLmsg($this->selectorConfig['type'] . '-areaDescription'); ?>
    });

    new Jsw.List({
        renderTo: 'main',
        id: 'sites-list',
        data: <?php echo Zend_Json::encode($this->sitesList->fetchData()); ?>,
        dataUrl: '/web/site-select-list-data/type/<?php echo $this->selectorConfig['type']; ?>',
        columns: [{
            header: <?php echo $this->sitesList->jsLmsg('domain'); ?>,
            sortable: true,
            dataIndex: 'displayName',
            renderer: function(item) {
                if (item.subdomain) {
                    return '<div class="level1">' + item.displayName + '</div>';
                } else {
                    return item.displayName;
                }
            }
        }, {
            header: <?php echo $this->selectorConfig['statusTitleKey'] ? $this->sitesList->jsLmsg($this->selectorConfig['statusTitleKey']) : "''"; ?>,
            renderer: function(item) {
                var link = Jsw.prepareUrl('/web/proxy/type/<?php echo $this->selectorConfig['type']; ?>/id/' + item.domainId);
                if (item.subdomain) {
                    link += '/subdomain-id/' + item.subdomainId;
                }
                var status = <?php echo $this->selectorConfig['statusField'] ? ("item." . $this->selectorConfig['statusField']) : "''"; ?>;
                status = status ? (status + ' ') : '';
                var target = <?php echo $this->selectorConfig['newWindow'] ? "'target=\"_blank\"'" : "''"; ?>;
                return status + '<a ' + target + ' href="' + link + '">[' + <?php echo $this->sitesList->jsLmsg($this->selectorConfig['linkTitleKey']); ?> + ']</a>';
            }
        }]
    });

});
//]]>
</script>
