Blink tab title when your name mentioned

This commit is contained in:
calzoneman 2013-03-30 00:49:41 -05:00
parent 6fbe2732c7
commit 31fd011b4d
3 changed files with 27 additions and 1 deletions

View file

@ -68,6 +68,7 @@ function initCallbacks() {
$("#opt_qopen_allow_playnext").prop("checked", opts.qopen_allow_playnext);
$("#opt_pagetitle").attr("placeholder", opts.pagetitle);
document.title = opts.pagetitle;
PAGETITLE = opts.pagetitle;
$("#opt_customcss").attr("placeholder", opts.customcss);
$("#customCss").remove();
if(opts.customcss != "") {

View file

@ -21,6 +21,9 @@ var GRABBEDLI = null;
var OLDINDEX = -1;
var CHATHIST = [];
var CHATHISTIDX = 0;
var FOCUSED = true;
var PAGETITLE = "Sync";
var TITLE_BLINK;
var uname = readCookie("sync_uname");
var pw = readCookie("sync_pw");
@ -35,6 +38,14 @@ var Rank = {
var socket = io.connect(IO_URL);
initCallbacks();
$(window).focus(function() {
FOCUSED = true;
onWindowFocus();
})
.blur(function() {
FOCUSED = false
});
var params = {};
if(window.location.search) {
var parameters = window.location.search.substring(1).split("&");

View file

@ -128,8 +128,17 @@ function addUserDropdown(entry, name) {
function formatChatMessage(data) {
var div = document.createElement("div");
if(data.msg.indexOf(uname) != -1)
if(data.msg.toUpperCase().indexOf(uname.toUpperCase()) != -1) {
$(div).addClass("nick-highlight");
if(!FOCUSED) {
TITLE_BLINK = setInterval(function() {
if(document.title == "*Chat*")
document.title = PAGETITLE;
else
document.title = "*Chat*";
}, 1000);
}
}
if(data.msgclass == "action") {
var message = document.createElement("span");
$(message).addClass("action");
@ -708,3 +717,8 @@ function handleRankChange() {
}
}
}
function onWindowFocus() {
clearInterval(TITLE_BLINK);
document.title = PAGETITLE;
}