Skip to content

Neon whiteboard #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<canvas class="whiteboard"></canvas>
<div class="colors">
<div class="colorpicker3"></div>
<i class="fa fa-eraser" id="eraser"></i>
<!-- <i class="fa fa-eraser" id="eraser"></i> -->
<button id="wipe">Wipe Whiteboard</button>
</div>
</footer>
Expand Down
26 changes: 13 additions & 13 deletions js/chat2/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ window.onload = function() {
var newName = this.value;
setCookie("nme", newName); // Update the cookie with the new username
setName(nme, newName); // Apply the new username
console.log(`New Name: ${newName}`);
//console.log(`New Name: ${newName}`);
});

// Check if a color is stored in cookies
Expand All @@ -85,7 +85,7 @@ window.onload = function() {
const newColor = getRandomColor(); // Generate a new random color
setCookie("color", newColor, 365); // Update the cookie with the new color
setColor(pick, newColor); // Apply the new color
console.log(`New Color: ${newColor}`);
//console.log(`New Color: ${newColor}`);
};

// Function to append messages to the log
Expand All @@ -106,15 +106,15 @@ window.onload = function() {
return false;
}

// Send username and message as JSON to the server
const fullMessage = {
username: nme.value,
color: getComputedStyle(pick).backgroundColor,
text: msg.value,
};
// Send username and message as JSON to the server
const fullMessage = {
username: nme.value,
color: getComputedStyle(pick).backgroundColor,
text: msg.value,
};

console.log("Sending message:", JSON.stringify(fullMessage));
conn.send(JSON.stringify(fullMessage));
//console.log("Sending message:", JSON.stringify(fullMessage));
conn.send(JSON.stringify(fullMessage));

// Clear the message input field
msg.value = "";
Expand All @@ -129,7 +129,7 @@ window.onload = function() {

// Event handler when open
conn.onopen = function(evt) {
console.log("%c Connection established", "color: red");
console.log("%c Connection established to chat", "color: lightgreen");
};
// Event handler for when the WebSocket connection is closed
conn.onclose = function(evt) {
Expand All @@ -140,13 +140,13 @@ window.onload = function() {
conn.onmessage = function(evt) {
try {
// Log raw data for debugging
console.log("Raw data received:", evt.data);
//console.log("Raw data received:", evt.data);

// Parse the incoming JSON string into a JavaScript object
const data = JSON.parse(evt.data);

// Log parsed data for debugging
console.log("Parsed data:", data);
//console.log("Parsed data:", data);

// Ensure `data` has both `username` and `text`
if (!data.username || !data.text) {
Expand Down
Loading