From ff7585cbbf9a746002f46315800b01ad3607d40d Mon Sep 17 00:00:00 2001 From: zouap Date: Fri, 24 Jun 2022 16:42:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=A6=96=E9=A1=B5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zouap --- public/home/home.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/public/home/home.js b/public/home/home.js index 7343dba0b..abf2bdb70 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -74,28 +74,30 @@ var swiperOrg = new Swiper(".homeorg-list", { }, }); -var output = document.getElementById("newmessage"); -var url = "ws://" + document.location.host + "/action/notification"; -if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){ - url = "wss://" + document.location.host + "/action/notification" -} -var socket = new WebSocket(url); - -socket.onopen = function () { - messageQueue = []; - console.log("message has connected."); -}; - var maxSize = 20; var html =document.documentElement; var lang = html.attributes["lang"] var isZh = true; if(lang != null && lang.nodeValue =="en-US" ){ isZh=false; -}else{ } -socket.onmessage = function (e) { +$(document).onreadystatechange(function(){ + + var output = document.getElementById("newmessage"); + var url = "ws://" + document.location.host + "/action/notification"; + if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){ + url = "wss://" + document.location.host + "/action/notification" + } + var socket = new WebSocket(url); + + socket.onopen = function () { + messageQueue = []; + console.log("message has connected."); + }; + + + socket.onmessage = function (e) { var data =JSON.parse(e.data) var html = ""; if (data != null){ @@ -177,6 +179,8 @@ socket.onmessage = function (e) { swiperNewMessage.updateSlides(); swiperNewMessage.updateProgress(); }; +}); + function getTaskLink(record){ var re = getRepoLink(record); @@ -437,7 +441,10 @@ function getAction(opType,isZh){ } } -queryRecommendData(); +$(document).onreadystatechange(function(){ + queryRecommendData(); +}); + function queryRecommendData(){ $.ajax({