<table width="100%" cellpadding='0'>
<%
  sv = @dip.server
%>
<tr>
 <th colspan="2">
  <%= form('focus', context)%>
  <select name='ipaddr' onchange="this.form.submit()">
   <option value="">All</option>
<%
   @dip.server.recent.each do |host, info|
     next unless info['nickname']
     selected = (info['addr'] == @focus) ? "selected" : ""
%>
   <option <%=selected%> value="<%=h info['addr']%>"><%=h info['nickname']%></option>
<%
   end
%>
  </select>
  <input type="submit" value="Show" />
  </form>
 </th>
</tr>
<%
  sv.msg_holder.each do |msg|
    next if @hidden[msg.key]
    sent = msg.sent?
    if @focus
      next if sent && msg.to_addr != @focus
      next if !sent && msg.from_addr != @focus
    end

    if msg.sent?
      opened_icon = msg.opened ? '!' : '?'
%>
<tr bgcolor="#eeeeff">
 <td>
  <%=h msg.time.strftime("%H:%M:%S") %> 
  To: <%=h sv.member(msg.to_addr)['nickname']%>
 </td>
 <td align="right">
  <%= opened_icon%>
  [<%=a('focus', {'ipaddr'=>msg.to_addr}, context)%>v</a>]
  [<%=a('hide', {'key'=>msg.key}, context)%>X</a>]
 </td>
</tr>
<tr>
 <td colspan="2">
  <pre><%=h msg.message %></pre>
 </td>
</tr>
<%
    else  
      if msg.opened
%>
<tr bgcolor="#ffeeee">
 <td>
  <%=h msg.time.strftime("%H:%M:%S") %> 
  From: <%=h sv.member(msg.from_addr)['nickname']%>
 </td>
 <td align="right">
  [<%=a('send', {'key'=>msg.key}, context)%>reply</a>]
  [<%=a('focus', {'ipaddr'=>msg.from_addr}, context)%>v</a>]
  [<%=a('hide', {'key'=>msg.key}, context)%>X</a>]
 </td>
</tr>
<tr>
 <td colspan="2">
  <pre><%=h msg.message %></pre>
 </td>
</tr>
<%
      else
%>
<tr bgcolor="#ffeeee">
 <td>
  <%=h msg.time.strftime("%H:%M:%S") %>
  From: <%=h sv.member(msg.from_addr)['nickname']%>
 </td>
 <td align="right">
  [<%=a('open', {'key'=>msg.key}, context)%>open</a>]
 </td>
</tr>
<%
      end
    end
  end
%>
</table>
