im a stupid hoe

This commit is contained in:
Kasper Rynning-Tønnesen
2015-05-09 01:48:10 +02:00
parent 905dbd455c
commit 9b60d27ee1
2 changed files with 997158 additions and 0 deletions

36
static/js/chat.js Normal file
View 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

File diff suppressed because one or more lines are too long