Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e646d21f0 |
9
api/chat.php
Normal file
9
api/chat.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// In the future, you can add logic here to process $_POST['message']
|
||||||
|
// and connect to an AI service.
|
||||||
|
|
||||||
|
$canned_response = "Thanks for your message! We'll be in touch shortly. For now, this is a canned response.";
|
||||||
|
|
||||||
|
echo json_encode(['reply' => $canned_response]);
|
||||||
141
assets/css/custom.css
Normal file
141
assets/css/custom.css
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
|
||||||
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
background-color: #F3F4F6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-widget-button {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 2rem;
|
||||||
|
right: 2rem;
|
||||||
|
background-color: #4F46E5;
|
||||||
|
color: white;
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
||||||
|
transition: transform 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-widget-button:hover {
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-widget-button svg {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-popup {
|
||||||
|
display: none;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 6.5rem;
|
||||||
|
right: 2rem;
|
||||||
|
width: 375px;
|
||||||
|
max-width: 90vw;
|
||||||
|
height: 70vh;
|
||||||
|
max-height: 600px;
|
||||||
|
background: #FFFFFF;
|
||||||
|
border-radius: 0.75rem;
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
transform: translateY(20px);
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-popup.show {
|
||||||
|
display: flex;
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-header {
|
||||||
|
background: #4F46E5;
|
||||||
|
color: white;
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-header h5 {
|
||||||
|
margin: 0;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-header .btn-close {
|
||||||
|
filter: invert(1) grayscale(100%) brightness(200%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-area {
|
||||||
|
flex-grow: 1;
|
||||||
|
padding: 1rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-message {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
gap: 0.5rem;
|
||||||
|
max-width: 85%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-message .avatar {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-message .message-content {
|
||||||
|
padding: 0.75rem 1rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-message {
|
||||||
|
align-self: flex-end;
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-message .message-content {
|
||||||
|
background-color: #4F46E5;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bot-message {
|
||||||
|
align-self: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bot-message .message-content {
|
||||||
|
background-color: #E5E7EB;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-input-area {
|
||||||
|
padding: 1rem;
|
||||||
|
border-top: 1px solid #E5E7EB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-input-area .form-control:focus {
|
||||||
|
border-color: #4F46E5;
|
||||||
|
box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero {
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
color: white;
|
||||||
|
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
66
assets/js/main.js
Normal file
66
assets/js/main.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
|
const chatPopup = document.getElementById('chat-popup');
|
||||||
|
const chatOpenButton = document.getElementById('chat-open-button');
|
||||||
|
const chatCloseButton = document.getElementById('chat-close-button');
|
||||||
|
const chatArea = document.getElementById('chat-area');
|
||||||
|
const chatForm = document.getElementById('chat-form');
|
||||||
|
const chatInput = document.getElementById('chat-input');
|
||||||
|
|
||||||
|
const toggleChat = () => {
|
||||||
|
chatPopup.classList.toggle('show');
|
||||||
|
};
|
||||||
|
|
||||||
|
chatOpenButton.addEventListener('click', toggleChat);
|
||||||
|
chatCloseButton.addEventListener('click', toggleChat);
|
||||||
|
|
||||||
|
const addMessage = (sender, message) => {
|
||||||
|
const messageWrapper = document.createElement('div');
|
||||||
|
const avatarUrl = sender === 'user' ? 'https://picsum.photos/seed/avatar-user/100/100' : 'https://picsum.photos/seed/avatar-bot/100/100';
|
||||||
|
const avatarAlt = sender === 'user' ? 'User Avatar' : 'Chatbot Avatar';
|
||||||
|
const messageClass = sender === 'user' ? 'user-message' : 'bot-message';
|
||||||
|
|
||||||
|
messageWrapper.className = `chat-message ${messageClass}`;
|
||||||
|
messageWrapper.innerHTML = `
|
||||||
|
<img src="${avatarUrl}" alt="${avatarAlt}" class="avatar">
|
||||||
|
<div class="message-content">
|
||||||
|
${message}
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
chatArea.appendChild(messageWrapper);
|
||||||
|
chatArea.scrollTop = chatArea.scrollHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
chatForm.addEventListener('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const userMessage = chatInput.value.trim();
|
||||||
|
if (userMessage === '') return;
|
||||||
|
|
||||||
|
addMessage('user', userMessage);
|
||||||
|
chatInput.value = '';
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
fetch('api/chat.php', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
body: `message=${encodeURIComponent(userMessage)}`
|
||||||
|
})
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
if (data.reply) {
|
||||||
|
addMessage('bot', data.reply);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
addMessage('bot', 'Sorry, something went wrong. Please try again later.');
|
||||||
|
});
|
||||||
|
}, 500); // Simulate bot thinking
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initial bot message
|
||||||
|
setTimeout(() => {
|
||||||
|
addMessage('bot', 'Hello! How can I help you today?');
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
164
index.php
164
index.php
@ -1,131 +1,49 @@
|
|||||||
<?php
|
<!DOCTYPE html>
|
||||||
declare(strict_types=1);
|
|
||||||
@ini_set('display_errors', '1');
|
|
||||||
@error_reporting(E_ALL);
|
|
||||||
@date_default_timezone_set('UTC');
|
|
||||||
|
|
||||||
$phpVersion = PHP_VERSION;
|
|
||||||
$now = date('Y-m-d H:i:s');
|
|
||||||
?>
|
|
||||||
<!doctype html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>New Style</title>
|
<title>Chat Page</title>
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--bg-color-start: #6a11cb;
|
|
||||||
--bg-color-end: #2575fc;
|
|
||||||
--text-color: #ffffff;
|
|
||||||
--card-bg-color: rgba(255, 255, 255, 0.01);
|
|
||||||
--card-border-color: rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: 'Inter', sans-serif;
|
|
||||||
background: linear-gradient(45deg, var(--bg-color-start), var(--bg-color-end));
|
|
||||||
color: var(--text-color);
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
min-height: 100vh;
|
|
||||||
text-align: center;
|
|
||||||
overflow: hidden;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
body::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path d="M-10 10L110 10M10 -10L10 110" stroke-width="1" stroke="rgba(255,255,255,0.05)"/></svg>');
|
|
||||||
animation: bg-pan 20s linear infinite;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
@keyframes bg-pan {
|
|
||||||
0% { background-position: 0% 0%; }
|
|
||||||
100% { background-position: 100% 100%; }
|
|
||||||
}
|
|
||||||
main {
|
|
||||||
padding: 2rem;
|
|
||||||
}
|
|
||||||
.card {
|
|
||||||
background: var(--card-bg-color);
|
|
||||||
border: 1px solid var(--card-border-color);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 2rem;
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
-webkit-backdrop-filter: blur(20px);
|
|
||||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
.loader {
|
|
||||||
margin: 1.25rem auto 1.25rem;
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
border: 3px solid rgba(255, 255, 255, 0.25);
|
|
||||||
border-top-color: #fff;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: spin 1s linear infinite;
|
|
||||||
}
|
|
||||||
@keyframes spin {
|
|
||||||
from { transform: rotate(0deg); }
|
|
||||||
to { transform: rotate(360deg); }
|
|
||||||
}
|
|
||||||
.hint {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
.sr-only {
|
|
||||||
position: absolute;
|
|
||||||
width: 1px; height: 1px;
|
|
||||||
padding: 0; margin: -1px;
|
|
||||||
overflow: hidden;
|
|
||||||
clip: rect(0, 0, 0, 0);
|
|
||||||
white-space: nowrap; border: 0;
|
|
||||||
}
|
|
||||||
h1 {
|
|
||||||
font-size: 3rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin: 0 0 1rem;
|
|
||||||
letter-spacing: -1px;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
}
|
|
||||||
code {
|
|
||||||
background: rgba(0,0,0,0.2);
|
|
||||||
padding: 2px 6px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 1rem;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<main>
|
|
||||||
<div class="card">
|
<div class="hero d-flex align-items-center justify-content-center vh-100" style="background-image: url('https://picsum.photos/seed/hero-chat/1600/900');">
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<div class="text-center">
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<h1 class="display-3 fw-bold">Welcome to our Support Chat</h1>
|
||||||
<span class="sr-only">Loading…</span>
|
<p class="lead">Ask us anything! Our bot is here to help you 24/7.</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="hint">Flatlogic AI is collecting your requirements and applying the first changes.</p>
|
|
||||||
<p class="hint">This page will update automatically as the plan is implemented.</p>
|
|
||||||
<p>Runtime: PHP <code><?= htmlspecialchars($phpVersion) ?></code> — UTC <code><?= htmlspecialchars($now) ?></code></p>
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
|
||||||
<footer>
|
<!-- Chat Popup -->
|
||||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
<div id="chat-popup" class="chat-popup">
|
||||||
</footer>
|
<div class="chat-header">
|
||||||
|
<h5 class="mb-0">Chat with us</h5>
|
||||||
|
<button type="button" class="btn-close" id="chat-close-button"></button>
|
||||||
|
</div>
|
||||||
|
<div id="chat-area" class="chat-area"></div>
|
||||||
|
<div class="chat-input-area">
|
||||||
|
<form id="chat-form" class="d-flex">
|
||||||
|
<input type="text" id="chat-input" class="form-control" placeholder="Type a message..." autocomplete="off">
|
||||||
|
<button type="submit" class="btn btn-primary ms-2">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-send-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M15.964.686a.5.5 0 0 0-.65-.65L.767 5.855H.766l-.452.18a.5.5 0 0 0-.082.887l.41.26.001.002 4.995 3.178 3.178 4.995.002.002.26.41a.5.5 0 0 0 .886-.083l6-15Zm-1.833 1.89L6.637 10.07l-.215-.338a.5.5 0 0 0-.154-.154l-.338-.215 7.494-7.494 1.178-.471-.47 1.178Z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Chat Button -->
|
||||||
|
<div id="chat-open-button" class="chat-widget-button">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193l-3.72 3.72a1.125 1.125 0 0 1-1.59 0l-3.72-3.72a1.125 1.125 0 0 1 0-1.59l3.72-3.72a1.125 1.125 0 0 1 1.59 0l3.72 3.72c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193l-3.72 3.72a1.125 1.125 0 0 1-1.59 0l-3.72-3.72a1.125 1.125 0 0 1 0-1.59l3.72-3.72a1.125 1.125 0 0 1 1.59 0l3.72 3.72" />
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M12 18.75a.75.75 0 0 1 .75.75v.008a.75.75 0 0 1-.75.75h-.008a.75.75 0 0 1-.75-.75v-.008a.75.75 0 0 1 .75-.75h.008Z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="assets/js/main.js?v=<?php echo time(); ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user