fixes
This commit is contained in:
parent
af46fd4cf1
commit
6250f6ba15
1 changed files with 24 additions and 17 deletions
|
|
@ -104,8 +104,12 @@ window.ChatHubHandler = (function ($) {
|
||||||
|
|
||||||
// eslint-disable-next-line no-warning-comments
|
// eslint-disable-next-line no-warning-comments
|
||||||
// TODO userpart userjoin deniedpv
|
// TODO userpart userjoin deniedpv
|
||||||
$('<li></li>').append(tag + ': ' + targetid + ': ').append(message).addClass(tag).appendTo(notifications);
|
$('<li></li>').append(tag + ': ' + targetid + ': ').append(message.Value).addClass(tag).appendTo(notifications);
|
||||||
};
|
};
|
||||||
|
var setChanInfo = function (chanInfo) {
|
||||||
|
var chanId = 'r' + chanInfo.Name;
|
||||||
|
$('#tv_' + chanId).replaceWith(chanInfo.Topic);
|
||||||
|
}
|
||||||
|
|
||||||
var setActiveChan = function (chanId) {
|
var setActiveChan = function (chanId) {
|
||||||
if (frontChanId != chanId) {
|
if (frontChanId != chanId) {
|
||||||
|
|
@ -118,6 +122,14 @@ window.ChatHubHandler = (function ($) {
|
||||||
$('#inp_' + chanId).focus();
|
$('#inp_' + chanId).focus();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function join(roomName)
|
||||||
|
{
|
||||||
|
chat.server.join(roomName).done(function (chatInfo) {
|
||||||
|
setChanInfo(chatInfo);
|
||||||
|
setActiveChan(chatInfo.Name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
var chatbar = $('<div class="chatbar"></div>');
|
var chatbar = $('<div class="chatbar"></div>');
|
||||||
|
|
||||||
var roomjoin = $('<div class="chatctl" class="form-control"></div>');
|
var roomjoin = $('<div class="chatctl" class="form-control"></div>');
|
||||||
|
|
@ -146,6 +158,7 @@ window.ChatHubHandler = (function ($) {
|
||||||
var roomview = $('<div></div>').addClass('container');
|
var roomview = $('<div></div>').addClass('container');
|
||||||
roomview.appendTo(chatlist);
|
roomview.appendTo(chatlist);
|
||||||
roomview.prop('id', 'v' + chanId);
|
roomview.prop('id', 'v' + chanId);
|
||||||
|
$('<div></div>').prop('id', 'tv_' + chanId).appendTo(roomview);
|
||||||
var msglist = $('<ul></ul>').addClass('mesglist');
|
var msglist = $('<ul></ul>').addClass('mesglist');
|
||||||
msglist.prop('id', chanId);
|
msglist.prop('id', chanId);
|
||||||
msglist.appendTo(roomview);
|
msglist.appendTo(roomview);
|
||||||
|
|
@ -178,10 +191,6 @@ window.ChatHubHandler = (function ($) {
|
||||||
else buildChan('@', 'u', userName, chat.server.sendPV);
|
else buildChan('@', 'u', userName, chat.server.sendPV);
|
||||||
};
|
};
|
||||||
|
|
||||||
$view.data('chans').split(',').forEach(function (chan) {
|
|
||||||
buildRoom(chan);
|
|
||||||
});
|
|
||||||
|
|
||||||
/*var getUsers = function () {
|
/*var getUsers = function () {
|
||||||
$.get('/api/chat/users').done(function (users) {
|
$.get('/api/chat/users').done(function (users) {
|
||||||
$.each(users, function () {
|
$.each(users, function () {
|
||||||
|
|
@ -190,24 +199,24 @@ window.ChatHubHandler = (function ($) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};*/
|
};*/
|
||||||
// eslint-disable-next-line no-warning-comments
|
$view.data('chans').split(',').forEach(function (chan){
|
||||||
// TODO only query user list for a given channel, and only for a participant
|
buildRoom(chan);
|
||||||
function onCx() {
|
});
|
||||||
setTimeout(function () {
|
|
||||||
chans.forEach(function (room) {
|
|
||||||
chat.server.join(room).done(function (chatInfo) {
|
|
||||||
setActiveChan('r' + chatInfo.Name);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 120);
|
|
||||||
|
|
||||||
|
function onCx() {
|
||||||
$view.removeClass('disabled');
|
$view.removeClass('disabled');
|
||||||
|
setTimeout(function () {
|
||||||
|
chans.forEach(function (chan) {
|
||||||
|
join(chan);
|
||||||
|
});
|
||||||
|
}, 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onDisCx() {
|
function onDisCx() {
|
||||||
$view.addClass('disabled');
|
$view.addClass('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Start the connection.
|
// Start the connection.
|
||||||
$.connection.hub.start().done(function () {
|
$.connection.hub.start().done(function () {
|
||||||
onCx();
|
onCx();
|
||||||
|
|
@ -221,14 +230,12 @@ window.ChatHubHandler = (function ($) {
|
||||||
});
|
});
|
||||||
}, 30000); // Re-start connection after 30 seconds
|
}, 30000); // Re-start connection after 30 seconds
|
||||||
});
|
});
|
||||||
|
|
||||||
chanName.keydown(function (event) {
|
chanName.keydown(function (event) {
|
||||||
if (event.which == 13) {
|
if (event.which == 13) {
|
||||||
if (this.value.length == 0) return;
|
if (this.value.length == 0) return;
|
||||||
buildRoom(this.value);
|
buildRoom(this.value);
|
||||||
chat.server.join(this.value).done(function (chatInfo) {
|
join(this.value);
|
||||||
setActiveChan('r' + chatInfo.Name);
|
|
||||||
});
|
|
||||||
this.value = '';
|
this.value = '';
|
||||||
}
|
}
|
||||||
// else TODO showRoomInfo(this.value);
|
// else TODO showRoomInfo(this.value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue