// $(document).ready(function (){ // middleWareJS() // }) // window.onfocus = function () { // getSocketState() // } window.onload = function (){ middleWareJS() } function middleWareJS(){ let footer = document.querySelector("footer") let body = document.body.style; if (document.querySelector(".block-list-of-users")){ footer.style.display = "none" } else { footer.style.display = "" } // let window_messages = document.querySelector(".container-messages") // let new_timeout_time; // if (window_messages !== null){ // // check_new_messages(window) // new_timeout_time = short_timeout // } else { // new_timeout_time = long_timeout // } // if (check_msg !== null){ // clearInterval(check_msg) // } // check_new_messages_timeout(new_timeout_time) } // function getSocketState () { // function onopen_ws (){ // let sw_int = setInterval(function (){ // if (chatSocket.readyState > 1){ // chatSocket = new WebSocket(ws_url) // // chatSocket.onopen = function (){ // } else if (chatSocket.readyState === 1){ // clearInterval(sw_int) // } else { // console.log("connecting...") // } // // // } // // // // },1000) // } // } function restart_ws (){ let sw_int = setInterval(function (){ if (chatSocket.readyState > 1){ // chatSocket = new WebSocket(ws_url) init_ws() // chatSocket.onopen = function (){ } else if (chatSocket.readyState === 1){ clearInterval(sw_int) console.log("open") } else { console.log("connecting...") } // } },1000) } function init_ws () { chatSocket = new WebSocket(ws_url); if (chatSocket.readyState !== 1) { restart_ws() } chatSocket.addEventListener('open',socket_open) chatSocket.addEventListener('close',socket_close) chatSocket.addEventListener('message',wsReceiveData) // chatSocket.onmessage = function (e) { // wsReceiveData(e); // return false; // } // chatSocket.onclose = function (){ // console.log("closed") // setTimeout(restart_ws,1000) // // } // chatSocket.onopen = function (){ // console.log("open") // } } function socket_open(e){ console.log("connect") } function socket_close(e){ console.log("closed") setTimeout(restart_ws,1000) } 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 changeImgLang(el) { // // let img = document.getElementById('dropbtn_lang') // // if (el.innerText === 'RU'){ // img.style.background = "url('/static/img/png/ru.png') no-repeat left center;" // } // else if(el.innerText === 'EN'){ // img.style.background = "url('/static/img/png/en.png')" // img.style.backgroundRepeat = "no-repeat" // img.style.backgroundPosition = "left center" // // } // // } // var window_messages = document.querySelector(".container-messages") // function middleWareJS (){ // let prs_ = null // // if (r !== 'undefined' && r !== null && r !== ""){ // // // // let prs = JSON.parse(r) // // prs_ = JSON.parse(r) // // } else { // // // // // } // // let r = getCookieValue('user_alerts') // // // // return prs_; // // } // var res_cookie = null // var name_cookie = null // // // var old_cookeis = document.cookie // // var name_delete = null // // function getCookieValue(name_1) { // name_cookie = name_1 // let cur_state = document.cookie; // // let finded_str = ''; // let cur_state_by_opts = cur_state.split('; '); // for (let i=0; i= 0) { // finded_str = cur_state_by_opts[i]; // delete cur_state_by_opts[i]; // } // } // let save_str = cur_state_by_opts.join('; '); // // let result = document.cookie.match("(^|[^;]+)\s*" + name_1 + "\s*=\s*([^;]+)") // res_cookie = result ? result.pop() : "" // return res_cookie // // name_delete = name // }