From fa360267a000d9b85994aa9be5dd76332361b2c2 Mon Sep 17 00:00:00 2001 From: borissedw Date: Thu, 24 Aug 2023 15:18:58 +0300 Subject: [PATCH] 0.0.165 --- static/js/filters_functions_find_route.js | 5 +++ static/js/global_js.js | 41 +++++++++++++++++++++-- templates/tb_base.html | 2 +- 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 static/js/filters_functions_find_route.js diff --git a/static/js/filters_functions_find_route.js b/static/js/filters_functions_find_route.js new file mode 100644 index 0000000..c4e8535 --- /dev/null +++ b/static/js/filters_functions_find_route.js @@ -0,0 +1,5 @@ +function filters_func_find_route_main (){ + let urls_for_els = { + 'road_url':'' + } +} \ No newline at end of file diff --git a/static/js/global_js.js b/static/js/global_js.js index 557905e..54330ee 100644 --- a/static/js/global_js.js +++ b/static/js/global_js.js @@ -1,8 +1,13 @@ -$(document).ready(function (){ - getNewMessageSession() -}) +// $(document).ready(function (){ +// getNewMessageSession() +// }) + +// window.onfocus = function () { +// getSocketState() +// } function getNewMessageSession(){ + // let window_messages = document.querySelector(".container-messages") // let new_timeout_time; // if (window_messages !== null){ @@ -17,6 +22,36 @@ function getNewMessageSession(){ // check_new_messages_timeout(new_timeout_time) } +// function getSocketState () { +chatSocket.onclose = function (){ + console.log("closed") + setTimeout(onopen_ws,1000) + +} +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) +} + +chatSocket.onopen = function (){ + console.log("open") +} + +// } + // var window_messages = document.querySelector(".container-messages") diff --git a/templates/tb_base.html b/templates/tb_base.html index e290ee1..a612038 100644 --- a/templates/tb_base.html +++ b/templates/tb_base.html @@ -13,7 +13,7 @@ {#var user_id = {{ user.id }}#} ws_url = `ws://{% get_ws_address %}/ws/socket-server/?user_id={{ user.id }}`; - const chatSocket = new WebSocket(ws_url); + let chatSocket = new WebSocket(ws_url); const beep = new Audio('/static/sounds/beep_2.mp3')