<%inherit file="/html/_base.html" />
<div>${ module.name }</div>
<div class="source" >
  <table>
% for lineno, line in enumerate(source.splitlines()):
    <% lineno += 1 %>
    <tr 
% if lineno in module.statements:
%   if module.statements[lineno]:
        class="hit"
%   else:
        class="miss"
%   endif
% endif
        >
      <td class="lineno" >${ lineno }</td>
      <td><pre>${ line }</pre></td>
%   if conditions.get(lineno):
%     if any(condition.conditions_missed(module.options.report_conditions_with_literals) \
             for col, condition_list in conditions.get(lineno).items() \
             for condition in condition_list):
      <td class="missed-conditions"><div>${ decorate_line(lineno, line, conditions)}</div></td>
%     endif
%   endif
    </tr>
% endfor
</table>
</div>
<%def name="decorate_line(lineno, line, conditions)">
<%
    decoration = ""
    for col_offset in conditions.get(lineno, {}):
        conditions_for_col_offset = \
            conditions[lineno][col_offset]
        for condition in conditions_for_col_offset:
            if not condition.conditions_missed(module.options.report_conditions_with_literals):
                continue
            decoration += condition.result().replace("\n", "<br>") + "<br><br>"
%>
${ decoration }
</%def>
<script type="text/javascript">
  $(function () {
    $('td.missed-conditions').each( function(index, element) {
      $(element).siblings('.lineno').addClass('hoverable');
      $(element).siblings().hover(function (event) {
        $(element).dialog('open');
      }, function (event) {
        $(element).dialog('close');
      });
      $(element).dialog({autoOpen: false});
    });
  });
</script>
