SRV1 10 лет назад
Родитель
Сommit
78a26077cc

+ 14 - 4
apps/web/priv/static/app/js/chat.js

@@ -52,6 +52,7 @@ function mouseWheelHandler(e) {
 
 
 function chatMessage(chatName, id, me, string) {
+  console.log("chatName "+chatName);
     var i=0;
     var colors=['#FDFDFD','#DFF1F4'];
     var x1 = 10;
@@ -126,7 +127,15 @@ if (!String.prototype.encodeHTML) {
   };
 }
 
+if (!String.prototype.entag) {
+  String.prototype.entag = function () {
+    return (this[0]!="_"?"_":"")+this.replace(/\./g, '-dot-').replace(/@/g, '-at-'); }; }
+
+if (!String.prototype.detag) {
+  String.prototype.detag = function () { return this.substr(1).replace(/-at-/g,'@').replace(/-dot-/g,'.').replace(/tag-/,''); }; }
+
 function addOnlineUser(name,full_name,score,insertMode) {
+    name = name.entag();
     var listElement = document.getElementById("Online-List");
     var clickEvent = ' onclick="openChat(evt);" '; 
     var events = ' onmouseover="onlineHover(evt);" onmouseout="onlineHoverOut(evt);" ' + clickEvent;
@@ -135,7 +144,7 @@ function addOnlineUser(name,full_name,score,insertMode) {
     var y = (insertMode == "insertTop") ? 0 : listElement.getBBox().height;
     var html = '<g xmlns="http://www.w3.org/2000/svg" height="60" transform="translate(0, '+y+')">' +
             '<g xmlns:data="'+name+'" fill="#DBEBED" '+eventsColor+'>' +
-            '    <rect cursor="pointer" xmlns:data="'+name+'" fill="#DBEBED" id="'+name+'" x="10" y="0" width="196" height="48" ' +'>'+utf8decode(full_name)+'</rect></g>' +
+            '    <rect cursor="pointer" xmlns:data="'+name+'" fill="#DBEBED" id="'+name+'" x="10" y="0" width="196" height="48" ' +'>'+full_name+'</rect></g>' +
             '<text xmlns:data="'+name+'" '+eventsColor+' '+
             'font-family="Exo 2" font-size="18" cursor="pointer" font-weight="normal" line-spacing="18"'+
             ' fill="#3B5998">' +
@@ -170,7 +179,7 @@ function shiftTranslate(name,shiftValue) {
     return rect.parentNode.parentNode;
 }
 
-function removeOnlineUser(name) { shiftTranslate(name,-1).remove(); }
+function removeOnlineUser(name) { shiftTranslate(name.entag(),-1).remove(); }
 
 function createChat(chatName) {
     var html = '<g xmlns="http://www.w3.org/2000/svg" id="'+chatName+'" y="0" clip-path="url(#myClip3)" transform="translate(1.000000, 107.000000)"></g>';
@@ -188,10 +197,11 @@ function openChat(evt) {
     var full_name = $("#Online-List").find("#"+name)[0].textContent;
     currentChat = "Chat+"+name;
     var chatElement = document.getElementById(currentChat);
+//    console.log(chatElement);
     if (null == chatElement) {
         // read from local KVS
         createChat(currentChat);
-        chatMessage(currentChat,"1","System",full_name+" "+i18n("PrivateChat"));
+        chatMessage(currentChat,"1","System",utf8decode(full_name)+" "+i18n("PrivateChat"));
     }
     document.getElementById(currentChat).style.display = '';
     document.getElementById("onlineChatEdit").setAttribute("xmlns:data",currentChat);
@@ -315,7 +325,7 @@ function chatEditor(evt) {
                     tuple(atom('message'),
                          bin(document.user),
                          bin(document.names),
-                         bin(chatContainer.substr(5)),
+                         bin(chatContainer.substr(5).detag()),
                          utf8toByteArray(text)))));
             }
             else

+ 1 - 1
apps/web/priv/static/app/js/okey/okey_protocol.js

@@ -79,7 +79,7 @@ function OkeyApiProviderScope(scope) {
         emitEvent: function(raw) {
             var msgName = dec(raw).value[0][0].value;
             if (msgName == "game_event") msgName = dec(raw).value[0][2].value;
-            console.log(String(dec(raw)));
+            //console.log(String(dec(raw)));
             for (var event, i = eventMap.length, obj; i--; ) {
                 event = eventMap[i];
                 if (eventMap[i] == msgName)

+ 3 - 3
apps/web/priv/static/app/js/roster.js

@@ -19,7 +19,7 @@ function RosterHandlers(scope) {
             name    = dec(e.raw).value[0][2].value;
             surname = dec(e.raw).value[0][3].value;
             score   = dec(e.raw).value[0][4];
-        if (null != document.getElementById(id)) removeOnlineUser(id);
+        if (null != document.getElementById(id.entag())) removeOnlineUser(id);
         addOnlineUser(id,name+" "+surname,score,"insertTop");
         if ( name == document.names)
             $("#Quota")[0].lastElementChild.textContent = i18n("Score") + ": " + score;
@@ -32,7 +32,7 @@ function RosterHandlers(scope) {
             name    = dec(e.raw).value[0][2].value;
             surname = dec(e.raw).value[0][3].value;
             score   = dec(e.raw).value[0][4];
-        if (null != document.getElementById(id)) removeOnlineUser(id);
+        if (null != document.getElementById(id.entag())) removeOnlineUser(id);
         addOnlineUser(id,name+" "+surname,score,"appendChild");
     });
 
@@ -59,7 +59,7 @@ function RosterHandlers(scope) {
             names   = dec(e.raw).value[0][1].value[0][1].value,
             to      = dec(e.raw).value[0][2].value,
             message = dec(e.raw).value[0][3].value;
-        chatMessage("Chat+"+from,"1",from==document.user?"Self":from,utf8decode(message));
+        chatMessage("Chat+"+from.entag(),"1",from==document.user?"Self":from,utf8decode(message));
         if (null != currentChat) {
             onlineHover();
             mouseWheelHandler({'detail':-10000,'wheelDelta':-10000});