Guest User

Untitled

a guest
Mar 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <title>Sample Bot</title>
  6. <style language="text/css">
  7. input#userInput {
  8. padding: 4px;
  9. font-size: 1em;
  10. width: calc(100% - 8px);
  11. border: 0;
  12. }
  13.  
  14. input::placeholder {
  15. color: #aaa;
  16. }
  17.  
  18. p.userRequest {
  19. margin: 4px;
  20. margin-right: 0px;
  21. padding: 4px 10px 4px 10px;
  22. min-width: 33%;
  23. max-width: 80%;
  24. font-family: sans-serif;
  25. text-align: right;
  26. float: right;
  27. background-color: #febd69;
  28. }
  29.  
  30. p.Response {
  31. margin: 4px;
  32. margin-left: 0px;
  33. padding: 4px 10px 4px 10px;
  34. font-family: sans-serif;
  35. min-width: 33%;
  36. max-width: 80%;
  37. float: left;
  38. background-color: #232f3e;
  39. color: #fff;
  40. }
  41. .chat-box {
  42. position:fixed;
  43. right:15px;
  44. bottom:0;
  45. width: 256px;
  46. }
  47.  
  48. .chat-closed {
  49. height: 35px;
  50. background: #232f3e;
  51. line-height: 35px;
  52. font-size: 18px;
  53. text-align: center;
  54. border:1px solid #232f3e;
  55. color: #fff;
  56. }
  57.  
  58. .chat-header {
  59. height: 35px;
  60. background: #232f3e;
  61. line-height: 33px;
  62. text-indent: 12px;
  63. border:1px solid #232f3e;
  64. border-bottom:none;
  65. color: #fff;
  66. }
  67.  
  68. .chat-content{
  69. height:300px;
  70. background:#ffffff;
  71. border:1px solid #232f3e;
  72. overflow-y:auto;
  73. word-wrap: break-word;
  74. }
  75.  
  76. .chat-body {
  77. height: 272px;
  78. background-color: #eee;
  79. overflow: scroll;
  80. overflow-x: hidden;
  81. }
  82.  
  83. #chatform {
  84. margin: 0;
  85. padding: 0;
  86. }
  87.  
  88. .clear {
  89. clear: both;
  90. }
  91. .hide {
  92. display:none;
  93. }
  94. </style>
  95. </head>
  96.  
  97. <body onload="greet()">
  98. <h1 style="text-align: left">Bot Interface</h1>
  99. <div class="chat-box">
  100. <div id="header" class="chat-header" onclick="toggle()">Online Support</div>
  101. <div id="content" class="chat-content hide">
  102. <div id="conversation" class="chat-body"></div>
  103. <form id="chatform" onsubmit="return pushChat();">
  104. <input type="text" id="userInput" size="80" value="" placeholder="Ask me anything">
  105. </form>
  106. </div>
  107. <div>
  108. </body>
  109. <script type="text/javascript">
  110. function toggle() {
  111. content = document.getElementById("content");
  112. content.classList.toggle("hide");
  113. }
  114.  
  115. function greet(){
  116. showResponse("Hi!, How can i help you?");
  117. }
  118. function pushChat() {
  119. var inputText = document.getElementById('userInput');
  120. if (inputText && inputText.value && inputText.value.trim().length > 0) {
  121.  
  122. var input = inputText.value.trim();
  123. inputText.value = '...';
  124. showRequest(input);
  125. inputText.locked = false;
  126. inputText.value = '';
  127. showResponse("Response");
  128. }
  129. return false;
  130. }
  131.  
  132. function showRequest(daText) {
  133.  
  134. var conversationDiv = document.getElementById('conversation');
  135. var requestPara = document.createElement("P");
  136. var clear = document.createElement("div");
  137. clear.classList.add("clear");
  138. requestPara.className = 'userRequest';
  139. requestPara.appendChild(document.createTextNode(daText));
  140. conversationDiv.appendChild(requestPara);
  141. conversationDiv.appendChild(clear);
  142. conversationDiv.scrollTop = conversationDiv.scrollHeight;
  143. }
  144.  
  145. function showResponse(Response) {
  146.  
  147. var conversationDiv = document.getElementById('conversation');
  148. var responsePara = document.createElement("P");
  149. responsePara.className = 'Response';
  150. if (Response) {
  151. responsePara.appendChild(document.createTextNode(Response));
  152. responsePara.appendChild(document.createElement('br'));
  153. }
  154. var clear = document.createElement("div");
  155. clear.classList.add("clear");
  156. conversationDiv.appendChild(responsePara);
  157. conversationDiv.appendChild(clear);
  158. conversationDiv.scrollTop = conversationDiv.scrollHeight;
  159. }
  160. </script>
  161.  
  162. </html>
Add Comment
Please, Sign In to add comment