Unverified Commit 8e53b25b authored by Julien Palard's avatar Julien Palard
Browse files

FIX: Profile switcher under constrained CSP.

parent 01673090
window.addEventListener("DOMContentLoaded", function (event) {
function set_lang(lang) {
document.cookie = "django_language=" + lang + ";samesite=strict;max-age=31536000;path=/";
window.location.reload(true);
}
document.querySelectorAll("button[data-lang]").forEach(function (button) {
button.addEventListener("click", function(e) {
set_lang(button.dataset.lang);
});
});
});
...@@ -72,16 +72,16 @@ ...@@ -72,16 +72,16 @@
<div class="col-md-8 offset-md-2"> <div class="col-md-8 offset-md-2">
<p> <p>
<h3>Preferred language</h3> <h3>Preferred language</h3>
<script>
function set_lang(lang) {
document.cookie = "django_language=" + lang + ";samesite=strict;max-age=31536000;path=/";
window.location.reload(true);
}
</script>
<ul> <ul>
{% get_current_language as current_language %} {% get_current_language as current_language %}
{% for language_tag, language in languages %} {% for language_tag, language in languages %}
<li><button type="button" class="btn btn-{% if language_tag != current_language%}outline-{%endif%}secondary" onclick="set_lang('{{ language_tag }}')">{{ language }}</button></li> <li>
<button
type="button"
data-lang="{{ language_tag }}"
class="btn btn-{% if language_tag != current_language%}outline-{%endif%}secondary">{{ language }}
</button>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
</p> </p>
...@@ -108,4 +108,5 @@ ...@@ -108,4 +108,5 @@
</div> </div>
</div> </div>
</div> </div>
<script src="{% static 'js/profile.js' %}?v={{ version }}" type="text/javascript"></script>
{% endblock %} {% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment