Advertisement
Guest User

Untitled

a guest
Dec 1st, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Object.extend(RegExp, {
  2.     escape: function(text) {
  3.         if (!arguments.callee.sRE) {
  4.             var specials = ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^'];
  5.             arguments.callee.sRE = new RegExp('(\\' + specials.join('|\\') + ')', 'g');
  6.         }
  7.         return text.replace(arguments.callee.sRE, '\\$1');
  8.     }
  9. });
  10. Object.extend(String, {
  11.     reverse: function(text) {
  12.         return text.split('').reverse().join('');
  13.     }
  14. });
  15. var _chat = window.IPBoard;
  16. _chat.prototype.chat = {
  17.     polling: 3,
  18.     lastpolled: 0,
  19.     lastMsgId: 0,
  20.     lastTime: '',
  21.     condenseTime: 0,
  22.     maxMessages: 0,
  23.     moderator: 0,
  24.     private: 0,
  25.     kicked: false,
  26.     chattingUpdate: 60,
  27.     bypassFlag: false,
  28.     templates: [],
  29.     emoticons: {},
  30.     soundEnabled: 0,
  31.     soundReady: false,
  32.     soundOnImg: '',
  33.     soundOffImg: '',
  34.     nameFormatting: $H(),
  35.     groups: $H(),
  36.     windowHasFocus: true,
  37.     activeTab: 'chatroom',
  38.     forumIdMap: $H(),
  39.     ignoreChats: $H(),
  40.     privateChats: $H(),
  41.     typedChats: $H(),
  42.     unreadTabs: $H(),
  43.     unreadCount: 0,
  44.     badwords: $H(),
  45.     noBuffer: 0,
  46.     hideEnterExit: 0,
  47.     inactiveKick: 0,
  48.     lastAction: 0,
  49.     lastUser: $H(),
  50.     init: function() {
  51.         Debug.write("Initializing ips.chat.js");
  52.         document.observe("dom:loaded", function() {
  53.             if (!ipb.vars['board_url'] && ipb.vars['base_url']) {
  54.                 ipb.vars['board_url'] = ipb.vars['base_url'].replace(/index\.php\?.*?$/, "");
  55.                 Debug.write("Set board_url to " + ipb.vars['board_url']);
  56.             }
  57.             ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  58.             ipb.chat.drawIframes();
  59.             Event.observe(window, 'message', function(e) {
  60.                 ipb.chat.handleMessageFromChild(e.data);
  61.             });
  62.             new PeriodicalExecuter(ipb.chat.getMessages, ipb.chat.polling);
  63.             $('chat-submit').observe('click', ipb.chat.sendChat);
  64.             Event.observe('message_textarea', 'keypress', ipb.chat.checkForSendChat);
  65.             ipb.chat.ping();
  66.             new PeriodicalExecuter(ipb.chat.ping, ipb.chat.chattingUpdate);
  67.             if ($('sound_toggle')) {
  68.                 $('sound_toggle').observe('click', function(e) {
  69.                     if (ipb.chat.soundEnabled) {
  70.                         ipb.chat.soundEnabled = 0;
  71.                         ipb.Cookie.set('chat_sounds', 'off');
  72.                         Debug.write("Chat sounds disabled");
  73.                         $('sound_toggle_img').writeAttribute('src', ipb.chat.soundOffImg);
  74.                     } else {
  75.                         ipb.chat.soundEnabled = 1;
  76.                         ipb.Cookie.set('chat_sounds', 'on');
  77.                         Debug.write("Chat sounds enabled");
  78.                         $('sound_toggle_img').writeAttribute('src', ipb.chat.soundOnImg);
  79.                     }
  80.                     Event.stop(e);
  81.                     return false;
  82.                 });
  83.             }
  84.             $('leave_room').observe('click', function(e) {
  85.                 ipb.chat.templates['msg-K'] = new Template("");
  86.             });
  87.             ipb.chat.initKickLinks();
  88.             soundManager.onready(function(oStatus) {
  89.                 if (oStatus.success) {
  90.                     ipb.chat.soundReady = true;
  91.                     if (isRTL) {
  92.                         $('sm2-container').setStyle({
  93.                             left: '0px',
  94.                             right: '-9999px'
  95.                         });
  96.                     }
  97.                 }
  98.             });
  99.             if (Prototype.Browser.IE) {
  100.                 document.onfocusin = function() {
  101.                     ipb.chat.cleanTitle();
  102.                     ipb.chat.windowHasFocus = true;
  103.                 };
  104.                 document.onfocusout = function() {
  105.                     ipb.chat.unreadCount = 0;
  106.                     ipb.chat.windowHasFocus = false;
  107.                 };
  108.             } else {
  109.                 Event.observe(window, 'focus', function() {
  110.                     Debug.write('has focus');
  111.                     ipb.chat.cleanTitle();
  112.                     ipb.chat.windowHasFocus = true;
  113.                 });
  114.                 Event.observe(window, 'blur', function() {
  115.                     ipb.chat.unreadCount = 0;
  116.                     ipb.chat.windowHasFocus = false;
  117.                 });
  118.             }
  119.             $$('#chat-tab-holder a').each(function(elem) {
  120.                 id = elem.identify();
  121.                 if ($(id)) {
  122.                     $(id).observe("click", ipb.chat.switchTab);
  123.                 }
  124.             });
  125.             $$('.chatmodmenu').each(function(menu) {
  126.                 id = menu.identify();
  127.                 if ($(id + "_menucontent")) {
  128.                     new ipb.Menu(menu, $(id + "_menucontent"), {}, {
  129.                         afterOpen: ipb.chat.repositionModMenu
  130.                     });
  131.                 }
  132.             });
  133.             if ($('chat_new_window')) {
  134.                 $('chat_new_window').observe('click', ipb.chat.openInNewWindow);
  135.             }
  136.             if ($('emoticons_custom_menu_menucontent')) {
  137.                 $('emoticons_custom_menu_menucontent').on('click', 'a, img', ipb.chat.emoticonClick);
  138.             }
  139.             if (isMobile) {
  140.                 if ((navigator.userAgent.match(/iPhone OS 2/i)) || (navigator.userAgent.match(/iPhone OS 3/i)) || (navigator.userAgent.match(/iPhone OS 4/i))) {
  141.                     Event.observe(window, 'scroll', function() {
  142.                         $('chat-form').setStyle({
  143.                             top: (window.pageYOffset + window.innerHeight - 34) + 'px'
  144.                         });
  145.                     });
  146.                 }
  147.             }
  148.         });
  149.     },
  150.     emoticonClick: function(e) {
  151.         $('emoticons_custom_menu_menucontent').hide();
  152.         return true;
  153.     },
  154.     openInNewWindow: function(e) {
  155.         var _url = document.location.toString();
  156.         if (_url.charAt(_url.length - 1) == '#') {
  157.             _url = _url.substr(0, _url.length - 1);
  158.         }
  159.         if (_url.indexOf('?') != '-1') {
  160.             _url += '&_popup=1';
  161.         } else {
  162.             _url += '?_popup=1';
  163.         }
  164.         window.open(_url, "chatpopout", "status=0,toolbar=0,location=1,menubar=0,directories=0,resizable=1,scrollbars=1,height=550,width=750");
  165.         Event.stop(e);
  166.         window.location = ipb.vars['board_url'];
  167.         return false;
  168.     },
  169.     switchTab: function(e) {
  170.         Event.stop(e);
  171.         elem = Event.findElement(e);
  172.         id = elem.identify();
  173.         if (id.match(/close\-chat\-tab\-(.+?)/g)) {
  174.             ipb.chat.closePrivateTab(id);
  175.             return false;
  176.         }
  177.         rel = $(id).rel;
  178.         if (rel == ipb.chat.activeTab) {
  179.             Debug.write("Clicked on active tab");
  180.             return false;
  181.         }
  182.         ipb.chat.switchToTab(rel);
  183.         return false;
  184.     },
  185.     switchToTab: function(rel) {
  186.         if ($('storage_' + rel)) {
  187.             if ($F('message_textarea').strip()) {
  188.                 ipb.chat.typedChats.set(ipb.chat.activeTab, $F('message_textarea'));
  189.                 $('message_textarea').clear();
  190.             }
  191.             $('storage_container_' + ipb.chat.activeTab).update($('messages-display').innerHTML);
  192.             $('messages-display').update($('storage_container_' + rel).innerHTML).addClassName('messages-list');
  193.             $('storage_container_' + rel).update();
  194.             $('tab-' + ipb.chat.activeTab).removeClassName('active');
  195.             $('tab-' + rel).addClassName('active');
  196.             ipb.chat.activeTab = rel;
  197.             ipb.chat.updateTabUnreadCount();
  198.             $('messages-display').scrollTop = $('messages-display').scrollHeight + 500;
  199.             if (ipb.chat.typedChats.get(ipb.chat.activeTab)) {
  200.                 $('message_textarea').value = ipb.chat.typedChats.get(ipb.chat.activeTab);
  201.                 ipb.chat.typedChats.unset(ipb.chat.activeTab);
  202.             }
  203.             if (!isMobile) {
  204.                 $('message_textarea').focus();
  205.             }
  206.             ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  207.         }
  208.     },
  209.     buildTab: function(id) {
  210.         if (!ipb.chat.nameFormatting.get(id)) {
  211.             return false;
  212.         }
  213.         if ($("tab-" + id)) {
  214.             if (!$("storage_" + id)) {
  215.                 var newOuter = new Element('div', {
  216.                     id: "storage_container_" + id
  217.                 }).addClassName('storage-container');
  218.                 var newStorage = new Element('ul', {
  219.                     id: "storage_" + id
  220.                 });
  221.                 $('iframeContainer').insert(newOuter.insert(newStorage));
  222.                 ipb.chat.typedChats.unset(id);
  223.             }
  224.             return true;
  225.         }
  226.         var name = ipb.chat.nameFormatting.get(id)[2].stripTags();
  227.         var _existed = false;
  228.         $('chat-tab-holder').childElements().each(function(elem) {
  229.             var _thisId = $(elem).readAttribute('id').replace(/tab-/, '');
  230.             var _name = $(elem).innerHTML.stripTags().strip().replace(/ /g, '');
  231.             if (name == _name) {
  232.                 $(elem).writeAttribute('id', 'tab-' + id);
  233.                 $("storage_container_" + _thisId).writeAttribute('id', "storage_container_" + id);
  234.                 $("storage_" + _thisId).writeAttribute('id', "storage_" + id);
  235.                 if (ipb.chat.activeTab == _thisId) {
  236.                     ipb.chat.activeTab = id;
  237.                 }
  238.                 _existed = true;
  239.             }
  240.         });
  241.         if (!_existed) {
  242.             var newTab = new Element('li', {
  243.                 id: "tab-" + id
  244.             });
  245.             newTab.update(ipb.chat.templates['new-tab'].evaluate({
  246.                 id: id,
  247.                 name: name
  248.             }));
  249.             $('chat-tab-holder').insert({
  250.                 bottom: newTab
  251.             });
  252.             $('chat-room-list').style.display = '';
  253.         }
  254.         $$('#chat-tab-holder a').each(function(elem) {
  255.             elem.stopObserving();
  256.             _id = elem.identify();
  257.             if ($(_id)) {
  258.                 $(_id).observe("click", ipb.chat.switchTab);
  259.             }
  260.         });
  261.         if (!$("storage_" + id)) {
  262.             var newOuter = new Element('div', {
  263.                 id: "storage_container_" + id
  264.             }).addClassName('storage-container');
  265.             var newStorage = new Element('ul', {
  266.                 id: "storage_" + id
  267.             });
  268.             $('iframeContainer').insert(newOuter.insert(newStorage));
  269.         }
  270.         return true;
  271.     },
  272.     closePrivateTab: function(id) {
  273.         _rel = id.replace(/close-chat-tab-/, '');
  274.         if (!_rel) {
  275.             return false;
  276.         }
  277.         if (_rel == ipb.chat.activeTab) {
  278.             ipb.chat.switchToTab('chatroom');
  279.         }
  280.         if ($("storage_container_" + _rel)) {
  281.             $("storage_container_" + _rel).remove();
  282.         }
  283.         $("tab-" + _rel).remove();
  284.         ipb.chat.typedChats.unset(_rel);
  285.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  286.         return false;
  287.     },
  288.     sendPrivateChat: function(id) {
  289.         var message = $F("priv_chat_text_" + id).strip();
  290.         if (message == '') {
  291.             return false;
  292.         }
  293.         ipb.chat.privateChats.get('privchatwindow_' + id).hide();
  294.         $("priv_chat_text_" + id).clear();
  295.         if ($('storage_' + id)) {
  296.             ipb.chat.switchToTab(id);
  297.             $('storage_container_' + ipb.chat.activeTab).update($('messages-display').innerHTML);
  298.             $('messages-display').update($('storage_container_' + id).innerHTML).addClassName('messages-list');
  299.             $('storage_container_' + id).update();
  300.             $('tab-' + ipb.chat.activeTab).removeClassName('active');
  301.             $('tab-' + id).addClassName('active');
  302.             ipb.chat.activeTab = id;
  303.         } else {
  304.             $('storage_container_' + ipb.chat.activeTab).update($('messages-display').innerHTML);
  305.             ipb.chat.buildTab(id);
  306.             ipb.chat.switchToTab(id);
  307.         }
  308.         message = ipb.chat.cleanMessage(message);
  309.         if (ipb.chat.sendMessageToChild("server=" + serverHost + "&path=" + serverPath + "&room=" + roomId + "&user=" + userId + "&access_key=" + accessKey + "&lmsg=" + ipb.chat.lastMsgId + "&action=private&message=" + message + '&toUser=' + id + '&charset=' + ipb.vars['charset'])) {
  310.             $('messages-display').scrollTop = $('messages-display').scrollHeight + 500;
  311.             message = message.escapeHTML();
  312.             ipb.chat.bypassFlag = true;
  313.             ipb.chat.updateMessages("1,0~~||~~" + Math.round(new Date().getTime() / 1000) + ",1," + userName.replace(',', '~~#~~') + "," + message + ",private=" + id + "," + userId + "~~||~~");
  314.             ipb.chat.bypassFlag = false;
  315.         }
  316.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  317.         Debug.write("Sending private chat to " + name);
  318.         return false;
  319.     },
  320.     drawIframes: function() {
  321.         if (window.postMessage) {
  322.             var iframe = new Element('iframe', {
  323.                 'id': 'chatProxy'
  324.             });
  325.             iframe.writeAttribute('src', 'http://' + serverHost + serverPath + 'web/postMessage.php?parent=' + ourUrl);
  326.             iframe.setStyle('position', 'absolute');
  327.             iframe.setStyle('left', '-150px');
  328.             iframe.setStyle('top', '0px');
  329.             iframe.setStyle('display', 'none');
  330.             $('iframeContainer').insert(iframe);
  331.         } else {
  332.             var iframe = new Element('iframe', {
  333.                 'id': 'chatProxy'
  334.             });
  335.             iframe.writeAttribute('src', 'http://' + serverHost + serverPath + 'web/iframeProxy.php?parent=' + ourUrl);
  336.             iframe.setStyle('position', 'absolute');
  337.             iframe.setStyle('left', '-150px');
  338.             iframe.setStyle('top', '0px');
  339.             iframe.setStyle('display', 'none');
  340.             $('iframeContainer').insert(iframe);
  341.         }
  342.     },
  343.     cleanTitle: function() {
  344.         if (document.title.match(/\(\d+\) (.+?)/gi)) {
  345.             setTimeout(function() {
  346.                 document.title = document.title.replace(/\(\d+\) (.+?)/gi, "$1")
  347.             }, 200);
  348.         }
  349.         ipb.chat.unreadCount = 0;
  350.     },
  351.     triggerMessageSound: function() {
  352.         if (ipb.chat.soundEnabled && ipb.chat.soundReady && !ipb.chat.bypassFlag) {
  353.             soundManager.play('message', ipb.vars['board_url'] + '/public/sounds/message.mp3');
  354.         }
  355.     },
  356.     triggerEnterSound: function() {
  357.         if (ipb.chat.soundEnabled && ipb.chat.soundReady) {
  358.             soundManager.play('enter', ipb.vars['board_url'] + '/public/sounds/enter.mp3');
  359.         }
  360.     },
  361.     triggerLeaveSound: function() {
  362.         if (ipb.chat.soundEnabled && ipb.chat.soundReady) {
  363.             soundManager.play('leave', ipb.vars['board_url'] + '/public/sounds/leave.mp3');
  364.         }
  365.     },
  366.     checkForSendPrivateChat: function(e) {
  367.         if (e.keyCode == Event.KEY_RETURN) {
  368.             Event.stop(e);
  369.             elem = Event.findElement(e);
  370.             id = elem.identify();
  371.             _id = id.replace(/priv_chat_text_/, '');
  372.             ipb.chat.sendPrivateChat(_id);
  373.             return false;
  374.         }
  375.         return true;
  376.     },
  377.     checkForSendChat: function(e) {
  378.         if (e.keyCode == Event.KEY_RETURN) {
  379.             ipb.chat.sendChat(e);
  380.         }
  381.     },
  382.     sendChat: function(e) {
  383.         Event.stop(e);
  384.         var chatPost = $F('message_textarea').strip();
  385.         if (chatPost == '') {
  386.             return false;
  387.         }
  388.         chatPost = ipb.chat.cleanMessage(chatPost);
  389.         if (ipb.chat.activeTab != 'chatroom') {
  390.             var _thisMessage = "&action=private&toUser=" + ipb.chat.activeTab;
  391.             var _thisExtra = "private=" + ipb.chat.activeTab;
  392.         } else {
  393.             var _thisMessage = "&action=post";
  394.             var _thisExtra = '0';
  395.         }
  396.         if (ipb.chat.sendMessageToChild("server=" + serverHost + "&path=" + serverPath + "&room=" + roomId + "&user=" + userId + "&access_key=" + accessKey + "&lmsg=" + ipb.chat.lastMsgId + _thisMessage + "&message=" + chatPost + '&charset=' + ipb.vars['charset'])) {
  397.             $('messages-display').scrollTop = $('messages-display').scrollHeight + 500;
  398.             chatPost = chatPost.escapeHTML();
  399.             ipb.chat.bypassFlag = true;
  400.             ipb.chat.updateMessages("1,0~~||~~" + Math.round(new Date().getTime() / 1000) + ",1," + userName.replace(',', '~~#~~') + "," + chatPost + "," + _thisExtra + "," + userId + "~~||~~");
  401.             ipb.chat.bypassFlag = false;
  402.         }
  403.         $('message_textarea').clear();
  404.         $('messages-display').scrollTop = $('messages-display').scrollHeight + 500;
  405.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  406.         return false;
  407.     },
  408.     sendMessageToChild: function(message) {
  409.         if (ipb.chat.kicked) {
  410.             return false;
  411.         }
  412.         var elem = $('chatProxy').contentWindow;
  413.         if (window.postMessage) {
  414.             Debug.write("Using window.postMessage method");
  415.             elem.postMessage(message, 'http://' + serverHost);
  416.         } else {
  417.             Debug.write("Using iframe hash method");
  418.             elem.location = 'http://' + serverHost + serverPath + '/web/iframeProxy.php?parent=' + ourUrl + '#' + message + '&timestamp=' + Math.round(new Date().getTime() / 1000);
  419.         }
  420.         return true;
  421.     },
  422.     handleMessageFromChild: function(message) {
  423.         if (ipb.chat.kicked) {
  424.             return false;
  425.         }
  426.         if (message.substr(0, 7) == 'height=') {
  427.             return false;
  428.         }
  429.         if (message.length > 0) {
  430.             if (message.substr(0, 8) == '__post__' || message.substr(0, 12) == '__moderate__') {
  431.                 ipb.chat.getMessages();
  432.             } else {
  433.                 ipb.chat.updateMessages(message);
  434.             }
  435.         }
  436.     },
  437.     getMessages: function(pe) {
  438.         curtime = parseInt(new Date().getTime().toString().substring(0, 10));
  439.         ipb.chat.checkInactivity(curtime);
  440.         if (ipb.chat.kicked) {
  441.             pe.stop();
  442.             return false;
  443.         }
  444.         if (curtime - ipb.chat.lastpolled < ipb.chat.polling) {
  445.             return false;
  446.         }
  447.         ipb.chat.lastpolled = curtime;
  448.         ipb.chat.sendMessageToChild("server=" + serverHost + "&path=" + serverPath + "&room=" + roomId + "&user=" + userId + "&access_key=" + accessKey + "&msg=" + ipb.chat.lastMsgId + "&charset=" + ipb.vars['charset']);
  449.     },
  450.     updateMessages: function(text) {
  451.         if (!text) {
  452.             return true;
  453.         }
  454.         if (text.substr(0, 2) != '0,' && text.substr(0, 2) != '1,') {
  455.             return true;
  456.         }
  457.         var messages = text.split("~~||~~");
  458.         var scrollBottom = false;
  459.         try {
  460.             var _borderTop = getComputedStyle($('messages-display'), '').getPropertyValue('border-top-width').replace('px', '');
  461.             var _borderBottom = getComputedStyle($('messages-display'), '').getPropertyValue('border-bottom-width').replace('px', '');
  462.             var _padTop = getComputedStyle($('messages-display'), '').getPropertyValue('padding-top').replace('px', '');
  463.             var _padBottom = getComputedStyle($('messages-display'), '').getPropertyValue('padding-bottom').replace('px', '');
  464.         } catch (e) {
  465.             var _borderTop = $('messages-display').currentStyle.borderWidth.replace('px', '');
  466.             var _borderBottom = $('messages-display').currentStyle.borderWidth.replace('px', '');
  467.             var _padTop = $('messages-display').currentStyle.paddingTop.replace('px', '');
  468.             var _padBottom = $('messages-display').currentStyle.paddingBottom.replace('px', '');
  469.         }
  470.         if (isNaN(_borderBottom) || isNaN(_borderTop)) {
  471.             _borderBottom = convertToPixels(_borderBottom, '');
  472.             _borderTop = convertToPixels(_borderTop, '');
  473.         }
  474.         var _totalOffset = parseInt(_borderTop) + parseInt(_borderBottom) + parseInt(_padTop) + parseInt(_padBottom);
  475.         if (($('messages-display').getHeight() - _totalOffset + $('messages-display').scrollTop) >= ($('messages-display').scrollHeight - 10)) {
  476.             scrollBottom = true;
  477.         }
  478.         var _updatedCount = 0;
  479.         var _showOwn = false;
  480.         var _initialEmpty = false;
  481.         var _startLMI = ipb.chat.lastMsgId;
  482.         for (var i = 0; i < messages.length; i++) {
  483.             messages[i] = messages[i].replace(/%20/gi, ' ');
  484.             messages[i] = messages[i].replace(/%23/gi, '#');
  485.             messages[i] = messages[i].replace(/%22/gi, '&quot;');
  486.             messages[i] = messages[i].replace(/%3C/gi, '&lt;');
  487.             messages[i] = messages[i].replace(/%3E/gi, '&gt;');
  488.             messages[i] = messages[i].replace(/\</gi, '&lt;');
  489.             messages[i] = messages[i].replace(/\>/gi, '&gt;');
  490.             messages[i] = ipb.chat.manualDecode(messages[i]);
  491.             var msgDetails = messages[i].split(',');
  492.             if (i == 0) {
  493.                 if (msgDetails[0] != 1) {
  494.                     $$('.storage-container').each(function(elem) {
  495.                         var _id = $(elem).id.replace(/storage_container_/, '');
  496.                         var ulList = ipb.chat.getStorageContainer(_id);
  497.                         ulList.insert({
  498.                             bottom: ipb.chat.templates['msg-K'].evaluate()
  499.                         });
  500.                         if (_id != ipb.chat.activeTab) {
  501.                             $("storage_container_" + _id).update(ulList);
  502.                         } else {
  503.                             $('messages-display').update(ulList).addClassName('messages-list');
  504.                         }
  505.                     });
  506.                     if (!ipb.vars['member_id']) {}
  507.                     ipb.chat.kicked = true;
  508.                     $('messages-display').scrollTop = $('messages-display').scrollHeight + 500;
  509.                     return true;
  510.                 } else {
  511.                     if (!ipb.chat.bypassFlag && msgDetails[1] == ipb.chat.lastMsgId) {
  512.                         if (ipb.chat.lastMsgId == 0) {
  513.                             ipb.chat.bypassFlag = true;
  514.                             ipb.chat.lastMsgId = 1;
  515.                             _initialEmpty = true;
  516.                             msgDetails[1] = 2;
  517.                             msgDetails[2] = userName;
  518.                             msgDetails[3] = '';
  519.                             msgDetails[4] = '1_' + userId;
  520.                             msgDetails[5] = userId;
  521.                         } else {
  522.                             return true;
  523.                         }
  524.                     }
  525.                     if (!ipb.chat.bypassFlag) {
  526.                         if (ipb.chat.lastMsgId == 0) {
  527.                             _showOwn = true;
  528.                         }
  529.                         ipb.chat.lastMsgId = msgDetails[1];
  530.                     }
  531.                     if (!_initialEmpty) {
  532.                         continue;
  533.                     }
  534.                 }
  535.             }
  536.             if (!_startLMI && ipb.chat.noBuffer) {
  537.                 continue;
  538.             }
  539.             if (msgDetails[1]) {
  540.                 if (!ipb.chat.bypassFlag && msgDetails[5] == userId && (msgDetails[1] == 1 || msgDetails[1] == 3) && !_showOwn) {
  541.                     continue;
  542.                 }
  543.                 var _thisRowId = 'chatroom';
  544.                 if (msgDetails[1] == 1) {
  545.                     if (msgDetails[4]) {
  546.                         var userDetails = msgDetails[4].split('=');
  547.                         if (userDetails[1]) {
  548.                             var _user = msgDetails[5] == userId ? userDetails[1] : msgDetails[5];
  549.                             if (!$('storage_' + _user)) {
  550.                                 var _forumUser = ipb.chat.forumIdMap.get(_user);
  551.                                 if (!_forumUser) {
  552.                                     continue;
  553.                                 }
  554.                                 var _blocked = 0;
  555.                                 if (_forumUser[0]) {
  556.                                     _blocked = ipb.chat.ignoreChats.get(_forumUser[0]);
  557.                                 } else {
  558.                                     _blocked = ipb.chat.ignoreChats.get('g_' + _user);
  559.                                 }
  560.                                 if (_blocked) {
  561.                                     continue;
  562.                                 }
  563.                                 if (!ipb.chat.buildTab(_user)) {
  564.                                     continue;
  565.                                 }
  566.                                 ipb.chat.switchToTab(_user);
  567.                             }
  568.                             _thisRowId = _user;
  569.                         }
  570.                     }
  571.                 }
  572.                 var ulList = ipb.chat.getStorageContainer(_thisRowId);
  573.                 var alsoTo = null;
  574.                 var _itemDate = new Date();
  575.                 var _secs = parseInt(msgDetails[0]) ? parseInt(msgDetails[0]) : parseInt(new Date().getTime());
  576.                 _itemDate.setTime(_secs * 1000);
  577.                 var _hours = _itemDate.getHours();
  578.                 var _mins = _itemDate.getMinutes() + "";
  579.                 if (_mins.length == 1) {
  580.                     _mins = "0" + _mins;
  581.                 }
  582.                 if (ipb.chat.condenseTime) {
  583.                     var _minsLastChar = _mins.charAt(_mins.length - 1);
  584.                     if (_minsLastChar == 1 || _minsLastChar == 2 || _minsLastChar == 3 || _minsLastChar == 4) {
  585.                         _mins = _mins.charAt(0) + "" + 0;
  586.                     } else if (_minsLastChar == 6 || _minsLastChar == 7 || _minsLastChar == 8 || _minsLastChar == 9) {
  587.                         _mins = _mins.charAt(0) + "" + 5;
  588.                     }
  589.                 }
  590.                 if (ipb.chat.user24hour) {
  591.                     _itemDate = _hours + ':' + _mins;
  592.                 } else {
  593.                     if (_hours > 12) {
  594.                         _itemDate = (_hours - 12) + ':' + _mins + ' ' + ipb.lang['time_pm'];
  595.                     } else if (_hours == 0) {
  596.                         _itemDate = 12 + ':' + _mins + ' ' + ipb.lang['time_am'];
  597.                     } else if (_hours == 12) {
  598.                         _itemDate = _hours + ':' + _mins + ' ' + ipb.lang['time_pm'];
  599.                     } else {
  600.                         _itemDate = _hours + ':' + _mins + ' ' + ipb.lang['time_am'];
  601.                     }
  602.                 }
  603.                 if (_itemDate != ipb.chat.lastTime && !ipb.chat.bypassFlag) {
  604.                     var dateItem = new Element('li');
  605.                     dateItem.update("<div>" + _itemDate + "</div>").addClassName('chat-time');
  606.                     ulList.insert({
  607.                         bottom: dateItem
  608.                     });
  609.                     ipb.chat.lastUser.set(_thisRowId, 0);
  610.                 }
  611.                 var listItemVal = '';
  612.                 msgDetails[2] = msgDetails[2].replace('~~#~~', ",");
  613.                 msgDetails[2] = ipb.chat.unCleanMessage(msgDetails[2]);
  614.                 msgDetails[4] = msgDetails[4].replace('~~#~~', ",");
  615.                 msgDetails[3] = msgDetails[3].replace('~~#~~', ",");
  616.                 msgDetails[3] = ipb.chat.unCleanMessage(msgDetails[3]);
  617.                 msgDetails[3] = ipb.chat.parseEmoticonsAndBbcode(msgDetails[3], msgDetails[5]);
  618.                 if (msgDetails[1] == 1) {
  619.                     if (msgDetails[3].match(/^\/me /gi)) {
  620.                         msgDetails[1] = 3;
  621.                         msgDetails[3] = msgDetails[3].replace(/^\/me /gi, '');
  622.                     }
  623.                 }
  624.                 if (msgDetails[1] == 1) {
  625.                     msgDetails[2] = ipb.chat.formatName(msgDetails[5], msgDetails[2]);
  626.                     var _ownClass = '';
  627.                     if (msgDetails[5] == userId) {
  628.                         _ownClass = 'chat-myown';
  629.                     }
  630.                     if (msgDetails[5] == ipb.chat.lastUser.get(_thisRowId)) {
  631.                         listItemVal = ipb.chat.templates['msg-1-compound'].evaluate({
  632.                             date: _itemDate,
  633.                             username: msgDetails[2],
  634.                             photo: ipb.chat.nameFormatting.get(msgDetails[5]) ? ipb.chat.nameFormatting.get(msgDetails[5])[3] : '',
  635.                             message: msgDetails[3],
  636.                             ownclass: _ownClass
  637.                         });
  638.                     } else {
  639.                         listItemVal = ipb.chat.templates['msg-1'].evaluate({
  640.                             date: _itemDate,
  641.                             username: msgDetails[2],
  642.                             photo: ipb.chat.nameFormatting.get(msgDetails[5]) ? ipb.chat.nameFormatting.get(msgDetails[5])[3] : '',
  643.                             message: msgDetails[3],
  644.                             ownclass: _ownClass
  645.                         });
  646.                     }
  647.                     _updatedCount++;
  648.                     ipb.chat.unreadCount++;
  649.                     if (_thisRowId != ipb.chat.activeTab) {
  650.                         if (ipb.chat.unreadTabs.get(_thisRowId)) {
  651.                             ipb.chat.unreadTabs.set(_thisRowId, ipb.chat.unreadTabs.get(_thisRowId) + 1);
  652.                         } else {
  653.                             ipb.chat.unreadTabs.set(_thisRowId, 1);
  654.                         }
  655.                     }
  656.                     ipb.chat.lastUser.set(_thisRowId, msgDetails[5]);
  657.                 } else if (msgDetails[1] == 2) {
  658.                     var details = msgDetails[4].split('_');
  659.                     if (details[0] == 1) {
  660.                         var _action = ipb.lang['entered_room'];
  661.                         if (_startLMI > 0) {
  662.                             ipb.chat.addUserToList(details[1], msgDetails[2], details[2]);
  663.                         }
  664.                         var _details = ipb.chat.groups.get(details[3]);
  665.                         if (_details) {
  666.                             msgDetails[2] = _details[0].replace(/__DBQ__/g, '"') + msgDetails[2] + _details[1].replace(/__DBQ__/g, '"');
  667.                         }
  668.                         $('chat-tab-holder').childElements().each(function(elem) {
  669.                             var _thisId = $(elem).readAttribute('id').replace(/tab-/, '');
  670.                             var _name = $(elem).innerHTML.stripTags().strip().replace(/&nbsp;/g, '');
  671.                             if (msgDetails[2] == _name) {
  672.                                 $(elem).writeAttribute('id', 'tab-' + details[1]);
  673.                                 $("storage_container_" + _thisId).writeAttribute('id', "storage_container_" + details[1]);
  674.                                 $("storage_" + _thisId).writeAttribute('id', "storage_" + details[1]);
  675.                                 if (ipb.chat.activeTab == _thisId) {
  676.                                     ipb.chat.activeTab = details[1];
  677.                                 }
  678.                                 alsoTo = details[1];
  679.                             }
  680.                         });
  681.                     } else if (details[0] == 2) {
  682.                         var _action = ipb.lang['left_room'];
  683.                         if (_startLMI > 0) {
  684.                             ipb.chat.removeUserFromList(details[1], msgDetails[2]);
  685.                         }
  686.                         msgDetails[2] = ipb.chat.formatName(details[1], msgDetails[2]);
  687.                         if ($('storage_container_' + details[1])) {
  688.                             alsoTo = details[1];
  689.                         }
  690.                     }
  691.                     if (!ipb.chat.bypassFlag && ipb.chat.hideEnterExit) {
  692.                         continue;
  693.                     }
  694.                     var _photo = ipb.chat.nameFormatting.get(details[1]) ? ipb.chat.nameFormatting.get(details[1])[3] : '<!--uid' + details[1] + '-->';
  695.                     listItemVal = ipb.chat.templates['msg-2'].evaluate({
  696.                         date: _itemDate,
  697.                         username: msgDetails[2],
  698.                         photo: _photo,
  699.                         action: _action
  700.                     });
  701.                     ipb.chat.lastUser.set(_thisRowId, 0);
  702.                 } else if (msgDetails[1] == 3) {
  703.                     msgDetails[2] = ipb.chat.formatName(msgDetails[5], msgDetails[2]);
  704.                     listItemVal = ipb.chat.templates['msg-3'].evaluate({
  705.                         username: msgDetails[2],
  706.                         photo: ipb.chat.nameFormatting.get(msgDetails[5])[3],
  707.                         message: msgDetails[3]
  708.                     });
  709.                     _updatedCount++;
  710.                     ipb.chat.unreadCount++;
  711.                     if (_thisRowId != ipb.chat.activeTab) {
  712.                         if (ipb.chat.unreadTabs.get(_thisRowId)) {
  713.                             ipb.chat.unreadTabs.set(_thisRowId, parseInt(ipb.chat.unreadTabs.get(_thisRowId)) + 1);
  714.                         } else {
  715.                             ipb.chat.unreadTabs.set(_thisRowId, 1);
  716.                         }
  717.                     }
  718.                     ipb.chat.lastUser.set(_thisRowId, 0);
  719.                 } else if (msgDetails[1] == 4) {
  720.                     listItemVal = ipb.chat.templates['msg-4'].evaluate({
  721.                         message: msgDetails[3]
  722.                     });
  723.                     $$('.storage-container').each(function(elem) {
  724.                         var _id = $(elem).id.replace(/storage_/, '');
  725.                         if (_id != 'chatroom') {
  726.                             var _ulList = ipb.chat.getStorageContainer(_id);
  727.                             _ulList.insert({
  728.                                 bottom: ipb.chat.templates['msg-K'].evaluate()
  729.                             });
  730.                             $(elem).update(_ulList);
  731.                         }
  732.                     });
  733.                     $('messages-display').update(ipb.chat.getStorageContainer(ipb.chat.activeTab)).addClassName('messages-list');
  734.                     _updatedCount++;
  735.                     ipb.chat.unreadCount++;
  736.                     if (_thisRowId != ipb.chat.activeTab) {
  737.                         if (ipb.chat.unreadTabs.get(_thisRowId)) {
  738.                             ipb.chat.unreadTabs.set(_thisRowId, parseInt(ipb.chat.unreadTabs.get(_thisRowId)) + 1);
  739.                         } else {
  740.                             ipb.chat.unreadTabs.set(_thisRowId, 1);
  741.                         }
  742.                     }
  743.                     ipb.chat.lastUser.set(_thisRowId, 0);
  744.                 } else if (msgDetails[1] == 5) {
  745.                     ipb.chat.removeUserFromList(msgDetails[4], msgDetails[3]);
  746.                     msgDetails[2] = ipb.chat.formatName(msgDetails[5], msgDetails[2]);
  747.                     msgDetails[3] = ipb.chat.formatName(msgDetails[4], msgDetails[3]);
  748.                     listItemVal = ipb.chat.templates['msg-5'].evaluate({
  749.                         username: msgDetails[2],
  750.                         date: _itemDate,
  751.                         extra: msgDetails[3]
  752.                     });
  753.                     ipb.chat.lastUser.set(_thisRowId, 0);
  754.                 }
  755.                 ulList.insert({
  756.                     bottom: listItemVal
  757.                 });
  758.                 if (ipb.chat.maxMessages > 0) {
  759.                     if (ulList.childElements().length > ipb.chat.maxMessages) {
  760.                         var _toRemove = ulList.childElements().length - ipb.chat.maxMessages;
  761.                         for (var tr = 0; tr < _toRemove; tr++) {
  762.                             ulList.firstDescendant().remove();
  763.                         }
  764.                     }
  765.                 }
  766.                 if (ipb.chat.activeTab != _thisRowId) {
  767.                     $('storage_container_' + _thisRowId).update(ulList);
  768.                 } else {
  769.                     $('messages-display').update(ulList).addClassName('messages-list');
  770.                 }
  771.                 if (alsoTo) {
  772.                     var otherUlList = ipb.chat.getStorageContainer(alsoTo);
  773.                     otherUlList.insert({
  774.                         bottom: listItemVal
  775.                     });
  776.                     if (ipb.chat.activeTab != alsoTo) {
  777.                         $('storage_container_' + alsoTo).update(otherUlList);
  778.                     } else {
  779.                         $('messages-display').update(otherUlList).addClassName('messages-list');
  780.                     }
  781.                 }
  782.                 if (!ipb.chat.bypassFlag) {
  783.                     ipb.chat.lastTime = _itemDate;
  784.                 }
  785.             }
  786.         }
  787.         if (!ipb.chat.windowHasFocus && ipb.chat.unreadCount > 0) {
  788.             if (document.title.match(/\(\d+\) (.+?)/gi)) {
  789.                 document.title = document.title.replace(/\(\d+\) (.+?)/gi, "(" + ipb.chat.unreadCount + ") $1");
  790.             } else {
  791.                 document.title = "(" + ipb.chat.unreadCount + ") " + document.title;
  792.             }
  793.         }
  794.         ipb.chat.updateTabUnreadCount();
  795.         if (_updatedCount) {
  796.             ipb.chat.triggerMessageSound();
  797.         }
  798.         if (_initialEmpty) {
  799.             ipb.chat.bypassFlag = false;
  800.         }
  801.         if (ipb.chat.getStorageContainer('chatroom').empty()) {
  802.             var _whateverItWas = ipb.chat.bypassFlag;
  803.             ipb.chat.bypassFlag = true;
  804.             ipb.chat.updateMessages("1," + ipb.chat.lastMsgId + "~~||~~" + Math.round(new Date().getTime() / 1000) + ",2," + userName.replace(',', '~~#~~') + ",,1_" + userId + "," + userId + "~~||~~");
  805.             ipb.chat.bypassFlag = _whateverItWas;
  806.         }
  807.         if (scrollBottom) {
  808.             Debug.write("Scrolling down to: " + $('messages-display').scrollHeight);
  809.             $('messages-display').scrollTop = $('messages-display').scrollHeight + 500;
  810.         }
  811.         return true;
  812.     },
  813.     checkInactivity: function(timestamp) {
  814.         if (!timestamp || !ipb.chat.inactiveKick) {
  815.             return;
  816.         }
  817.         var _inactiveSeconds = ipb.chat.inactiveKick * 60;
  818.         if (timestamp - ipb.chat.lastAction > _inactiveSeconds) {
  819.             var _whateverItWas = ipb.chat.bypassFlag;
  820.             ipb.chat.bypassFlag = true;
  821.             ipb.chat.updateMessages("0," + ipb.chat.lastMsgId + "~~||~~" + Math.round(new Date().getTime() / 1000) + ",5," + userName.replace(',', '~~#~~') + ",,1_" + userId + "," + userId + "~~||~~");
  822.             ipb.chat.bypassFlag = _whateverItWas;
  823.             ipb.chat.kicked = true;
  824.         }
  825.         return;
  826.     },
  827.     updateTabUnreadCount: function() {
  828.         ipb.chat.unreadTabs.set(ipb.chat.activeTab, 0);
  829.         ipb.chat.unreadTabs.each(function(pair) {
  830.             if (pair.key == ipb.chat.activeTab) {
  831.                 var _thisHtml = $('tab-' + pair.key).innerHTML;
  832.                 if (_thisHtml.match(/(.+?) \(\d+\)\<\/a\>/gi)) {
  833.                     _thisHtml = _thisHtml.replace(/(.+?) \(\d+\)\<\/a\>/gi, "$1</a>");
  834.                 }
  835.                 $('tab-' + pair.key).update(_thisHtml);
  836.                 return;
  837.             }
  838.             if (!$('tab-' + pair.key) || !pair.value) {
  839.                 return;
  840.             }
  841.             var _thisHtml = $('tab-' + pair.key).innerHTML;
  842.             if (_thisHtml.match(/(.+?) \(\d+\)\<\/a\>/gi)) {
  843.                 _thisHtml = _thisHtml.replace(/(.+?) \(\d+\)\<\/a\>/gi, "$1 (" + pair.value + ")</a>");
  844.             } else {
  845.                 _thisHtml = _thisHtml.replace(/\<\/a\>/i, '') + " (" + pair.value + ")</a>";
  846.             }
  847.             $('tab-' + pair.key).update(_thisHtml);
  848.         });
  849.         $$('#chat-tab-holder a').each(function(elem) {
  850.             id = elem.identify();
  851.             if ($(id)) {
  852.                 $(id).stopObserving('click');
  853.                 $(id).observe("click", ipb.chat.switchTab);
  854.             }
  855.         });
  856.     },
  857.     getStorageContainer: function(tab) {
  858.         if (!$('storage_' + tab)) {
  859.             return new Element('ul', {
  860.                 id: 'storage_' + tab
  861.             });
  862.         } else {
  863.             return new Element('ul', {
  864.                 id: 'storage_' + tab
  865.             }).update($('storage_' + tab).innerHTML);
  866.         }
  867.     },
  868.     addUserToList: function(user_id, username, forum_user_id) {
  869.         if (!$('user_' + user_id) && !$('link_' + forum_user_id)) {
  870.             var htmlFragment = new Element('li', {
  871.                 id: 'user_' + user_id
  872.             });
  873.             new Ajax.Request(ipb.vars['base_url'] + "&app=ipchat&module=ajax&section=adduser&md5check=" + ipb.vars['secure_hash'] + "&id=" + forum_user_id + "&user=" + user_id + '&_nocache=' + new Date().getTime(), {
  874.                 method: 'get',
  875.                 onSuccess: function(t) {
  876.                     if (Object.isUndefined(t.responseJSON)) {
  877.                         Debug.error("Invalid response returned from the server");
  878.                         return;
  879.                     }
  880.                     htmlFragment.update(t.responseJSON['html']);
  881.                     ipb.chat.nameFormatting.set(user_id, [t.responseJSON['prefix'], t.responseJSON['suffix'], t.responseJSON['name'], "<img class='ipsUserPhoto ipsUserPhoto_mini' src='" + t.responseJSON['pp_small_photo'] + "' />"]);
  882.                     ipb.chat.forumIdMap.set(user_id, [forum_user_id, t.responseJSON['_canBeIgnored'], t.responseJSON['g_id']]);
  883.                     $('online-chat-count').innerHTML = parseInt($('online-chat-count').innerHTML) + 1;
  884.                     var modMenu = new Element('ul', {
  885.                         'class': 'kickmenu',
  886.                         id: 'mod_link_' + user_id + '_menucontent'
  887.                     });
  888.                     if (isMobile) {
  889.                         if (user_id != userId) {
  890.                             if (ipb.chat.moderator) {
  891.                                 var modML = new Element('li');
  892.                                 var modLink = new Element('a', {
  893.                                     id: 'kick_user_' + user_id,
  894.                                     'class': 'kick_user',
  895.                                     href: '#',
  896.                                     title: ipb.lang['chat_kick_user']
  897.                                 });
  898.                                 modMenu = modMenu.update(modML.update(modLink.update(ipb.lang['chat_kick_user'])));
  899.                                 var modML = new Element('li');
  900.                                 var modLink = new Element('a', {
  901.                                     id: 'ban_user_' + user_id + '_' + forum_user_id,
  902.                                     'class': 'ban_user',
  903.                                     href: '#',
  904.                                     title: ipb.lang['chat_ban_user']
  905.                                 });
  906.                                 modMenu = modMenu.insert({
  907.                                     bottom: modML.update(modLink.update(ipb.lang['chat_ban_user']))
  908.                                 });
  909.                             }
  910.                             if (ipb.chat.private) {
  911.                                 var modML = new Element('li');
  912.                                 var modLink = new Element('a', {
  913.                                     id: 'priv_user_' + user_id + '_' + forum_user_id,
  914.                                     'class': 'priv_user',
  915.                                     href: '#',
  916.                                     title: ipb.lang['chat_priv_user']
  917.                                 });
  918.                                 modMenu = modMenu.insert({
  919.                                     bottom: modML.update(modLink.update(ipb.lang['chat_priv_user']))
  920.                                 });
  921.                             }
  922.                             if (ipb.chat.ignoreChats.get(forum_user_id ? forum_user_id : 'g_' + user_id)) {
  923.                                 var modML = new Element('li');
  924.                                 var modLink = new Element('a', {
  925.                                     id: 'unblock_user_' + user_id + '_' + forum_user_id,
  926.                                     'class': 'block_user',
  927.                                     href: '#',
  928.                                     title: ipb.lang['unblock_priv_user']
  929.                                 });
  930.                                 modMenu = modMenu.insert({
  931.                                     bottom: modML.update(modLink.update(ipb.lang['unblock_priv_user']))
  932.                                 });
  933.                             } else {
  934.                                 var modML = new Element('li');
  935.                                 var modLink = new Element('a', {
  936.                                     id: 'block_user_' + user_id + '_' + forum_user_id,
  937.                                     'class': 'block_user',
  938.                                     href: '#',
  939.                                     title: ipb.lang['block_priv_user']
  940.                                 });
  941.                                 modMenu = modMenu.insert({
  942.                                     bottom: modML.update(modLink.update(ipb.lang['block_priv_user']))
  943.                                 });
  944.                             }
  945.                         } else {
  946.                             var modML = new Element('li');
  947.                             var modLink = new Element('a', {
  948.                                 id: 'leave_room',
  949.                                 href: ipb.vars['base_url'] + "module=ipschat&section=chat&do=leave&room=" + roomId + "&user=" + userId + "&access_key=" + accessKey + "&secure_key=" + ipb.vars['secure_hash'],
  950.                                 title: ipb.lang['leave_room']
  951.                             });
  952.                             modMenu = modMenu.insert({
  953.                                 bottom: modML.update(modLink.update(ipb.lang['leave_room']))
  954.                             });
  955.                         }
  956.                     } else {
  957.                         if (user_id != userId) {
  958.                             if (ipb.chat.moderator) {
  959.                                 var modML = new Element('li');
  960.                                 var modLink = new Element('a', {
  961.                                     id: 'kick_user_' + user_id,
  962.                                     'class': 'kick_user',
  963.                                     href: '#',
  964.                                     title: ipb.lang['chat_kick_user']
  965.                                 });
  966.                                 modMenu = modMenu.update(modML.update(modLink.update("<img src='" + ipb.vars['img_url'] + "/user_delete.png' /> " + ipb.lang['chat_kick_user'])));
  967.                                 var modML = new Element('li');
  968.                                 var modLink = new Element('a', {
  969.                                     id: 'ban_user_' + user_id + '_' + forum_user_id,
  970.                                     'class': 'ban_user',
  971.                                     href: '#',
  972.                                     title: ipb.lang['chat_ban_user']
  973.                                 });
  974.                                 modMenu = modMenu.insert({
  975.                                     bottom: modML.update(modLink.update("<img src='" + ipb.vars['img_url'] + "/user_delete.png' /> " + ipb.lang['chat_ban_user']))
  976.                                 });
  977.                             }
  978.                             if (ipb.chat.private) {
  979.                                 var modML = new Element('li');
  980.                                 var modLink = new Element('a', {
  981.                                     id: 'priv_user_' + user_id + '_' + forum_user_id,
  982.                                     'class': 'priv_user',
  983.                                     href: '#',
  984.                                     title: ipb.lang['chat_priv_user']
  985.                                 });
  986.                                 modMenu = modMenu.insert({
  987.                                     bottom: modML.update(modLink.update("<img src='" + ipb.vars['img_url'] + "/user_comment.png' /> " + ipb.lang['chat_priv_user']))
  988.                                 });
  989.                             }
  990.                             if (ipb.chat.ignoreChats.get(forum_user_id ? forum_user_id : 'g_' + user_id)) {
  991.                                 var modML = new Element('li');
  992.                                 var modLink = new Element('a', {
  993.                                     id: 'unblock_user_' + user_id + '_' + forum_user_id,
  994.                                     'class': 'block_user',
  995.                                     href: '#',
  996.                                     title: ipb.lang['unblock_priv_user']
  997.                                 });
  998.                                 modMenu = modMenu.insert({
  999.                                     bottom: modML.update(modLink.update("<img src='" + ipb.vars['img_url'] + "/comments_ignore.png' /> " + ipb.lang['unblock_priv_user']))
  1000.                                 });
  1001.                             } else {
  1002.                                 var modML = new Element('li');
  1003.                                 var modLink = new Element('a', {
  1004.                                     id: 'block_user_' + user_id + '_' + forum_user_id,
  1005.                                     'class': 'block_user',
  1006.                                     href: '#',
  1007.                                     title: ipb.lang['block_priv_user']
  1008.                                 });
  1009.                                 modMenu = modMenu.insert({
  1010.                                     bottom: modML.update(modLink.update("<img src='" + ipb.vars['img_url'] + "/comments_ignore.png' /> " + ipb.lang['block_priv_user']))
  1011.                                 });
  1012.                             }
  1013.                         } else {
  1014.                             var modML = new Element('li');
  1015.                             modMenu = modMenu.update(modML.update('<em>' + ipb.lang['cant_kick_self'] + '</em>'));
  1016.                         }
  1017.                         $('mod-menu-container').insert({
  1018.                             bottom: modMenu
  1019.                         });
  1020.                     }
  1021.                     var _hasBeenInserted = false;
  1022.                     $$('#chatters-online > li').each(function(elem) {
  1023.                         if (!_hasBeenInserted) {
  1024.                             if (ipb.chat.moderator) {
  1025.                                 var _name = $(elem).firstDescendant().next().innerHTML.stripTags().replace(/\<\!--.+?--\>/ig, "").strip();
  1026.                                 if (username.toLowerCase() < _name.toLowerCase()) {
  1027.                                     $(elem).insert({
  1028.                                         before: htmlFragment
  1029.                                     });
  1030.                                     _hasBeenInserted = true;
  1031.                                 }
  1032.                             } else {
  1033.                                 var _name = $(elem).innerHTML.stripTags().replace(/\<\!--.+?--\>/ig, "").strip();
  1034.                                 if (username.toLowerCase() < _name.toLowerCase()) {
  1035.                                     $(elem).insert({
  1036.                                         before: htmlFragment
  1037.                                     });
  1038.                                     _hasBeenInserted = true;
  1039.                                 }
  1040.                             }
  1041.                         }
  1042.                     });
  1043.                     if (!_hasBeenInserted) {
  1044.                         $('chatters-online').insert({
  1045.                             bottom: htmlFragment
  1046.                         });
  1047.                     }
  1048.                     if (isMobile) {
  1049.                         $('user_' + user_id).insert({
  1050.                             bottom: modMenu
  1051.                         });
  1052.                     }
  1053.                     $('storage_chatroom').innerHTML = $('storage_chatroom').innerHTML.replace('<!--uid' + user_id + '-->', ipb.chat.nameFormatting.get(user_id)[3]);
  1054.                     if (!isMobile) {
  1055.                         new ipb.Menu($('mod_link_' + user_id), $('mod_link_' + user_id + '_menucontent'), {}, {
  1056.                             afterOpen: ipb.chat.repositionModMenu
  1057.                         });
  1058.                     }
  1059.                     ipb.chat.initKickLinks();
  1060.                     ipb.chat.triggerEnterSound();
  1061.                     if ($('chat-tab-count')) {
  1062.                         var _curCount = parseInt($('chat-tab-count').innerHTML);
  1063.                         var _newCount = _curCount + 1;
  1064.                         $('chat-tab-count').update(_newCount);
  1065.                         $('chat-tab-count').writeAttribute('title', ipb.chat.templates['count-title'].evaluate({
  1066.                             count: _newCount
  1067.                         }));
  1068.                     }
  1069.                 }
  1070.             });
  1071.         }
  1072.     },
  1073.     removeUserFromList: function(user_id, username) {
  1074.         if ($('user_' + user_id)) {
  1075.             $('user_' + user_id).remove();
  1076.             if ($('mod_link_' + user_id + '_menucontent')) {
  1077.                 $('mod_link_' + user_id + '_menucontent').remove();
  1078.             }
  1079.             $('online-chat-count').innerHTML = parseInt($('online-chat-count').innerHTML) - 1;
  1080.             ipb.chat.triggerLeaveSound();
  1081.             if ($('chat-tab-count')) {
  1082.                 var _curCount = parseInt($('chat-tab-count').innerHTML);
  1083.                 var _newCount = _curCount - 1;
  1084.                 $('chat-tab-count').update(_newCount);
  1085.                 $('chat-tab-count').writeAttribute('title', ipb.chat.templates['count-title'].evaluate({
  1086.                     count: _newCount
  1087.                 }));
  1088.             }
  1089.         }
  1090.     },
  1091.     initKickLinks: function() {
  1092.         $$('.kick_user', '.ban_user', '.priv_user', '.block_user', '.unblock_user').each(function(elem) {
  1093.             $(elem).stopObserving('click');
  1094.         });
  1095.         $$('.kick_user').each(function(elem) {
  1096.             $(elem).observe('click', ipb.chat.kickUser);
  1097.         });
  1098.         $$('.ban_user').each(function(elem) {
  1099.             $(elem).observe('click', ipb.chat.banUser);
  1100.         });
  1101.         $$('.priv_user').each(function(elem) {
  1102.             $(elem).observe('click', ipb.chat.privateChat);
  1103.         });
  1104.         $$('.block_user').each(function(elem) {
  1105.             $(elem).observe('click', ipb.chat.blockPrivateChats);
  1106.         });
  1107.         $$('.unblock_user').each(function(elem) {
  1108.             $(elem).observe('click', ipb.chat.unblockPrivateChats);
  1109.         });
  1110.     },
  1111.     unblockPrivateChats: function(e) {
  1112.         Event.stop(e);
  1113.         var elem = Event.findElement(e, 'a');
  1114.         var elemId = elem.id.replace("block_user_", "");
  1115.         var elemP = elemId.split('_');
  1116.         ipb.menus.closeAll();
  1117.         if (elemId == userId) {
  1118.             alert(ipb.lang['cant_kick_self']);
  1119.             return false;
  1120.         } else {
  1121.             Debug.write("Unblocked the user with id " + elemId);
  1122.         }
  1123.         if (elemP[1]) {
  1124.             new Ajax.Request(ipb.vars['base_url'] + "app=ipchat&module=ajax&section=block&md5check=" + ipb.vars['secure_hash'] + "&id=" + elemP[1] + "&block=0&_nocache=" + new Date().getTime(), {
  1125.                 method: 'post'
  1126.             });
  1127.         } else {
  1128.             var cookie = ipb.Cookie.get('chat_ignored_guests');
  1129.             if (cookie) {
  1130.                 var cookies = cookie.split(',');
  1131.                 var newCookies = new Array();
  1132.                 for (var abcdefg = 0; abcdefg < cookies.length; abcdefg++) {
  1133.                     if (cookies[abcdefg] && cookies[abcdefg] != elemP[0]) {
  1134.                         newCookies.push(cookies[abcdefg]);
  1135.                     }
  1136.                 }
  1137.                 ipb.Cookie.set('chat_ignored_guests', newCookies.join(','));
  1138.             }
  1139.         }
  1140.         ipb.chat.ignoreChats.unset(elemP[1] ? elemP[1] : 'g_' + elemP[0]);
  1141.         $(elem).removeClassName('unblock_user').addClassName('block_user');
  1142.         $(elem).writeAttribute({
  1143.             title: ipb.lang['block_priv_user']
  1144.         });
  1145.         if (isMobile) {
  1146.             $(elem).update(ipb.lang['block_priv_user']);
  1147.         } else {
  1148.             $(elem).update("<img src='" + ipb.vars['img_url'] + "/comments_ignore.png' /> " + ipb.lang['block_priv_user']);
  1149.         }
  1150.         ipb.chat.initKickLinks();
  1151.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  1152.         return false;
  1153.     },
  1154.     blockPrivateChats: function(e) {
  1155.         Event.stop(e);
  1156.         var elem = Event.findElement(e, 'a');
  1157.         var elemId = elem.id.replace("block_user_", "");
  1158.         var elemP = elemId.split('_');
  1159.         var _forumUser = ipb.chat.forumIdMap.get(elemP[0]);
  1160.         if (!_forumUser[1]) {
  1161.             alert(ipb.lang['cant_block_user']);
  1162.             return false;
  1163.         }
  1164.         ipb.menus.closeAll();
  1165.         if (elemId == userId) {
  1166.             alert(ipb.lang['cant_kick_self']);
  1167.             return false;
  1168.         } else {
  1169.             Debug.write("Blocked the user with id " + elemId);
  1170.         }
  1171.         if (elemP[1]) {
  1172.             new Ajax.Request(ipb.vars['base_url'] + "app=ipchat&module=ajax&section=block&md5check=" + ipb.vars['secure_hash'] + "&id=" + elemP[1] + "&block=1&_nocache=" + new Date().getTime(), {
  1173.                 method: 'post'
  1174.             });
  1175.         } else {
  1176.             var cookie = ipb.Cookie.get('chat_ignored_guests');
  1177.             var newCookies = new Array();
  1178.             if (cookie) {
  1179.                 var cookies = cookie.split(',');
  1180.                 for (var abcdefg = 0; abcdefg < cookies.length; abcdefg++) {
  1181.                     if (cookies[abcdefg] && cookies[abcdefg] != elemP[0]) {
  1182.                         newCookies.push(cookies[abcdefg]);
  1183.                     }
  1184.                 }
  1185.             }
  1186.             newCookies.push(elemP[0]);
  1187.             ipb.Cookie.set('chat_ignored_guests', newCookies.join(','));
  1188.         }
  1189.         var _thisid = elemP[1] ? elemP[1] : 'g_' + elemP[0];
  1190.         ipb.chat.ignoreChats.set(_thisid, _thisid);
  1191.         $(elem).removeClassName('block_user').addClassName('unblock_user');
  1192.         $(elem).writeAttribute({
  1193.             title: ipb.lang['unblock_priv_user']
  1194.         });
  1195.         if (isMobile) {
  1196.             $(elem).update(ipb.lang['unblock_priv_user']);
  1197.         } else {
  1198.             $(elem).update("<img src='" + ipb.vars['img_url'] + "/comments_ignore.png' /> " + ipb.lang['unblock_priv_user']);
  1199.         }
  1200.         ipb.chat.initKickLinks();
  1201.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  1202.         return false;
  1203.     },
  1204.     privateChat: function(e) {
  1205.         Event.stop(e);
  1206.         var elem = Event.findElement(e, 'a');
  1207.         var elemId = elem.id.replace("priv_user_", "");
  1208.         var elemP = elemId.split('_');
  1209.         ipb.menus.closeAll();
  1210.         if (elemP[0] == userId) {
  1211.             alert(ipb.lang['cant_kick_self']);
  1212.             return false;
  1213.         }
  1214.         if (ipb.chat.ignoreChats.get(elemP[1] ? elemP[1] : 'g_' + elemP[0])) {
  1215.             alert(ipb.lang['noprivate_withignored']);
  1216.             return false;
  1217.         }
  1218.         if (ipb.chat.privateChats.get('privchatwindow_' + elemP[0])) {
  1219.             ipb.chat.privateChats.get('privchatwindow_' + elemP[0]).show();
  1220.         } else {
  1221.             if (isMobile) {
  1222.                 ipb.chat.privateChats.set('privchatwindow_' + elemP[0], new ipb.Popup('privchatwindow_' + elemP[0], {
  1223.                     type: 'modal',
  1224.                     modal: true,
  1225.                     initial: ipb.chat.templates['send_private'].evaluate({
  1226.                         id: elemP[0]
  1227.                     }),
  1228.                     stem: false,
  1229.                     hideAtStart: false,
  1230.                     attach: {
  1231.                         target: $('mod_link_' + elemP[0]),
  1232.                         position: 'auto'
  1233.                     },
  1234.                     w: '320px'
  1235.                 }));
  1236.                 $('priv_' + elemP[0] + '_wrap').scrollTo();
  1237.             } else {
  1238.                 ipb.chat.privateChats.set('privchatwindow_' + elemP[0], new ipb.Popup('privchatwindow_' + elemP[0], {
  1239.                     type: 'balloon',
  1240.                     modal: false,
  1241.                     initial: ipb.chat.templates['send_private'].evaluate({
  1242.                         id: elemP[0]
  1243.                     }),
  1244.                     stem: true,
  1245.                     hideAtStart: false,
  1246.                     attach: {
  1247.                         target: $('mod_link_' + elemP[0]),
  1248.                         position: 'auto'
  1249.                     },
  1250.                     w: '400px'
  1251.                 }));
  1252.             }
  1253.             Event.observe('priv_chat_text_' + elemP[0], 'keypress', ipb.chat.checkForSendPrivateChat);
  1254.             new ipb.Menu($('mod_link_' + elemP[0]), $('mod_link_' + elemP[0] + '_menucontent'), {}, {
  1255.                 afterOpen: ipb.chat.repositionModMenu
  1256.             });
  1257.             ipb.chat.initKickLinks();
  1258.         }
  1259.         return false;
  1260.     },
  1261.     banUser: function(e) {
  1262.         Event.stop(e);
  1263.         if (!confirm(ipb.lang['ban_user_confirm'])) {
  1264.             return false;
  1265.         }
  1266.         var elem = Event.findElement(e, 'a');
  1267.         var elemId = elem.id.replace("ban_user_", "");
  1268.         var elemP = elemId.split('_');
  1269.         ipb.menus.closeAll();
  1270.         if (elemId == userId) {
  1271.             alert(ipb.lang['cant_kick_self']);
  1272.             return false;
  1273.         } else {
  1274.             Debug.write("Banned the user with id " + elemId);
  1275.         }
  1276.         new Ajax.Request(ipb.vars['base_url'] + "app=ipchat&module=ajax&section=ban&md5check=" + ipb.vars['secure_hash'] + "&id=" + elemP[1] + '&_nocache=' + new Date().getTime(), {
  1277.             method: 'post'
  1278.         });
  1279.         ipb.chat.sendMessageToChild("server=" + serverHost + "&path=" + serverPath + "&room=" + roomId + "&user=" + userId + "&access_key=" + accessKey + "&action=kick&against=" + elemP[0]);
  1280.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  1281.         return false;
  1282.     },
  1283.     kickUser: function(e) {
  1284.         Event.stop(e);
  1285.         var elem = Event.findElement(e, 'a');
  1286.         var elemId = elem.id.replace("kick_user_", "");
  1287.         ipb.menus.closeAll();
  1288.         if (elemId == userId) {
  1289.             alert(ipb.lang['cant_kick_self']);
  1290.             return false;
  1291.         } else {
  1292.             Debug.write("Kicked the user with id " + elemId);
  1293.         }
  1294.         ipb.chat.sendMessageToChild("server=" + serverHost + "&path=" + serverPath + "&room=" + roomId + "&user=" + userId + "&access_key=" + accessKey + "&action=kick&against=" + elemId);
  1295.         ipb.chat.lastAction = parseInt(new Date().getTime().toString().substring(0, 10));
  1296.         return false;
  1297.     },
  1298.     cleanMessage: function(message) {
  1299.         message = message.replace(/\r/g, '');
  1300.         message = message.replace(/\n/g, "__N__");
  1301.         message = message.replace(/,/g, "__C__");
  1302.         message = message.replace(/=/g, "__E__");
  1303.         message = message.replace(/\+/g, "__PS__");
  1304.         message = message.replace(/&/g, "__A__");
  1305.         message = message.replace(/%/g, "__P__");
  1306.         return message;
  1307.     },
  1308.     unCleanMessage: function(message) {
  1309.         message = message.replace(/__PS__/g, "+");
  1310.         message = message.replace(/__P__/g, "%");
  1311.         message = message.replace(/__A__/g, "&");
  1312.         message = message.replace(/__E__/g, "=");
  1313.         message = message.replace(/__C__/g, ",");
  1314.         message = message.replace(/__N__/g, "<br />");
  1315.         return message;
  1316.     },
  1317.     isValidUrl: function(url) {
  1318.         Debug.write("Checking url: " + url);
  1319.         var regexp = /^(https?|ftp|file):\/\/([^<>\"\s]+|[a-z0-9/\._\-!&\#;,%\+\?:=])/i;
  1320.        return regexp.test(url);
  1321.    },
  1322.    parseEmoticonsAndBbcode: function(text, chatUserId) {
  1323.        var urlReplacements = $H();
  1324.        var iteration = 0;
  1325.        while (text.match(/\[url\](.+?)\[\/url\]/gi)) {
  1326.            var matches = /\[url\](.+?)\[\/url\]/gi.exec(text);
  1327.            if (matches != null) {
  1328.                matches[1] = matches[1].replace(/&quot;/g, '');
  1329.                if (ipb.chat.isValidUrl(matches[1])) {
  1330.                    urlReplacements.set("__URL" + iteration + "__", "<a target='_blank' class='bbc' href='" + matches[1] + "'>" + matches[1] + "</a>");
  1331.                    text = text.replace(matches[0], "__URL" + iteration + "__");
  1332.                    iteration++;
  1333.                } else {
  1334.                    text = text.replace(matches[0], matches[1]);
  1335.                }
  1336.            }
  1337.        }
  1338.        while (text.match(/\[url=(.+?)\](.+?)\[\/url\]/gi)) {
  1339.            var matches = /\[url=(.+?)\](.+?)\[\/url\]/gi.exec(text);
  1340.            if (matches != null) {
  1341.                matches[1] = matches[1].replace(/&quot;/g, '').replace(/"/g, '');
  1342.                 if (ipb.chat.isValidUrl(matches[1])) {
  1343.                     urlReplacements.set("__URL" + iteration + "__", "<a target='_blank' class='bbc' href='" + matches[1].replace(/"/gi, '').replace(/&quot;/gi, '') + "'>" + matches[2] + "</a>");
  1344.                     text = text.replace(matches[0], "__URL" + iteration + "__");
  1345.                     iteration++;
  1346.                 } else {
  1347.                     text = text.replace(matches[0], matches[1]);
  1348.                 }
  1349.             }
  1350.         }
  1351.         var exp = /(\b(https?|ftp|file):\/\/([^<>\"\s]+|[a-z0-9/\._\-!&\#;,%\+\?:=]+))/ig;
  1352.        text = text.replace(exp, "<a target='_blank' class='bbc' href='$1'>$1</a>");
  1353.        urlReplacements.each(function(pair) {
  1354.            text = text.replace(pair.key, pair.value);
  1355.        });
  1356.        text = text.replace(/\[b\](.+?)\[\/b\]/gi, "<strong class='bbc'>$1</strong>");
  1357.        text = text.replace(/\[i\](.+?)\[\/i\]/gi, "<em class='bbc'>$1</em>");
  1358.        text = text.replace(/\[u\](.+?)\[\/u\]/gi, "<u class='bbc'>$1</u>");
  1359.        text = text.replace('!', '&#33;');
  1360.        ipb.chat.emoticons.each(function(emoticon) {
  1361.            var _tmp = emoticon.value.split(',');
  1362.            var img = "$1<img src='" + ipb.vars['emoticon_url'] + '/' + _tmp[1] + "' class='bbc' />$2";
  1363.            var _regexp = new RegExp("(^|\\s)" + RegExp.escape(emoticon.key) + "(\\s|$)", "gi");
  1364.            while (text.match(_regexp)) {
  1365.                text = text.replace(_regexp, img);
  1366.            }
  1367.        });
  1368.        if (chatUserId) {
  1369.            var groupId = ipb.chat.forumIdMap.get(chatUserId);
  1370.            if (groupId) {
  1371.                groupId = groupId[2];
  1372.            }
  1373.        }
  1374.        var bypass = false;
  1375.        if (groupId) {
  1376.            var bypass = ipb.chat.groups.get(groupId)[2];
  1377.        }
  1378.        var badwordReplacements = $H();
  1379.        var iteration = 0;
  1380.        if (!bypass) {
  1381.            ipb.chat.badwords.each(function(badword) {
  1382.                if (!badword.value[1]) {
  1383.                    badword.value[1] = '######';
  1384.                }
  1385.                if (badword.key == 'ass') {
  1386.                    if (badword.value[0]) {
  1387.                        var pattern = '(\\b|!|\\?|\\.|,|$)' + RegExp.escape(String.reverse(badword.key)) + '(?!lc)(^|\\b|\\s)';
  1388.                    } else {
  1389.                        var pattern = RegExp.escape(String.reverse(badword.key)) + '(?!lc)';
  1390.                    }
  1391.                    var _test = String.reverse(text);
  1392.                    var _regexp = new RegExp(pattern, "gi");
  1393.                    while (matches = _regexp.exec(_test)) {
  1394.                        if (matches != null) {
  1395.                            if (badword.value[0]) {
  1396.                                badwordReplacements.set("__BW" + iteration + "__", String.reverse(matches[2]) + badword.value[1] + String.reverse(matches[1]));
  1397.                            } else {
  1398.                                badwordReplacements.set("__BW" + iteration + "__", badword.value[1]);
  1399.                            }
  1400.                            _test = _test.replace(matches[0], "__" + iteration + "WB__");
  1401.                            iteration++;
  1402.                        }
  1403.                    }
  1404.                    text = String.reverse(_test);
  1405.                    return;
  1406.                }
  1407.                if (badword.value[0]) {
  1408.                    var pattern = '(^|\\b|\\s)' + RegExp.escape(badword.key) + '(\\b|!|\\?|\\.|,|$)';
  1409.                } else {
  1410.                    var pattern = RegExp.escape(badword.key);
  1411.                }
  1412.                var _regexp = new RegExp(pattern, "gi");
  1413.                while (matches = _regexp.exec(text)) {
  1414.                    if (matches != null) {
  1415.                        if (badword.value[0]) {
  1416.                            badwordReplacements.set("__BW" + iteration + "__", matches[1] + badword.value[1] + matches[2]);
  1417.                        } else {
  1418.                            badwordReplacements.set("__BW" + iteration + "__", badword.value[1]);
  1419.                        }
  1420.                        text = text.replace(matches[0], "__BW" + iteration + "__");
  1421.                        iteration++;
  1422.                    }
  1423.                }
  1424.            });
  1425.            badwordReplacements.each(function(pair) {
  1426.                text = text.replace(pair.key, pair.value);
  1427.            });
  1428.        }
  1429.        return text;
  1430.    },
  1431.    formatName: function(_user_id, _user_name) {
  1432.        var _details = ipb.chat.nameFormatting.get(_user_id);
  1433.        if (_details) {
  1434.            return _details[0].replace(/__DBQ__/g, '"') + _user_name + _details[1].replace(/__DBQ__/g, '"');
  1435.        }
  1436.        return _user_name;
  1437.    },
  1438.    ping: function(pe) {
  1439.        if (ipb.chat.kicked) {
  1440.            pe.stop();
  1441.            return false;
  1442.        }
  1443.        new Ajax.Request(ipb.vars['base_url'] + "app=ipchat&module=ajax&section=update&md5check=" + ipb.vars['secure_hash'] + '&_nocache=' + new Date().getTime(), {
  1444.            method: 'get'
  1445.        });
  1446.    },
  1447.    manualDecode: function(string) {
  1448.        string = string.replace(/\%([a-zA-Z0-9]{2})/gi, function(hex) {
  1449.            return String.fromCharCode(parseInt(hex.replace('%', ''), 16));
  1450.        });
  1451.        return string;
  1452.    },
  1453.    repositionModMenu: function(menu) {
  1454.        var _top = $(menu.target).getStyle('top').replace(/px/, '');
  1455.        var _cont = $('chatters-online-wrap').scrollTop;
  1456.        Debug.write("Online chatters current top pos: " + _top);
  1457.        Debug.write("Online chatters scroll offset: " + _cont);
  1458.        Debug.write("New top pos: " + (_top - _cont));
  1459.        $(menu.target).setStyle('top:' + (_top - _cont) + 'px;');
  1460.    }
  1461. };
  1462. ipb.chat.init();
  1463.  
  1464. function convertToPixels(_str, _context) {
  1465.    if (/px$/.test(_str)) {
  1466.        return parseInt(_str);
  1467.    }
  1468.    var tmp = document.createElement('div');
  1469.    tmp.style.visbility = 'hidden';
  1470.    tmp.style.position = 'absolute';
  1471.    tmp.style.lineHeight = '0';
  1472.    if (/%$/.test(_str)) {
  1473.        _context = _context.parentNode || _context;
  1474.        tmp.style.height = _str;
  1475.    } else {
  1476.        tmp.style.borderStyle = 'solid';
  1477.        tmp.style.borderBottomWidth = '0';
  1478.        tmp.style.borderTopWidth = _str;
  1479.    }
  1480.    if (!_context) {
  1481.        _context = document.body;
  1482.    }
  1483.    _context.appendChild(tmp);
  1484.    var px = tmp.offsetHeight;
  1485.    _context.removeChild(tmp);
  1486.    return px + 'px';
  1487. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement