#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Visakhapatnam
    Posts
    11
    Rep Power
    0

    Emotions for chat


    Hello all,hw r u? Recently i have done chat module withphp,mysql,javascript and jquery.Chat module is working correctly.Now i want to insert emotions.I have tried and its working in weird manner.Anyone plz help...
    mail me il mail u d scripts so that you can understand.
    Thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    Post the script here. That is what this form is for. Be sure to read ManiacDan's New User Guide first.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Visakhapatnam
    Posts
    11
    Rep Power
    0
    Originally Posted by gw1500se
    Post the script here. That is what this form is for. Be sure to read ManiacDan's New User Guide first.
    Hi if u dnt mind can i mail u my scripts??
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    please use standard English, this "chat speak" is really hard to read -- at least for non-native speakers. Kthx.

    And he just told you to post the code. Or upload it somewhere and post the link (you have to obfuscate the URL).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Visakhapatnam
    Posts
    11
    Rep Power
    0
    Originally Posted by Jacques1
    Hi,

    please use standard English, this "chat speak" is really hard to read -- at least for non-native speakers. Kthx.

    And he just told you to post the code. Or upload it somewhere and post the link (you have to obfuscate the URL).
    Thank you.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Location
    Visakhapatnam
    Posts
    11
    Rep Power
    0

    my code


    Originally Posted by mohnish
    Hi if u dnt mind can i mail u my scripts??
    Hello here is my script,please check once and correct me.
    PHP Code:
    <?php include("connection.php"); ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">

    .chatbox
    {
    border:2px solid #990000;
    height:220px;
    width:450px;
    overflow-y: auto;
    }
    .textbox
    {
    min-height:35px;
    border:2px solid #666666;
    width:450px;
    margin-top:-14px;
    }
    </style>
    <script type="text/javascript" src="js/jquery-latest.js"></script>
    <script type="text/javascript" >
    //$(document).ready(function()
    //{
    //      $("#chat").emotions();
    //});
    function smile_display(e)
    {
            if (e.keyCode == 13)
        {
            SmileyConvert();
        }
    }
    function SmileyConvert()
    {
      //alert('hi');
      var text = document.getElementById('tarea').value;
      //alert(text);
      text = text.replace(':D', '<img src="emotions/grin.gif" border="0">');
      text = text.replace('o:)', '<img src="emotions/angel.gif" border="0">');
      text = text.replace(':3', '<img src="emotions/colonthree.gif" border="0">');
      
      text = text.replace("\n", '<br>');  // How to globally replace this character ???
      document.getElementById('chat').innerHTML = text;
    }


    //var refreshId = setInterval(function()
    //{
    //    $('#chat').emotions();
    //    $('#chat').load('refreshd.php');        
    //}, 5000);

    var user;
    function user(a)
    {
      user=a;
      document.getElementById("usr").innerHTML="you login as "+a;
    }
    function smiles(e)
    {
       //alert(event.keyCode);
        if(e.keyCode == 13)
        {
           if((user!="user1")&&(user!="user2"))
           {
             alert("please login");
             return false;
           }
           var content=document.getElementById('tarea').value;
           if(content!="")
           {
            // document.getElementById('tarea').value="";
             $.ajax({type:"post",cache:false,url:"insert.php",data:"cont="+content+"&user="+user,success:function(html)
                                                                                 {
                                                                                   //$('#chat').html(html);
                                                                                   $("#chat").scrollTop = $("#chat").scrollHeight; 
                                                                                 }
                });
           }
        }
        else
        {
          return false;
        }
    }
    function insertSmiley(smiley)
    {
       document.getElementById("tarea").value=document.getElementById("tarea").value+smiley;
       tarea.focus();


    </script>
    </head>

    <body>

    <div id="usr">u want to login as :<input type="button" value="user1" onClick="user('user1')" />
                                      <input type="button" value="user2" onClick="user('user2')" /></div>
    <div id="chat" class="chatbox">
    <table cellpadding="4px" >
    <?php
    $chatdata
    =mysql_query("select * from (select * from chatdata order by id desc limit 13) AS T1 order by id asc");
    while(
    $chatdata_exe=mysql_fetch_array($chatdata))
    {
      echo 
    "<tr><td>".$chatdata_exe['user']." </td><td>:</td><td style='word-break:break-all;'>".$chatdata_exe['data']."</td></tr>";
    }
    ?>
    </table>
    </div>

    <table>
     <tr><td> 
       <input type="text" class="textbox" id="tarea" onKeyPress="smiles(event);" onKeyUp="smile_display(event);" value="" />
     </td><td>
            <table>
            <tr>
                    <td><img src='emotions/grin.gif'  onclick="insertSmiley(':D')" /></td>
                    <td><img src="emotions/angel.gif" onClick="insertSmiley('o:)')" /></td>
                    <td><img src="emotions/colonthree.gif" onClick="insertSmiley(':3')" /></td>
                    <td><img src="emotions/confused.gif" onClick="insertSmiley('o.O')" /></td>
                </tr>
                <tr>    
                    <td><img src="emotions/cry.gif" onClick="insertSmiley(':'(')" /></td>
                    <td><img src="emotions/devil.gif" onClick="insertSmiley('3:)')" /></td>
                    <td><img src="emotions/pacman.gif" onClick="insertSmiley(':v')" /></td>
                    <td><img src="emotions/gasp.gif" onClick="insertSmiley(':O')" /></td>
                </tr>
                <tr>    
                    <td><img src="emotions/glasses.gif" onClick="insertSmiley('8)')" /></td>
                    <td><img src="emotions/grumpy.gif" onClick="insertSmiley('^_^')" /></td>
                    <td><img src="emotions/heart.gif" onClick="insertSmiley('<3')" /></td>
                    <td><img src="emotions/wink.gif" onClick="insertSmiley(';)')" /></td>
                </tr>
            </table>
    </td></tr>
    </table>
    </body>
    </html>
    [[ Almost got that. To show PHP code, paste your code into the text editor, select it, and hit the button. --requinix
    Last edited by requinix; February 2nd, 2013 at 01:59 AM.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,623
    Rep Power
    595
    Is it generating the output you expect? The only thing I see wrong at the moment is that you are using the deprecated MySQL extensions. You should be using PDO.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo