Browse Source

fix some map zooming issues

testing
Burathar 4 years ago
parent
commit
520847904e
  1. 78
      app/templates/base.html
  2. 15
      app/templates/game_bunny_dashboard.html
  3. 124
      app/templates/game_hunter_dashboard.html
  4. 10
      app/templates/game_owner_dashboard.html
  5. 1
      app/templates/game_player.html

78
app/templates/base.html

@ -11,52 +11,56 @@ @@ -11,52 +11,56 @@
{% block navbar %}
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ url_for('main.index') }}">The Hunt</a>
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="{{ url_for('main.index') }}">The Hunt</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ url_for('main.index') }}">Home</a></li>
{% if current_user.is_authenticated %}
<li><a href="{{ url_for('main.create_game') }}">Create Game</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %}
<li><a href="{{ url_for('auth.login') }}">Login</a></li>
{% else %}
<li><a href="{{ url_for('main.user_profile', username=current_user.name) }}">
<div class="hidden-xs hidden-sm">
{{ current_user.name }}{% if game is defined %}/{{ game.name }}{% endif %}</div>
</a></li>
<li><a href="{{ url_for('auth.logout') }}">Logout</a></li>
{% endif %}
</ul>
</div>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="{{ url_for('main.index') }}">Home</a></li>
{% if current_user.is_authenticated %}
<li><a href="{{ url_for('main.create_game') }}">Create Game</a></li>
{% endif %}
</ul>
<ul class="nav navbar-nav navbar-right">
{% if current_user.is_anonymous %}
<li><a href="{{ url_for('auth.login') }}">Login</a></li>
{% else %}
<li><a href="{{ url_for('main.user_profile', username=current_user.name) }}"><div class="hidden-xs hidden-sm">{{ current_user.name }}{% if game is defined %}/{{ game.name }}{% endif %}</div></a></li>
<li><a href="{{ url_for('auth.logout') }}">Logout</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
{% endblock %}
{% block content %}
<div class="container">
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-info" role="alert">{{ message }}</div>
{% endfor %}
{% endif %}
{% endwith %}
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-info" role="alert">{{ message }}</div>
{% endfor %}
{% endif %}
{% endwith %}
{# application content needs to be provided in the app_content block #}
{% block app_content %}{% endblock %}
{# application content needs to be provided in the app_content block #}
{% block app_content %}{% endblock %}
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
{{ moment.include_moment() }}
{{ super() }}
{{ moment.include_moment() }}
{% endblock %}

15
app/templates/game_bunny_dashboard.html

@ -60,21 +60,22 @@ @@ -60,21 +60,22 @@
<script type="text/javascript", crossorigin="anonymous">
// Leaflet Map
map = getMap()
var string = '{{ current_user.player_in(game).encode_objectives() |safe }}'
var objectives = JSON.parse(string)
markers = []
var objectives = JSON.parse('{{ current_user.player_in(game).encode_objectives() |safe }}')
for (var i = 0; i < objectives.length; i++){
addObjectiveMarker(map, objectives[i])
markers.push([objectives[i].latitude, objectives[i].longitude])
}
var self = JSON.parse('{{ json.dumps(current_user.last_location(game), cls=location_encoder)|safe }}')
var self = JSON.parse('{{ json.dumps(current_user.last_location(), cls=location_encoder)|safe }}')
if (self){
addPlayerMarker(map, self)
markers.push([self.latitude, self.longitude])
}
map.fitBounds(
objectives.map(o => [o.latitude, o.longitude]).concat([self].map(p => [p.latitude, p.longitude]))
);
if (markers.length > 0) {
map.fitBounds(markers);
}
</script>
{% endblock %}

124
app/templates/game_hunter_dashboard.html

@ -9,81 +9,91 @@ @@ -9,81 +9,91 @@
{% block player_app_content %}
<div class="row">
<div class="col-xs-0 col-md-1"></div>
<div class="col-xs-0 col-md-1"></div>
<div class="col-xs-12 col-md-7">
<h2>Bunnies</h2>
<div class="table">
<table class="table">
<thead>
<tr>
<th scope="col">Player Name</th>
<th scope="col">Times Caught</th>
<th scope="col">Last location</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% set player = current_user.player_in(game) %}
{% for bunny in game.bunnies() %}
<tr>
<td>{{ bunny.user.name }}</td>
<td><span style="color:green;">{{ bunny.player_caught_by_players | selectattr('catching_player', '==', player) | selectattr('review.name', '==', 'accepted') |list|length}}</span> /
<span style="color:red;">{{ bunny.player_caught_by_players | selectattr('catching_player', '==', player) | selectattr('review.name', '==', 'denied') |list|length}}</span> /
<span style="color:gray;">{{ bunny.player_caught_by_players | selectattr('catching_player', '==', player) | selectattr('review.name', '==', 'none') |list|length}}</span>
</td>
<td>{% with location = bunny.last_location(offset=hunter_delay) %}
{% if location %}{{ moment(location.timestamp).fromNow()}}
{% else %}
{{ location }}
{% endif %}
{% endwith %}</td>
<td>
<a href="{{ url_for('main.catch_bunny', game_name=game.name, bunny_name=bunny.user.name) }}">
<button class="btn btn-success btn-sm">Catch</button>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<span style="font-size: smaller;">
(<span style="color:green;">Accepted</span>/<span style="color:red;">Denied</span>/<span style="color:gray;">Not reviewed</span>)
</span>
<div class="col-xs-12 col-md-7">
<h2>Bunnies</h2>
<div class="table">
<table class="table">
<thead>
<tr>
<th scope="col">Player Name</th>
<th scope="col">Times Caught</th>
<th scope="col">Last location</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
{% set player = current_user.player_in(game) %}
{% for bunny in game.bunnies() %}
<tr>
<td>{{ bunny.user.name }}</td>
<td><span
style="color:green;">{{ bunny.player_caught_by_players | selectattr('catching_player', '==', player) | selectattr('review.name', '==', 'accepted') |list|length}}</span>
/
<span
style="color:red;">{{ bunny.player_caught_by_players | selectattr('catching_player', '==', player) | selectattr('review.name', '==', 'denied') |list|length}}</span>
/
<span
style="color:gray;">{{ bunny.player_caught_by_players | selectattr('catching_player', '==', player) | selectattr('review.name', '==', 'none') |list|length}}</span>
</td>
<td>{% with location = bunny.last_location(offset=hunter_delay) %}
{% if location %}{{ moment(location.timestamp).fromNow()}}
{% else %}
{{ location }}
{% endif %}
{% endwith %}</td>
<td>
<a
href="{{ url_for('main.catch_bunny', game_name=game.name, bunny_name=bunny.user.name) }}">
<button class="btn btn-success btn-sm">Catch</button>
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<span style="font-size: smaller;">
(<span style="color:green;">Accepted</span>/<span style="color:red;">Denied</span>/<span
style="color:gray;">Not
reviewed</span>)
</span>
</div>
</div>
<div class="col-xs-12 col-md-3">
{% include '_game_player_info.html' %}
</div>
</div>
<div class="col-xs-12 col-md-3">
{% include '_game_player_info.html' %}
</div>
</div>
<div class="row">
<div class="col-xs-1 col-md-1"></div>
<div id="map" style=" height: 500px; border-radius: 10px; " class="col-xs-10 col-md-10"></div>
<div class="col-xs-1 col-md-1"></div>
<div class="col-xs-1 col-md-1"></div>
<div id="map" style=" height: 500px; border-radius: 10px; " class="col-xs-10 col-md-10"></div>
<div class="col-xs-1 col-md-1"></div>
</div>
{% endblock %}
{% block scripts %}
{{ super() }}
<script type="text/javascript", crossorigin="anonymous">
<script type="text/javascript" , crossorigin="anonymous">
// Leaflet Map
map = getMap()
var bunnies = JSON.parse('{{ json.dumps(game.last_locations(game.bunnies(), offset=hunter_delay), cls=location_encoder)|safe }}')
for (var i = 0; i < bunnies.length; i++){
markers = []
var bunnies = JSON.parse(
'{{ json.dumps(game.last_locations(game.bunnies(), offset=hunter_delay), cls=location_encoder)|safe }}')
for (var i = 0; i < bunnies.length; i++) {
addPlayerMarker(map, bunnies[i])
markers.push([bunnies[i].latitude, bunnies[i].longitude])
}
var self = JSON.parse('{{ json.dumps(current_user.last_location(game), cls=location_encoder)|safe }}')
if (self){
var self = JSON.parse('{{ json.dumps(current_user.last_location(), cls=location_encoder)|safe }}')
if (self) {
addPlayerMarker(map, self, greenPlayerIcon)
markers.push([self.latitude, self.longitude])
}
map.fitBounds(
bunnies.map(o => [o.latitude, o.longitude]).concat([self].map(p => [p.latitude, p.longitude]))
);
if (markers.length > 0) {
map.fitBounds(markers);
}
</script>
{% endblock %}

10
app/templates/game_owner_dashboard.html

@ -101,21 +101,23 @@ @@ -101,21 +101,23 @@
<script type="text/javascript", crossorigin="anonymous">
// Leaflet Map
map = getMap()
markers = []
var objectives = JSON.parse('{{ json.dumps(game.objectives, cls=objective_encoder)|safe }}')
for (var i = 0; i < objectives.length; i++){
addObjectiveMarker(map, objectives[i])
markers.push([objectives[i].latitude, objectives[i].longitude])
}
var players = JSON.parse('{{ json.dumps(game.last_player_locations(), cls=location_encoder)|safe }}')
for (var i = 0; i < players.length; i++){
addPlayerMarker(map, players[i])
markers.push([players[i].latitude, players[i].longitude])
}
map.fitBounds(
objectives.map(o => [o.latitude, o.longitude]).concat(players.map(p => [p.latitude, p.longitude]))
);
if (markers.length > 0) {
map.fitBounds(markers);
}
//Delete Game button
function deleteGame() {

1
app/templates/game_player.html

@ -75,7 +75,6 @@ @@ -75,7 +75,6 @@
{{ super() }}
<script type="text/javascript" , crossorigin="anonymous">
// Leaflet Map
'{% set last_location = player.last_location() %}'
map = getMap()
var locations = JSON.parse('{{ json.dumps(player.locations_during_game(), cls=location_encoder)|safe }}')

Loading…
Cancel
Save