<html>
<head>
  <title>Email Debugger</title>
  <style type="text/css">
    pre {
      white-space: pre-wrap;       /* Since CSS 2.1 */
      white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
      white-space: -pre-wrap;      /* Opera 4-6 */
      white-space: -o-pre-wrap;    /* Opera 7 */
      word-wrap: break-word;       /* Internet Explorer 5.5+ */
      line-height: 15px;
    }
  </style>
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
  <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"/>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
</head>
<body>
<div class="container-fluid">
  <div class="card mt-2">
    <form method="POST" action="{% url 'email-debugger' %}" class="form-inline m-0">
      {% for field in form %}
        <label class="m-2" for="{{ field.name }}">{{ field.label }}</label>
        {{ field }}
      {% endfor %}
      <button type="submit" class="btn btn-primary m-2">Render</button>
    </form>
  </div>

  {% if subject %}
  <div class="card mt-2" style="height:85%;">
    <div class="card-header">
      <ul id="tabnav" class="nav nav-pills card-header-pills">
        <li class="nav-item">
          <a class="nav-link active" data-toggle="tab" href="#html-body">HTML</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" data-toggle="tab" href="#plain-body">Plaintext</a>
        </li>
      </ul>
    </div>
    <div class="card-content" style="height:100%;">
      <div class="tab-content" style="height:100%;">
        <div id="html-body" class="tab-pane active" style="height:100%;">
          <iframe frameborder="0" width="100%" height="100%" src="data:text/html,{{ html_body|urlencode }}"></iframe>
        </div>
        <div id="plain-body" class="tab-pane"><pre class="p-1">{{ text_body }}</pre></div>
      </div>
    </div>
  </div>
  {% endif %}
</div>
</body>
<script>
$('#tabnav a').on('click', function (e) {
  e.preventDefault();
  $(this).tab('show');
});
</script>
</html>
