?? common.js
字號:
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 = "<span class='private-message'>"+text+"</span>"; 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 = "<span class='history-message'>"+text+"</span>"; 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 = "<span class='error-message'>"+text+"</span>"; 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<numChildren;i++){ var chatLineDiv = yakDiv.childNodes[i]; yakDiv.removeChild(chatLineDiv); numChildren = yakDiv.childNodes.length; if(numChildren == 0){ return; } }}function addChatText(yakWin, 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"); } } var chatLineDiv = document.createElement("div"); chatLineDiv.setAttribute("class", "chat-line"); var appendFailed = false; try { if (!isAnnouncement) { nameSpan.innerHTML = 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 += "<div class=\"chat-line\">"; if (!isAnnouncement) { inn += "<span class=\""; if (isAnnouncement) { inn += "chat-announcement"; } else if (fromIsCurrentUser) { inn += "client-name"; } else { inn += "operator-name"; } inn += "\">" + from + ": </span>"; // yakDiv.innerHTML = inn; } // var inn = yakDiv.innerHTML; inn += "<span class=\""; inn += (isAnnouncement ? "chat-announcement\">" : "chat_text\">"); inn += text + "</span></div>"; 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 = "<a class=\"operator-name\" href=javascript:parent.openIM('"+encodedFrom+"')> "+from+"</a>"; } 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 += "<div class=\"chat-line\">"; if (!isAnnouncement) { inn += "<span class=\""; if (isAnnouncement) { inn += "chat-announcement"; } else if (fromIsCurrentUser) { inn += "client-name"; } else { inn += "operator-name"; } inn += "\">" + date+ " "+from + ": </span>"; // yakDiv.innerHTML = inn; } // var inn = yakDiv.innerHTML; inn += "<span class=\""; inn += (isAnnouncement ? "chat-announcement\">" : "chat_text\">"); inn += text + "</span></div>"; 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 += "<div class=\"history-message\">"; if (!isAnnouncement) { inn += "<span class=\""; if (isAnnouncement) { inn += "history-message"; } else if (fromIsCurrentUser) { inn += "history-message"; } else { inn += "history-message"; } inn += "\">" + date+" "+from + ": </span>"; // yakDiv.innerHTML = inn; } // var inn = yakDiv.innerHTML; inn += "<span class=\""; inn += (isAnnouncement ? "history-message\">" : "history-message\">"); inn += text + "</span></div>"; 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 = "<table width=100%>"; var participant = escape(from); var link = "<a href=javascript:parent.openIM('"+participant+"')><b><u>"+text+"</b></u></a><br/>"; newMessage += "<tr><td class=private-message colspan=2>Private Message from " + from + " (Click to join)</td></tr>"; newMessage += "<tr height=1><td colspan=2 bgcolor=#d3d5d6 height=1></td></tr>"; newMessage += "<tr><td colspan=2 class=chat-line>" + link + "</td></tr>"; newMessage += "</table>"; 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);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -