message notifications et pv dans l'ordre

main
Paul Schneider 9 years ago
parent 69efe96c77
commit 9b479c5c33
1 changed files with 24 additions and 10 deletions

@ -2,6 +2,24 @@
ViewBag.Title = "Chat"; ViewBag.Title = "Chat";
} }
<h2>Chat</h2> <h2>Chat</h2>
<style>
.discussion {
color: black;
font-family: monospace;
}
.notif {
color: black;
font-family: monospace;
font-style: italic;
}
.pv {
color: black;
font-family: monospace;
font-style: bold;
}
</style>
<div class="container"> <div class="container">
<input type="text" id="message" /> <input type="text" id="message" />
<input type="button" id="sendmessage" value="Send" /> <input type="button" id="sendmessage" value="Send" />
@ -17,10 +35,6 @@
} }
<ul id="discussion"> <ul id="discussion">
</ul> </ul>
<ul id="private">
</ul>
<ul id="chatnotifs">
</ul>
</div> </div>
@section scripts { @section scripts {
<!--Script references. --> <!--Script references. -->
@ -37,18 +51,18 @@
// Create a function that the hub can call back to display messages. // Create a function that the hub can call back to display messages.
chat.client.addMessage = function (name, message) { chat.client.addMessage = function (name, message) {
// Add the message to the page. // Add the message to the page.
$('#discussion').append('<li><strong>' + htmlEncode(name) $('#discussion').append('<li class="discussion"><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>'); + '</strong>: ' + htmlEncode(message) + '</li>');
}; };
chat.client.PV = function (name, message) { chat.client.addPV = function (name, message) {
// Add the pv to the page. // Add the pv to the page.
$('#private').append('<li><strong>' + htmlEncode(name) $('#discussion').append('<li class="pv"><strong>' + htmlEncode(name)
+ '</strong>: ' + htmlEncode(message) + '</li>'); + '</strong>: ' + htmlEncode(message) + '</li>');
}; };
chat.client.notify = function (tag, message) { chat.client.notify = function (tag, message, data) {
// Add the pv to the page. // Add the pv to the page.
$('#chatnotifs').append('<li><i>' + htmlEncode(tag) $('#discussion').append('<li class="notif"><i>' + htmlEncode(tag)
+ '</i> ' + htmlEncode(message) + '</li>'); + '</i> ' + htmlEncode(message) +' '+ htmlEncode(data) +'</li>');
}; };
// Get the user name and store it to prepend to messages. // Get the user name and store it to prepend to messages.
$('#displayname').val(prompt('Enter your name:', '')); $('#displayname').val(prompt('Enter your name:', ''));

Loading…