Fixe le comportement du chat

This commit is contained in:
2017-03-16 17:13:47 +01:00
parent 1eaa0021cb
commit 5a4f654978

View File

@ -46,12 +46,17 @@
<script src="~/api/signalr/hubs"></script> <script src="~/api/signalr/hubs"></script>
<!--SignalR script to update the chat page and send messages.--> <!--SignalR script to update the chat page and send messages.-->
<script> <script>
var pvuis;
var audio = new Audio('/sounds/bell.mp3');
$(function () { // This optional function html-encodes messages for display in the page.
var pvuis; function htmlEncode(value) {
var audio = new Audio('/sounds/bell.mp3'); var encodedValue = $('<div />').text(value).html();
return encodedValue;
}
var setPrivate = function (li) { var setPrivate = function (li) {
console.log("here I am"); console.log("here I am");
$("#sendmessagebox").addClass("hidden"); $("#sendmessagebox").addClass("hidden");
$("#sendpvbox").removeClass("hidden"); $("#sendpvbox").removeClass("hidden");
@ -95,7 +100,8 @@
); );
}; };
// Reference the auto-generated proxy for the hub. $(document).ready(function(){
// Reference the auto-generated proxy for the hub.
var chat = $.connection.chatHub; var chat = $.connection.chatHub;
// 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) {
@ -216,20 +222,12 @@
}, 3000); // Re-start connection after 3 seconds }, 3000); // Re-start connection after 3 seconds
}); });
}); });
$(window).unload(function () { chat.server.abort(); });
}); });
// This optional function html-encodes messages for display in the page.
function htmlEncode(value) {
var encodedValue = $('<div />').text(value).html();
return encodedValue;
}
</script> </script>
@if (!ViewBag.IsAuthenticated) { // Get the user name and store it to prepend to messages. @if (!ViewBag.IsAuthenticated) { // Get the user name and store it to prepend to messages.
<script> <script>
$('#displayname').val(prompt('Enter your name:', '')); $('#displayname').val(prompt('Enter your name:', ''));
</script> </script>
} } } }