Advertisement
Guest User

chathtml

a guest
Oct 30th, 2024
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Chat Interface</title>
  7. <style>
  8. body {
  9. font-family: Arial, sans-serif;
  10. background-color: #f0f0f0;
  11. display: flex;
  12. justify-content: center;
  13. align-items: center;
  14. height: 100vh;
  15. margin: 0;
  16. }
  17. .chat-container {
  18. background-color: #fff;
  19. border: 1px solid #ccc;
  20. border-radius: 10px;
  21. padding: 20px;
  22. width: 300px;
  23. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  24. }
  25. .chat-container h2 {
  26. margin-top: 0;
  27. }
  28. .message-box {
  29. width: 100%;
  30. height: 100px;
  31. margin-bottom: 10px;
  32. padding: 10px;
  33. border: 1px solid #ccc;
  34. border-radius: 5px;
  35. }
  36. .send-button {
  37. width: 100%;
  38. padding: 10px;
  39. background-color: #007bff;
  40. color: #fff;
  41. border: none;
  42. border-radius: 5px;
  43. cursor: pointer;
  44. }
  45. .send-button:hover {
  46. background-color: #0056b3;
  47. }
  48. .chat-log {
  49. height: 200px;
  50. overflow-y: auto;
  51. margin-bottom: 10px;
  52. border: 1px solid #ccc;
  53. padding: 10px;
  54. border-radius: 5px;
  55. background-color: #f9f9f9;
  56. }
  57. .chat-log p {
  58. margin: 0;
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <div class="chat-container">
  64. <h2>Chat</h2>
  65. <div class="chat-log" id="chat-log"></div>
  66. <textarea class="message-box" id="message-box" placeholder="Type your message here..."></textarea>
  67. <button class="send-button" onclick="sendMessage()">Send</button>
  68. </div>
  69.  
  70. <script>
  71. const chatLog = document.getElementById('chat-log');
  72. const messageBox = document.getElementById('message-box');
  73.  
  74. function sendMessage() {
  75. const message = messageBox.value;
  76. if (message.trim() !== '') {
  77. // Display the message in the chat log
  78. const userMessage = document.createElement('p');
  79. userMessage.textContent = 'You: ' + message;
  80. chatLog.appendChild(userMessage);
  81.  
  82. // Send the message to the Flipper Zero (this part needs to be implemented)
  83. console.log('Message sent:', message);
  84.  
  85. // Clear the message box
  86. messageBox.value = '';
  87.  
  88. // Simulate receiving a response from the Flipper Zero
  89. setTimeout(() => {
  90. const flipperResponse = document.createElement('p');
  91. flipperResponse.textContent = 'Flipper: ' + 'Response to "' + message + '"';
  92. chatLog.appendChild(flipperResponse);
  93. }, 1000);
  94. }
  95. }
  96.  
  97. // Function to receive messages from the Flipper Zero
  98. function receiveMessage(message) {
  99. const flipperResponse = document.createElement('p');
  100. flipperResponse.textContent = 'Flipper: ' + message;
  101. chatLog.appendChild(flipperResponse);
  102. }
  103.  
  104. // Example of receiving a message (this part needs to be replaced with actual implementation)
  105. setTimeout(() => {
  106. receiveMessage('Hello from Flipper Zero!');
  107. }, 2000);
  108. </script>
  109. </body>
  110. </html>
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement