User:Shoyrukon/chat.js

var pingon = /\b(shoy|shoyru|shoyrukon)\b/i; //ping keywords as regex var wikichatid = "#Chat_182"; //chat id for wikichat var self = ""; //my own name, to ignore when i type in pm var lastel = null; onNewMessage.push(function(el) {   lastel = el;    setTimeout(function { if (!$(el).hasClass("inline-alert")) { //not some alert if ($(el).attr("data-user") && $(el).find(".message").length > 0) { //make sure it has a user and a message if ($(wikichatid).find('#'+$(el).attr('id')).length > 0) { //the element was found in the wikichat section, so is public if ($(el).find(".message").text.search(pingon) !== -1) { //apply ping keyword search console.log("[chat] "+$(el).attr("data-user")+" pinged you!"); notify($(el).attr('data-user'),$(el).find(".message").text); $(el).find(".message").addClass("gaz_hilite"); }				}				else { //element not found in wikichat, so must be private if ($(el).attr("data-user") !== self) { //ignore self console.log("[chat] "+$(el).attr("data-user")+" PMed you!"); notifyPM($(el).attr('data-user'),$(el).find(".message").text); }				}			}		}	},100); }); //