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 @@
<div class="col-md-8 offset-md-2">
<p>
<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>
{% get_current_language as current_language %}
{% 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 %}
</ul>
</p>
......@@ -108,4 +108,5 @@
</div>
</div>
</div>
<script src="{% static 'js/profile.js' %}?v={{ version }}" type="text/javascript"></script>
{% 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