Nicer effect on chat icon

This commit is contained in:
Kasper Rynning-Tønnesen
2015-05-09 12:12:20 +02:00
parent 2f56513936
commit f314b080a1
3 changed files with 47 additions and 95 deletions

View File

@@ -1,3 +1,4 @@
var blink_interval;
function chat(data)
{
@@ -11,14 +12,17 @@ function chat(data)
document.getElementById("chat-btn").addEventListener("click", function(){
console.log("clicked");
$("#text-chat-input").focus();
$("#chat-btn").css("color", "white");
//$("#chat-btn").css("color", "white");
$("#chat-btn").css("opacity", 1);
clearInterval(blink_interval);
});
socket.on("chat,"+chan.toLowerCase(), function(data)
{
if($("#chat-bar").position()["left"] != 0)
{
$("#chat-btn").css("color", "grey");
//$("#chat-btn").css("color", "grey");
blink_interval = setInterval(chat_blink, 2000);
}
var color = intToARGB(hashCode(data.substring(0,8))).substring(0,6);
$("#chat").append("<li><span style='color:"+color+";'>"+data.substring(0,8)+"</span></li>");
@@ -27,6 +31,12 @@ socket.on("chat,"+chan.toLowerCase(), function(data)
document.getElementById("chat").scrollTop = document.getElementById("chat").scrollHeight
});
function chat_blink()
{
$("#chat-btn").css("opacity", 0.5);
setTimeout(function(){$("#chat-btn").css("opacity", 1);}, 1000);
}
function hashCode(str) { // java String#hashCode
var hash = 0;
for (var i = 0; i < str.length; i++) {