Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
comments on sendchatmessage
Browse files Browse the repository at this point in the history
  • Loading branch information
IanHuntress committed Dec 8, 2015
1 parent e4648d8 commit 4889922
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ io.sockets.on('connection', function (socket) {
});

//User sends a chat message
<<<<<<< HEAD
socket.on('chat:message', function(room, uid, message, name){
=======
socket.on('chat:message', function(room, uid, message, name){
>>>>>>> comments on sendchatmessage
draw.chatMessage(room, uid, message, name);
io.sockets.in(room).emit('chat:message', uid, message, name);
});
Expand Down
2 changes: 1 addition & 1 deletion src/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ input[type=checkbox] {
#chatBox {
position: absolute;
bottom: 0px;
right: 20px;
right: 60px;
width: 180px;
height: 200px;
z-index: 400;
Expand Down
10 changes: 6 additions & 4 deletions src/static/js/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1169,16 +1169,17 @@ function processSettings(settings) {
}

function chatToggleShow() {
//If it's currently big, make it small, vice versa
//If the user does not have a name, ask for one

if($("#chatBox").height() > 10){
$("#chatBox").animate({height : 10},200);
$("#chatMessages").hide();
$("#chatInput").hide();
} else {

if(chatName == ""){
chatName = prompt("What is your name?", "");
}

$("#chatBox").animate({height : 200},200);
$("#chatMessages").show();
$("#chatInput").show();
Expand All @@ -1187,12 +1188,13 @@ function chatToggleShow() {
}

function sendChatMessage() {
//get the text, emit it, clear the text
var message = $('#chatInput').val();
socket.emit('chat:message', room, uid, message, chatName || "unnamed");
$('#chatInput').val('');
return(false);
return(false);//prevents page reload on submit
}

//does chatName belong here?
var chatName = "";
chatToggleShow();
$("#chatLabel").click(function() {chatToggleShow();} );
Expand Down

0 comments on commit 4889922

Please sign in to comment.