Skip to content

Commit a9955d9

Browse files
qnighystefano-maggiolo
authored andcommitted
Make sure language cookie is set globally.
Setting language in submission list pages etc. makes the cookie local in the path of the page. Usually this behavior is not desired. This commit forces the cookie to be set globally.
1 parent fb5cb1b commit a9955d9

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

cms/server/static/cws_utils.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,19 @@ CMS.CWSUtils.prototype.update_time = function() {
217217
}
218218
};
219219

220-
CMS.CWSUtils.switch_lang = function() {
220+
CMS.CWSUtils.prototype.switch_lang = function() {
221+
var cookie_path = this.url_root + "/";
221222
var lang = $("#lang").val();
222223
if (lang === "") {
223-
document.cookie = "language=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
224+
document.cookie = "language="
225+
+ "; expires=Thu, 01 Jan 1970 00:00:00 GMT"
226+
+ "; path=" + cookie_path;
224227
} else {
225228
var expires = new Date();
226229
expires.setFullYear(expires.getFullYear() + 1);
227230
document.cookie = "language=" + lang
228-
+ "; expires=" + expires.toUTCString();
231+
+ "; expires=" + expires.toUTCString()
232+
+ "; path=" + cookie_path;
229233
}
230234
location.reload();
231235
};

cms/server/templates/contest/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<a class="brand" href="{{ url_root }}/">{{ contest.description }}</a>
5252
{% if len(langs) > 1 %}
5353
<p class="navbar-text pull-right">
54-
<select id="lang" class="form-control btn btn-info" onchange="CMS.CWSUtils.switch_lang()">
54+
<select id="lang" class="form-control btn btn-info" onchange="utils.switch_lang()">
5555
<option value=""{% if cookie_lang is None %} selected{% end %}>{{ _("Automatic (%s)") % lang_names[browser_lang] }}</option>
5656
{% for lang_code, lang_name in sorted(lang_names.iteritems(), key=lambda x: x[1]) %}
5757
<option value="{{ lang_code }}"{% if cookie_lang == lang_code %} selected{% end %}>{{ lang_name }}</option>

0 commit comments

Comments
 (0)