User:Tappity/chat.js

Notification.requestPermission;

//set a variable to determine Focus or not. window.hasFocus = true; $(window).bind('focus', function { window.hasFocus = true; }); $(window).bind('blur', function { window.hasFocus = false; });

var alertPing = function(type) { console.log('in alert ping') var msg = 'Something happened.'; /*   if (type == 'user-post') { msg += 'Someone posted.'; }   if (type == 'name-alert') { msg += ' And you\'ve been mentioned.'; }   */    console.log('-- ' + msg); if (msg) { var myNotification = new Notification(msg); } }

var showTime = function { var prevtime = $(this).prev.find('.time').text; var thistime = $(this).find('.time').text; if(prevtime != thistime) { $(this).find('.time').css('display','inline'); } }

var visibleLastTime = function { //If the latest message has a different time from the previous one, show the time! $('.Chat li.continued:last-of-type').each(showTime); };

$('.Chat li.continued').each(showTime);

NodeChatDiscussion.prototype.chatPing = function(chat) { console.log('in chat ping') visibleLastTime; var text = chat.attributes.text; if (chat.attributes.isInlineAlert && text != $.msg('chat-welcome-message',wgSiteName)) { //Don't bother alerting when you first join! alertPing; return; }   var isFromSelf = chat.attributes.name != wgUserName; if (mainRoom.isInitialized && !chat.attributes.isInlineAlert) { var pings = ['Tappity', 'Tap', 'Slayze', 'Taptap']; //if (!window.hasFocus) { //Only annoy people if the window isn't focused for (var i = 0; i < pings.length; i++) { if (text.toLowerCase.indexOf(pings[i].toLowerCase) != -1 || this != mainRoom.viewDiscussion) { alertPing; this.scrollToBottom; return; }           }        //}    } }

console.log(5);

mainRoom.model.chats.bind('afteradd', $.proxy(mainRoom.viewDiscussion.chatPing, mainRoom.viewDiscussion));

console.log('start');