123 lines
3.2 KiB
JavaScript
123 lines
3.2 KiB
JavaScript
// $(document).ready(function (){
|
|
// middleWareJS()
|
|
// })
|
|
|
|
// window.onfocus = function () {
|
|
// getSocketState()
|
|
// }
|
|
let map_of_words_en = new Map([
|
|
['закрыть'],['Close']
|
|
])
|
|
let map_of_words_ru = new Map([
|
|
['close'],['Закрыть']
|
|
])
|
|
function translate_words (word,lang){
|
|
let corr_word = word.toLowersCase()
|
|
let trans_word = null
|
|
if (lang === 'ru'){
|
|
trans_word = map_of_words_ru.get(`${corr_word}`)
|
|
|
|
} else if (lang === 'en') {
|
|
trans_word = map_of_words_en.get(`${corr_word}`)
|
|
}
|
|
|
|
}
|
|
|
|
function check_return_trans_word (str) {
|
|
if (!str === undefined && str === '' && str){
|
|
return str
|
|
} else {
|
|
console.log(`error! str = ${str}`)
|
|
}
|
|
}
|
|
|
|
window.onload = function (){
|
|
middleWareJS()
|
|
}
|
|
|
|
function middleWareJS(){
|
|
let footer = document.querySelector("footer")
|
|
let body = document.querySelector("body")
|
|
|
|
if (document.querySelector(".menu_buttons.curtain.left") || window.location.href.includes('support') || window.location.href.includes('chat')){
|
|
footer.style.display = "none"
|
|
body.style.overflow = "hidden"
|
|
|
|
} else {
|
|
footer.style.display = ""
|
|
body.style.overflow = ""
|
|
}
|
|
|
|
}
|
|
|
|
function getTypeOfData (data) {
|
|
let type = typeof data
|
|
return type
|
|
}
|
|
|
|
|
|
function getInfoAboutUser (){
|
|
let user_type = ''
|
|
if (screen.width <= 700){
|
|
user_type = 'mobile'
|
|
} else if (screen.width > 1024) {
|
|
user_type = 'desctop'
|
|
} else if (screen.width > 700 && screen.width < 1024) {
|
|
user_type = 'laptop'
|
|
}
|
|
return user_type
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
let img = document.getElementById('dropbtn_lang')
|
|
if (window.location.href.indexOf("ru") > -1){
|
|
img.style.background = "url('/static/img/png/ru.png')"
|
|
img.style.backgroundRepeat = "no-repeat"
|
|
img.style.backgroundPosition = "left center"
|
|
|
|
}else if(window.location.href.indexOf("en") > -1){
|
|
img.style.background = "url('/static/img/png/en.png')"
|
|
img.style.backgroundRepeat = "no-repeat"
|
|
img.style.backgroundPosition = "left center"
|
|
}
|
|
});
|
|
|
|
window.addEventListener('scroll', () => {
|
|
// let headerBG = document.getElementById('header_bg')
|
|
//
|
|
// headerBG.style.backgroundColor = 'rgb(248 248 248 / 90%)'
|
|
// headerBG.style.padding = '20px 40px'
|
|
// headerBG.style.paddingBottom = 'padding: 10px 40px 10px 40px'
|
|
// headerBG.style.paddingRight = 'padding: 10px 40px 10px 40px'
|
|
// headerBG.style.paddingLeft = 'padding: 10px 40px 10px 40px'
|
|
})
|
|
|
|
// Действия при изменении URL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function scroll_ev (event,el){
|
|
let curtain = document.querySelector(".menu_buttons.filters")
|
|
let user_type = getInfoAboutUser()
|
|
let ch = el.scrollY
|
|
let top = 293 - ch + 20
|
|
if (user_type !== 'mobile' && user_type !== 'laptop'){
|
|
if (el.scrollY === 300){
|
|
curtain.style.top = `${top}px`
|
|
} else if (el.scrollY < 300) {
|
|
curtain.style.top = `${top}px`
|
|
} else if (el.scrollY > 300){
|
|
top = 15
|
|
curtain.style.top = `${top}px`
|
|
}
|
|
if (el.scrollY === 0){
|
|
top = 293 - ch
|
|
curtain.style.top = `${top}px`
|
|
}
|
|
}
|
|
}
|
|
|