User:Kangaroopower/ChatHacksLite.js

/* * ChatHacks Lite. Basically Chathacks with a lot less stuff in it * So it works with the rest of my js and only has stuff I'll use. */

if(wgCanonicalSpecialPageName == 'Chat') { //Send message function NodeChatController.prototype.sendMessage = function (event) { if(!this.active) { return true; }		if (event.which == 13 && !event.shiftKey) { event.preventDefault; mainRoom.resetActivityTimer; var inputField = this.viewDiscussion.getTextInput; var send = Preparse.call(this, inputField.val); if (inputField.val && send) { var chatEntry = new models.ChatEntry({roomId: this.roomId, name: wgUserName, text: inputField.val}); if( this.isPrivate == true ) { //is prive if( this.afterInitQueue.length < 1 || this.model.users.length < 2 ){ this.mainController.socket.send( this.model.privateRoom.xport ); }					if( !this.isInitialized ) { this.afterInitQueue.push(chatEntry.xport); //temp chat entry in case of slow connection time chatEntry.set({temp : true, avatarSrc: wgAvatarUrl }); this.model.chats.add(chatEntry); } else { this.socket.send(chatEntry.xport); }				} else { this.socket.send(chatEntry.xport); }				event.preventDefault; }			inputField.val(''); $.log('submitting form'); inputField.focus; }	}	mainRoom.viewDiscussion.unbind('sendMessage'); mainRoom.viewDiscussion.bind('sendMessage', $.proxy(mainRoom.sendMessage, mainRoom));

NodeChatController.prototype.inlineAlert = function(text) { for(var i in text.split('\n')) { this.viewDiscussion.chatUL.append('' + text.split('\n')[i] + ''); }		this.viewDiscussion.scrollToBottom; }	function Preparse(input) { //Parse slash commands. var text = input.split(' '); if(text[0]) {text[0] = text[0].toLowerCase;} switch(text[0]) { case '/id': this.inlineAlert('ID: ' + this.roomId); break; case '/nc': //Clear the active chat window $('#Write [name="message"]').val('Nobody Cares'); break; case '/me': //Emote if(text[1] != undefined) {$('#Write [name="message"]').val('* ' + wgUserName + ' ' + build(text, 1));} else {$('#Write [name="message"]').val('* ' + wgUserName);} return true; break; }	}

function toggleAway { var myChat = new ChatSocket; if($('#ChatHeader .User').hasClass('away') == true) { myChat.socket.sendCommand('setstatus', '"statusState":"here","statusMessage":""'); }		else { myChat.socket.sendCommand('setstatus', '"statusState":"away","statusMessage":""'); }	}

function groupPM { //Returns the NodeChatController for the active window var users = prompt('Enter comma seperated list of users to start a PM with',''), users = users.split(','); mainRoom.openPrivateChat(users); }	$(function {		importScriptURI('http://monchbox.wikia.com/wiki/MediaWiki:ChatSocket.js?action&ctype=text/javascript');		$('#Write').append('AFKPM');		//Unbind all of the window listeners that set your status to back		$(window).unbind('mousemove').unbind('focus').unbind('keypress');	}); } else { $(function {		if($('.chat-join button').length != 0) {			$('.chat-join button').replaceWith('' + $('.chat-join button').html + '');			clearInterval(window.chatcheck);			$('#Chatlink').click(function  { window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); window.chatwindow.onload = function { window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:Kangaroopower/ChatHacksLite.js&action=raw&ctype=text/javascript'); }			});		}	}); }