Explorar el Código

Merge branch 'master' of https://github.com/Omnimaga/OmnomIRC3

Florian DORMONT hace 11 años
padre
commit
387dcaab72
Se han modificado 2 ficheros con 20 adiciones y 6 borrados
  1. 4 1
      app/OmnomIRC.js
  2. 16 5
      app/www/js/omnomirc.js

+ 4 - 1
app/OmnomIRC.js

@@ -214,8 +214,11 @@ if(cluster.isMaster){
 			var sockets = io.sockets.clients(data.name),
 				i;
 			runWithUserList(data.name,function(users){
+				var temp = [],i;
+				for(i in users) i && temp.push(users[i]);
+				users = temp;
 				socket.emit('message',{
-					message: data.name+" users:\n"+users.join("\n\t"),
+					message: data.name+" users:\n\t\t"+users.join("\n\t\t"),
 					room: data.name,
 					from: 0
 				});

+ 16 - 5
app/www/js/omnomirc.js

@@ -223,10 +223,14 @@
 						i,
 						msg = function(msg){
 							string = '<span class="cell date_cell">[<abbr class="date date_'+time+'" title="'+date.toISOString()+'"></abbr>]</span>';
-							child = $('<li>').html(string+'<span class="cell">'+msg.htmlentities().replace(
-								/(https?:\/\/(([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?))/g,
-								"<a href=\"$1\" title=\"\">$1</a>"
-							)+'</span>');
+							child = $('<li>').html(string+'<span class="cell">'+
+								msg
+									.htmlentities()
+									.replace(
+										/(https?:\/\/(([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?))/g,
+										"<a href=\"$1\" title=\"\">$1</a>"
+									)
+							+'</span>');
 							$o.msg({html:child},data.room);
 						};
 					if(data.from != 0){
@@ -703,7 +707,14 @@
 		}
 	});
 	String.prototype.htmlentities = function(){
-		return this.replace(/&/g, '&amp;').replace(/\s/g, '&nbsp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
+		return this
+			.replace(/&/g, '&amp;')
+			.replace(/</g, '&lt;')
+			.replace(/>/g, '&gt;')
+			.replace(/\n/g,'<br/>')
+			.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;')
+			.replace(/\s/g, '&nbsp;')
+			.replace(/"/g, '&quot;');
 	};
 	$(document).ready(function(){
 		$.extend(settings,$.parseJSON($.localStorage('settings')));