From: <fza...@us...> - 2005-11-30 22:04:41
|
Update of /cvsroot/struts/ajaxchat In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13448 Modified Files: index.jsp lobby.jsp room.jsp Log Message: Index: index.jsp =================================================================== RCS file: /cvsroot/struts/ajaxchat/index.jsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** index.jsp 29 Nov 2005 23:08:30 -0000 1.1 --- index.jsp 30 Nov 2005 22:04:28 -0000 1.2 *************** *** 14,20 **** --- 14,28 ---- </head> + <!-- Note that inline styles are used here to overcome some problem that was --> + <!-- beating me where the stylesheet linked in here wouldn't get picked up. --> + <!-- It would happen when deployed on Resin, but also started to happen when --> + <!-- viewing the app with Firefox running locally on Tomcat. I have no clue --> + <!-- why it was happening, and if it is ever solved then the inline styles --> + <!-- should be removed in favor of the linked in stylesheet. --> + <body class="cssMain" onLoad="LoginActionForm.username.focus();"> <div class="cssHeading"><fmt:message key="messages.appTitle" /></div> + <div class="cssAppVersion"><fmt:message key="app.version" /></div> <hr/><br/> Index: lobby.jsp =================================================================== RCS file: /cvsroot/struts/ajaxchat/lobby.jsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lobby.jsp 29 Nov 2005 23:08:30 -0000 1.1 --- lobby.jsp 30 Nov 2005 22:04:28 -0000 1.2 *************** *** 67,70 **** --- 67,71 ---- if (xhrLobbyUpdateStats == null || xhrLobbyUpdateStats.readyState == 0 || xhrLobbyUpdateStats.readyState == 4) { + // Create XMLHttpRequest object instance based on browser type. try { if (window.XMLHttpRequest){ *************** *** 73,78 **** --- 74,83 ---- xhrLobbyUpdateStats = new ActiveXObject('Microsoft.XMLHTTP'); } + // Set the Javascript function that will act as a callback for + // any events the instance fires. xhrLobbyUpdateStats.onreadystatechange = lobbyUpdateStatsHandler; + // Set the target URI for the request. target = "<html:rewrite action="ajaxLobbyUpdateStats" />"; + // One minor problem that if (sendAJAXRequest) { xhrLobbyUpdateStats.open("post", target, true); *************** *** 129,132 **** --- 134,138 ---- <div class="cssHeading"><fmt:message key="messages.appTitle" /></div> + <div class="cssAppVersion"><fmt:message key="app.version" /></div> <hr/><br/> Index: room.jsp =================================================================== RCS file: /cvsroot/struts/ajaxchat/room.jsp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** room.jsp 29 Nov 2005 23:08:30 -0000 1.1 --- room.jsp 30 Nov 2005 22:04:28 -0000 1.2 *************** *** 90,93 **** --- 90,94 ---- if (xhrListUsersInRoom == null || xhrListUsersInRoom.readyState == 0 || xhrListUsersInRoom.readyState == 4) { + // Create XMLHttpRequest object instance based on browser type. try { if (window.XMLHttpRequest){ *************** *** 96,101 **** --- 97,106 ---- xhrListUsersInRoom = new ActiveXObject('Microsoft.XMLHTTP'); } + // Set the Javascript function that will act as a callback for + // any events the instance fires. xhrListUsersInRoom.onreadystatechange = listUsersInRoomHandler; + // Set the target URI for the request. target = "<html:rewrite action="ajaxListUsersInRoom" />"; + // Go ahead and fire off the request, no payload to send. xhrListUsersInRoom.open("post", target, true); xhrListUsersInRoom.send(null); *************** *** 154,157 **** --- 159,163 ---- if (xhrGetMessages == null || xhrGetMessages.readyState == 0 || xhrGetMessages.readyState == 4) { + // Create XMLHttpRequest object instance based on browser type. try { if (window.XMLHttpRequest){ *************** *** 160,165 **** --- 166,175 ---- xhrGetMessages = new ActiveXObject('Microsoft.XMLHTTP'); } + // Set the Javascript function that will act as a callback for + // any events the instance fires. xhrGetMessages.onreadystatechange = getMessagesHandler; + // Set the target URI for the request. target = "<html:rewrite action="ajaxGetMessages" />"; + // Go ahead and fire off the request, no payload to send. xhrGetMessages.open("post", target, true); xhrGetMessages.send(null); *************** *** 186,189 **** --- 196,202 ---- root = msgDOM.getElementsByTagName("messages")[0]; messages = root.getElementsByTagName("message"); + // Now we're going to cycle through all the <message> elements in + // the returns XML and for each we'll pull out the pertinent details + // and construct HTML for it. for (i = 0; i < messages.length; i++) { message = messages[i]; *************** *** 218,222 **** } } ! // Lastly, always scroll to the bottom objChatScroll.scrollTop = 1000000; } else { --- 231,235 ---- } } ! // Lastly, always scroll to the bottom. objChatScroll.scrollTop = 1000000; } else { *************** *** 249,256 **** /** ! * This function trims whitespace from both ends of a string. */ function fullTrim(inString) { return (inString.replace(/^\s*(.*\S|.*)\s*$/, '$1')); } // End fullTrim(). --- 262,271 ---- /** ! * Utility function to trim whitespace from both ends of a string. */ function fullTrim(inString) { + return (inString.replace(/^\s*(.*\S|.*)\s*$/, '$1')); + } // End fullTrim(). *************** *** 265,270 **** --- 280,287 ---- function postMessage() { + // Only try and send if the user entered something. userInputText = document.getElementById("userInput"); if (fullTrim(userInputText.value) != "") { + // Create XMLHttpRequest object instance based on browser type. if (window.XMLHttpRequest){ xhrPostMessage = new XMLHttpRequest(); *************** *** 273,280 **** --- 290,303 ---- } try { + // Set the target URI for the request. target = "<html:rewrite action="ajaxPostMessage" />"; target += "?msgText=" + escape(userInputText.value); + // Go ahead and fire off the request, no payload to send. Well, + // technically, the payload was appended to the URI as a query + // string. In this case that was probably the easiest way to go. xhrPostMessage.open("post", target, true); xhrPostMessage.send(null); + // Some UI niceness: clear what was just sent and set focus to the + // user input box. userInputText.value = ""; userInputText.focus(); *************** *** 287,291 **** --- 310,320 ---- + /** + * This function is called when the increase font size image is clicked. + * It's a simple client-side adjustment, simply setting the font-size + * style attribute of the chat scroll. + */ function increaseChatScrollFontSize() { + cs = document.getElementById("chatScroll"); scrollChatFontSize = scrollChatFontSize + 2; *************** *** 294,301 **** --- 323,337 ---- } cs.style.fontSize = scrollChatFontSize + "pt"; + } + /** + * This function is called when the decrease font size image is clicked. + * It's a simple client-side adjustment, simply setting the font-size + * style attribute of the chat scroll. + */ function decreaseChatScrollFontSize() { + cs = document.getElementById("chatScroll"); scrollChatFontSize = scrollChatFontSize - 2; *************** *** 304,309 **** --- 340,347 ---- } cs.style.fontSize = scrollChatFontSize + "pt"; + } + </script> *************** *** 314,318 **** <table align="center" border="1" bordercolor="#000000" width="100%" height="100%" cellpadding="4" cellspacing="0" class="cssRoomMainTable"> ! <!-- Header section --> <tr> <td colspan="2" class="cssRoomHeader" height="40"> --- 352,357 ---- <table align="center" border="1" bordercolor="#000000" width="100%" height="100%" cellpadding="4" cellspacing="0" class="cssRoomMainTable"> ! ! <!-- ***** Header section ***** --> <tr> <td colspan="2" class="cssRoomHeader" height="40"> *************** *** 321,325 **** </td> </tr> ! <!-- Chat scroll section --> <tr> <td height="100%" valign="top"> --- 360,365 ---- </td> </tr> ! ! <!-- ***** Chat scroll section ***** --> <tr> <td height="100%" valign="top"> *************** *** 331,376 **** </td> </tr> ! <!-- User control section --> <tr> ! <td height="60" valign="middle" id="userControl" class="cssRoomUserControl"> ! <!-- Leave room button --> ! <input type="button" ! value="<fmt:message key="labels.leaveRoomButton" />" ! class="cssButton" onClick="leaveRoom();" /> ! ! <!-- Clear history button --> ! <input type="button" ! value="<fmt:message key="labels.clearHistoryButton" />" ! class="cssButton" onClick="clearHistory();" /> ! ! <!-- Increase/Decrease font size --> ! <fmt:message key="labels.fontSize" /> ! <img src="img/zoomUp.gif" align="absmiddle" ! alt="<fmt:message key="labels.increaseFontSize" />" ! onClick="increaseChatScrollFontSize();" ! onMouseOver="this.style.cursor='hand';" ! onMouseOut="this.style.cursor='';"> ! ! <img src="img/zoomDown.gif" align="absmiddle" ! alt="<fmt:message key="labels.decreaseFontSize" />" ! onClick="decreaseChatScrollFontSize()"; ! onMouseOver="this.style.cursor='hand';" ! onMouseOut="this.style.cursor='';"> ! <br/> ! <!-- Your color --> ! <fmt:message key="labels.yourColor" /> ! <select class="cssSelect" id="yourColor"> ! <%@ include file="/inc/color_options.inc" %> ! </select> ! ! <!-- Their color --> ! <fmt:message key="labels.theirColor" /> ! <select class="cssSelect" id="theirColor"> ! <%@ include file="/inc/color_options.inc" %> ! </select> </td> </tr> ! <!-- User input section --> <tr> <td height="70" valign="middle" class="cssRoomUserInput"> --- 371,430 ---- </td> </tr> ! ! <!-- ***** User control section ***** --> <tr> ! <td height="66" valign="middle" id="userControl" class="cssRoomUserControl"> ! <table border="0" cellpadding="2" cellspacing="0" width="100%" ! height="100%" class="cssRoomUserControl"> ! <tr> ! <td width="50%" ! <!-- Leave room button --> ! <input type="button" ! value="<fmt:message key="labels.leaveRoomButton" />" ! class="cssButton" onClick="leaveRoom();" /> ! ! <!-- Clear history button --> ! <input type="button" ! value="<fmt:message key="labels.clearHistoryButton" />" ! class="cssButton" onClick="clearHistory();" /> ! </td> ! <td width="50%" align="right"> ! <!-- Your color --> ! <fmt:message key="labels.yourColor" /> ! <select class="cssSelect" id="yourColor"> ! <%@ include file="/inc/color_options.inc" %> ! </select> ! </td> ! </tr> ! <tr> ! <td> ! <!-- Increase/Decrease font size --> ! <fmt:message key="labels.fontSize" /> ! ! <img src="img/zoomUp.gif" align="absmiddle" hspace="2" ! alt="<fmt:message key="labels.increaseFontSize" />" ! onClick="increaseChatScrollFontSize();" ! onMouseOver="this.style.cursor='hand';" ! onMouseOut="this.style.cursor='';"> ! <img src="img/zoomDown.gif" align="absmiddle" hspace="8" ! alt="<fmt:message key="labels.decreaseFontSize" />" ! onClick="decreaseChatScrollFontSize()"; ! onMouseOver="this.style.cursor='hand';" ! onMouseOut="this.style.cursor='';"> ! </td> ! <td align="right"> ! <!-- Their color --> ! <fmt:message key="labels.theirColor" /> ! <select class="cssSelect" id="theirColor"> ! <%@ include file="/inc/color_options.inc" %> ! </select> ! </td> ! </tr> ! </table> </td> </tr> ! ! <!-- ***** User input section ***** --> <tr> <td height="70" valign="middle" class="cssRoomUserInput"> *************** *** 382,385 **** --- 436,440 ---- </td> </tr> + </table> |