Skip to content

Commit

Permalink
Inconsistencies fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
herronjo committed Dec 2, 2024
1 parent 4f4967e commit ac0a708
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 33 deletions.
5 changes: 2 additions & 3 deletions components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,13 @@ class HeaderComponent extends HTMLElement {
api.pfp || "https://betacdn.stibarc.com/pfp/default.png"
);
menuprofile.textContent = api.username;
menuprofile.addEventListener("click", () => {
location.href = `/user.html?username=${api.username}`;
});
menuprofile.setAttribute("href", `/user.html?username=${api.username}`);
} else {
mypfp.setAttribute(
"src",
"https://betacdn.stibarc.com/pfp/default.png"
);
menuprofile.setAttribute("href", "");
}
});

Expand Down
23 changes: 22 additions & 1 deletion tv/chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,28 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@300;400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/css/themes/default.css" id="theme">
<style>
:root {
--text: black;
--background: #98DFF3;
--primaryFocus: #3ea1b1;
--red: #c32222;
--redBg: #f14e4e;
--color1: #49B9CA;
--color2: #ffffff;
--color3: #d7d7d7;
--color4: #0e0e0e;
--color5: #3ea1b1;
--color6: #54cbdd;
--color8: #d8d8d8;
--color9: #bcbcbc;
--color10: #e7e7e7;
--color11: #fafafa;
}
.sysnotif {
color: #7F7F7F;
}
</style>
<link rel="stylesheet" href="/css/global.css">
<style>
body {
Expand Down
65 changes: 36 additions & 29 deletions tv/chat.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
window.addEventListener("load", function() {
const shouldShowJoinLeave = window.location.search.includes("showjoinleave");

const socket = new io("https://tv.stibarc.com");

let lastUserToSend = "";
Expand All @@ -11,19 +13,20 @@ window.addEventListener("load", function() {
lastUserToSend = data.user.username;
});

// socket.on("chatmemberschange", function(data) {
// lastUserToSend = "";
// const evt = document.createElement("i");
// evt.classList.add("width100", "sysnotif");
// evt.setAttribute("title", new Date().toLocaleString());
// if (data.event === "join") {
// evt.textContent = `${data.username} joined the chat.`;
// } else if (data.event === "leave") {
// evt.textContent = `${data.username} left the chat.`;
// }
// $("#chatmessages").append(evt);
// $("#chatmessages").scrollTop = $("#chatmessages").scrollHeight;
// });
socket.on("chatmemberschange", function(data) {
if (!shouldShowJoinLeave) return;
lastUserToSend = "";
const evt = document.createElement("i");
evt.classList.add("width100", "sysnotif");
evt.setAttribute("title", new Date().toLocaleString());
if (data.event === "join") {
evt.textContent = `${data.username} joined the chat.`;
} else if (data.event === "leave") {
evt.textContent = `${data.username} left the chat.`;
}
$("#chatmessages").append(evt);
$("#chatmessages").scrollTop = $("#chatmessages").scrollHeight;
});

socket.on("history", function(data) {
lastUserToSend = "";
Expand All @@ -37,22 +40,26 @@ window.addEventListener("load", function() {
lastUserToSend = msg.user.username;
break;
}
// case "join": {
// const evt = document.createElement("i");
// evt.classList.add("width100", "sysnotif");
// evt.setAttribute("title", new Date(msg.time).toLocaleString());
// evt.textContent = `${msg.username} joined the chat.`;
// $("#chatmessages").append(evt);
// break;
// }
// case "leave": {
// const evt = document.createElement("i");
// evt.classList.add("width100", "sysnotif");
// evt.setAttribute("title", new Date(msg.time).toLocaleString());
// evt.textContent = `${msg.username} left the chat.`;
// $("#chatmessages").append(evt);
// break;
// }
case "join": {
if (!shouldShowJoinLeave) break;
lastUserToSend = "";
const evt = document.createElement("i");
evt.classList.add("width100", "sysnotif");
evt.setAttribute("title", new Date(msg.time).toLocaleString());
evt.textContent = `${msg.username} joined the chat.`;
$("#chatmessages").append(evt);
break;
}
case "leave": {
if (!shouldShowJoinLeave) break;
lastUserToSend = "";
const evt = document.createElement("i");
evt.classList.add("width100", "sysnotif");
evt.setAttribute("title", new Date(msg.time).toLocaleString());
evt.textContent = `${msg.username} left the chat.`;
$("#chatmessages").append(evt);
break;
}
}
});
$("#chatmessages").scrollTop = $("#chatmessages").scrollHeight;
Expand Down
2 changes: 2 additions & 0 deletions tv/tv.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ window.addEventListener("load", async function() {
break;
}
case "join": {
lastUserToSend = "";
const evt = document.createElement("i");
evt.classList.add("width100", "sysnotif");
evt.setAttribute("title", new Date(msg.time).toLocaleString());
Expand All @@ -79,6 +80,7 @@ window.addEventListener("load", async function() {
break;
}
case "leave": {
lastUserToSend = "";
const evt = document.createElement("i");
evt.classList.add("width100", "sysnotif");
evt.setAttribute("title", new Date(msg.time).toLocaleString());
Expand Down

0 comments on commit ac0a708

Please sign in to comment.