<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
            <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
            <title>rMPD</title>
            <!--<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>-->
            <link rel="stylesheet" type="text/css" href="display.css"/>
    </head>
    
    <body>
        <h1>MPD Web</h1>
        <h2>Search</h2>

        <!-- Search Form -->
        <form action="search.rb" method="get">
            <input type="text" name="search" value="<%= $term %>" />
            <select name="type">
            <% ['title','artist','album','filename'].each do |t| %>
                <option value="<%= t %>"
                <%= ($type==t) ? 'selected="selected"' : '' %>>
                    <%= t %>
                </option>
            <% end %>
            </select>
            <input type="submit" value="Search" />
        </form>

        <!-- Display results -->
        <% if $searching %>
        <table>
            <tr>
            <% $config[:fbHeaders].each do |title| %>
                <th><%= title %></th>
            <% end %>
            </tr>
            <!--~~~~~~~~~~~~-->
            <% $results.each do |f| %>
            <tr>
            <% $config[:fbContent].each do |col| %>
                <td>
                <% if col == 'tools' %>
                    <%= file_tools f['file'] %>
                <% else %>
                    <%= f[col] %>
                <% end %>
                </td>
            <% end %>
            </tr>
            <% end %>
        </table>
        <% end %>

        <!-- Link home -->
        <div style="margin-top: 3em;">
            <a href="index.rb">Home</a>
        </div>
    </body>
</html>
