Skip to content

Instantly share code, notes, and snippets.

@cyancey76
Forked from mxew/chatNumberThing.js
Last active December 5, 2018 22:06
Show Gist options
  • Save cyancey76/ff5db81cbc948c9e92b4cd18a9f9adc8 to your computer and use it in GitHub Desktop.
Save cyancey76/ff5db81cbc948c9e92b4cd18a9f9adc8 to your computer and use it in GitHub Desktop.
Chat numbers for #indiediscotheque
var chatsolab = 1;
$("#chat-txt-message").bind("keyup", function() {
var start = this.selectionStart;
var lastChar = String.fromCharCode(this.value.charCodeAt(start - 1));
if( lastChar == "@" ) {
$("#chat-txt-message").val("@");
} else if( lastChar == "!" ) {
$("#chat-txt-message").val("!");
} else if( event.which == 13 ) {
var chatsolab = Math.floor(Math.random() * 1000) + 1;
if (chatsolab < 10) {
chatsolab = "0" + chatsolab;
}
$("#chat-txt-message").val("`"+chatsolab+"` ");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment