fix: take into account cookie in js
This commit is contained in:
parent
1d67debfd0
commit
1a3cecabe5
|
@ -42,8 +42,8 @@ body {
|
|||
}
|
||||
|
||||
.no-js .requires-js {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
display: none !important;
|
||||
visibility: hidden !important;
|
||||
}
|
||||
|
||||
details {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
allowed: [],
|
||||
centre: 'All',
|
||||
list: null,
|
||||
lang: 'en',
|
||||
lang: null,
|
||||
};
|
||||
|
||||
function addJsClass() {
|
||||
|
@ -62,6 +62,16 @@
|
|||
dataCentre.value = state.centre;
|
||||
|
||||
let language = document.getElementById('language');
|
||||
if (state.lang === null) {
|
||||
state.lang = language.dataset.accept;
|
||||
let cookie = document.cookie
|
||||
.split(';')
|
||||
.find(row => row.trim().startsWith('lang='));
|
||||
if (cookie !== undefined) {
|
||||
state.lang = decodeURIComponent(cookie.split('=')[1]);
|
||||
}
|
||||
}
|
||||
|
||||
language.value = state.lang;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,15 @@ pub enum Language {
|
|||
}
|
||||
|
||||
impl Language {
|
||||
pub fn code(&self) -> &'static str {
|
||||
match self {
|
||||
Self::English => "en",
|
||||
Self::Japanese => "ja",
|
||||
Self::German => "de",
|
||||
Self::French => "fr",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_codes(val: Option<&str>) -> Self {
|
||||
let val = match val {
|
||||
Some(v) => v,
|
||||
|
|
|
@ -52,7 +52,7 @@ Remote Party Finder
|
|||
</details>
|
||||
</div>
|
||||
<div class="right">
|
||||
<select id="language">
|
||||
<select id="language" data-accept="{{ lang.code() }}">
|
||||
<option value="en">English</option>
|
||||
<option value="ja">日本語</option>
|
||||
<option value="de">Deutsch</option>
|
||||
|
|
Loading…
Reference in New Issue