fixed issues with certain characters in user names

This commit is contained in:
Samuel Kent
2024-02-03 09:58:56 +11:00
parent 42cf703556
commit d03d5b0fd9
5 changed files with 25 additions and 7 deletions
+7
View File
@@ -94,12 +94,19 @@ io.on("connection", (socket) => {
teamName: teamName,
buzzerId: buzzerId
}
console.log(userInfo);
io.emit("userInfoToClient", userInfo);
});
//used by the host when they refresh the page.
socket.on("refreshUserInfo", () => {
io.emit("userInfoToClient", userInfo);
});
socket.on("unregisterUsers", () => {
userInfo = new Object();
io.emit("userInfoToClient", userInfo);
io.emit("reconnectUsers");
});
socket.on("objectionToServer", (userName) => {
+2 -1
View File
@@ -1,6 +1,7 @@
function userInfoToClient(userInfo) {
for (const user in userInfo) {
const userId = user.replaceAll(" ","_");
re = new RegExp("\\W","g");
const userId = user.replaceAll(re,"_");
if ($("#userListPanel").find("#"+userId).length >= 1) {
//update buzzer icon of existing user
$("#userListPanel").find("#"+userId).find("img").attr("data-buzzerId",userInfo[user].buzzerId);
+6 -3
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>No, you do not need to mute this site anymore.</title>
<title>You may now put weird characters in your name.</title>
<link rel="stylesheet" href="styleMain.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
@@ -10,10 +10,13 @@
const egg = new Audio('Egg.wav');
$("#userName").change(function() {
okSsuka.play();
$("#playerLink").attr("href", "/play?user="+this.value+"&team=Players");
re = new RegExp("\\#|\\&","g");
const userName = this.value.replaceAll(re,">:(");
$("#playerLink").attr("href", "/play?user="+userName+"&team=Players");
$("#playerLink").html("Players");
$("#chaserLink").attr("href", "/play?user="+this.value+"&team=Chasers");
$("#chaserLink").attr("href", "/play?user="+userName+"&team=Chasers");
$("#chaserLink").html("Chasers");
});
$("#egg").click(function() {
+5 -2
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>No, you do not need to mute this site anymore.</title>
<title>No, you do not need to mute this site anymore. (yes, even on firefox)</title>
<link rel="stylesheet" href="styleMain.css">
<script src="browserFunctions.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
@@ -10,6 +10,8 @@
$(document).ready(function() {
var socket = io();
socket.emit("refreshUserInfo");
socket.on("userInfoToClient", (userInfo) => {
userInfoToClient(userInfo);
});
@@ -46,6 +48,7 @@
$("#unregisterUsers").click(function() {
socket.emit("unregisterUsers");
location.reload();
});
socket.on("objectionToClient", (userName) => {
@@ -80,7 +83,7 @@
<br>
<br>
<br>
<button id="unregisterUsers" type="button" style="height: 30px;">Remove all players</button>
<button id="unregisterUsers" type="button" style="height: 30px;">Remove/Reconnect all players</button>
</div>
<div id="userListPanel">
<div id="PlayersList">
+5 -1
View File
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>No, you do not need to mute this site anymore.</title>
<title>No, you do not need to mute this site anymore. (yes, even on firefox)</title>
<link rel="stylesheet" href="styleMain.css">
<script src="browserFunctions.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
@@ -150,6 +150,10 @@
userInfoToClient(userInfo);
});
socket.on("reconnectUsers", () => {
location.reload();
});
socket.on("gameStateToClient", (currentTeam, currentScore) => {
gameStateToClient(currentTeam, currentScore);
});