Files
apps.supersamsev.ru/webroot/js/custom.js
T

42 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
function replaceToRus(str) {
let replacer = {
"q": "й", "w": "ц", "e": "у", "r": "к", "t": "е", "y": "н", "u": "г",
"i": "ш", "o": "щ", "p": "з", "[": "х", "]": "ъ", "a": "ф", "s": "ы",
"d": "в", "f": "а", "g": "п", "h": "р", "j": "о", "k": "л", "l": "д",
";": "ж", "'": "э", "z": "я", "x": "ч", "c": "с", "v": "м", "b": "и",
"n": "т", "m": "ь", ",": "б", ".": "ю",
"/": ".", '@': '"', '#': '№', '$': ';', '^': ':', '&': '?', '?': ',',
};
for(let i=0; i < str.length; i++){
if(replacer[str[i]] != undefined){
str = str.replace(str[i], replacer[str[i]]);
}
}
return str;
}
function replaceToEng(str) {
let replacer = {
"й": "q", "ц": "w", "у": "e", "к": "r", "е": "t", "н": "y", "г": "u",
"ш": "i", "щ": "o", "з": "p", "х": "[", "ъ": "]", "ф": "a", "ы": "s",
"в": "d", "а": "f", "п": "g", "р": "h", "о": "j", "л": "k", "д": "l",
"ж": ";", "э": "'", "я": "z", "ч": "x", "с": "c", "м": "v", "и": "b",
"т": "n", "ь": "m", "б": ",", "ю": ".",
".": "/", '"': '@', '№': '#', ';': '$', ':': '^', '?': '&', ',': '?',
};
for(let i=0; i < str.length; i++){
if(replacer[str[i]] != undefined){
str = str.replace(str[i], replacer[str[i]]);
}
}
return str;
}
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}