mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
im a stupid hoe
This commit is contained in:
36
static/js/chat.js
Normal file
36
static/js/chat.js
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
function chat(data)
|
||||
{
|
||||
if(data.value.length > 150)
|
||||
return;
|
||||
socket.emit("chat", data.value);
|
||||
data.value = "";
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById("chat-btn").addEventListener("click", function(){
|
||||
console.log("clicked");
|
||||
$("#text-chat-input").focus();
|
||||
});
|
||||
|
||||
socket.on("chat,"+chan.toLowerCase(), function(data)
|
||||
{
|
||||
var color = intToARGB(hashCode(data.substring(0,8))).substring(0,6);
|
||||
$("#chat").append("<li><span style='color:"+color+";'>"+data.substring(0,8)+"</span>"+data.substring(8)+"</li>");
|
||||
document.getElementById("chat").scrollTop = document.getElementById("chat").scrollHeight
|
||||
});
|
||||
|
||||
function hashCode(str) { // java String#hashCode
|
||||
var hash = 0;
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function intToARGB(i){
|
||||
return ((i>>24)&0xFF).toString(16) +
|
||||
((i>>16)&0xFF).toString(16) +
|
||||
((i>>8)&0xFF).toString(16) +
|
||||
(i&0xFF).toString(16);
|
||||
}
|
||||
997122
typescript
Normal file
997122
typescript
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user