Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.     $DataBase = new DataBase();
  3.     $User = new User($DataBase->con);
  4.    
  5.     if (!$User->IsLogged()) header("Location: /login");
  6.     $UName = $User->GetNume($_COOKIE['uid']);
  7. ?>
  8. <html>
  9. <head>
  10. <script type="text/javascript" src="../loadjs/jquery"></script>
  11.         <script type="text/javascript">
  12.         jQuery(document).ready(function($) {
  13.             $("#send").click(function () {
  14.                 SendMessage();
  15.                 $("#mesaj").focus();
  16.             });
  17.  
  18.             $('#mesaj').bind('keypress', function(e) {
  19.                 var code = (e.keyCode ? e.keyCode : e.which);
  20.                 if(code == 13) {
  21.                     SendMessage();
  22.                 }
  23.             });
  24.  
  25.             $("#smiles img").click(function () {
  26.                 $("#mesaj").val($("#mesaj").val()+" "+$(this).attr("data-code"));
  27.                 $("#mesaj").focus();
  28.             });
  29.  
  30.             $('#user').live('click', function() {
  31.                 $("#mesaj").val($("#mesaj").val()+" ["+$(this).text()+"] ");
  32.                 $("#mesaj").focus();
  33.             });
  34.  
  35.             Update();
  36.         });
  37.  
  38.         function SendMessage() {
  39.             var mess = $("#mesaj").val();
  40.             if (mess.length > 1) {
  41.                 $("#mesaj").val("");
  42.                 $.post("ajax/chat/send", { mesaj : mess }, function (data) {
  43.                     $("#messages").html(data.messages);
  44.                     $("#online").html(data.online);
  45.                     ShowSmiles();
  46.                 }, "json");
  47.             }
  48.         }
  49.  
  50.         function Update() {
  51.             $.post("ajax/chat/update", { process: 'update' }, function(data) {
  52.                 $("#messages").html(data.messages);
  53.                 $("#online").html(data.online);
  54.                 ShowSmiles();
  55.                 setTimeout(function () {
  56.                     Update();
  57.                 },2000);
  58.             }, "json");
  59.         }
  60.  
  61.         function ShowSmiles() {
  62.             $("#smiles img").each(function () {
  63.                 $("#messages").html(
  64.                     $("#messages").html().split($(this).attr('data-code')).join($(this)[0].outerHTML)
  65.                 );
  66.             });
  67.             $("#messages").html(
  68.                 $("#messages").html().split("[<?=$UName?>]").join("<span id=\"foryou\"><?=$UName?></span>, ")
  69.             );
  70.             $("#messages").scrollTop($("#messages")[0].scrollHeight);
  71.         }
  72.         </script>
  73.  
  74.         <style type="text/css">
  75.             body {
  76.                 font-family: Tahoma;
  77.                 font-size: 13px;
  78.             }
  79.  
  80.             #chat {
  81.                 width: 700px;
  82.                 height: 500px;
  83.             }
  84.  
  85.             #messages, #online {
  86.                 margin: 5px;
  87.                 border: 1px solid #888;
  88.                 padding: 10px;
  89.                 overflow-x:auto;
  90.                 float: left;
  91.                 height: 300px;
  92.                 background: rgba(255,255,255,0.5);
  93.             }
  94.  
  95.             #smiles {
  96.                 margin: 5px;
  97.                 width: 700px;
  98.             }
  99.  
  100.             #smiles img, #user {
  101.                 cursor: pointer;
  102.             }
  103.  
  104.             #messages {
  105.                 width: 500px;
  106.             }
  107.  
  108.             #online {
  109.                 width: 130px;
  110.             }
  111.  
  112.             #mesaj {
  113.                 width: 523px;
  114.                 margin: 5px;
  115.                 height: 30px;
  116.                 font-size: 20px;
  117.                 padding-left: 5px;
  118.             }
  119.  
  120.             #send {
  121.                 height: 30px;
  122.                 width: 150px;
  123.             }
  124.  
  125.             #foryou {
  126.                 color: red;
  127.             }
  128.         </style>
  129.     </head>
  130.     <body>
  131.         <div id="chat">
  132.             <div id="messages">Loading</div>
  133.             <div id="online">Loading</div>
  134.             <div id="smiles">
  135.                 <img src="/template/img/smilies/smile.gif" data-code=":)" alt="Bucuros">
  136.                 <img src="/template/img/smilies/sad.gif" data-code=":(" alt="Mahnit">
  137.                 <img src="/template/img/smilies/cry.gif" data-code=":'-(" alt="Pling">
  138.                 <img src="/template/img/smilies/acute.gif" data-code=":acute:" alt="Mai mai mai...">
  139.                 <img src="/template/img/smilies/aggressive.gif" data-code=":aggressive:" alt="Bataie">
  140.                 <img src="/template/img/smilies/airkiss.gif" data-code=":airkiss:" alt="Te pup">
  141.                 <img src="/template/img/smilies/ae.gif" data-code=":ae:" alt="Iuhuuu!">
  142.                 <img src="/template/img/smilies/blum3.gif" data-code=":blum3:" alt="Limbuta">
  143.                 <img src="/template/img/smilies/bounce.gif" data-code=":bounce:" alt="Opa!">
  144.                 <img src="/template/img/smilies/bravo.gif" data-code=":bravo:" alt="Bravo">
  145.                 <img src="/template/img/smilies/beer2.gif" data-code=":beer:" alt="O bere de la mine!">
  146.                 <img src="/template/img/smilies/cake.gif" data-code=":cake:" alt="Felicitari!">
  147.                 <img src="/template/img/smilies/crazy.gif" data-code=":crazy:" alt="Nebun">
  148.                 <img src="/template/img/smilies/crybaby.gif" data-code=":cry:" alt="Pling in hohote">
  149.                 <img src="/template/img/smilies/eyebrow.gif" data-code=":serios:" alt="Serios?">
  150.             </div>
  151.             <input type="text" placeholder="Mesaj..." id="mesaj"/>
  152.             <button id="send">Trimite</button>
  153.         </div>
  154.     </body>
  155. </html>