fix localization
This commit is contained in:
@@ -1,34 +1,58 @@
|
||||
window.cookies = {
|
||||
Read: function (name) {
|
||||
try {
|
||||
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
|
||||
if (match) return decodeURIComponent(match[2]);
|
||||
return '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
Read: function (name) {
|
||||
try {
|
||||
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
|
||||
if (match) return decodeURIComponent(match[2]);
|
||||
return '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
Write: function (name, value, expiresIso) {
|
||||
try {
|
||||
var expires = '';
|
||||
if (expiresIso) {
|
||||
expires = '; expires=' + new Date(expiresIso).toUTCString();
|
||||
}
|
||||
document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/';
|
||||
} catch (e) { }
|
||||
},
|
||||
Delete: function (cookie_name) {
|
||||
document.cookie = cookie_name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
}
|
||||
};
|
||||
|
||||
window.ajax = {
|
||||
Post: async function (url, data) {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'include',
|
||||
body: JSON.stringify(data)
|
||||
});
|
||||
const text = await res.text();
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
} catch {
|
||||
return { success: res.ok, message: text };
|
||||
}
|
||||
} catch (err) {
|
||||
return { success: false, message: err?.toString() ?? 'network error' };
|
||||
}
|
||||
}
|
||||
},
|
||||
Write: function (name, value, expiresIso) {
|
||||
try {
|
||||
var expires = '';
|
||||
if (expiresIso) {
|
||||
expires = '; expires=' + new Date(expiresIso).toUTCString();
|
||||
}
|
||||
document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/';
|
||||
} catch (e) { }
|
||||
}
|
||||
};
|
||||
|
||||
window.getBrowserLanguage = function () {
|
||||
try {
|
||||
return (navigator.languages && navigator.languages[0]) || navigator.language || navigator.userLanguage || '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
try {
|
||||
return (navigator.languages && navigator.languages[0]) || navigator.language || navigator.userLanguage || '';
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
window.setHtmlLang = function (lang) {
|
||||
try {
|
||||
if (document && document.documentElement) document.documentElement.lang = lang || '';
|
||||
} catch (e) { }
|
||||
try {
|
||||
if (document && document.documentElement) document.documentElement.lang = lang || '';
|
||||
} catch (e) { }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user