Commit b34435f7 by xcoder

VPN-45 7. Насктройку языка надо сохранять. Я ставлю англ, обновляю страницу - язык снова русс

и вообще язык надо от системы брать
1 parent ba8f2878
...@@ -14,9 +14,31 @@ const langArr = [ ...@@ -14,9 +14,31 @@ const langArr = [
]; ];
const key = "KRYSTALVPN"; const key = "KRYSTALVPN";
const LANG = "LANG";
window.onload = function () { window.onload = function () {
let position = null; let position = null;
let platform = "desktop";
let langStr = null;
if (mobileCheck() && window.innerWidth <= 1023) {
platform = "mobile";
}
try {
langStr = JSON.parse(localStorage.getItem(LANG));
} catch (error) {
console.log("localStorage is not supported");
}
if (langStr == null) {
const lang = getLangFromBrowser();
switchLang(lang, platform);
}
else {
switchLang(langStr, platform);
}
try { try {
position = JSON.parse(localStorage.getItem(key)); position = JSON.parse(localStorage.getItem(key));
...@@ -75,6 +97,12 @@ function switchLang(lang, platform) { ...@@ -75,6 +97,12 @@ function switchLang(lang, platform) {
const dd = document.querySelector("#langSwitcher"); const dd = document.querySelector("#langSwitcher");
const ddMobile = document.querySelector("#langSwitcherMobile"); const ddMobile = document.querySelector("#langSwitcherMobile");
try {
localStorage.setItem(LANG, JSON.stringify(lang));
} catch (error) {
console.log("localStorage is not supported");
}
if (dd != null) { if (dd != null) {
const title = langArr.filter((elem) => elem.lang === lang)[0].title; const title = langArr.filter((elem) => elem.lang === lang)[0].title;
dd.innerHTML = title; dd.innerHTML = title;
...@@ -325,3 +353,9 @@ function mobileCheck() { ...@@ -325,3 +353,9 @@ function mobileCheck() {
return check || sizeCheck; return check || sizeCheck;
} }
function getLangFromBrowser() {
const userLang = navigator.language || navigator.userLanguage;
const lang = userLang.split("-")[0];
return lang;
}
\ No newline at end of file \ No newline at end of file
...@@ -903,7 +903,7 @@ hr.delimeter { ...@@ -903,7 +903,7 @@ hr.delimeter {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: flex-end;
justify-content: center; justify-content: center;
margin-bottom: 14px; margin-bottom: 14px;
...@@ -911,6 +911,12 @@ hr.delimeter { ...@@ -911,6 +911,12 @@ hr.delimeter {
user-select: none; user-select: none;
} }
@media screen and (max-width: 980px) {
.main > .main-second > .card.descr > .third-description-wrapper {
align-items: center;
}
}
.main .main
> .main-second > .main-second
> .card.descr > .card.descr
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!