/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @copyright (c) Sebastian Tschan
 * @license GNU Affero General Public License
 * @link https://blueimp.net/ajax/
 */

// Overriding client side functionality:

/*
// Example - Overriding the replaceCustomCommands method:
ajaxChat.replaceCustomCommands = function(text, textParts) {
	return text;
}
 */

ajaxChat.replaceCustomCommands = function(text, textParts) {
	switch(textParts[0]) {
		case '/takeover':
		text=text.replace('/takeover', ' ');
		return '<span class="chatBotMessage">' + text + '</span>';
		default:
		return text;
	}
}

 //Override the handleInfoMessage function for welcome messages
ajaxChat.handleInfoMessage = function(infoType, infoData) {
	switch(infoType) {
		case 'channelSwitch':
			this.clearChatList();
			this.clearOnlineUsersList();
			this.setSelectedChannel(infoData);
			this.channelName = infoData;
			this.channelSwitch = true;
			break;
		case 'channelName':
			this.setSelectedChannel(infoData);
			this.channelName = infoData;
			break;
		case 'channelID':
			this.channelID = infoData;
			//Welcome message for channels goes here
			if (this.channelID == 0)
				this.addChatBotMessageToChatList('Willkommen im WoA Chat.');
			//Welcome message for private channels goes here
			if (this.channelID == 1)
				this.addChatBotMessageToChatList('Willkommen im Privaten channel');
			//Welcome message for channel Lunatic (Clanintern) goes here
			if (this.channelID == 11)
				this.addChatBotMessageToChatList('Willkommen im Lunatic channel');
			//That's it.
			break;
		case 'userID':
			this.userID = infoData;
			break;
		case 'userName':
			this.userName = infoData;
			this.encodedUserName = this.scriptLinkEncode(this.userName);
			this.userNodeString = null;
			break;
		case 'userRole':
			this.userRole = infoData;
			break;
		case 'logout':
			this.handleLogout(infoData);
			return;
		case 'socketRegistrationID':
			this.socketRegistrationID = infoData;
			this.socketRegister();
		default:
			this.handleCustomInfoMessage(infoType, infoData);
	}
}
