joermd commited on
Commit
a229033
·
verified ·
1 Parent(s): aebc6bd

Update index.html

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