chore: generate messages following map creation

Also, reuse the `U` global namespace for `MAP`.
This commit is contained in:
David Larlet 2024-02-19 17:08:48 -05:00
parent 61d3e70ae0
commit 5c0ca55f8c
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
3 changed files with 10 additions and 16 deletions

View file

@ -24,5 +24,4 @@
{% block map_init %} {% block map_init %}
{% include "umap/map_init.html" %} {% include "umap/map_init.html" %}
{% endblock map_init %} {% endblock map_init %}
{% include "umap/map_messages.html" %}
{% endblock content %} {% endblock content %}

View file

@ -2,9 +2,16 @@
<div id="map"></div> <div id="map"></div>
<!-- djlint:off --> <!-- djlint:off -->
<script defer type="text/javascript"> <script defer type="text/javascript">
let MAP
window.addEventListener('DOMContentLoaded', (event) => { window.addEventListener('DOMContentLoaded', (event) => {
MAP = new U.Map("map", {{ map_settings|notag|safe }}); U.MAP = new U.Map("map", {{ map_settings|notag|safe }})
}); {% for m in messages %}
{# We have just one, but we need to loop, as for messages API #}
U.MAP.ui.alert({
content: "{{ m }}",
level: "{{ m.tags }}",
duration: 100000
})
{% endfor %}
})
</script> </script>
<!-- djlint:on --> <!-- djlint:on -->

View file

@ -1,12 +0,0 @@
<script type="text/javascript">
window.addEventListener('DOMContentLoaded', (event) => {
{% for m in messages %}
{# We have just one, but we need to loop, as for messages API #}
MAP.ui.alert({
content: "{{ m }}",
level: "{{ m.tags }}",
duration: 100000
})
{% endfor %}
})
</script>