Selaa lähdekoodia

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).

j8
yanas 11 vuotta sitten
vanhempi
commit
8f84261169
6 muutettua tiedostoa jossa 23 lisäystä ja 32 poistoa
  1. 0
    1
      app.js
  2. 6
    5
      chat.js
  3. 5
    1
      css/main.css
  4. 5
    23
      etherpad.js
  5. 4
    0
      index.html
  6. 3
    2
      muc.js

+ 0
- 1
app.js Näytä tiedosto

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

+ 6
- 5
chat.js Näytä tiedosto

@@ -61,10 +61,10 @@ var Chat = (function (my) {
61 61
     /**
62 62
      * Appends the given message to the chat conversation.
63 63
      */
64
-    my.updateChatConversation = function (nick, message) {
64
+    my.updateChatConversation = function (from, displayName, message) {
65 65
         var divClassName = '';
66 66
 
67
-        if (nickname == nick) {
67
+        if (connection.emuc.myroomjid == from) {
68 68
             divClassName = "localuser";
69 69
         }
70 70
         else {
@@ -81,7 +81,8 @@ var Chat = (function (my) {
81 81
         message = processReplacements(message);
82 82
 
83 83
         $('#chatconversation').append('<div class="' + divClassName + '"><b>'
84
-                                        + nick + ': </b>' + message + '</div>');
84
+                                        + displayName + ': </b>'
85
+                                        + message + '</div>');
85 86
         $('#chatconversation').animate(
86 87
                 { scrollTop: $('#chatconversation')[0].scrollHeight}, 1000);
87 88
     };
@@ -188,8 +189,8 @@ var Chat = (function (my) {
188 189
 
189 190
             unreadMsgElement.setAttribute(
190 191
                     'style',
191
-                    'top:' + Util.toInteger(topIndent)
192
-                     + '; left:' + Util.toInteger(leftIndent) +';');
192
+                    'top:' + topIndent
193
+                     + '; left:' + leftIndent +';');
193 194
         }
194 195
         else
195 196
             unreadMsgElement.innerHTML = '';

+ 5
- 1
css/main.css Näytä tiedosto

@@ -35,6 +35,10 @@ html, body{
35 35
     z-index: 0;
36 36
 }
37 37
 
38
+#etherpadButton {
39
+    display: none;
40
+}
41
+
38 42
 .videocontainer>span {
39 43
     display: none; /* enable when you want nicks to be shown */
40 44
     position: absolute;
@@ -261,7 +265,7 @@ html, body{
261 265
     -webkit-text-shadow: 0 0 10px #ffffff;
262 266
     -moz-text-shadow: 0 0 10px #ffffff;
263 267
     text-shadow: 0 0 10px #ffffff;
264
-    -webkit-transform: scale(1.1);
268
+    /* -webkit-transform: scale(1.1); */
265 269
 }
266 270
 
267 271
 a.button:hover {

+ 5
- 23
etherpad.js Näytä tiedosto

@@ -22,9 +22,9 @@ var Etherpad = (function (my) {
22 22
             else
23 23
                 etherpadName = name;
24 24
 
25
-            createEtherpadButton();
25
+            enableEtherpadButton();
26 26
         }
27
-    }
27
+    };
28 28
 
29 29
     /**
30 30
      * Opens/hides the Etherpad.
@@ -77,27 +77,9 @@ var Etherpad = (function (my) {
77 77
     /**
78 78
      * Creates the Etherpad button and adds it to the toolbar.
79 79
      */
80
-    function createEtherpadButton() {
81
-        //<div class="header_button_separator"></div>
82
-        //<a class="button" onclick='Etherpad.openEtherpad("teeest");'>
83
-        //<i title="Open shared document" class="fa fa-file-text fa-lg"></i></a>
84
-        var separator = document.createElement('div');
85
-        separator.className = 'header_button_separator';
86
-
87
-        var button = document.createElement('a');
88
-        button.className = 'button';
89
-        button.setAttribute('onclick', 'Etherpad.toggleEtherpad(0);');
90
-        
91
-        var buttonImage = document.createElement('i');
92
-        buttonImage.setAttribute('title', 'Open shared document');
93
-        buttonImage.className = 'fa fa-file-text fa-lg';
94
-
95
-        button.appendChild(buttonImage);
96
-
97
-        var toolbar = document.getElementById('toolbar');
98
-        toolbar.insertBefore(button,
99
-                toolbar.childNodes[toolbar.childNodes.length - 4]);
100
-        toolbar.insertBefore(separator, button);
80
+    function enableEtherpadButton() {
81
+        if (!$('#etherpadButton').is(":visible"))
82
+            $('#etherpadButton').css({display:'inline-block'});
101 83
     }
102 84
 
103 85
     /**

+ 4
- 0
index.html Näytä tiedosto

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

+ 3
- 2
muc.js Näytä tiedosto

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

Loading…
Peruuta
Tallenna