Update index.html
Browse files- index.html +262 -261
index.html
CHANGED
@@ -1,284 +1,285 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html dir="rtl" lang="ar">
|
3 |
<head>
|
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 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
139 |
</head>
|
140 |
<body>
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
</div>
|
164 |
-
<div class="chat-box" id="chatBox">
|
165 |
-
<div class="typing-indicator" id="typingIndicator">جاري الكتابة...</div>
|
166 |
-
</div>
|
167 |
-
<div class="input-container">
|
168 |
-
<input type="text" id="userInput" placeholder="اكتب سؤالك هنا..." onkeypress="handleKeyPress(event)">
|
169 |
-
<button id="sendButton" onclick="sendMessage()">
|
170 |
-
<i class="fas fa-paper-plane"></i> إرسال
|
171 |
-
</button>
|
172 |
-
</div>
|
173 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
async function sendToAPI(message) {
|
206 |
-
const sendButton = document.getElementById('sendButton');
|
207 |
-
const userInput = document.getElementById('userInput');
|
208 |
-
const typingIndicator = document.getElementById('typingIndicator');
|
209 |
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
typingIndicator.style.display = 'block';
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
body: JSON.stringify({
|
222 |
-
message: message
|
223 |
-
})
|
224 |
-
});
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
|
230 |
-
|
231 |
-
|
|
|
232 |
|
233 |
-
|
234 |
-
|
235 |
-
if (done) break;
|
236 |
-
|
237 |
-
const chunk = new TextDecoder().decode(value);
|
238 |
-
accumulatedResponse += chunk;
|
239 |
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
addMessage('عذراً، حدث خطأ في الاتصال. يرجى المحاولة مرة أخرى.', 'bot-message');
|
247 |
-
} finally {
|
248 |
-
isWaitingForResponse = false;
|
249 |
-
sendButton.disabled = false;
|
250 |
-
userInput.disabled = false;
|
251 |
-
typingIndicator.style.display = 'none';
|
252 |
-
}
|
253 |
}
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
263 |
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
}
|
273 |
-
|
274 |
-
lastBotMessage.textContent = text;
|
275 |
-
chatBox.scrollTop = chatBox.scrollHeight;
|
276 |
-
}
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
283 |
</body>
|
284 |
-
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html dir="rtl" lang="ar">
|
3 |
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>مكتبة أستاذ ريمون - دردشة مباشرة</title>
|
7 |
+
<!-- تم تصحيح وسم الربط بإضافة علامة الاقتباس والنهاية -->
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
:root {
|
11 |
+
--primary-color: #1a237e;
|
12 |
+
--secondary-color: #283593;
|
13 |
+
--accent-color: #3949ab;
|
14 |
+
--background-light: #e8eaf6;
|
15 |
+
--text-color: #121212;
|
16 |
+
}
|
17 |
+
|
18 |
+
body {
|
19 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
20 |
+
margin: 0;
|
21 |
+
padding: 20px;
|
22 |
+
background-color: #f0f2f5;
|
23 |
+
}
|
24 |
+
.chat-container {
|
25 |
+
max-width: 800px;
|
26 |
+
margin: 0 auto;
|
27 |
+
background: white;
|
28 |
+
border-radius: 15px;
|
29 |
+
box-shadow: 0 2px 15px rgba(0,0,0,0.1);
|
30 |
+
padding: 20px;
|
31 |
+
}
|
32 |
+
.header {
|
33 |
+
text-align: center;
|
34 |
+
margin-bottom: 20px;
|
35 |
+
padding: 15px;
|
36 |
+
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
|
37 |
+
color: white;
|
38 |
+
border-radius: 10px;
|
39 |
+
position: relative;
|
40 |
+
}
|
41 |
+
.header h1 {
|
42 |
+
margin: 0;
|
43 |
+
font-size: 24px;
|
44 |
+
}
|
45 |
+
.customer-service-icon {
|
46 |
+
position: absolute;
|
47 |
+
left: 20px;
|
48 |
+
top: 50%;
|
49 |
+
transform: translateY(-50%);
|
50 |
+
font-size: 2.5em;
|
51 |
+
color: #fff;
|
52 |
+
}
|
53 |
+
.chat-box {
|
54 |
+
height: 400px;
|
55 |
+
overflow-y: auto;
|
56 |
+
border: 1px solid #ddd;
|
57 |
+
padding: 15px;
|
58 |
+
margin-bottom: 20px;
|
59 |
+
border-radius: 8px;
|
60 |
+
background-color: var(--background-light);
|
61 |
+
}
|
62 |
+
.input-container {
|
63 |
+
display: flex;
|
64 |
+
gap: 10px;
|
65 |
+
margin-bottom: 10px;
|
66 |
+
}
|
67 |
+
input {
|
68 |
+
flex: 1;
|
69 |
+
padding: 12px;
|
70 |
+
border: 2px solid var(--primary-color);
|
71 |
+
border-radius: 8px;
|
72 |
+
font-size: 16px;
|
73 |
+
background-color: white;
|
74 |
+
}
|
75 |
+
button {
|
76 |
+
padding: 12px 25px;
|
77 |
+
background-color: var(--primary-color);
|
78 |
+
color: white;
|
79 |
+
border: none;
|
80 |
+
border-radius: 8px;
|
81 |
+
cursor: pointer;
|
82 |
+
font-weight: bold;
|
83 |
+
transition: background-color 0.3s ease;
|
84 |
+
}
|
85 |
+
button:hover {
|
86 |
+
background-color: var(--accent-color);
|
87 |
+
}
|
88 |
+
button:disabled {
|
89 |
+
background-color: #cccccc;
|
90 |
+
cursor: not-allowed;
|
91 |
+
}
|
92 |
+
.message {
|
93 |
+
margin-bottom: 12px;
|
94 |
+
padding: 12px;
|
95 |
+
border-radius: 8px;
|
96 |
+
max-width: 80%;
|
97 |
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
98 |
+
white-space: pre-wrap;
|
99 |
+
}
|
100 |
+
.user-message {
|
101 |
+
background-color: #fff;
|
102 |
+
margin-left: 20%;
|
103 |
+
border-right: 4px solid var(--accent-color);
|
104 |
+
}
|
105 |
+
.bot-message {
|
106 |
+
background-color: #fff;
|
107 |
+
margin-right: 20%;
|
108 |
+
border-left: 4px solid var(--primary-color);
|
109 |
+
}
|
110 |
+
.faq-container {
|
111 |
+
display: grid;
|
112 |
+
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
|
113 |
+
gap: 10px;
|
114 |
+
margin-bottom: 15px;
|
115 |
+
}
|
116 |
+
.faq-button {
|
117 |
+
background-color: var(--background-light);
|
118 |
+
border: 1px solid var(--primary-color);
|
119 |
+
padding: 10px;
|
120 |
+
border-radius: 5px;
|
121 |
+
cursor: pointer;
|
122 |
+
transition: all 0.3s ease;
|
123 |
+
font-weight: bold;
|
124 |
+
color: var(--primary-color);
|
125 |
+
}
|
126 |
+
.faq-button:hover {
|
127 |
+
background-color: var(--primary-color);
|
128 |
+
color: white;
|
129 |
+
}
|
130 |
+
.typing-indicator {
|
131 |
+
display: none;
|
132 |
+
margin-bottom: 12px;
|
133 |
+
padding: 12px;
|
134 |
+
border-radius: 8px;
|
135 |
+
max-width: 80%;
|
136 |
+
margin-right: 20%;
|
137 |
+
background-color: #f0f0f0;
|
138 |
+
}
|
139 |
+
</style>
|
140 |
</head>
|
141 |
<body>
|
142 |
+
<div class="chat-container">
|
143 |
+
<div class="header">
|
144 |
+
<i class="fas fa-headset customer-service-icon"></i>
|
145 |
+
<h1>مكتبة أستاذ ريمون</h1>
|
146 |
+
<p>خدمة العملاء - متوفرين على مدار الساعة</p>
|
147 |
+
</div>
|
148 |
+
<div class="faq-container">
|
149 |
+
<button class="faq-button" onclick="askFAQ('اسعار الورق')">
|
150 |
+
<i class="fas fa-file-alt"></i> أسعار الورق
|
151 |
+
</button>
|
152 |
+
<button class="faq-button" onclick="askFAQ('تحدث عن مكتبتك التي اسمها مكتبة استاذ ريمون')">
|
153 |
+
<i class="fas fa-store"></i> عن المكتبة
|
154 |
+
</button>
|
155 |
+
<button class="faq-button" onclick="askFAQ('قائمة المنتجات')">
|
156 |
+
<i class="fas fa-list"></i> قائمة المنتجات
|
157 |
+
</button>
|
158 |
+
<button class="faq-button" onclick="askFAQ('عروضكم')">
|
159 |
+
<i class="fas fa-percentage"></i> العروض
|
160 |
+
</button>
|
161 |
+
<button class="faq-button" onclick="askFAQ('طرق الدفع')">
|
162 |
+
<i class="fas fa-credit-card"></i> طرق الدفع
|
163 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
</div>
|
165 |
+
<div class="chat-box" id="chatBox">
|
166 |
+
<div class="typing-indicator" id="typingIndicator">جاري الكتابة...</div>
|
167 |
+
</div>
|
168 |
+
<div class="input-container">
|
169 |
+
<input type="text" id="userInput" placeholder="اكتب سؤالك هنا..." onkeypress="handleKeyPress(event)">
|
170 |
+
<button id="sendButton" onclick="sendMessage()">
|
171 |
+
<i class="fas fa-paper-plane"></i> إرسال
|
172 |
+
</button>
|
173 |
+
</div>
|
174 |
+
</div>
|
175 |
|
176 |
+
<script>
|
177 |
+
const API_URL = 'https://g2mgow5tgbxsjy-7777.proxy.runpod.net/proxy/4000/chat/stream';
|
178 |
+
let isWaitingForResponse = false;
|
179 |
|
180 |
+
function handleKeyPress(event) {
|
181 |
+
if (event.key === 'Enter' && !isWaitingForResponse) {
|
182 |
+
sendMessage();
|
183 |
+
}
|
184 |
+
}
|
185 |
|
186 |
+
function askFAQ(question) {
|
187 |
+
if (!isWaitingForResponse) {
|
188 |
+
addMessage(question, 'user-message');
|
189 |
+
sendToAPI(question);
|
190 |
+
}
|
191 |
+
}
|
192 |
|
193 |
+
async function sendMessage() {
|
194 |
+
if (isWaitingForResponse) return;
|
195 |
|
196 |
+
const input = document.getElementById('userInput');
|
197 |
+
const message = input.value.trim();
|
198 |
+
|
199 |
+
if (message) {
|
200 |
+
addMessage(message, 'user-message');
|
201 |
+
input.value = '';
|
202 |
+
await sendToAPI(message);
|
203 |
+
}
|
204 |
+
}
|
|
|
|
|
|
|
|
|
|
|
205 |
|
206 |
+
async function sendToAPI(message) {
|
207 |
+
const sendButton = document.getElementById('sendButton');
|
208 |
+
const userInput = document.getElementById('userInput');
|
209 |
+
const typingIndicator = document.getElementById('typingIndicator');
|
|
|
210 |
|
211 |
+
try {
|
212 |
+
isWaitingForResponse = true;
|
213 |
+
sendButton.disabled = true;
|
214 |
+
userInput.disabled = true;
|
215 |
+
typingIndicator.style.display = 'block';
|
|
|
|
|
|
|
|
|
216 |
|
217 |
+
const response = await fetch(API_URL, {
|
218 |
+
method: 'POST',
|
219 |
+
headers: {
|
220 |
+
'Content-Type': 'application/json',
|
221 |
+
},
|
222 |
+
body: JSON.stringify({
|
223 |
+
message: message
|
224 |
+
})
|
225 |
+
});
|
226 |
|
227 |
+
if (!response.ok) {
|
228 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
229 |
+
}
|
230 |
|
231 |
+
const reader = response.body.getReader();
|
232 |
+
let accumulatedResponse = '';
|
|
|
|
|
|
|
|
|
233 |
|
234 |
+
while (true) {
|
235 |
+
const {value, done} = await reader.read();
|
236 |
+
if (done) break;
|
237 |
+
|
238 |
+
const chunk = new TextDecoder().decode(value);
|
239 |
+
accumulatedResponse += chunk;
|
240 |
|
241 |
+
// تحديث الرسالة الخاصة بالبوت مع الاستجابة المتراكمة
|
242 |
+
updateLastBotMessage(accumulatedResponse);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
}
|
244 |
|
245 |
+
} catch (error) {
|
246 |
+
console.error('Error:', error);
|
247 |
+
addMessage('عذراً، حدث خطأ في الاتصال. يرجى المحاولة مرة أخرى.', 'bot-message');
|
248 |
+
} finally {
|
249 |
+
isWaitingForResponse = false;
|
250 |
+
sendButton.disabled = false;
|
251 |
+
userInput.disabled = false;
|
252 |
+
typingIndicator.style.display = 'none';
|
253 |
+
}
|
254 |
+
}
|
255 |
|
256 |
+
function addMessage(text, className) {
|
257 |
+
const chatBox = document.getElementById('chatBox');
|
258 |
+
const messageDiv = document.createElement('div');
|
259 |
+
messageDiv.className = `message ${className}`;
|
260 |
+
messageDiv.textContent = text;
|
261 |
+
chatBox.insertBefore(messageDiv, document.getElementById('typingIndicator'));
|
262 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
263 |
+
}
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
+
function updateLastBotMessage(text) {
|
266 |
+
const chatBox = document.getElementById('chatBox');
|
267 |
+
let lastBotMessage = chatBox.querySelector('.bot-message:last-of-type');
|
268 |
+
|
269 |
+
if (!lastBotMessage) {
|
270 |
+
lastBotMessage = document.createElement('div');
|
271 |
+
lastBotMessage.className = 'message bot-message';
|
272 |
+
chatBox.insertBefore(lastBotMessage, document.getElementById('typingIndicator'));
|
273 |
+
}
|
274 |
+
|
275 |
+
lastBotMessage.textContent = text;
|
276 |
+
chatBox.scrollTop = chatBox.scrollHeight;
|
277 |
+
}
|
278 |
+
|
279 |
+
// رسالة الترحيب
|
280 |
+
window.onload = function() {
|
281 |
+
addMessage("مرحباً بك في مكتبة أستاذ ريمون! كيف يمكنني مساعدتك اليوم؟", 'bot-message');
|
282 |
+
}
|
283 |
+
</script>
|
284 |
</body>
|
285 |
+
</html>
|