From 782a4697531236782ac319ac82ffb47d5a3e9c9c Mon Sep 17 00:00:00 2001 From: Kum1ta Date: Tue, 6 Aug 2024 23:34:22 +0200 Subject: [PATCH] Notification : - Added function on cross for close notification - Added stop timer when mouse is over Global : - Improved security --- .../site/liveChat/showActualGameMessage.js | 31 ++++++--- .../site/liveChat/showPrivateChat.js | 44 ++++++++----- site/interface/site/notification/main.js | 59 ++++++++++++------ site/interface/site/websocket.js | 7 +-- .../Class/__pycache__/User.cpython-310.pyc | Bin 3541 -> 0 bytes .../getPrivateListMessage.cpython-310.pyc | Bin 1081 -> 0 bytes .../getPrivateListUser.cpython-310.pyc | Bin 1273 -> 0 bytes .../__pycache__/login.cpython-310.pyc | Bin 2373 -> 0 bytes .../sendPrivateMessage.cpython-310.pyc | Bin 740 -> 0 bytes .../typeRequets/getPrivateListMessage.py | 4 +- 10 files changed, 95 insertions(+), 50 deletions(-) delete mode 100644 websocket-server/Class/__pycache__/User.cpython-310.pyc delete mode 100644 websocket-server/typeRequets/__pycache__/getPrivateListMessage.cpython-310.pyc delete mode 100644 websocket-server/typeRequets/__pycache__/getPrivateListUser.cpython-310.pyc delete mode 100644 websocket-server/typeRequets/__pycache__/login.cpython-310.pyc delete mode 100644 websocket-server/typeRequets/__pycache__/sendPrivateMessage.cpython-310.pyc diff --git a/site/interface/site/liveChat/showActualGameMessage.js b/site/interface/site/liveChat/showActualGameMessage.js index 475b633..be4c6d3 100644 --- a/site/interface/site/liveChat/showActualGameMessage.js +++ b/site/interface/site/liveChat/showActualGameMessage.js @@ -6,7 +6,7 @@ /* By: edbernar { - divMessageListChatHome.innerHTML += ` -
-

${element.content}

-

${element.date}

-
- `; + newDiv = document.createElement("div"); + contentNode = document.createTextNode(element.content); + dateNode = document.createTextNode(element.date); + newDiv.classList.add(element.from == me ? "meMessage" : "opponentMessage"); + tmp = document.createElement("p"); + tmp.classList.add("content"); + tmp.appendChild(contentNode); + newDiv.appendChild(tmp); + tmp = document.createElement("p"); + tmp.classList.add("time"); + tmp.appendChild(dateNode); + newDiv.appendChild(tmp); + divMessageListChatHome.appendChild(newDiv); }); divMessageListChatHome.scrollTop = divMessageListChatHome.scrollHeight; divMessageListChatHome.innerHTML += ` diff --git a/site/interface/site/liveChat/showPrivateChat.js b/site/interface/site/liveChat/showPrivateChat.js index b4217cb..d174e8f 100644 --- a/site/interface/site/liveChat/showPrivateChat.js +++ b/site/interface/site/liveChat/showPrivateChat.js @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* showPrivateChat.js :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar ${user.name} + h2Username.appendChild(h2UsernameNode); + divButtonTypeChatHome.appendChild(h2Username); + divButtonTypeChatHome .innerHTML += `

Return

`; h2Button[0].style.cursor = "default"; @@ -71,16 +74,29 @@ async function changeButton(user) async function displayAllMessage(divMessageListChatHome) { + let newDiv = null; + let contentNode = null; + let dateNode = null; + let tmp = null; + divMessageListChatHome.style.height = "230px"; divMessageListChatHome.style.paddingBottom = "20px"; divMessageListChatHome.innerHTML = ''; messageList.forEach(element => { - divMessageListChatHome.innerHTML += ` -
-

${element.content}

-

${element.date}

-
- `; + newDiv = document.createElement("div"); + contentNode = document.createTextNode(element.content); + dateNode = document.createTextNode(element.date); + console.log(element.from, userMeInfo.id); + newDiv.classList.add(element.from === userMeInfo.id ? "meMessage" : "opponentMessage"); + tmp = document.createElement("p"); + tmp.classList.add("content"); + tmp.appendChild(contentNode); + newDiv.appendChild(tmp); + tmp = document.createElement("p"); + tmp.classList.add("time"); + tmp.appendChild(dateNode); + newDiv.appendChild(tmp); + divMessageListChatHome.appendChild(newDiv); }); divMessageListChatHome.scrollTop = divMessageListChatHome.scrollHeight; } diff --git a/site/interface/site/notification/main.js b/site/interface/site/notification/main.js index 102f517..9e54739 100644 --- a/site/interface/site/notification/main.js +++ b/site/interface/site/notification/main.js @@ -3,25 +3,25 @@ /* ::: :::::::: */ /* main.js :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: edbernar +#+ +:+ +#+ */ +/* By: edbernar { + divHeader.parentNode.style.animation = "slideOut 0.21s"; + setTimeout(() => { + divHeader.parentNode.remove(); + }, 199); + }); if (img) divHeader.appendChild(icon); divHeader.appendChild(h1Title); @@ -52,20 +58,21 @@ function createHeader(title, img) function createContent(message) { - const divContent = document.createElement("div"); - const pMessage = document.createElement("p"); - const limit = 100; + const divContent = document.createElement("div"); + const pMessage = document.createElement("p"); + const pMessageNode = document.createTextNode(message); + const limit = 100; divContent.classList.add("content"); pMessage.style.textAlign = "center"; if (message.length > limit) message = message.substring(0, limit) + "..."; - pMessage.innerHTML = message; + pMessage.appendChild(pMessageNode); divContent.appendChild(pMessage); return (divContent); } -function createLoadBar(timer) +function createLoadBar(newNotification, timer) { const divLoadBar = document.createElement("div"); const progress = document.createElement("div"); @@ -79,6 +86,10 @@ function createLoadBar(timer) progress.style.height = '5px'; progress.style.width = '0px'; progress.style.backgroundColor = 'black'; + newNotification.addEventListener("mouseover", () => { + clearInterval(interval); + progress.style.width = "100%"; + }); interval = setInterval(() => { progress.style.width = (intervalTimer * i) * 100 / timer + "%"; i++; @@ -86,19 +97,21 @@ function createLoadBar(timer) setTimeout(() => { clearInterval(interval); }, timer); - return (divLoadBar); + newNotification.appendChild(divLoadBar); + return (interval); } function createFooter(action, actionText) { const newButton = document.createElement("div"); + const textNode = document.createTextNode(actionText); if (action == null) return (null); newButton.style.cursor = "pointer"; if (actionText.length > 20) actionText = actionText.substring(0, 20) + "..."; - newButton.innerHTML = actionText; + newButton.appendChild(textNode); newButton.setAttribute("onclick", action); newButton.classList.add("footer"); if (typeof(action) !== "function") @@ -114,8 +127,10 @@ function newNotification(title, message, img, action, timer, actionText) const header = createHeader(title, img); const content = createContent(message); const footer = createFooter(action, actionText); - const loadBar = createLoadBar(timer); + let intervalLoadBar = null; + let timeoutInTimout = null; + console.log("New notification: " + message); newNotification.classList.add("notification"); newNotification.style.width = "100%"; newNotification.appendChild(header); @@ -123,13 +138,18 @@ function newNotification(title, message, img, action, timer, actionText) newNotification.appendChild(content); if (footer) newNotification.appendChild(footer); - newNotification.appendChild(loadBar); - setTimeout(() => { - setTimeout(() => { + intervalLoadBar = createLoadBar(newNotification, timer); + const timeout = setTimeout(() => { + timeoutInTimout = setTimeout(() => { divNotification.removeChild(newNotification); }, 199); newNotification.style.animation = "slideOut 0.21s"; }, timer); + newNotification.addEventListener("mouseover", () => { + clearTimeout(timeout); + clearTimeout(timeoutInTimout); + clearInterval(intervalLoadBar); + }); } class notification @@ -146,7 +166,6 @@ class notification new(title, message, img=null, action=null, actionText="Confirm") { - console.log("New notification: " + message); newNotification(title, message, img, action, this.timer, actionText); } } diff --git a/site/interface/site/websocket.js b/site/interface/site/websocket.js index 1530af1..7a315bd 100644 --- a/site/interface/site/websocket.js +++ b/site/interface/site/websocket.js @@ -6,7 +6,7 @@ /* By: edbernar { }; socket.onmessage = (event) => { - let response; + let response; try { response = JSON.parse(event.data); @@ -51,8 +51,7 @@ socket.onmessage = (event) => { { try { functionResponse[typeResponse.indexOf(response.type)](response.content); - } - catch { + } catch { console.warn(response); } } diff --git a/websocket-server/Class/__pycache__/User.cpython-310.pyc b/websocket-server/Class/__pycache__/User.cpython-310.pyc deleted file mode 100644 index 3d2c99dec4fa0acd83c4da50d15e9c62192a8bc3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3541 zcmbVPO>f-B8J-!EyWB6WEGv#bl3>%KZ5D;Ra^usc2nsk(?IPJ0iE6>?0>p|#DJ$)g z%8)Bpi*=AfKK521z4Ra*eanC7zu=)jKTyDbpa&o7KJN@kaW_2_rNAL)-j_4)KJPQn zyoy?_I>YtokKgY9Vx6(SQ>T1c===f5ql26#sJo%98z8H!FHne`uq>$EgCap6u zv?c$Xb?ukB!1+HgsiGx_H*)Rauku z=X_X~4cWv4^o=sTVavheIydpO+vL*#0*i7wT$AQ`zr0nHuT)rs9LGKjGJ>2p4 z&@9*?Q`Lk^e#SXl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D>lj@U5VYk#Nj*TVWIs$L_E;`2C2t6zhEVmho3Ls*cgA88 zMkV%Y!df&&Qf`g{eX_nsU47b86s5>?j5<6z_bBX`++1e!{Ld9`rCxRGZmV8zZYlD^ tKL_=qK9AGtC_WASabyl~s#mqwe_JMXe`@Rcp1P;zM8ZpqKvlPY|IkDA-c8_)w6T+-}md$z8I$X-&C+ zQon-;eMlaC^E>z*eArh($X5^)XYSe>#0U4--^|X<&d&U1qKSzy0_(+x&$X{vLcZZ) zbm8AeuvHa+6HXgshj0d(#ciHBw*JzbGut06duDS{t2;b*%yuXr9Rm^VXwkg%K)7AfQKH{z{C+< zBQGa=ET%Ehw9mM$t(Y89p1Dc}Y=*3m9&NiZ*5_;<&Q_{E7q$9s@OrP&45LS z!O>>`r^^NfY5xLSy#ja#-1g~!0I!VG83G(%?^&AlEto%R04z@vp4nsa8h2ugXG zV#?halAg4Egc>c8b}lCUOw0!K3C!?gLII%{xy_`{G6#y0fIDbWt^qum5zf8irrDnuC4e=01NtFQHJhR}V SjM_h$^Plp&^UIyhyT1WaZvg}V diff --git a/websocket-server/typeRequets/__pycache__/getPrivateListUser.cpython-310.pyc b/websocket-server/typeRequets/__pycache__/getPrivateListUser.cpython-310.pyc deleted file mode 100644 index d176516c1b0dc41a52d6fb862940bae8fd0fc7b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1273 zcmbVLOK;>v5Vk$eJd({m!aiVGB$P`SA-g@3=b#X6v%ZcF!(#r{{2oSGdb(c=gQXHD2cpK3n2Bv|r)# zCBBOGYy5hNZy;XaZT7iSHnOlfPBqL9JKe_xN4@_7`@~<@R%{`OdGHgVi;2 zT>+4%T&jecs!Zc36_byKT4(S9AtM^c8O?+OkHs|gnM}wi^O#JvNHxi`SW*t89kiE8 zuu7Pev6qFJ7qtE3Y!IDoI9Ag&Zb}njs-UUP!Bo(}I1x9E=Q(3iQy7|>48xN7;gmV@ zvnY*{K}p#Tf|sPdLDpAEXAQynYG*C%Y%B*W{jfzjYqOPBYpvCxVj~n`N&VA##WJ(o zpq0$zNT|u-G&1r^P_mOra~iXVhQ|l~U_gqMtOuPHuP?_%etwn?qVv7FWvT~M#bP`m)BmzQ_I~jQKq->nnA|GkLBRKrLkOUZj#HL3}}pZ zI@$k^1dH!thhfWnxcIl&?WN{o^!+!M#hjuqFGqoAaQ=W3?xFbH{>1tUAC9)UbLM<) z@8R=#WZ5XOr7K-?BU8~S)#50QKp*8GRMRo89%sVTE}OP6fJnJ)5pr~J|+jZM<9lQA4Kb+eCNAAy8y*~j; CdVAXd diff --git a/websocket-server/typeRequets/__pycache__/login.cpython-310.pyc b/websocket-server/typeRequets/__pycache__/login.cpython-310.pyc deleted file mode 100644 index 479b8697c4e04cd639be03272534ceffb48edcd8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2373 zcmah~&u<$=6rP#gwbzNArfHj|ZCavI1Qu=FxK5!^LDD+VNMKb>6-1;cvi&B_CXUyg zSvR%ilvL%)6_5y0dO_-qKY$w-?%d|eDMzkFsJu68H*H8@SNnG6%{M>xz3+V+W-@&Y zuletOUjF?kV}DTR)yv1u6h3+t4KUy}wh+Jh0tW#OxZptolG`5mkb*wwhqUcwU;vK5 zARMLMJ!e6{5FGoOEjVx-PT<>xVK|9z4@Te=z7ud7&fq%jgD77kT8n%+g#NRO??i`aOK)wgL?tiyg_KZ<~FiioZ94ySN` zW9x1eL%t@kG7_cs*_9}2=nrzaaw8ZIkn-j6LLOxz_aL7`fyqoaqm@tv?Q#@^^>*@x zEGwzTvfLzBWErH=yT9SCS;zQ_$fYA~oO?1d{W>Z~O}%7`!Zk@-G=;oznyRMW#wj#G zH^Ms7b6-F*NY`LF=42s%3$Z$lMr^sfPq;4zoIXe8&~Z2uAK_@1iSOX&nvCzhN&DLF)R4nX!qhtlys``UM-0dHdryXdqC@ zk40E&9sWf06!;6Pz+Hrchzl6x!x1hbCL?hmg6%l;w|%;AZI?xEYmu`}!CCt#7BeOX z{Em3)?499DJjJGXBq-o=zW#b6u* z-agVB=rTFDgkG#>QaxLFHgG0IGCo7U1e2P1Sd|T`jI5*HAej9V@copwELg;GP0Ap) zgqOyA^qvthz|V7kOT4hStgo`Pl+CnNlDz|19#HyXUhNf*ZQ*gTtgf$z(5%UiNG5av cji2_p=o37?-M@r?aNGUUAMrDI_oe&)0SjLO&Hw-a diff --git a/websocket-server/typeRequets/__pycache__/sendPrivateMessage.cpython-310.pyc b/websocket-server/typeRequets/__pycache__/sendPrivateMessage.cpython-310.pyc deleted file mode 100644 index c69613897273ebd94f4c72b5d57aefc720ae9e4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 740 zcmZWlL5mYH6i(8#o!0J(?yk7EqRe50?%;J15wy@fbXja!X)k4VlDb_xNlm7$Eiu7coS5J6v3#RW6uoA-6L2;kOb(UoE-52#_bR z^<4ml7#^bp^$|vlu)=%P$BcGRQ2Y*66ky}ADCOxW;jumVcNHP9ZN9+P9{}Fr<%0|} zypM8{q7}{vBWseAjI7|=HO>j6P%rKyz>>owz+-Z>iO9qB)+UpmuDiHNM>QdksHn_^j)<4*m9_ z-#PGy{pGe}b)SWP68b%}BlvtUQKK0=c#v?dqnF&!p^}LqsWjzSij<2qpvt};_<1A* zAFHxu)Q%}2&~Y*0F16e}60>MLV)Z|F)isn6Lmi$=XdQBP#+8Uv z_)Nyr1U%^Qq}y%|x+)SnhReB#c{t~1TE?$<+JFu-u0s2e=lu1QgWg&=*-WOr8O*_C zVQ&AQz6s5B9e`XC&%-rb#RQk!M{xD$ozgbGhrLVkOYMQ^I3R8ijyU7jU>5|&dz45v P9rMQ+n5F==T8;b$2xPu{ diff --git a/websocket-server/typeRequets/getPrivateListMessage.py b/websocket-server/typeRequets/getPrivateListMessage.py index cee83fa..90ffbcc 100644 --- a/websocket-server/typeRequets/getPrivateListMessage.py +++ b/websocket-server/typeRequets/getPrivateListMessage.py @@ -6,7 +6,7 @@ # By: edbernar