-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
115 lines (104 loc) · 2.92 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>dewsdwsd</title>
<style>
.chatbot-container {
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
font-family: Arial, sans-serif;
max-width: 500px;
margin: 0 auto;
}
.chatbot-header {
background-color: #337ab7;
color: white;
padding: 10px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
}
.chatbot-dialogue {
height: 300px;
overflow-y: scroll;
padding: 10px;
}
.chatbot-message {
margin-bottom: 10px;
}
.chatbot-message p {
margin: 0;
padding: 8px;
border-radius: 5px;
}
.received {
background-color: #f1f1f1;
}
.sent {
background-color: #337ab7;
color: white;
text-align: right;
}
.chatbot-input {
display: flex;
padding: 10px;
justify-content: space-between;
}
.chatbot-input input {
flex: 1;
margin-right: 10px;
padding: 10px;
border-radius: 5px;
border: none;
}
.chatbot-input button {
padding: 10px;
border-radius: 5px;
border: none;
background-color: #337ab7;
color: white;
cursor: pointer;
}
</style>
</head>
<body>
<div class="chatbot-container">
<div class="chatbot-header">
<h3>ربات چت</h3>
</div>
<div class="chatbot-dialogue">
<div class="chatbot-message received">
<p>سلام! چطور میتوانم به شما کمک کنم؟</p>
</div>
<div class="chatbot-message sent">
<p>من میخواهم بدانم که آیا شما میتوانید به من کمک کنید؟</p>
</div>
</div>
<div class="chatbot-input">
<input type="text" placeholder="نوشتن پیام ..." />
<button>ارسال</button>
</div>
</div>
<script>
const chatbotDialogue = document.querySelector('.chatbot-dialogue');
const chatbotInput = document.querySelector('.chatbot-input input');
function sendMessage(message, sender) {
const messageDiv = document.createElement('div');
messageDiv.classList.add('chatbot-message', sender);
messageDiv.innerHTML = `<p>${message}</p>`;
chatbotDialogue.appendChild(messageDiv);
}
chatbotInput.addEventListener('keydown', function(event) {
if (event.keyCode === 13) {
const message = event.target.value;
sendMessage(message, 'sent');
event.target.value = '';
// send message to backend and get response
const response = 'پیام شما دریافت شد!';
sendMessage(response, 'received');
}
});
</script>
</body>
</html>