|
|
|
@ -1,33 +1,33 @@
|
|
|
|
window.ChatHubHandler = (function ($) {
|
|
|
|
window.ChatHubHandler = (function ($) {
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
# chat control ids
|
|
|
|
# chat control ids
|
|
|
|
|
|
|
|
|
|
|
|
## inputs
|
|
|
|
## inputs
|
|
|
|
|
|
|
|
|
|
|
|
* msg_<rname> : input providing a room message
|
|
|
|
* msg_<rname> : input providing a room message
|
|
|
|
* pv_<uname> : input providing a private message
|
|
|
|
* pv_<uname> : input providing a private message
|
|
|
|
* command : input providing server command
|
|
|
|
* command : input providing server command
|
|
|
|
* roomname : input (hidden or not) providing a room name
|
|
|
|
* roomname : input (hidden or not) providing a room name
|
|
|
|
|
|
|
|
|
|
|
|
## persistent containers
|
|
|
|
## persistent containers
|
|
|
|
|
|
|
|
|
|
|
|
* chatview : the global container
|
|
|
|
* chatview : the global container
|
|
|
|
* rooms : container from room displays
|
|
|
|
* rooms : container from room displays
|
|
|
|
* pvs : container from pv displays
|
|
|
|
* pvs : container from pv displays
|
|
|
|
* server : container for server messages
|
|
|
|
* server : container for server messages
|
|
|
|
|
|
|
|
|
|
|
|
## temporary containers
|
|
|
|
## temporary containers
|
|
|
|
|
|
|
|
|
|
|
|
* room_<rname> : room message list
|
|
|
|
* room_<rname> : room message list
|
|
|
|
* pv_<uname> : private discussion display
|
|
|
|
* pv_<uname> : private discussion display
|
|
|
|
|
|
|
|
|
|
|
|
## css classes
|
|
|
|
## css classes
|
|
|
|
|
|
|
|
|
|
|
|
* form-control
|
|
|
|
* form-control
|
|
|
|
* btn btn-default
|
|
|
|
* btn btn-default
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
$.fn.filterByData = function (prop, val) {
|
|
|
|
$.fn.filterByData = function (prop, val) {
|
|
|
|
return this.filter(function () { return $(this).data(prop) == val; });
|
|
|
|
return this.filter(function () { return $(this).data(prop) == val; });
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -78,7 +78,7 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
$('<li></li>').append(tag + ': ' + targetid).append(message).addClass(tag).appendTo(notifications);
|
|
|
|
$('<li></li>').append(tag + ': ' + targetid).append(message).addClass(tag).appendTo(notifications);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var setActiveRoom = function(room) {
|
|
|
|
var setActiveRoom = function (room) {
|
|
|
|
var frontRoom;
|
|
|
|
var frontRoom;
|
|
|
|
if (frontRoomName !== '') {
|
|
|
|
if (frontRoomName !== '') {
|
|
|
|
frontRoom = $('#vroom_' + frontRoomName);
|
|
|
|
frontRoom = $('#vroom_' + frontRoomName);
|
|
|
|
@ -110,7 +110,7 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
chatlist.appendTo($view);
|
|
|
|
chatlist.appendTo($view);
|
|
|
|
var buildRoom = function (room) {
|
|
|
|
var buildRoom = function (room) {
|
|
|
|
var roomTag = $('<a>' + room + '</a>').addClass('btn');
|
|
|
|
var roomTag = $('<a>' + room + '</a>').addClass('btn');
|
|
|
|
roomTag.prop('id', 'sel_' + room).click(function() {
|
|
|
|
roomTag.prop('id', 'sel_' + room).click(function () {
|
|
|
|
setActiveRoom(room);
|
|
|
|
setActiveRoom(room);
|
|
|
|
$(this).removeClass('btn-primary');
|
|
|
|
$(this).removeClass('btn-primary');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -128,7 +128,7 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
.prop('hint', 'hello')
|
|
|
|
.prop('hint', 'hello')
|
|
|
|
.prop('title', 'send to ' + room)
|
|
|
|
.prop('title', 'send to ' + room)
|
|
|
|
.addClass('form-control')
|
|
|
|
.addClass('form-control')
|
|
|
|
.keydown(function(ev) {
|
|
|
|
.keydown(function (ev) {
|
|
|
|
if (ev.which == 13) {
|
|
|
|
if (ev.which == 13) {
|
|
|
|
if (this.value.length == 0) return;
|
|
|
|
if (this.value.length == 0) return;
|
|
|
|
chat.server.send(room, this.value);
|
|
|
|
chat.server.send(room, this.value);
|
|
|
|
@ -139,25 +139,25 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
setActiveRoom(room);
|
|
|
|
setActiveRoom(room);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$view.data('chans').split(',').forEach(function(chan) {
|
|
|
|
$view.data('chans').split(',').forEach(function (chan) {
|
|
|
|
buildRoom(chan);
|
|
|
|
buildRoom(chan);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function onCx () {
|
|
|
|
function onCx() {
|
|
|
|
setTimeout(function () {
|
|
|
|
setTimeout(function () {
|
|
|
|
getUsers();
|
|
|
|
getUsers();
|
|
|
|
}, 120);
|
|
|
|
}, 120);
|
|
|
|
|
|
|
|
|
|
|
|
$('#chatview').removeClass('disabled');
|
|
|
|
$('#chatview').removeClass('disabled');
|
|
|
|
|
|
|
|
|
|
|
|
chans.forEach(function(room) {
|
|
|
|
chans.forEach(function (room) {
|
|
|
|
chat.server.join(room).done(function(chatInfo) {
|
|
|
|
chat.server.join(room).done(function (chatInfo) {
|
|
|
|
setActiveRoom(chatInfo.Name);
|
|
|
|
setActiveRoom(chatInfo.Name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function onDisCx () {
|
|
|
|
function onDisCx() {
|
|
|
|
$('#chatview').addClass('disabled');
|
|
|
|
$('#chatview').addClass('disabled');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -181,7 +181,7 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
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) {
|
|
|
|
chat.server.join(this.value).done(function (chatInfo) {
|
|
|
|
setActiveRoom(chatInfo.Name);
|
|
|
|
setActiveRoom(chatInfo.Name);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.value = '';
|
|
|
|
this.value = '';
|
|
|
|
@ -240,7 +240,7 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// This optional function html-encodes messages for display in the page.
|
|
|
|
// This optional function html-encodes messages for display in the page.
|
|
|
|
function htmlEncode (value) {
|
|
|
|
function htmlEncode(value) {
|
|
|
|
var encodedValue = $('<div />').text(value).html();
|
|
|
|
var encodedValue = $('<div />').text(value).html();
|
|
|
|
return encodedValue;
|
|
|
|
return encodedValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -275,7 +275,7 @@ window.ChatHubHandler = (function ($) {
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$(document).ready(function($) {
|
|
|
|
$(document).ready(function ($) {
|
|
|
|
ChatView($('#chatview'), true);
|
|
|
|
ChatView($('#chatview'), true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|