Added message count

This commit is contained in:
Mattias Erming 2014-05-03 19:54:51 +02:00
parent 13e4115f04
commit 880b9b4104
1 changed files with 24 additions and 16 deletions

View File

@ -54,15 +54,13 @@ $(function() {
.end() .end()
.end() .end()
.find(".input") .find(".input")
.tabComplete({list: commands}) .tabComplete({list: commands});
.end();
$("#network-" + data.id) $("#network-" + data.id)
.append(render("channels", {channels: [data.chan]})) .append(render("channels", {channels: [data.chan]}))
.find(".channel") .find(".channel")
.last() .last()
.trigger("click") .trigger("click");
.end();
break; break;
case "msg": case "msg":
@ -81,16 +79,14 @@ $(function() {
.prev(".show-more") .prev(".show-more")
.show(); .show();
chat.find(".messages") chat.find(".messages")
.scrollGlue({speed: 400}) .scrollGlue({speed: 400});
.end();
$("#networks") $("#networks")
.html(render("networks", {networks: data.networks})) .html(render("networks", {networks: data.networks}))
.parent() .parent()
.find("button") .find("button")
.first() .first()
.trigger("click") .trigger("click");
.end();
break; break;
case "part": case "part":
@ -102,8 +98,7 @@ $(function() {
case "users": case "users":
$("#window-" + data.id) $("#window-" + data.id)
.find(".users") .find(".users")
.html(render("users", {users: data.users})) .html(render("users", {users: data.users}));
.end();
break; break;
} }
} }
@ -114,11 +109,24 @@ $(function() {
var target = button.data("target"); var target = button.data("target");
sidebar.find(".active").removeClass("active"); sidebar.find(".active").removeClass("active");
button.addClass("active") button.addClass("active")
$(target).css({ .find(".badge")
"z-index": z++ .empty();
}).find("input") $(target).css("z-index", z++)
.focus() .find("input")
.end(); .focus();
});
chat.on("append", ".messages", function() {
var messages = $(this);
var id = messages.closest(".window").find(".form").data("target");
var badge = $("#channel-" + id + ":not(.active)")
.find(".badge");
console.log(badge);
if (badge.length == 0) {
return;
}
var i = (parseInt(badge.html()) || 0) + 1;
badge.html(i);
}); });
chat.on("click", ".show-more .btn", function() { chat.on("click", ".show-more .btn", function() {
@ -131,7 +139,7 @@ $(function() {
var user = $(this); var user = $(this);
var id = user.closest(".window").find(".form").data("target"); var id = user.closest(".window").find(".form").data("target");
var name = user.html().replace(/[\s+@]/g, ""); var name = user.html().replace(/[\s+@]/g, "");
if (name == "-!-" || name.indexOf(".") != -1) { if (name.match(/[#.]|-!-/) != null) {
return; return;
} }
socket.emit("input", { socket.emit("input", {