<!DOCTYPE html>
<html>
    <head>
        <meta name="GENERATOR" content="LMS {$layout.lmsv}">
        {include file="language.html"}
        <title>LMS – {if $layout.pagetitle neq ""}{$layout.pagetitle}{/if}</title>
        <link href="css/style.css" rel="stylesheet" type="text/css">
        <script src="js/common.js"></script>
        {if $js}
        <script>
            {$js}
        </script>
        {/if}
    </head>
    {if ! $part}
        <frameset name="all" frameborder="0" framespacing="0" ROWS="36,*">
            <frame scrolling="no" frameborder="0" marginheight="0" marginwidth="0" name="top" noresize src="?m=choosenetdevice{if isset($netdevid)}&netdevid={$netdevid}{/if}&p=top">
            <frame scrolling="always" frameborder="0" marginheight="0" marginwidth="0" name="main" noresize src="?m=choosenetdevice{if isset($netdevid)}&netdevid={$netdevid}{/if}&p=main">
        </frameset>
    {/if}
    {if $part eq "top"}
    <body class="lms-ui-popup">
        <form name="search" method="post" action="?m=choosenetdevice&netdevid={$netdevid}&p=main" target="main">
            <input type="submit" class="hiddenbtn">
            <table cellpadding="5" width="100%">
                <tr>
                    <td class="fall dark" align="center" nowrap>
                        <img src="img/netdev.gif" alt="">
                        <input type="text" name="searchnetdev" value="{$searchnetdev}" size="20" onkeyup="document.search.submit();">
                    </td>
                </tr>
            </table>
        </form>
        <script>

            window.addEventListener('DOMContentLoaded', function() {
                document.querySelector('form[name="search"] [name="searchnetdev"]').focus();
            });

        </script>
    </body>
    {/if}
    {if $part eq "main"}
    <body class="lms-ui-popup">
        <script>

            window.addEventListener('DOMContentLoaded', function() {
                var tbody = document.querySelector('tbody');
                tbody.addEventListener('click',function(e) {
                    if (e.target.tagName == 'TD') {
                        window.parent.parent.postMessage({
                                targetValue: e.target.parentNode.getAttribute('data-netdevice-id'),
                                targetSelector: "#" + targetfield.getAttribute('id')
                            }, "*"
                        );
                        window.parent.parent.popclick();
                    }
                });
            });

        </script>
        <table class="lmsbox lms-ui-background-cycle">
            {if $netdevices}
                <thead>
                    <tr>
                        <td class="nobr"><strong>{trans('Name:')}</strong></td>
                        <td class="nobr">{trans('Location:')}</td>
                        <td class="nobr">{trans('Producer:')}</td>
                        <td class="nobr">{trans('Empty ports:')}</td>
                    </tr>
                </thead>
            {/if}
            <tbody style="border: 0;">
                {foreach $netdevices as $netdevice}
                    <tr class="highlight" data-netdevice-id="{$netdevice.id}">
                        <td>
                            <strong>{$netdevice.name|escape}</strong>
                        </td>
                        <td>{$netdevice.location}</td>
                        <td>{$netdevice.producer|escape}</td>
                        <td class="text-center">{$netdevice.ports}</td>
                    </tr>
                {foreachelse}
                    <tr style="border: 0;">
                        <td colspan="5" class="empty-table">
                            {if $searchnetdev}
                                    {trans('No such devices matching search criteria.')}
                            {else}
                                    {trans('Enter device name.')}
                            {/if}
                        </td>
                    </tr>
                {/foreach}
            </tbody>
        </table>
    </body>
    {/if}
</html>
