Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="controls">
- <input id="textbox" name="sendtext" class="controls-elements" placeholder="Напишите сообщение и нажмите Enter" type="text"></input>
- <button id="send" onclick="buttonOtprav()" class="controls-elements" type="submit">Отправить</button>
- </div>
- var username = "";
- function send_message(conv,message){
- if (conv.length > 4) {
- conv = conv + "<br>";
- }
- $("#converse").html(conv +"<div class='message-box left-img'><div class='picture'><img src='/my2/a.png' title='user name'></div><div class='mes'><span class = 'current-msg'>" + "<span id='chat-bot'>Бот: </span><p>" + message + "</p></span></div></div>");
- $(".current-msg").hide();
- $(".current-msg").delay(500).fadeIn();
- $(".current-msg").removeClass("current-msg");
- }
- function get_username(conv){
- send_message(conv,"Привет, могу ли я чем то помочь?");
- }
- function ai(conv,message){
- if (username<4) {
- username = message;
- send_message(conv,"Hi, "+ username + ". How are you?");
- }
- else{
- // $("#send").click(function(){
- $.get("getresponse.php", {q:message}, function(data, status){
- // alert("Data: " + data + "nStatus: " + status);
- send_message(conv,data);
- });
- // });
- }
- }
- $(function(){
- var open = false;
- var conv = $("#converse").html();
- get_username(conv);
- $("#send").click(function(){
- var usermsg = $("#textbox").val();
- conv = $("#converse").html();
- console.log(conv.length);
- if (usermsg != "") {
- $("#textbox").val("");
- if (conv.length > 4) {
- conv = conv + "<br>";
- }
- $("#converse").html(conv + "<div class='message-box right-img'><div class='picture'><img src='/my2/user.png' title='user name'></div><div class='mes'><span><span id='chat-user'>Пользователь: </span><p>" + usermsg + "</p></span></div></div>");
- $("#converse").scrollTop($("#converse").prop("scrollHeight"));
- conv = $("#converse").html();
- ai(conv,usermsg);
- }
- });
- $("#chat-button").click(function(){
- $("#chat-box").animate({"right":"0px"});
- });
- $("#cancel").click(function(){
- $("#chat-box").animate({"right":"-300px"});
- });
- });
Add Comment
Please, Sign In to add comment