< >

zitate-zum-chat-hinzufugen.php


Quell Code


<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <style>
      button{
  width:22px;
  height:22px;
  border:1px solid red;
  border-radius:50%;
}

.zit{
  background:grey;
  border:2px solid orange;
  display:block;
}
h5{
  margin:0;
  padding:0;
}
#chat{
  margin-top:50px;
}
.text::selection{
  background:blue;
}
.messages{
  border:1px solid black;
  display:flex;
  margin:10px 0;
  padding:5px;
  flex-direction:column;
}
.oben{
  display:flex;
}
.chat_zitate:hover:after{
  content:'kompletten Text makieren für Zitat';
  display:block;
  width:200px;
  background:black;
  color:white;
  top:-50px;

  position:relative;
}

.chat_zitate:hover{
    cursor:pointer;
}
textarea,#senden{
  width:60%;
  margin-left:20%;
  margin-top:20px;
}

    </style>
    <title></title>
  </head>
<body>
  <h1>Chat</h1>
  <input type="hidden" id="chat1">
    <input type="hidden" id="chat2">
<div id="chat">
  
  
    <div class="messages">
      <div class="oben">
           <button class="chat_zitate">Z</button><div class="user" id="user-peter">Peter</div>
      </div>
      <div class="unten">
           <div class="text">hallo Werner alles klar</div>
      </div>
    </div>
    <div class="messages">
      <div class="oben">
           <button class="chat_zitate">Z</button><div class="user" id="user-werner">Werner</div>
      </div>
      <div class="unten">
           <div class="text">Ja Peter alles bestens</div>
      </div>
    </div>
  
  
  <?php
  if(isset($_POST['text'])){
  
function bbc2html($tmpText){
 /*[b]*/ $tmpText = preg_replace('#\[b\](.*)\[/b\]#isU', '<b>$1</span>', $tmpText);
 /*[i]*/ $tmpText = preg_replace('#\[i\](.*)\[/i\]#isU', '<i>$1</span>', $tmpText);
 /*[u]*/ $tmpText = preg_replace('#\[u\](.*)\[/u\]#isU', '<span style="text-decoration:underline">$1</span>', $tmpText);
 /*[color]*/ $tmpText = preg_replace('#\[ZITAT=(.*)\](.*)\[\/ZITAT\]#isU', '<span class="zit"><h5>$1</h5>$2</span>', $tmpText);
 /*[size] */ $tmpText = preg_replace('#\[size=([0-9]{1,2})\](.*)\[\/size\]#isU', '<span style="font-size:$1px;">$2</span>', $tmpText);
 /*[font] */ $tmpText = preg_replace('#\[font=(.*)\](.*)\[\/font\]#isU', '<span style="font-family:$1;">$2</span>', $tmpText);
 /*[url]*/ $tmpText = preg_replace('#\[url=(.*)\](.*)\[\/url\]#isU', '<a href="$1">$2</a>', $tmpText);
 /*[url]*/ $tmpText = preg_replace('#\[url\](.*)\[\/url\]#isU', '<a href="$1">$1</a>', $tmpText);
 /*[img]*/ $tmpText = preg_replace('#\[img\](.*)\[\/img\]#isU', '<img src="$1" alt="Bild" />', $tmpText);
 /*[center]*/ $tmpText = preg_replace('#\[center\](.*)\[\/center\]#isU', '<div style="text-align:center">$1</div>', $tmpText);
 /*[right] */ $tmpText = preg_replace('#\[right\](.*)\[\/right\]#isU', '<div style="text-align:right">$1</div>', $tmpText);
  return $tmpText;
}
$te=$_POST['text'];
  $text=bbc2html($te);
  $user=$_POST['user'];
echo "<div class='messages'>
  <div class= 'oben'>   <button class='chat_zitate'>Z</button>
  <div class='user' id='user-basti'>$user</div>
  </div>
  <div class='unten'><div class='text'>$text</div>
  </div>
  </div>";
  
  
  
  }
  ?>
  
  
</div>
<form method="POST">
<p>Dein name :<input type="text" name="user" value="basti1012">
  <textarea name="text" id="text_area" ></textarea> 
       <input type="submit" name="senden" value="senden">
  </form>
<script>
$('title').html('hallo neuer Titke');
function start(){

$('.messages .text').mousedown(function(e){ 
  user=$(this).parent().parent().children().children().next().html();
  dest1 = e.pageX;  
  p=0;
  //   console.log('START'+dest1); 
  $('.messages .text').on('click',function(r){ 
         var dest2 = r.pageX;     
         console.log('ENDE'+dest2);   
         var jj=dest1-dest2;     
         if(jj<=3){    
           console.log('Zu wennig makiert');
         }        
         if(jj>=4){        
              console.log('Fired= Minimum: '+dest1+'Ist: '+jj+' Maximum:  '+dest2)    
              tool()     
         }else{      
         }   
     });
     function tool(){   
          if (document.getSelection){      
              txt = document.getSelection();    
              toolaus(txt);   
          }else if (document.selection){
              txt = document.selection.createRange().text;     
              toolaus(txt);
          }else{}   
          function toolaus(txt){   
            p++;
            if(p==1){
               var vorhanden_inhalt=$('#text_area').val();
               $('#text_area').val(vorhanden_inhalt+' [ZITAT='+user+']'+txt+'[/ZITAT]');  
              

            }
            //document.execCommand("copy");
         } 
     }
   });
 
$('.chat_zitate').click(function(){
        user=$(this).next().html();
        txt=$(this).parent().next().children().html();
        $(this).parent().next().children().css('background','red')
        var vorhanden_inhalt=$('#text_area').val();
        $('#text_area').val(vorhanden_inhalt+' [ZITAT='+user+']'+txt+'[/ZITAT]');
});
}


/*
$('#senden').click(function(){
    $('.text').css('background','none');
    var inhalttextarea=$('#text_area').val();
    var inhalttextarea1=$('#chat2').val();
    $('#text_area').val('');
    //var chatin=$('#chat').html();
    //$('#chat').html(chatin+"<div class='messages'><div class= 'oben'>   <button class='chat_zitate'>Z</button><div class='user' id='user-basti'>basti</div></div><div class='unten'><div class='text'>"+inhalttextarea+"</div></div></div>"); 
  

       $.ajax({
         type: 'POST',
             url: 'chat_rquest.php',
             data: {inhalttextarea:inhalttextarea},
             success: function(data){ 
                 if(data==1){
                     chat_holen(chatname);
                 }
             }
     });
  
 
  
  
  //setTimeout(function(){
  //start();
  //},2500);
})

  
 */
start()

</script>
</body>
</html>