//////////////////// //Chat Window Manager functions //////////////////// //////////////////// //ChatBoxes Creation //////////////////// var nBox = 0; var maxBox = 5; var chatBoxWidth = 230; var chatBoxHeight = 180; var videoBoxHeight = 145; var visibleChatBoxes = new Array(); var offsetForFlowBox = 0; var chatBoxSeparation = chatBoxWidth+12; //Create chatbox for new conversations //Open chatbox for old conversations function createChatBox(guest_slug,isGroup){ var guest_name = getNameFromSlug(guest_slug) if(isGroup){ var chatBoxTitle = I18n.t("chat.muc.group", {group: guest_name}) } else { var chatBoxTitle = guest_name; } //Box Variable name = getChatVariableFromSlug(guest_slug) if (typeof window[getChatVariableFromSlug(guest_slug)] == 'undefined') { //Add div with id = guest_slug $("#chat_divs").append("
") //Offset Management for new box boxParams = getBoxParams(); var offset = boxParams[0]; var position = boxParams[1]; window[getChatVariableFromSlug(guest_slug)] = $("#" + guest_slug).chatbox({id: user_name, user:{key : "value"}, hidden: false, offset: offset, // relative to right edge of the browser window width: chatBoxWidth, // width of the chatbox height: chatBoxHeight, // height of the chatbox video: 0, //height of the videoBox title : chatBoxTitle, position: position, priority: visibleChatBoxes.length+1, groupBox: isGroup, boxClosed: function(id) { closeChatBox(guest_slug) }, messageSent: function(id, user, msg){ sendChatMessage(guest_slug, msg) }}); visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)]; return true; } else { if (visibleChatBoxes.indexOf(window[getChatVariableFromSlug(guest_slug)]) == -1) { //Offset Management for old box boxParams = getBoxParams(); var offset = boxParams[0]; var position = boxParams[1]; window[getChatVariableFromSlug(guest_slug)].chatbox("option", "offset", offset); window[getChatVariableFromSlug(guest_slug)].chatbox("option", "position", position); visibleChatBoxes[position-1] = window[getChatVariableFromSlug(guest_slug)]; } window[getChatVariableFromSlug(guest_slug)].chatbox("option", "hidden", false); window[getChatVariableFromSlug(guest_slug)].parent().toggle(true) return false; } } function getBoxParams(){ var boxParams = new Array(2); if (nBox==maxBox){ //Select box to replaced replaced = visibleChatBoxes[getBoxIndexToReplace()]; replaced.chatbox("option", "hidden", true) index = visibleChatBoxes.indexOf(replaced); boxParams[0] = replaced.chatbox("option", "offset") boxParams[1] = replaced.chatbox("option", "position") } else { nBox++; boxParams[0] = (nBox-1)*(chatBoxSeparation); if((nBox!=1)&&(mainChatBox!=null)){ boxParams[0] = boxParams[0] - offsetForFlowBox; } boxParams[1] = nBox; } return boxParams } function closeChatBox(guest_slug){ var position = getChatBoxForSlug(guest_slug).chatbox("option", "position"); for (i=position+1;i