User:A.r.s.h.©/Ultimate chat.js

//it is small now but if you have anything chat contact me A.r.s.h.//

//chat hacks//

importScriptPage('User:Monchoman45/ChatHacks.js', 'c');

//multi user P.M.//

importScriptPage('User:Joeytje50/ChatPMs.js', 'c')

//chat sech bar//

$('#ChatHeader').append('  ')

/ * ChatSocket.js, by Monchoman45. */ /*'enter': 'join', 		'join': function(com, text) { //Now for a command with chutzpah - join any chat on Wikia 			//Need to fix this so that joined rooms can be selected 			if(com) { 				var data = new models.OpenPrivateRoom({roomId: com}); 				mainRoom.baseOpenPrivateRoom(data, true); 				$('.private').before(' ' + com + ' 0 '); 				mainRoom.showRoom(com); 				mainRoom.chats.privates[com].init; 			} 			else {this.inlineAlert(i18n['errroom'].replace(/\$1/g, text.split(' ')[0]));} 		}, 		'leave': 'part', 		'part': function(com, text) { //Leave the room you're looking at, or the room you specify 			if(!com) {var id = this.roomId; var chat = this;} 			else {var id = com; var chat = mainRoom.chats.privates[com];} 			$('#Room_' + id).remove; 			chat.socket.autoReconnect = false; 			chat.socket.socket.disconnect; 			if(!com) {mainRoom.show('main');} 		},*/ 		'roomid': 'id', 		'id': function(com, text) { 			this.inlineAlert(i18n['id'] + ': ' + this.roomId); 		}, 		'self': function(com, text) { //Send a message to yourself 			if(com) { 				newstr = ; 				for(var i = 0; i < com.length; i++) { 					switch(com.charAt(i)) { 						case '[': 							if(com.charAt(i + 1) == '[') { 								var k = com.indexOf(']', i); 								if(com.charAt(k + 1) == ']') { 									var substr = com.substring(i + 2, k); 									if(substr.indexOf('|') != -1) { 										var link = substr.substring(0, substr.indexOf('|')); 										var linktext = substr.substring(substr.indexOf('|') + 1, substr.length); 									} 									else { 										var link = substr; 										var linktext = link; 									} 									var linkspl = link.split(' '); 									link = ; 									for(var j in linkspl) {link += linkspl[j] + '_';} 									link = link.substring(0, link.length - 1); 									newstr += '' + linktext + ''; 									i = k + 1; 								} 							} 							else if(com.substring(i + 1, i + 8) == 'http://') { 								var k = com.indexOf(']', i); 								var splstr = com.substring(i + 1, k).split(' '); 								if(splstr == com.substring(i + 1, k)) { 									var linktext = '[1]'; 								} 								else { 									var linktext = build(splstr, 1); 								} 								newstr += '' + linktext + ''; 								i = k; 							} 							break; 						default: 							newstr += com.charAt(i); 							break; 					} 				} 				this.viewDiscussion.chatUL.append(' ' + wgUserName + ' (' + i18n['self'] + ') ' + newstr + ' '); 			} 			else { 				this.viewDiscussion.chatUL.append(' ' + wgUserName + ' (' + i18n['self'] + ') '); 			} 			this.viewDiscussion.scrollToBottom; 		}, 		'help': function(com, text) { 			if(com) { 				var ref = com.replace(/ /g, '.'); 				var str = ; 				var subcoms = []; 				var subdirs = []; 				while(typeof eval('window.commands.' + ref) == 'string') {ref.substring(0, ref.lastIndexOf('.')) + '.' + eval('window.commands' + ref).toLowerCase;} 				var command = eval('window.commands.' + ref); 				if(i18n['help-' + ref]) {str += i18n['help'].replace(/\$1/g, ref.replace(/\./g, ' ')).replace(/\$2/g, i18n['help-' + ref].replace(/\$1/g, i18n['example']).replace(/\$1/g, i18n['exampleuser']));} 				if(typeof command == 'object') { 					for(var i in command) { 						if(typeof command[i] == 'function') {subcoms.push(i);} 						if(typeof command[i] == 'object') {subdirs.push(i);} 					} 				} 				if(subcoms.length > 0) {str += '\n' + i18n['subcoms'] + ': ' + subcoms.join(', ');} 				if(subdirs.length > 0) {str += '\n' + i18n['subdirs'] + ': ' + subdirs.join(', ');} 				str = str.removeTrailing('\n'); 				if(str != ) {this.inlineAlert(str);} 				else {this.inlineAlert(i18n['nohelp'].replace(/\$1/g, command));} 			} 			else { 				var str = []; 				for(var i in window.commands) { 					if(typeof window.commands[i] == 'function' || typeof window.commands[i] == 'object') {str.push(i);} 				} 				this.inlineAlert(i18n['commands'].replace(/\$1/g, str.join(', '))); 			} 		} 	};  	//Parser helping function - takes an array of text created with .split(' '), 	//and an index number for where to start, then rebuilds the string. //Can also accept an index value for where to stop. function build(text, index, stop) { 		var newtext = ; 		if(stop == undefined || stop == 0) {stop = text.length} 		else if(stop < 0) {stop += text.length} 		if(index == stop || index == text.length - 1) {return text[index];} 		for(var i = index; i < stop; i++) { 			newtext += text[i] + ' '; 		} 		return newtext; 	}  	function toggleAway(msg) { 		if(!msg) {var msg = ;} 		if($('#ChatHeader .User').hasClass('away') == true) { 			mainRoom.setBack; 		} 		else { 			mainRoom.setAway(msg); 		} 	} 	toggleAway.back = function { //Force back status 		if($('#ChatHeader .User').hasClass('away') == true) {mainRoom.setBack;} 	} 	toggleAway.away = function(msg) { //Force away status 		if(!msg) {var msg = ;} 		if($('#ChatHeader .User').hasClass('away') == false) {mainRoom.setAway(msg);} 	}   	NodeChatController.prototype.clearWindow = function { 		this.viewDiscussion.chatUL.html(); 		this.inlineAlert(i18n['cleared']); 	}   	function active { //Returns the NodeChatController for the active window 		if(mainRoom.activeRoom && mainRoom.activeRoom != 'main') {return mainRoom.chats.privates[mainRoom.activeRoom];} 		else {return mainRoom;} 	}   	String.prototype.removeTrailing = function(char) { //Remove extraneous characters 		var str = this; 		while(str.charAt(0) == char) {str = str.substring(1, str.length);} 		while(str.charAt(str.length - 1) == char) {str = str.substring(0, str.length - 1);} 		return str; 	}   	function createCookie(name,value,days) { 		if (days) { 			var date = new Date; 			date.setTime(date.getTime+(days*24*60*60*1000)); 			var expires = "; expires="+date.toGMTString; 		} 		else var expires = ""; 		document.cookie = name+"="+value+expires+"; path=/"; 	}   	function readCookie(name) { 		var nameEQ = name + "="; 		var ca = document.cookie.split(';'); 		for(var i=0;i < ca.length;i++) { 			var c = ca[i]; 			while (c.charAt(0)==' ') c = c.substring(1,c.length); 			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 		} 		return null; 	}   	$(function  { 		if(!importScriptURI) {function importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}} 		importScriptURI('http://c.wikia.com/index.php?title=User:Monchoman45/ChatHacks.js/i18n.js&action=raw&ctype=text/javascript'); 		importScriptURI('http://monchbox.wikia.com/index.php?title=MediaWiki:APIQuery.js&action=raw&ctype=text/javascript'); //APIQuery for /unban   		$('head').append('<style type="text/css">\n.stafficon {\n\tmargin-bottom:-4px;\n\twidth:14px;\n\theight:14px;\n}\n.modicon {\n\tmargin-bottom:-3px;\n\twidth:14px;\n\theight:14px;\n}\n.UserStatsMenu {\n\tcolor:#000;\n}\n.Write [name="message"] {\n\twidth:93%;\n}\n.inline-alert span {\n\tcolor:#006CB0;\n\tcursor:pointer;\n}\n.inline-alert span:hover {\n\ttext-decoration:underline;\n}\n#pingspan {\n\tposition:absolute;\n\tz-index:5;\n\ttop:23px;\n\tmargin-left:15px;\n\tfont-size:15px;\n\tfont-weight:normal;\n\tline-height:15px;\n}\n#pings {\n\tresize:none;\n\tmargin-left:0;\n\tfont-size:12px;\n\theight:100px;\n\tdisplay:block;\n}\n#pingspan div span {\n\tfont-size:55%;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n#ChatHeader {\n\tz-index:9999;\n}\n ');   		//Unbind all of the window listeners that set your status to back 		$(window).unbind('mousemove').unbind('focus').unbind('keypress'); 		//Add the sound space 		$('body').append(' '); 	}); } else { 	$(function  { 		if(document.body.className.indexOf('skin-oasis') == -1) { 			var a = document.getElementsByTagName('a'); 			for(var i in a) { 				if(a[i].href && a[i].href.indexOf('/wiki/Special:Chat') != -1) { 					a[i].href = 'javascript:OpenChatWindow'; 				} 			} 		} 		else { 			window.chatcheck = setInterval('ChatCheck', 200); 		} 	});   	function ChatCheck { 		if($('.chat-join button').length != 0) { 			$('.chat-join button').replaceWith('<a class="wikia-button" onclick="OpenChatWindow">' + $('.chat-join button').html + '</a>'); 			clearInterval(window.chatcheck); 		} 	}   	function OpenChatWindow { 		window.chatwindow = window.open('/index.php?title=Special:Chat&useskin=wikia'); 		window.chatwindow.onload = function  { 			//addOnloadHook, importScript, and importStylesheet 			window.chatwindow.$('body').prepend(' \nfunction importScript(b){var a=wgScript+"?title="+encodeURIComponent(b.replace(/ /g,"_")).replace(/%2F/ig,"/").replace(/%3A/ig,":")+"&action=raw&ctype=text/javascript";return importScriptURI(a)}\nfunction importScriptURI(a){var b=document.createElement("script");b.setAttribute("src",a);b.setAttribute("type","text/javascript");document.getElementsByTagName("head")[0].appendChild(b);return b}\nfunction importScriptPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/javascript";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importScriptURI(a)}\nfunction importStylesheet(a){return importStylesheetURI(wgScript+"?action=raw&ctype=text/css&title="+encodeURIComponent(a.replace(/ /g,"_")))}\nfunction importStylesheetURI(b,d){var a=document.createElement("link");a.type="text/css";a.rel="stylesheet";a.href=b;if(d){a.media=d}document.getElementsByTagName("head")[0].appendChild(a);return a}\nfunction importStylesheetPage(b,d){var a="/index.php?title="+encodeURIComponent(b.replace(/ /g,"_")).replace("%2F","/").replace("%3A",":")+"&action=raw&ctype=text/css";if(typeof d=="string"){if(d.indexOf("://")==-1){a="http://"+d+".wikia.com"+a}else{a=d+a}}return importStylesheetURI(a)}\n//This isn\'t the same as the regular addOnloadHook, because the regular one runs from a script tag in the body that I don\'t feel like appending. It\'s easier to just make it $(function), which is essentially equivalent\nfunction addOnloadHook(func) {$(func);}\n '); 			//global.js 			window.chatwindow.importScriptURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.js&action=raw&ctype=text/javascript'); 			//wikia.js 			window.chatwindow.importScriptURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.js&action=raw&ctype=text/javascript'); 			//global.css 			window.chatwindow.importStylesheetURI('http://community.wikia.com/index.php?title=User:' + wgUserName + '/global.css&action=raw&ctype=text/css'); 			//wikia.css 			window.chatwindow.importStylesheetURI(wgServer + '/index.php?title=User:' + wgUserName + '/wikia.css&action=raw&ctype=text/css'); 		} 	}