diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-01-15 15:50:43 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-01-15 15:50:43 +0100 |
commit | d58f61770463aab2c71464c11f902f0074b49b62 (patch) | |
tree | 97f55098caa342c1146f4e0bdc9f299affb62739 /views/http | |
parent | 2d0da0b920035c90d56db5dbec6d62f5b50ba0c2 (diff) |
Diffstat (limited to 'views/http')
-rw-r--r-- | views/http/account.twig | 22 | ||||
-rw-r--r-- | views/http/base.twig | 7 | ||||
-rw-r--r-- | views/http/components/timer.twig | 6 | ||||
-rw-r--r-- | views/http/village.twig | 72 |
4 files changed, 101 insertions, 6 deletions
diff --git a/views/http/account.twig b/views/http/account.twig new file mode 100644 index 0000000..8b32feb --- /dev/null +++ b/views/http/account.twig @@ -0,0 +1,22 @@ +{% extends 'base.twig' %} + +{% block main %} +<h1>Account</h1> + +<form action="/account" method="post"> + <label> + Username + <input type="text" name="username" value="{{ user.username }}"> + </label> + <label> + E-Mail + <input type="email" name="email" value="{{ user.email }}"> + </label> + <label> + Password + <input type="password" name="password"> + </label> + + <input type="submit" value="Save"> +</form> +{% endblock %} diff --git a/views/http/base.twig b/views/http/base.twig index 15ddafd..bd59207 100644 --- a/views/http/base.twig +++ b/views/http/base.twig @@ -5,7 +5,12 @@ <header> <nav> <a href="/villages">Overview</a> - <a href="/logout">Logout</a> + {% if session.user %} + <a href="/account">Account</a> + <a href="/logout">Logout</a> + {% else %} + <a href="/login">Login</a> + {% endif %} </nav> <span>Logged in as {{ session.user.username }}</span> </header> diff --git a/views/http/components/timer.twig b/views/http/components/timer.twig index ccb31a7..4898a2e 100644 --- a/views/http/components/timer.twig +++ b/views/http/components/timer.twig @@ -14,12 +14,18 @@ document.addEventListener('DOMContentLoaded', function (ev) { window.location.reload(); } + const dd = Math.floor(diff/1000/60/60/24); + diff -= dd*1000*60*60*24; const hh = Math.floor(diff/1000/60/60); diff -= hh*1000*60*60; const mm = Math.floor(diff/1000/60); diff -= mm*1000*60; const ss = Math.floor(diff/1000); + timer.innerHTML = `${('00' + hh).slice(-2)}:${('00' + mm).slice(-2)}:${('00' + ss).slice(-2)}`; + if (dd > 0) { + timer.innerHTML = `${('00' + dd).slice(-2)}:${timer.innerHTML}`; + } } setTime(); }); diff --git a/views/http/village.twig b/views/http/village.twig index c157a04..a498ea6 100644 --- a/views/http/village.twig +++ b/views/http/village.twig @@ -132,7 +132,7 @@ {% endif %} {% if events['SendUnits'] %} - <h4>Send Resources / Units</h4> + <h4>Send Units</h4> <table> <thead> <tr> @@ -172,6 +172,68 @@ </tbody> </table> {% endif %} + + {% if events['SendResources'] %} + <h4>Send Resources</h4> + <table> + <thead> + <tr> + <th>Source</th> + <th>Destination</th> + <th>Resources</th> + <th>Time</th> + <th></th> + </tr> + </thead> + <tbody> + {% for event in events['SendResources'] %} + <tr> + <td>{{ village.get(event.source).name }}</td> + <td>{{ village.get(event.destination).name }}</td> + <td>Resources</td> + <td class="timer"> + {% include 'components/timer.twig' with { 'time': event.event.time|date('c') } %} + </td> + <td> + {% if event.isCanceled %} + Canceled + {% else %} + {% if event.event.villageId == village.id %} + <form action="/event/{{ event.event.id }}/cancel" method="post"> + <input type="submit" value="Cancel"> + </form> + {% endif %} + {% endif %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} + + {% if events['SendResourcesCarriers'] %} + <h4>Send Resources Carriers</h4> + <table> + <thead> + <tr> + <th>Source</th> + <th>Destination</th> + <th>Time</th> + </tr> + </thead> + <tbody> + {% for event in events['SendResourcesCarriers'] %} + <tr> + <td>{{ village.get(event.source).name }}</td> + <td>{{ village.get(event.destination).name }}</td> + <td class="timer"> + {% include 'components/timer.twig' with { 'time': event.event.time|date('c') } %} + </td> + </tr> + {% endfor %} + </tbody> + </table> + {% endif %} </div> <div class="village__main"> @@ -344,10 +406,10 @@ {% if village.getBuilding(village.id, 'PostOffice') %} <h3>Send Resources</h3> <form action="/village/{{ village.x }}/{{ village.y }}/send-resources" method="post"> - <input type="number" min="1" name="wood" placeholder="Amount Wood" required> - <input type="number" min="1" name="clay" placeholder="Amount Clay" required> - <input type="number" min="1" name="iron" placeholder="Amount Iron" required> - <input type="number" min="1" name="food" placeholder="Amount Food" required> + <input type="number" min="0" name="wood" placeholder="Amount Wood" required> + <input type="number" min="0" name="clay" placeholder="Amount Clay" required> + <input type="number" min="0" name="iron" placeholder="Amount Iron" required> + <input type="number" min="0" name="food" placeholder="Amount Food" required> <select name="village"> {% for v in villages %} <option value="{{ v.id }}">{{ v.name }}</option> |