{% extends "base.htm" %}

{% block content %}

<script>
  function convertUTCDateToLocalDate(date) {
  var newDate = new Date(date.getTime() + date.getTimeZoneOffset()*60*1000);
  var offset = date.getTimezoneOffset() / 60;
  var hours = date.getHours();
  newDate.setHours(hours - offset);
  return newDate;
  }
</script>


<h1>Minecraft Points of Interest </h1>

<h2> 2D Map </h2>
    {% if map_html_2d %}
    {{map_html_2d}}
    {% endif %}

{% if current_user.is_authenticated %}
  <h2>Add new POI</h2>
  <form method="post" class="poiform">
  {{ form.csrf_token }}
  {{ form.name.label }} {{ form.name }}
  {{ form.x.label }} {{ form.x(class_="coordnum") }}
  {{ form.y.label }} {{ form.y(class_="coordnum") }}
  {{ form.z.label }} {{ form.z(class_="coordnum") }}
  {{ form.public.label }} {{ form.public }}
  <input type="submit">
  </form>
{% endif %}

<h2> List of POIs </h2>
<table class="poi_list">
  <tr>
    <th>Name</th>
    <th>X</th>
    <th>Y</th>
    <th>Z</th>
    <th>created by</th>
    <th>created at</th>
  </tr>
{#      MCcoordstore - simple web based store for Minecraft points of interest
#      Copyright (C) 2021  Daniel Philip Weatherill

#      This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your option)
# any later version.

#      This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
# details.

#      You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}


  
  {% for poi in poi_table_data %}
  <tr>
    <td>{{ poi.name }} </td>
    <td>{{ poi.coord_x }} </td>
    <td>{{ poi.coord_y }} </td>
    <td>{{ poi.coord_z }} </td>
    <td>{{ poi.user.displayname }} </td>
    <td id="date{{poi.poiid}}">{{ poi.create_date.isoformat() }} </td>
    {% if poi.user == current_user %}
    <td> <a href="/poi/delete/{{poi.poiid}}" method=> delete </a></td>
    {% endif %}
  </tr>
  {% endfor %}
</table>


{% endblock %}

