Update index.html
Browse files- index.html +78 -321
index.html
CHANGED
@@ -1,328 +1,85 @@
|
|
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>
|
7 |
-
<style>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
font-family: 'Poppins', sans-serif;
|
25 |
-
background: linear-gradient(135deg, #6E45E2, #88D3CE);
|
26 |
-
height: 100vh; /* Full height */
|
27 |
-
display: flex;
|
28 |
-
align-items: center;
|
29 |
-
justify-content: center;
|
30 |
-
overflow: hidden;
|
31 |
-
}
|
32 |
-
|
33 |
-
/* Animation Background */
|
34 |
-
body::before {
|
35 |
-
content: '';
|
36 |
-
position: absolute;
|
37 |
-
top: -50%;
|
38 |
-
left: -50%;
|
39 |
-
width: 200%;
|
40 |
-
height: 200%;
|
41 |
-
background: radial-gradient(circle, rgba(98, 0, 234, 0.6), transparent);
|
42 |
-
animation: backgroundAnimation 6s infinite linear alternate;
|
43 |
-
z-index: 0;
|
44 |
-
}
|
45 |
-
|
46 |
-
@keyframes backgroundAnimation {
|
47 |
-
to {
|
48 |
-
transform: rotate(360deg);
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
.chat-container {
|
53 |
-
position: relative;
|
54 |
-
z-index: 1;
|
55 |
-
width: 100%; /* Full width for mobile */
|
56 |
-
height: 100%; /* Full height for mobile */
|
57 |
-
background: #ffffff;
|
58 |
-
border-radius: 15px 15px 0 0; /* Rounded top corners */
|
59 |
-
box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2); /* Subtle shadow */
|
60 |
-
display: flex;
|
61 |
-
flex-direction: column;
|
62 |
-
overflow: hidden;
|
63 |
-
}
|
64 |
-
|
65 |
-
@keyframes fadeIn {
|
66 |
-
from {
|
67 |
-
opacity: 0;
|
68 |
-
transform: translateY(30px);
|
69 |
-
}
|
70 |
-
to {
|
71 |
-
opacity: 1;
|
72 |
-
transform: translateY(0);
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
/* Header */
|
77 |
-
.chat-header {
|
78 |
-
background: linear-gradient(135deg, #6200ea, #3700b3);
|
79 |
-
color: #fff;
|
80 |
-
padding: 15px; /* Adjusted padding for mobile */
|
81 |
-
text-align: center;
|
82 |
-
font-size: 1.2rem; /* Adjusted for mobile */
|
83 |
-
font-weight: bold;
|
84 |
-
font-family: 'Cairo', sans-serif;
|
85 |
-
border-bottom: 1px solid #ddd;
|
86 |
-
}
|
87 |
-
|
88 |
-
/* Chat Box */
|
89 |
-
.chat-box {
|
90 |
-
flex: 1;
|
91 |
-
padding: 10px 15px; /* Smaller padding for mobile */
|
92 |
-
overflow-y: auto; /* Enable vertical scrolling */
|
93 |
-
max-height: calc(100vh - 140px); /* Dynamic height */
|
94 |
-
display: flex;
|
95 |
-
flex-direction: column;
|
96 |
-
background: #f8f9fa;
|
97 |
-
}
|
98 |
-
|
99 |
-
.chat-box .message {
|
100 |
-
margin-bottom: 10px; /* Reduced margin for compact spacing */
|
101 |
-
font-size: 0.9rem; /* Adjusted for mobile */
|
102 |
-
padding: 10px 15px;
|
103 |
-
border-radius: 20px;
|
104 |
-
max-width: 75%;
|
105 |
-
animation: slideIn 0.3s ease-in-out;
|
106 |
-
word-wrap: break-word;
|
107 |
-
font-family: 'Cairo', 'Poppins', sans-serif;
|
108 |
-
}
|
109 |
-
|
110 |
-
@keyframes slideIn {
|
111 |
-
from {
|
112 |
-
transform: translateY(10px);
|
113 |
-
opacity: 0;
|
114 |
-
}
|
115 |
-
to {
|
116 |
-
transform: translateY(0);
|
117 |
-
opacity: 1;
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
.chat-box .message.user {
|
122 |
-
margin-left: auto;
|
123 |
-
background: #e3f2fd;
|
124 |
-
color: #0D47A1;
|
125 |
-
text-align: right;
|
126 |
-
}
|
127 |
-
|
128 |
-
.chat-box .message.ai {
|
129 |
-
margin-right: auto;
|
130 |
-
background: #e8f5e9;
|
131 |
-
color: #1B5E20;
|
132 |
-
text-align: left;
|
133 |
-
}
|
134 |
-
|
135 |
-
/* Typing Animation */
|
136 |
-
.typing-animation {
|
137 |
-
display: flex;
|
138 |
-
margin: 10px 0;
|
139 |
-
justify-content: left;
|
140 |
-
align-items: center;
|
141 |
-
}
|
142 |
-
|
143 |
-
.typing-animation span {
|
144 |
-
display: inline-block;
|
145 |
-
width: 8px;
|
146 |
-
height: 8px;
|
147 |
-
margin: 0 3px;
|
148 |
-
background: #1B5E20;
|
149 |
-
border-radius: 50%;
|
150 |
-
animation: typing 1.3s infinite;
|
151 |
-
}
|
152 |
-
|
153 |
-
.typing-animation span:nth-child(2) {
|
154 |
-
animation-delay: 0.2s;
|
155 |
-
}
|
156 |
-
|
157 |
-
.typing-animation span:nth-child(3) {
|
158 |
-
animation-delay: 0.4s;
|
159 |
-
}
|
160 |
-
|
161 |
-
@keyframes typing {
|
162 |
-
0%, 80% {
|
163 |
-
transform: scale(0);
|
164 |
-
}
|
165 |
-
40% {
|
166 |
-
transform: scale(1);
|
167 |
-
}
|
168 |
-
}
|
169 |
-
|
170 |
-
/* Chat Input */
|
171 |
-
.chat-input {
|
172 |
-
display: flex;
|
173 |
-
align-items: center;
|
174 |
-
padding: 10px; /* Reduced padding for mobile */
|
175 |
-
background: #f9f9f9;
|
176 |
-
border-top: 1px solid #ddd;
|
177 |
-
}
|
178 |
-
|
179 |
-
.chat-input input {
|
180 |
-
flex: 1;
|
181 |
-
padding: 12px; /* Adjusted for smaller screens */
|
182 |
-
border: 1px solid #ddd;
|
183 |
-
border-radius: 30px;
|
184 |
-
margin-right: 10px;
|
185 |
-
font-size: 0.9rem; /* Smaller size for mobile */
|
186 |
-
font-family: 'Poppins', 'Cairo', sans-serif;
|
187 |
-
outline: none;
|
188 |
-
transition: all 0.3s ease;
|
189 |
-
}
|
190 |
-
|
191 |
-
.chat-input input:focus {
|
192 |
-
border-color: #6200ea;
|
193 |
-
box-shadow: 0 0 5px rgba(98, 0, 234, 0.5);
|
194 |
-
}
|
195 |
-
|
196 |
-
.chat-input button {
|
197 |
-
padding: 10px 15px; /* Adjusted for mobile */
|
198 |
-
background: linear-gradient(135deg, #6200ea, #3700b3);
|
199 |
-
border: none;
|
200 |
-
color: white;
|
201 |
-
border-radius: 20px;
|
202 |
-
cursor: pointer;
|
203 |
-
font-weight: bold;
|
204 |
-
font-size: 0.9rem; /* Adjusted for mobile */
|
205 |
-
font-family: 'Poppins', 'Cairo', sans-serif;
|
206 |
-
transition: all 0.3s ease;
|
207 |
-
}
|
208 |
-
|
209 |
-
.chat-input button:hover {
|
210 |
-
background: #5e35b1;
|
211 |
-
box-shadow: 0 5px 15px rgba(98, 0, 234, 0.4);
|
212 |
-
}
|
213 |
-
</style>
|
214 |
</head>
|
215 |
<body>
|
216 |
-
<
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
<
|
226 |
-
|
227 |
-
|
228 |
-
<script>
|
229 |
-
|
230 |
-
|
231 |
-
const
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
//
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
setTimeout(() => {
|
276 |
-
chatBox.scrollTop = chatBox.scrollHeight;
|
277 |
-
}, 100);
|
278 |
-
|
279 |
-
return typingDiv;
|
280 |
-
}
|
281 |
-
|
282 |
-
// Function to send a message
|
283 |
-
async function sendMessage() {
|
284 |
-
const userMessage = userInput.value.trim();
|
285 |
-
if (!userMessage) return;
|
286 |
-
|
287 |
-
addMessage("user", userMessage);
|
288 |
-
|
289 |
-
conversationHistory.push({ "role": "user", "content": userMessage });
|
290 |
-
|
291 |
-
const typingDiv = showTyping();
|
292 |
-
|
293 |
-
const data = { message: conversationHistory };
|
294 |
-
|
295 |
-
try {
|
296 |
-
const response = await fetch(apiUrl, {
|
297 |
-
method: "POST",
|
298 |
-
headers: {
|
299 |
-
"Content-Type": "application/json"
|
300 |
-
},
|
301 |
-
body: JSON.stringify(data)
|
302 |
-
});
|
303 |
-
|
304 |
-
if (response.ok) {
|
305 |
-
const aiResponse = await response.text();
|
306 |
-
chatBox.removeChild(typingDiv);
|
307 |
-
addMessage("ai", aiResponse);
|
308 |
-
conversationHistory.push({ "role": "assistant", "content": aiResponse });
|
309 |
-
} else {
|
310 |
-
throw new Error(`Error: ${response.status}`);
|
311 |
-
}
|
312 |
-
} catch (error) {
|
313 |
-
console.error("Error:", error);
|
314 |
-
chatBox.removeChild(typingDiv);
|
315 |
-
addMessage("ai", "AI: Sorry, something went wrong!");
|
316 |
-
}
|
317 |
-
|
318 |
-
userInput.value = "";
|
319 |
-
}
|
320 |
-
|
321 |
-
// Attach event listeners
|
322 |
-
sendBtn.addEventListener("click", sendMessage);
|
323 |
-
userInput.addEventListener("keypress", (e) => {
|
324 |
-
if (e.key === "Enter") sendMessage();
|
325 |
-
});
|
326 |
-
</script>
|
327 |
</body>
|
328 |
</html>
|
|
|
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>Get Page Access Token</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
text-align: center;
|
11 |
+
margin-top: 50px;
|
12 |
+
}
|
13 |
+
#token {
|
14 |
+
margin-top: 20px;
|
15 |
+
font-size: 16px;
|
16 |
+
color: green;
|
17 |
+
}
|
18 |
+
#error {
|
19 |
+
margin-top: 20px;
|
20 |
+
font-size: 16px;
|
21 |
+
color: red;
|
22 |
+
}
|
23 |
+
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
</head>
|
25 |
<body>
|
26 |
+
<h1>Connect Your Facebook Page</h1>
|
27 |
+
<p>Click the button below to connect your Facebook page and get the access token.</p>
|
28 |
+
|
29 |
+
<!-- Facebook Login Button -->
|
30 |
+
<a href="#" id="loginButton" style="display: inline-block; padding: 10px 20px; background-color: #1877F2; color: white; text-decoration: none; border-radius: 5px;">
|
31 |
+
Connect with Facebook
|
32 |
+
</a>
|
33 |
+
|
34 |
+
<!-- Display Access Token -->
|
35 |
+
<div id="token"></div>
|
36 |
+
<div id="error"></div>
|
37 |
+
|
38 |
+
<script>
|
39 |
+
// Facebook App ID
|
40 |
+
const APP_ID = '1091493532996125'; // Replace with your App ID
|
41 |
+
const REDIRECT_URI = encodeURIComponent('https://dooratre-db-test.static.hf.space/index.html'); // Replace with your redirect URI
|
42 |
+
|
43 |
+
// Generate Facebook OAuth URL
|
44 |
+
const oauthUrl = `https://www.facebook.com/v12.0/dialog/oauth?client_id=${APP_ID}&redirect_uri=${REDIRECT_URI}&scope=pages_manage_metadata,pages_read_engagement,pages_messaging,manage_pages&response_type=token`;
|
45 |
+
|
46 |
+
// Set the button's href to the OAuth URL
|
47 |
+
document.getElementById('loginButton').href = oauthUrl;
|
48 |
+
|
49 |
+
// Handle the response from Facebook
|
50 |
+
window.onload = () => {
|
51 |
+
const hash = window.location.hash.substring(1); // Get the hash from the URL
|
52 |
+
if (hash) {
|
53 |
+
const params = new URLSearchParams(hash);
|
54 |
+
const accessToken = params.get('access_token');
|
55 |
+
|
56 |
+
if (accessToken) {
|
57 |
+
// Display the access token
|
58 |
+
document.getElementById('token').innerText = `Access Token: ${accessToken}`;
|
59 |
+
|
60 |
+
// Fetch the user's pages
|
61 |
+
fetch(`https://graph.facebook.com/v12.0/me/accounts?access_token=${accessToken}`)
|
62 |
+
.then(response => response.json())
|
63 |
+
.then(data => {
|
64 |
+
if (data.data && data.data.length > 0) {
|
65 |
+
const pages = data.data;
|
66 |
+
let pageInfo = '';
|
67 |
+
pages.forEach(page => {
|
68 |
+
pageInfo += `Page ID: ${page.id}, Page Token: ${page.access_token}\n`;
|
69 |
+
});
|
70 |
+
document.getElementById('token').innerText += `\n\nPages:\n${pageInfo}`;
|
71 |
+
} else {
|
72 |
+
document.getElementById('error').innerText = 'No pages found for this user.';
|
73 |
+
}
|
74 |
+
})
|
75 |
+
.catch(error => {
|
76 |
+
document.getElementById('error').innerText = `Error fetching pages: ${error.message}`;
|
77 |
+
});
|
78 |
+
} else {
|
79 |
+
document.getElementById('error').innerText = 'Failed to retrieve access token.';
|
80 |
+
}
|
81 |
+
}
|
82 |
+
};
|
83 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
</body>
|
85 |
</html>
|