Commits

Philip Pryce  committed 62dedb5

Added theme configuration variable ready for theming, added emoticons to the config, along with their images, adding emoticons to the incoming parser and added an outgoing parser to create the 'tablumps'

  • Participants
  • Parent commits ac5bbec

Comments (0)

Files changed (13)

File css/default.css

 	background-color: #fbfbfb;
 	background-color: rgba(255, 255, 255, 0.8);
 }
+.view-list .message img { vertical-align: middle; }
 .view-list .title {
 	font-weight: bold;
 	text-align: right;

File images/bullet_add.png

Added
New image

File images/emotion_grin.png

Added
New image

File images/emotion_happy.png

Added
New image

File images/emotion_smile.png

Added
New image

File images/emotion_suprised.png

Added
New image

File images/emotion_tongue.png

Added
New image

File images/emotion_unhappy.png

Added
New image

File images/emotion_waii.png

Added
New image

File images/emotion_wink.png

Added
New image

File images/exclamation.png

Added
New image

File javascript/config.js

 	host: 'joltproject.com',	// Host address of the Jolt server
 	port: 4131,					// Port of the Jolt server or load ballancer.
 	
+	
 	title: "Jolt Chat Client",	// Displayed in the title of the browser before the current views name
 	
+	// Current Theme
+	theme: '',
+	
 	// Jolt Extensions
 	extensions: [				// An array of file names in the extensions folder
 		'accounts',
 		
 		// Bug reporting extension, only used on the offical jolt client, must come last
 		'bug_report'
-	]
+	],
+	
+	// Emoticons
+	emoticons: {
+		":D":		"emotion_grin",
+		"XD":		"emotion_happy",
+		":)":		"emotion_smile",
+		":O":		"emotion_suprised",
+		":P":		"emotion_tongue",
+		":(":		"emotion_unhappy",
+		":3":		"emotion_waii",
+		";)":		"emotion_wink",
+		":!:":		"exclamation",
+		":+:":		"bullet_add"
+	}
 	
 };
 // END CONFIG

File javascript/jolt.js

 		return h + ':' + m + ':' + s;
 	}
 	
-	function parse_msg (msg)
+	function parse_incoming_msg (msg)
 	{
 		// Only links so far
-		var regex = "(http(s?)://((w){3}|([a-zA-Z0-9-.]+))([a-zA-Z0-9]+)(/?([a-zA-Z0-9-_@!$%#?=+/.,:;~]+)?))";
+		var link_regex = "(http(s?)://((w){3}|([a-zA-Z0-9-.]+))([a-zA-Z0-9]+)(/?([a-zA-Z0-9-_@!$%#?=+/.,:;~]+)?))";
 		var replace = "<a href=\"$1\" title=\"$1\" target=\"_blank\">[link]</a>";
-		return msg.replace( new RegExp(regex, "g"), replace);
+		msg = msg.replace( new RegExp(link_regex, "g"), replace);
+		
+		if (msg.indexOf("$emote\t\t") === -1) { return msg; }
+		
+		var emote_regex = new RegExp("\\$emote\t\t([^\t]+)\t([^\t]+)\t\t;", "gi");
+		var matches = msg.match(emote_regex);
+		if (matches === null) {return msg; }
+		for (var i = 0, len = matches.length; i < len; i++)
+		{
+			var data = matches[i].substr(8).split("\t").slice(0, 2);
+			var code = data[0];
+			var src = data[1];
+			var emote = '<img src="images/' + src + '.png" alt="' + code + '" title="Emoticon: ' + code + '" />';
+			msg = msg.replace(matches[i], emote);
+		}
+		
+		return msg;
+	}
+	
+	function parse_outgoing_msg (msg)
+	{
+		for (var code in config.emoticons)
+		{
+			var src = config.emoticons[code];
+			var exp = code.replace(/([.?*+^$[\]\\(){}-])/g, "\\$1"); // Escape the code
+		    msg = msg.replace(new RegExp(exp, "g"), "$emote\t\t" + code + "\t" + src + "\t\t;");
+		}
+		
+		return msg;
 	}
 	
 	function deep_parse (deep_string, part_parse, delimeter1, delimeter2)
 		browser_fail: browser_fail,
 		load_extensions: load_extensions,
 		timestamp: timestamp,
-		parse_msg: parse_msg,
+		parse_incoming_msg: parse_incoming_msg,
+		parse_outgoing_msg: parse_outgoing_msg,
 		deep_parse: deep_parse,
 		hash_parser: hash_parser,
 		
 		{
 			// Someone else has left a channel you are in
 			var user = this.parameters.u;
-			var reason = this.parameters.r;
+			var reason = this.parameters.r || "quit";
 			var message = user + ' left [' + reason + ']';
 			
 			// Add a message to the correct channel
 		if (this.subcommand == 'main')
 		{
 			// Standard message recived
-			message = Jolt.parse_msg(this.content);
+			message = Jolt.parse_incoming_msg(this.content);
 			
 			UI.channel.add_message(channel, 'main', user, message);
 		}
 		if (this.subcommand == 'action')
 		{
 			// Action message recived
-			message = Jolt.parse_msg(this.content);
+			message = Jolt.parse_incoming_msg(this.content);
 			
 			UI.channel.add_message(channel, 'action', user, message);
 		}
 	Jolt.packet.register('pchat:msg', function ()
 	{
 		var user = this.parameters.from || "";
-		var message = Jolt.parse_msg(this.content);
+		var message = Jolt.parse_incoming_msg(this.content);
 		
 		if (this.parameters.e == 'spam')
 		{
 		if (this.mode == 'channel')
 		{
 			// Build standard message packet
-			content = this.value;
+			content = Jolt.parse_outgoing_msg(this.value);
 			var channel = UI.sidebar.current_name();
 			
 			UI.history.record('channel', channel, content);
 		if (this.mode == 'pchat')
 		{
 			// Build a pchat message packet
-			content = this.value;
+			content = parse_outgoing_msg(this.value);
 			var user = UI.sidebar.current_name();
 			
 			UI.history.record('pchat', user, content);
 			Packet(["pchat msg", "to=" + user, "e=msg", "", content]);
 			
 			// pchat packets dont get sent back, so just parse the sent info
-			content = Jolt.parse_msg(content);
+			content = Jolt.parse_incoming_msg(content);
 			
 			if (content != "") { UI.pchat.add_message(user, 'main', Jolt.datastore.username, content); }
 		}