forked from WebManufacture/ILAB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ilab_messages.js
41 lines (35 loc) · 1.15 KB
/
ilab_messages.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict'
function scrollMessages(){
$("#messageList").scrollTop($("#messageList")[0].scrollHeight);
}
function refreshMessages(event){
var serv = event.data.param1;
var Messages;
serv.GetMessages(function(res){
Messages=res;
for(var i=0; i<Messages.length;i++){
$('#messageList').append("<li>"+Messages[i].messageText+"</li>");
}
scrollMessages();
});
}
function sendMessages(event){
var serv = event.data.param1;
var messageText = $("#messageInput").val();
serv.AddMessages(messageText,function(res){
});
$("#messageInput").val("");
}
WS.DOMload(function(){
ServicesManager.onconnected = function(){
ServicesManager.GetService("ChatService", function(service, err){
//Тут вам доступен ваш сервис, или Null, если ошибка
if (service){
$("#refreshButton").bind('click', { param1: service }, refreshMessages);
$("#sendButton").bind('click', { param1: service }, sendMessages);
scrollMessages();
}
});
return;
}
});