Uses roomjid to distinguish the local participant in the chat. Defines etherpad button in the html instead of dynamically adding it through js. Disables chat icon scaling on new message (keeps the glow).

This commit is contained in:
yanas 2014-02-19 15:32:22 +01:00
parent 26df93e5cd
commit 8f84261169
6 changed files with 23 additions and 32 deletions

1
app.js
View File

@ -182,7 +182,6 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
container = document.createElement('span'); container = document.createElement('span');
container.className = 'videocontainer'; container.className = 'videocontainer';
remotes.appendChild(container); remotes.appendChild(container);
console.log("PLAY USER JOINEDDDDDDDD");
Util.playSoundNotification('userJoined'); Util.playSoundNotification('userJoined');
} }
var vid = document.createElement('video'); var vid = document.createElement('video');

11
chat.js
View File

@ -61,10 +61,10 @@ var Chat = (function (my) {
/** /**
* Appends the given message to the chat conversation. * Appends the given message to the chat conversation.
*/ */
my.updateChatConversation = function (nick, message) { my.updateChatConversation = function (from, displayName, message) {
var divClassName = ''; var divClassName = '';
if (nickname == nick) { if (connection.emuc.myroomjid == from) {
divClassName = "localuser"; divClassName = "localuser";
} }
else { else {
@ -81,7 +81,8 @@ var Chat = (function (my) {
message = processReplacements(message); message = processReplacements(message);
$('#chatconversation').append('<div class="' + divClassName + '"><b>' $('#chatconversation').append('<div class="' + divClassName + '"><b>'
+ nick + ': </b>' + message + '</div>'); + displayName + ': </b>'
+ message + '</div>');
$('#chatconversation').animate( $('#chatconversation').animate(
{ scrollTop: $('#chatconversation')[0].scrollHeight}, 1000); { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
}; };
@ -188,8 +189,8 @@ var Chat = (function (my) {
unreadMsgElement.setAttribute( unreadMsgElement.setAttribute(
'style', 'style',
'top:' + Util.toInteger(topIndent) 'top:' + topIndent
+ '; left:' + Util.toInteger(leftIndent) +';'); + '; left:' + leftIndent +';');
} }
else else
unreadMsgElement.innerHTML = ''; unreadMsgElement.innerHTML = '';

View File

@ -35,6 +35,10 @@ html, body{
z-index: 0; z-index: 0;
} }
#etherpadButton {
display: none;
}
.videocontainer>span { .videocontainer>span {
display: none; /* enable when you want nicks to be shown */ display: none; /* enable when you want nicks to be shown */
position: absolute; position: absolute;
@ -261,7 +265,7 @@ html, body{
-webkit-text-shadow: 0 0 10px #ffffff; -webkit-text-shadow: 0 0 10px #ffffff;
-moz-text-shadow: 0 0 10px #ffffff; -moz-text-shadow: 0 0 10px #ffffff;
text-shadow: 0 0 10px #ffffff; text-shadow: 0 0 10px #ffffff;
-webkit-transform: scale(1.1); /* -webkit-transform: scale(1.1); */
} }
a.button:hover { a.button:hover {

View File

@ -22,9 +22,9 @@ var Etherpad = (function (my) {
else else
etherpadName = name; etherpadName = name;
createEtherpadButton(); enableEtherpadButton();
} }
} };
/** /**
* Opens/hides the Etherpad. * Opens/hides the Etherpad.
@ -77,27 +77,9 @@ var Etherpad = (function (my) {
/** /**
* Creates the Etherpad button and adds it to the toolbar. * Creates the Etherpad button and adds it to the toolbar.
*/ */
function createEtherpadButton() { function enableEtherpadButton() {
//<div class="header_button_separator"></div> if (!$('#etherpadButton').is(":visible"))
//<a class="button" onclick='Etherpad.openEtherpad("teeest");'> $('#etherpadButton').css({display:'inline-block'});
//<i title="Open shared document" class="fa fa-file-text fa-lg"></i></a>
var separator = document.createElement('div');
separator.className = 'header_button_separator';
var button = document.createElement('a');
button.className = 'button';
button.setAttribute('onclick', 'Etherpad.toggleEtherpad(0);');
var buttonImage = document.createElement('i');
buttonImage.setAttribute('title', 'Open shared document');
buttonImage.className = 'fa fa-file-text fa-lg';
button.appendChild(buttonImage);
var toolbar = document.getElementById('toolbar');
toolbar.insertBefore(button,
toolbar.childNodes[toolbar.childNodes.length - 4]);
toolbar.insertBefore(separator, button);
} }
/** /**

View File

@ -43,6 +43,10 @@
</span> </span>
<div class="header_button_separator"></div> <div class="header_button_separator"></div>
<a class="button" onclick='openPreziDialog();'><i title="Share prezi" class="fa fa-picture-o fa-lg"></i></a> <a class="button" onclick='openPreziDialog();'><i title="Share prezi" class="fa fa-picture-o fa-lg"></i></a>
<span id="etherpadButton">
<div class="header_button_separator"></div>
<a class="button" onclick='Etherpad.toggleEtherpad(0);'><i title="Open shared document" class="fa fa-file-text fa-lg"></i></a>
</span>
<div class="header_button_separator"></div> <div class="header_button_separator"></div>
<a class="button" onclick='toggleFullScreen();'><i title="Enter / Exit Full Screen" class="fa fa-arrows-alt fa-lg"></i></a> <a class="button" onclick='toggleFullScreen();'><i title="Enter / Exit Full Screen" class="fa fa-arrows-alt fa-lg"></i></a>
</span> </span>

5
muc.js
View File

@ -139,11 +139,12 @@ Strophe.addConnectionPlugin('emuc', {
var txt = $(msg).find('>body').text(); var txt = $(msg).find('>body').text();
// TODO: <subject/> // TODO: <subject/>
// FIXME: this is a hack. but jingle on muc makes nickchanges hard // FIXME: this is a hack. but jingle on muc makes nickchanges hard
var nick = $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]').text() || Strophe.getResourceFromJid(msg.getAttribute('from')); var from = msg.getAttribute('from');
var nick = $(msg).find('>nick[xmlns="http://jabber.org/protocol/nick"]').text() || Strophe.getResourceFromJid(from);
if (txt) { if (txt) {
console.log('chat', nick, txt); console.log('chat', nick, txt);
Chat.updateChatConversation(nick, txt); Chat.updateChatConversation(from, nick, txt);
} }
return true; return true;
}, },