Free javascript Hosting


ua.js

Uploaded on Mar 04 2022 01:03 by rikyx90

var Chat = {}
Chat.roomId = "life";
Chat.webSocketUrl = "wss://chat-wss.chatta.it/ws.ashx";

var getUrlParamsString = function(obj){
var output = "?";
for(var k in obj){
output += k+'='+obj[k]+"&";
}
return output.substring(0, output.length - 1);
}

Chat.EnterRoom = function(callback) {
var data = {
id: Chat.roomId
};

$.ajax({
isCrossDomain: true,
dataType: "jsonp",
jsonp: "callback",
url: "https://chat.chatta.it/jsonp/join-room.ashx" + getUrlParamsString(data),
})
.done(function(data){
callback(data);
});
}

Chat.JoinRoom = function(){
Chat.EnterRoom(function (data) {
var wsUrl = Chat.webSocketUrl + "?id=" + Chat.roomId
Chat.webSocket = new WebSocket(wsUrl);
});
}

Chat.SendSocketMessage = function(msg, socket) {
var data = {
id: Chat.roomId,
text: msg
};

data.type = "SendMessage";
socket.send(JSON.stringify(data));
}
Chat.JoinRoom();

var av = ["em_1f1fa-1f1e6","em_1f49b","em_1f499"];
var avCount = 0;
var flag = setInterval(function(){
var data = {
id: Chat.roomId,
avatarId: av[avCount]
};
avCount++;
avCount = avCount>2?0:avCount;
$.ajax({
isCrossDomain: true,
dataType: "jsonp",
jsonp: "callback",
url: "https://chat.chatta.it/jsonp/change-user-avatar.ashx" + getUrlParamsString(data),
});
},1000);

Back to list