Make it pop

This commit is contained in:
Mattias Erming 2014-06-16 23:16:22 +02:00
parent 5f37880214
commit 5bd148d7b5
2 changed files with 8 additions and 3 deletions

BIN
client/audio/pop.ogg Normal file

Binary file not shown.

View File

@ -165,6 +165,9 @@ $(function() {
} }
} }
var pop = new Audio();
pop.src = "/audio/pop.ogg";
var viewport = $("#viewport"); var viewport = $("#viewport");
var touchDevice = (window.screen.width <= 768); var touchDevice = (window.screen.width <= 768);
@ -225,6 +228,10 @@ $(function() {
chat.on("append", ".messages", function() { chat.on("append", ".messages", function() {
var messages = $(this); var messages = $(this);
var id = messages.closest(".window").find(".form").data("target"); var id = messages.closest(".window").find(".form").data("target");
var last = messages.find(".row:last-child");
if (last.hasClass("highlight")) {
pop.play();
}
var link = $("#channel-" + id + ":not(.active)"); var link = $("#channel-" + id + ":not(.active)");
if (link.length == 0) { if (link.length == 0) {
@ -236,9 +243,7 @@ $(function() {
link.removeClass("pulse"); link.removeClass("pulse");
}, 500); }, 500);
var last = messages.find(".row:last-child");
var type = last.attr("class"); var type = last.attr("class");
var ignore = [ var ignore = [
"join", "join",
"part", "part",
@ -255,7 +260,7 @@ $(function() {
if (badge.length != 0) { if (badge.length != 0) {
var i = (parseInt(badge.html()) || 0) + 1; var i = (parseInt(badge.html()) || 0) + 1;
badge.html(i); badge.html(i);
if (messages.children().last().hasClass("highlight")) { if (last.hasClass("highlight")) {
badge.addClass("highlight"); badge.addClass("highlight");
} }
} }