<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>View Journal</title>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css"
    />
  </head>
  <body>
    <main class="container">
      {% if password_matches %}
      <form method="POST">
        <div class="field has-addons">
          <div class="control is-expanded">
            <textarea required class="textarea is-primary has-fixed-size" type="text" name="line"> </textarea>
          </div>
          <div class="control">
	        <button style="height: 100%" class="button is-primary" type="submit"> Add </button> 
          </div>
        </div>
          <input
            hidden="1"
            type="number"
            value="0"
            name="timezone_offset"
            id="utc_offset"
          />
      </form>
      {% endif %}
      <table class="table is-fullwidth">
        <thead>
          <tr>
            <th style="">Date</th>
            <th style="width: 100%">Note</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            {% for line in journal.lines | reverse %}
            <td>
              <time datetime="{{ line.uploaded_date }}">
                {{ line.uploaded_date | date(format="%Y-%m-%d %H:%M") }}
              </time>
            </td>
            <td>{{ line.line }}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </main>

    <script>
      let offset = new Date().getTimezoneOffset();
      document.getElementById("utc_offset").value = offset;
    </script>
  </body>
</html>