Fred T-H avatar Fred T-H committed 6551929

moving the html escaping to the js clients

Comments (0)

Files changed (3)

   {registered, [chut_user_supersup, chut_webserver,
                 chut_sup, chut_webserver_sup]},
   {applications, [kernel, stdlib]},
-  {mod, {chut_app,8080}}
+  {mod, {chut_app,9001}}
  ]}.
 		Chut._JSONP(Chut.url.history(id),'Chut.callbacks.history');
 	},
 	url: {
-		base: 'http://localhost:8080',
+		base: 'http://localhost:9001',
 		listen: function(user_id){
 			return Chut.url.base+"/listen?id="+escape(user_id)+'&'+Math.random();
 		},
 				var Box = $('#chut_'+Msg.to);
 				if(Box.length > 0){
 					if(Msg.action == 'sent'){
-						Box.append('<dl class="sent"><dt>'+user_id+':</dt><dd>'+Msg.message+'</dd></dl>');
+                        var dl = $('<dl>').attr('class', 'sent');
+                        var dt = $('<dt>').text(user_id);
+                        var dd = $('<dd>').text(Msg.message);
+                        Box.append(dl.append(dt).append(dd));
 					} else {
-						Box.append('<dl class="received"><dt>'+Msg.to+':</dt><dd>'+Msg.message+'</dd></dl>');
+                        var dl = $('<dl>').attr('class', 'received');
+                        var dt = $('<dt>').text(Msg.to);
+                        var dd = $('<dd>').text(Msg.message);
+						Box.append(dl.append(dt).append(dd));
 					}
 					Box.scrollTop(Box.height());
 				}
 				var Box = $('#chut_'+Msg.to);
 				if(Box.length > 0){
 					if(Msg.action == 'sent'){
-						Box.append('<dl class="hist sent"><dt>'+user_id+':</dt><dd>'+Msg.message+'</dd></dl>');
+                        var dl = $('<dl>').attr('class', 'hist sent');
+                        var dt = $('<dt>').text(user_id);
+                        var dd = $('<dd>').text(Msg.message);
+                        Box.append(dl.append(dt).append(dd));
 					} else {
-						Box.append('<dl class="hist received"><dt>'+Msg.to+':</dt><dd>'+Msg.message+'</dd></dl>');
+                        var dl = $('<dl>').attr('class', 'hist received');
+                        var dt = $('<dt>').text(Msg.to);
+                        var dd = $('<dd>').text(Msg.message);
+						Box.append(dl.append(dt).append(dd));
 					}
 					Box.scrollTop(Box.height());
 				}

src/chut_webserver.erl

 json_prepare({Verb,To=[_|_],Msg}) -> json_prepare({Verb,unicode:characters_to_binary(To),Msg});
 json_prepare({Verb,To,Msg=[_|_]}) -> json_prepare({Verb,To,unicode:characters_to_binary(Msg)});
 json_prepare({Verb,To,Msg}) ->
-    {struct, [{action,Verb},
-              {to,To},
-              {message,mochiweb_html:escape(Msg)}]}.
+    {struct, [{action,Verb},{to,To},{message,Msg}]}.
 
 reply(Req, JSON, Params) ->
     Callback = proplists:get_value("callback", Params),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.