Commit 74ee07ea authored by Wandenberg Peixoto's avatar Wandenberg Peixoto

small change on layout and escaping CRLF on text

parent e7c45f9e
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Chat - Push Stream Module Example</title> <title>Chat - Push Stream Module Example</title>
<style type="text/css">
form p { min-height: 20px;}
</style>
</head> </head>
<body> <body>
<form action="/pub" method="POST"> <form action="/pub" method="POST">
<p> <p>
<span style="display: block; float: left; width: 55px;">mode:</span> <span style="display: block; float: left; width: 55px;">mode:</span>
<span id="mode" style="display:none;"></span> <span id="mode"></span>
</p> </p>
<p> <p>
<span style="display: block; float: left; width: 55px;">satus:</span> <span style="display: block; float: left; width: 55px;">satus:</span>
...@@ -77,11 +80,11 @@ ...@@ -77,11 +80,11 @@
if (state == PushStream.OPEN) { if (state == PushStream.OPEN) {
$(".offline").hide(); $(".offline").hide();
$(".online").show(); $(".online").show();
$("#mode").html(pushstream.wrapper.type).show(); $("#mode").html(pushstream.wrapper.type);
} else { } else {
$(".offline").show(); $(".offline").show();
$(".online").hide(); $(".online").hide();
$("#mode").html("").hide(); $("#mode").html("");
} }
}; };
...@@ -97,7 +100,7 @@ ...@@ -97,7 +100,7 @@
$("#sendButton").click(function(){ $("#sendButton").click(function(){
if (($("#nick").val() != "") && ($("#message").val() != "") && ($("#room").val() != "")) { if (($("#nick").val() != "") && ($("#message").val() != "") && ($("#room").val() != "")) {
pushstream.sendMessage('{"nick":"' + $("#nick").val() + '", "text":"' + $("#message").val() + '"}', onSendText); pushstream.sendMessage('{"nick":"' + $("#nick").val() + '", "text":"' + $("#message").val().replace(/\r/g, '\\\\r').replace(/\n/g, '\\\\n') + '"}', onSendText);
} else { } else {
alert("nick, room and text are required"); alert("nick, room and text are required");
} }
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
<head> <head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Chat Long Polling - Push Stream Module Example</title> <title>Chat Long Polling - Push Stream Module Example</title>
<style type="text/css">
form p { min-height: 20px;}
</style>
</head> </head>
<body> <body>
<form action="/pub" method="POST"> <form action="/pub" method="POST">
<p> <p>
<span style="display: block; float: left; width: 55px;">mode:</span> <span style="display: block; float: left; width: 55px;">mode:</span>
<span id="mode" style="display:none;"></span> <span id="mode"></span>
</p> </p>
<p> <p>
<span style="display: block; float: left; width: 55px;">satus:</span> <span style="display: block; float: left; width: 55px;">satus:</span>
...@@ -77,11 +80,11 @@ ...@@ -77,11 +80,11 @@
if (state == PushStream.OPEN) { if (state == PushStream.OPEN) {
$(".offline").hide(); $(".offline").hide();
$(".online").show(); $(".online").show();
$("#mode").html(pushstream.wrapper.type).show(); $("#mode").html(pushstream.wrapper.type);
} else { } else {
$(".offline").show(); $(".offline").show();
$(".online").hide(); $(".online").hide();
$("#mode").html("").hide(); $("#mode").html("");
} }
}; };
...@@ -97,7 +100,7 @@ ...@@ -97,7 +100,7 @@
$("#sendButton").click(function(){ $("#sendButton").click(function(){
if (($("#nick").val() != "") && ($("#message").val() != "") && ($("#room").val() != "")) { if (($("#nick").val() != "") && ($("#message").val() != "") && ($("#room").val() != "")) {
pushstream.sendMessage('{"nick":"' + $("#nick").val() + '", "text":"' + $("#message").val() + '"}', onSendText); pushstream.sendMessage('{"nick":"' + $("#nick").val() + '", "text":"' + $("#message").val().replace(/\r/g, '\\\\r').replace(/\n/g, '\\\\n') + '"}', onSendText);
} else { } else {
alert("nick, room and text are required"); alert("nick, room and text are required");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment