/* * $RCSfile$ * $Revision: 27700 $ * $Date: 2006-02-23 11:34:13 -0800 (Thu, 23 Feb 2006) $ * * Copyright (C) 2003 Jive Software. All rights reserved. * * This software is the proprietary information of Jive Software. Use is subject to license terms. */ // Override the default trim method of String. String.prototype.trim = function () { var text = this; var start = 0; var end = text.length; var display = ""; for (var i=0; i= 33) { start = i; break; } else { start++; } } for (var i=text.length; i>start; i--) { var code = text.charCodeAt(i-1); if (code >= 33) { end = i; break; } } return text.substring(start,end); } // variable to tell whether or not a form has been clicked var clicked = false; function allowClick() { if (!clicked) { clicked = true; return true; } return false; } // Sequence for open window names var windowNameSeq = 0; // Array of all open windows var windows = new Array(); // Checks to see if a window exists function windowExists(name) { for (var i=0; i"+person+""; } else { lineDiv.innerHTML = "
"+person+"
"; } peopleDiv.appendChild(lineDiv); } function changePersonImage(roomWin, person, image){ var imagenode = getPersonElement(roomWin, person); if(imagenode != null){ var p = escape(person); var userNickname = roomWin.parent.getNickname(); var isUser = (userNickname == person); if(!isUser) { imagenode.innerHTML = "
"+person+"
"; } else { imagenode.innerHTML = "
"+person+"
"; } } } function removeAllPeople(roomWin){ var peopleDiv = roomWin.document.getElementById('rtext'); var col = peopleDiv.getElementsByTagName("div"); while(true){ var el = col[0]; if(el != null){ peopleDiv.removeChild(el); } else { break; } } } function nicknameExists(roomWin, person){ var rDiv = roomWin.document.getElementById('rtext'); var numChildren = rDiv.childNodes.length; for(i=0;i0){ return rDiv.childNodes[i-1]; } else { return null; } } } } function getPersonAfter(roomWin, person){ // The div to write to: var rDiv = roomWin.document.getElementById('rtext'); var numChildren = rDiv.childNodes.length; for(i=0;i0){ return rDiv.childNodes[i + 1]; } else { return null; } } } } function getFirstPerson(roomWin){ // The div to write to: var rDiv = roomWin.document.getElementById('rtext'); var numChildren = rDiv.childNodes.length; if(numChildren > 0){ return rDiv.childNodes[0]; } return null; } function hasPeople(roomWin){ // The div to write to: var rDiv = roomWin.document.getElementById('rtext'); var numChildren = rDiv.childNodes.length; if(numChildren > 0){ return true; } return false; } function insertText(yakWin, text){ // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); // Create a new span node in the yakDiv. Record the num of nodes right now - used later // to see if the node was really added: var chatLineDiv = yakWin.document.createElement("div"); chatLineDiv.setAttribute("class", "private-message"); try { chatLineDiv.innerHTML = ""+text+""; yakDiv.appendChild(chatLineDiv); } catch (exception) { } } function insertHistoryText(yakWin, text){ // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); // Create a new span node in the yakDiv. Record the num of nodes right now - used later // to see if the node was really added: var chatLineDiv = yakWin.document.createElement("div"); chatLineDiv.setAttribute("class", "history-message"); try { chatLineDiv.innerHTML = ""+text+""; yakDiv.appendChild(chatLineDiv); } catch (exception) { } } function insertErrorText(yakWin, text){ // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); // Create a new span node in the yakDiv. Record the num of nodes right now - used later // to see if the node was really added: var chatLineDiv = yakWin.document.createElement("div"); chatLineDiv.setAttribute("class", "error-message"); try { chatLineDiv.innerHTML = ""+text+""; yakDiv.appendChild(chatLineDiv); } catch (exception) { } } function clearChat(yakWin){ // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); var numChildren = yakDiv.childNodes.length; for(i=0;i"; if (!isAnnouncement) { inn += "" + from + ": "; // yakDiv.innerHTML = inn; } // var inn = yakDiv.innerHTML; inn += "" : "chat_text\">"); inn += text + ""; yakDiv.innerHTML = inn; } else { // yakDiv.appendChild(document.createElement("br")); } } function addChatTextAndDate(yakWin, date, from, text) { // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); // This will be an announcement if there is no from passed in var isAnnouncement = (from == ""); // Create a new span node in the yakDiv. Record the num of nodes right now - used later // to see if the node was really added: var numChildren = yakDiv.childNodes.length; var nameSpan = document.createElement("span"); var textSpan = document.createElement("span"); if (isAnnouncement) { nameSpan.setAttribute("class", "chat-announcement"); textSpan.setAttribute("class", "chat-announcement"); } else { textSpan.setAttribute("class", "text"); } // add another span containing the username if this is not an announcement: var fromIsCurrentUser = false; if (!isAnnouncement) { // is the from the same as the current user? fromIsCurrentUser = (nickname == from); if (fromIsCurrentUser) { nameSpan.setAttribute("class", "client-name"); } else { nameSpan.setAttribute("class", "operator-name"); } } if(!isAnnouncement && !fromIsCurrentUser){ var encodedFrom = escape(from); from = " "+from+""; } var chatLineDiv = document.createElement("div"); chatLineDiv.setAttribute("class", "chat-line"); var appendFailed = false; try { if (!isAnnouncement) { nameSpan.innerHTML = date+" "+from + ": "; chatLineDiv.appendChild(nameSpan); } textSpan.innerHTML = text; chatLineDiv.appendChild(textSpan); yakDiv.appendChild(chatLineDiv); } catch (exception) { appendFailed = true; } if (!appendFailed) { // Make sure the browser appended: appendFailed = (numChildren == yakDiv.childNodes.length); } if (appendFailed) { var inn = yakDiv.innerHTML; inn += "
"; if (!isAnnouncement) { inn += "" + date+ " "+from + ": "; // yakDiv.innerHTML = inn; } // var inn = yakDiv.innerHTML; inn += "" : "chat_text\">"); inn += text + "
"; yakDiv.innerHTML = inn; } else { // yakDiv.appendChild(document.createElement("br")); } } function addHistoryText(yakWin, date, from, text) { // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); // This will be an announcement if there is no from passed in var isAnnouncement = (from == "" || from == null); // Create a new span node in the yakDiv. Record the num of nodes right now - used later // to see if the node was really added: var numChildren = yakDiv.childNodes.length; var nameSpan = document.createElement("span"); var textSpan = document.createElement("span"); nameSpan.setAttribute("class", "history-message"); textSpan.setAttribute("class", "chat-line"); // add another span containing the username if this is not an announcement: var fromIsCurrentUser = false; if (!isAnnouncement) { // is the from the same as the current user? fromIsCurrentUser = (nickname == from); } else { textSpan.setAttribute("class", "history-message"); } var chatLineDiv = document.createElement("div"); var appendFailed = false; try { if (!isAnnouncement) { nameSpan.innerHTML = date+" "+from + ": "; chatLineDiv.appendChild(nameSpan); } textSpan.innerHTML = text; chatLineDiv.appendChild(textSpan); yakDiv.appendChild(chatLineDiv); } catch (exception) { appendFailed = true; } if (!appendFailed) { // Make sure the browser appended: appendFailed = (numChildren == yakDiv.childNodes.length); } if (appendFailed) { var inn = yakDiv.innerHTML; inn += "
"; if (!isAnnouncement) { inn += "" + date+" "+from + ": "; // yakDiv.innerHTML = inn; } // var inn = yakDiv.innerHTML; inn += "" : "history-message\">"); inn += text + "
"; yakDiv.innerHTML = inn; } } function addPrivateMessage(yakWin, from, text) { // The div to write to: var yakDiv = yakWin.document.getElementById('ytext'); var lineDiv = yakWin.document.createElement("div"); var isCurrentUser = (nickname == from); // This will be an announcement if there is no from passed in var newMessage = ""; var participant = escape(from); var link = ""+text+"
"; newMessage += ""; newMessage += ""; newMessage += ""; newMessage += "
Private Message from " + from + " (Click to join)
" + link + "
"; lineDiv.innerHTML = newMessage; yakDiv.appendChild(lineDiv); } function scrollYakToEnd (yakWin) { var endDiv = yakWin.document.getElementById('enddiv'); yakWin.scrollTo(0, yakWin.document.body.scrollHeight); } function scroll(yakWin){ yakWin.scrollBy(0, 40); }