Files
account_store/static/js/global_js.js
2023-12-05 16:58:32 +03:00

103 lines
2.8 KiB
JavaScript

// $(document).ready(function (){
// middleWareJS()
// })
// window.onfocus = function () {
// getSocketState()
// }
window.onload = function (){
middleWareJS()
}
function middleWareJS(){
let footer = document.querySelector("footer")
let body = document.querySelector("body")
let type = getInfoAboutUser()
if (type !== 'mobile'){
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/svg/ru.svg')"
img.style.backgroundRepeat = "no-repeat"
img.style.backgroundPosition = "center"
// img.style.backgroundSize = '50%'
}else if(window.location.href.indexOf("en") > -1){
img.style.background = "url('/static/img/svg/gb.svg')"
img.style.backgroundRepeat = "no-repeat"
img.style.backgroundPosition = "center"
// img.style.backgroundSize = '50%'
}
});
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`
}
}
}