Created
March 10, 2015 23:29
-
-
Save nfabian13/ffd042db78db59db2a21 to your computer and use it in GitHub Desktop.
Send message to all participants on Enter key pressed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To send messages | |
var txtMsg = document.querySelector("#txtMsg") | |
$("#txtMsg").keydown(function(event){ | |
if(event.keyCode == 13){ | |
session.signal({ | |
type: "chat", | |
data: txtMsg.value | |
}, function(error){ | |
if(error){ | |
console.log("signal error (" + error.code + "): " + error.message); | |
}else{ | |
txtMsg.value = ""; | |
} | |
} | |
); | |
} | |
}).focus(function(){ | |
this.value = ""; | |
}).blur(function(){ | |
if(this.value == ""){ | |
this.attr("placeholder", "Hit Enter key to send your message..."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment