X7 Chat Support Board
Welcome, Guest. Please login or register.
July 31, 2010, 07:25:57 PM

Login with username, password and session length
Search:     Advanced search
X7 Chat Version 3.0.0 Alpha 2 is now available (http://x7chat.com/support_forum/index.php?topic=3198.msg11497#new).
13036 Posts in 3760 Topics by 66531 Members
Latest Member: yurapro1982
* Home Help Search Login Register
+  X7 Chat Support Board
|-+  Version 1 Archive
| |-+  [Version 1] Mod Support
| | |-+  Larger Chat Message Box
« previous next »
Pages: [1] Reply Send this topic Print
Author Topic: Larger Chat Message Box  (Read 3595 times)
Dcoach
Member
*
Offline Offline

Posts: 8


View Profile Email
« on: January 01, 2005, 05:45:20 PM »
Reply with quote

I need a bigger chat message input box for the type of chats I'll be running.  

based on some prior advice, I modified this code in new.left.bottom:
OLD ROW:
   <tr valign="top">
      <td width="550" style="<?=$borderlr?>">
      <?
      print("
      <div align=\"left\">&nbsp;$chatmsg: <input type=\"text\" name=\"msg\" class=\"chatbox\" size=\"57\">
      <input type=\"submit\" value=\"$txt[85]\" onClick=\"javascript: setTimeout('dosndmsg()',500)\"></font></div>"
      );
      ?>
      </td>
   </tr>

   
My NEW ROW:

        <tr valign="top">
      <td width="550" style="<?=$borderlr?>">
      <?
      print("
      <div align=\"left\">&nbsp;$chatmsg: <textarea name=\"msg\" class=\"chatbox\" cols=\"75\" rows=\"6\"> </textarea>
      <input type=\"submit\" value=\"$txt[85]\" onClick=\"javascript: setTimeout('dosndmsg()',500)\"></font></div>"
      );
      ?>
      </td>
   </tr>

It looks fine, and it works fine unless someone hits the enter key while typing their chat message.  This creates a line break within the message.  If they just keep typing and let the text wrap, it would work fine, but if they hit the enter key (creating a line break within the message) and then hit send, to send the message, it seriously screws up the whole thing. After that, the only messages that will display in the upper box are the system generated messages.  Even the prior messages dissappear.  And even when I change the code back to how it was before, I get various errors and can't make it run right unless I just reinstall it.  

Can someone tell me how to make this work?
Report to moderator   Logged
E-Oreo
Administrator
Member
*****
Offline Offline

Posts: 3710


View Profile Email
« Reply #1 on: January 02, 2005, 11:16:30 AM »
Reply with quote

You can't use a multiline textarea because of the way that  javascript handles new lines (actually, javascript doesn't, which is the problem).  Javascript is 'line sensitive', ie: if you go to the next line it thinks you are done starting a the next function.

In order to fix the problem with a multiline textarea you would need to program chat to replace newlines with <br> before they are sent to the javascript function that prints them to the screen.

Reverting the code back to its original will not fix chat immediatly because the message is still in the db.  You can wait until messages expire or delete them from the table using PhpMyAdmin.
Report to moderator   Logged
Dcoach
Member
*
Offline Offline

Posts: 8


View Profile Email
« Reply #2 on: January 02, 2005, 04:28:19 PM »
Reply with quote

Thanks.  I think I should tell you that i'm very new to Web programming, but I think I get what you are saying.  I have books on PHP, MySQL, HTML, and JAVA, and I've been slogging through them and gradually figuring out how things work.  

As I understand it, when the user clicks on the "Send" button, the data is stored in the MySQL database.  Then some code from somewhere else in the program takes the data out of the MySQL database and ouputs it to the chat window.  (right?)

It looks like this line in new.left.bottom (in the same table row I modified inthe prior message) causes the input message to go to the MySQL database, and also uses JAVA script:

<input type=\"submit\" value=\"$txt[85]\" onClick=\"javascript: setTimeout('dosndmsg()',500)\">

Could I create a function to filter the line breaks from the message, and execute that function here before the text is saved in the messages database? If if it would be better, can you tell me more about how to do what you suggest, to fix the messages before they are displayed?

Can you tell me where to find the code that actually stores the message to MySQL, and the code that takes the messages out of the database and displays them in the chat window?  Any additional advice would be appreciated - I really need to make the larger input box work.

Many thanks...
Report to moderator   Logged
sameer
Guest
« Reply #3 on: January 05, 2005, 02:19:44 PM »
Reply with quote

Try adding something like this to your send.php

Code:
$msg = preg_replace("[\r\n]", "", $msg);

if you put it right under

Code:
if(isset($sent)){
if($msg != ""){

It will treat newlines as if a character has not been entered.  If you want it to actually insert a line break, you'll have to move it after the html parsing and use "<br>" as the second parameter to preg_replace.

- sameer
http://www.yenga.com (http://www.yenga.com)
Report to moderator   Logged
Dcoach
Member
*
Offline Offline

Posts: 8


View Profile Email
« Reply #4 on: January 06, 2005, 05:15:36 PM »
Reply with quote

sameer

thanks so much -
problem solved!
Report to moderator   Logged
Pages: [1] Reply Send this topic Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.11 seconds with 15 queries.