Update index.html
Browse files- index.html +6 -190
index.html
CHANGED
@@ -1,168 +1,13 @@
|
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="ar" dir="rtl">
|
3 |
<head>
|
4 |
-
|
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-beta3/css/all.min.css">
|
8 |
-
<style>
|
9 |
-
body {
|
10 |
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
11 |
-
margin: 0;
|
12 |
-
padding: 0;
|
13 |
-
display: flex;
|
14 |
-
height: 100vh;
|
15 |
-
background-color: #f0f0f0;
|
16 |
-
}
|
17 |
-
.main-content {
|
18 |
-
flex-grow: 1;
|
19 |
-
display: flex;
|
20 |
-
flex-direction: column;
|
21 |
-
padding: 20px;
|
22 |
-
width: 100%;
|
23 |
-
}
|
24 |
-
.header {
|
25 |
-
display: flex;
|
26 |
-
justify-content: space-between;
|
27 |
-
align-items: center;
|
28 |
-
padding: 10px 20px;
|
29 |
-
background-color: #ffffff;
|
30 |
-
border-radius: 15px;
|
31 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
32 |
-
margin-bottom: 20px;
|
33 |
-
}
|
34 |
-
.header-title {
|
35 |
-
font-size: 24px;
|
36 |
-
font-weight: bold;
|
37 |
-
color: #333;
|
38 |
-
}
|
39 |
-
.chat-container {
|
40 |
-
flex-grow: 1;
|
41 |
-
display: flex;
|
42 |
-
flex-direction: column;
|
43 |
-
background-color: #ffffff;
|
44 |
-
border-radius: 15px;
|
45 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
46 |
-
overflow: hidden;
|
47 |
-
margin: 0 auto;
|
48 |
-
width: 100%;
|
49 |
-
max-width: 1200px;
|
50 |
-
}
|
51 |
-
.messages {
|
52 |
-
flex: 1;
|
53 |
-
overflow-y: auto;
|
54 |
-
padding: 15px;
|
55 |
-
background-color: #fafafa;
|
56 |
-
}
|
57 |
-
.message {
|
58 |
-
padding: 12px;
|
59 |
-
margin: 8px 0;
|
60 |
-
border-radius: 12px;
|
61 |
-
font-size: 16px;
|
62 |
-
max-width: 70%;
|
63 |
-
word-break: break-word;
|
64 |
-
}
|
65 |
-
.user-message {
|
66 |
-
text-align: left;
|
67 |
-
background-color: #e0e0e0;
|
68 |
-
margin-right: auto;
|
69 |
-
}
|
70 |
-
.bot-message {
|
71 |
-
text-align: right;
|
72 |
-
background-color: #f5f5f5;
|
73 |
-
margin-left: auto;
|
74 |
-
}
|
75 |
-
.input-container {
|
76 |
-
display: flex;
|
77 |
-
padding: 12px;
|
78 |
-
background-color: #ffffff;
|
79 |
-
border-top: 1px solid #e0e0e0;
|
80 |
-
}
|
81 |
-
.input-container input {
|
82 |
-
flex: 1;
|
83 |
-
padding: 12px;
|
84 |
-
border-radius: 12px;
|
85 |
-
border: 1px solid #e0e0e0;
|
86 |
-
margin-left: 10px;
|
87 |
-
font-size: 16px;
|
88 |
-
}
|
89 |
-
.input-container button {
|
90 |
-
padding: 12px 24px;
|
91 |
-
border-radius: 12px;
|
92 |
-
background-color: #555;
|
93 |
-
color: white;
|
94 |
-
border: none;
|
95 |
-
cursor: pointer;
|
96 |
-
font-size: 16px;
|
97 |
-
}
|
98 |
-
.input-container button:hover {
|
99 |
-
background-color: #666;
|
100 |
-
}
|
101 |
-
.quick-actions {
|
102 |
-
display: flex;
|
103 |
-
justify-content: center;
|
104 |
-
margin-top: 20px;
|
105 |
-
flex-wrap: wrap;
|
106 |
-
gap: 10px;
|
107 |
-
}
|
108 |
-
.action-button {
|
109 |
-
background-color: #f0f0f0;
|
110 |
-
color: #333;
|
111 |
-
border: 1px solid #e0e0e0;
|
112 |
-
padding: 10px 15px;
|
113 |
-
border-radius: 5px;
|
114 |
-
cursor: pointer;
|
115 |
-
}
|
116 |
-
footer {
|
117 |
-
text-align: center;
|
118 |
-
padding: 15px;
|
119 |
-
background-color: #ffffff;
|
120 |
-
border-radius: 15px;
|
121 |
-
margin-top: 20px;
|
122 |
-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
123 |
-
}
|
124 |
-
.loading {
|
125 |
-
display: none;
|
126 |
-
text-align: center;
|
127 |
-
padding: 10px;
|
128 |
-
}
|
129 |
-
.loading.visible {
|
130 |
-
display: block;
|
131 |
-
}
|
132 |
-
</style>
|
133 |
</head>
|
134 |
<body>
|
135 |
-
|
136 |
-
<div class="header">
|
137 |
-
<div class="header-title">سبيدي</div>
|
138 |
-
</div>
|
139 |
-
|
140 |
-
<div class="chat-container">
|
141 |
-
<div class="messages" id="messages">
|
142 |
-
<!-- Messages will be displayed here -->
|
143 |
-
</div>
|
144 |
-
<div class="loading" id="loading">جاري التحميل...</div>
|
145 |
-
<div class="input-container">
|
146 |
-
<input type="text" id="message-input" placeholder="اكتب رسالتك..." onkeypress="handleKeyPress(event)">
|
147 |
-
<button onclick="sendMessage()">إرسال</button>
|
148 |
-
</div>
|
149 |
-
</div>
|
150 |
-
|
151 |
-
<div class="quick-actions">
|
152 |
-
<button class="action-button" onclick="sendQuickMessage('إنشاء صورة')">إنشاء صورة</button>
|
153 |
-
<button class="action-button" onclick="sendQuickMessage('شرح موضوع')">شرح موضوع</button>
|
154 |
-
<button class="action-button" onclick="sendQuickMessage('شكر المقابل')">شكر المقابل</button>
|
155 |
-
<button class="action-button" onclick="sendQuickMessage('حقيقة مثيرة')">حقيقة مثيرة</button>
|
156 |
-
</div>
|
157 |
-
|
158 |
-
<footer>
|
159 |
-
إلى هذا الشكل ليس الشكل النهائي بل فقط هو شكل تجريبي | جميع حقوق تصميم سبيدي محفوظة لشركة فاست برو عام 2024
|
160 |
-
</footer>
|
161 |
-
</div>
|
162 |
-
|
163 |
<script>
|
164 |
let isSending = false;
|
165 |
-
|
166 |
async function sendMessage() {
|
167 |
if (isSending) return;
|
168 |
|
@@ -175,16 +20,14 @@
|
|
175 |
input.value = '';
|
176 |
|
177 |
document.getElementById('loading').classList.add('visible');
|
178 |
-
|
179 |
try {
|
180 |
-
const response = await fetch('/
|
181 |
method: 'POST',
|
182 |
headers: {
|
183 |
'Content-Type': 'application/json',
|
184 |
},
|
185 |
body: JSON.stringify({ message: message })
|
186 |
});
|
187 |
-
|
188 |
if (response.ok) {
|
189 |
const data = await response.json();
|
190 |
appendMessage('bot-message', data.response);
|
@@ -199,35 +42,8 @@
|
|
199 |
}
|
200 |
}
|
201 |
}
|
202 |
-
|
203 |
-
|
204 |
-
var messages = document.getElementById('messages');
|
205 |
-
var messageDiv = document.createElement('div');
|
206 |
-
messageDiv.className = 'message ' + className;
|
207 |
-
messageDiv.textContent = message;
|
208 |
-
messages.appendChild(messageDiv);
|
209 |
-
messages.scrollTop = messages.scrollHeight;
|
210 |
-
}
|
211 |
-
|
212 |
-
function handleKeyPress(event) {
|
213 |
-
if (event.key === 'Enter') {
|
214 |
-
sendMessage();
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
function sendQuickMessage(message) {
|
219 |
-
document.getElementById('message-input').value = message;
|
220 |
-
sendMessage();
|
221 |
-
}
|
222 |
-
|
223 |
-
function initializeMessages() {
|
224 |
-
var today = new Date();
|
225 |
-
var hour = today.getHours();
|
226 |
-
var greeting = hour < 12 ? 'صباح الخير' : 'مساء الخير';
|
227 |
-
appendMessage('bot-message', `أهلاً بك، ${greeting}! كيف يمكنني مساعدتك اليوم؟`);
|
228 |
-
}
|
229 |
-
|
230 |
-
window.onload = initializeMessages;
|
231 |
</script>
|
232 |
</body>
|
233 |
</html>
|
|
|
1 |
+
<!-- templates/index.html -->
|
2 |
<!DOCTYPE html>
|
3 |
<html lang="ar" dir="rtl">
|
4 |
<head>
|
5 |
+
<!-- Previous head content remains the same -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
</head>
|
7 |
<body>
|
8 |
+
<!-- Previous body content remains the same until the script section -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
<script>
|
10 |
let isSending = false;
|
|
|
11 |
async function sendMessage() {
|
12 |
if (isSending) return;
|
13 |
|
|
|
20 |
input.value = '';
|
21 |
|
22 |
document.getElementById('loading').classList.add('visible');
|
|
|
23 |
try {
|
24 |
+
const response = await fetch('/message', { // Updated endpoint
|
25 |
method: 'POST',
|
26 |
headers: {
|
27 |
'Content-Type': 'application/json',
|
28 |
},
|
29 |
body: JSON.stringify({ message: message })
|
30 |
});
|
|
|
31 |
if (response.ok) {
|
32 |
const data = await response.json();
|
33 |
appendMessage('bot-message', data.response);
|
|
|
42 |
}
|
43 |
}
|
44 |
}
|
45 |
+
|
46 |
+
// Rest of the JavaScript functions remain the same
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
</script>
|
48 |
</body>
|
49 |
</html>
|