Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36400880a5 |
400
assets/css/custom.css
Normal file
400
assets/css/custom.css
Normal file
@ -0,0 +1,400 @@
|
||||
:root {
|
||||
--primary-color: #0D6EFD;
|
||||
--secondary-color: #6C757D;
|
||||
--font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
}
|
||||
|
||||
[data-theme="dark"] {
|
||||
--background-color: #121212;
|
||||
--surface-color: #1E1E1E;
|
||||
--text-color: #FFFFFF;
|
||||
--text-color-muted: rgba(255, 255, 255, 0.6);
|
||||
--border-color: #333;
|
||||
--input-bg: #3A3B3C;
|
||||
--header-bg: linear-gradient(to right, #1e1e1e, #2a2a2a);
|
||||
--divider-bg: #333;
|
||||
--divider-text: #aaa;
|
||||
--received-bubble-bg: #3A3B3C;
|
||||
}
|
||||
|
||||
[data-theme="light"] {
|
||||
--background-color: #F0F2F5;
|
||||
--surface-color: #FFFFFF;
|
||||
--text-color: #050505;
|
||||
--text-color-muted: rgba(0, 0, 0, 0.6);
|
||||
--border-color: #E0E0E0;
|
||||
--input-bg: #F0F2F5;
|
||||
--header-bg: #FFFFFF;
|
||||
--divider-bg: #E9EBEE;
|
||||
--divider-text: #65676B;
|
||||
--received-bubble-bg: #E4E6EB;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
font-family: var(--font-family);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.mobile-chat-container {
|
||||
width: 100%;
|
||||
max-width: 450px;
|
||||
height: 90vh;
|
||||
max-height: 800px;
|
||||
background-color: var(--surface-color);
|
||||
border-radius: 20px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
background: var(--header-bg);
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.chat-header .avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--primary-color);
|
||||
}
|
||||
|
||||
.chat-header .actions a,
|
||||
.chat-header .d-flex a {
|
||||
color: var(--text-color) !important;
|
||||
}
|
||||
|
||||
.chat-header .small {
|
||||
color: var(--text-color-muted) !important;
|
||||
}
|
||||
|
||||
.chat-body {
|
||||
flex-grow: 1;
|
||||
padding: 1rem;
|
||||
overflow-y: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.message-day-divider {
|
||||
text-align: center;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
.message-day-divider span {
|
||||
background-color: var(--divider-bg);
|
||||
color: var(--divider-text);
|
||||
padding: 0.25rem 0.75rem;
|
||||
border-radius: 12px;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.message {
|
||||
display: flex;
|
||||
margin-bottom: 1rem;
|
||||
max-width: 80%;
|
||||
}
|
||||
|
||||
.message.sent {
|
||||
align-self: flex-end;
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.message.received {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.message-bubble {
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.message.sent .message-bubble {
|
||||
background-color: var(--primary-color);
|
||||
color: white;
|
||||
border-top-right-radius: 5px;
|
||||
}
|
||||
|
||||
.message.received .message-bubble {
|
||||
background-color: var(--received-bubble-bg);
|
||||
color: var(--text-color);
|
||||
border-top-left-radius: 5px;
|
||||
}
|
||||
|
||||
.message-time {
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-color-muted);
|
||||
display: block;
|
||||
text-align: right;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.message.sent .message-time {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
[data-theme="light"] .message.sent .message-time {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.chat-footer {
|
||||
padding: 1rem;
|
||||
background-color: var(--surface-color);
|
||||
border-top: 1px solid var(--border-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.chat-footer .input-group {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.chat-footer .form-control {
|
||||
background-color: var(--input-bg);
|
||||
border-color: var(--input-bg);
|
||||
color: var(--text-color);
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.chat-footer .form-control::placeholder {
|
||||
color: var(--text-color-muted);
|
||||
}
|
||||
|
||||
.chat-footer .form-control:focus {
|
||||
background-color: var(--input-bg);
|
||||
border-color: var(--primary-color);
|
||||
box-shadow: none;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.chat-footer .btn-secondary {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-color-muted);
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.chat-footer .mic-button, .chat-footer .send-button {
|
||||
margin-left: 0.5rem;
|
||||
border-radius: 50%;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
font-size: 1.2rem;
|
||||
background-color: var(--primary-color);
|
||||
border-color: var(--primary-color);
|
||||
}
|
||||
|
||||
.voice-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.voice-message .bi-play-circle-fill {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.voice-progress {
|
||||
flex-grow: 1;
|
||||
height: 4px;
|
||||
background-color: rgba(255, 255, 255, 0.3);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.mic-button.recording {
|
||||
animation: pulse 1.5s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.7);
|
||||
}
|
||||
70% {
|
||||
box-shadow: 0 0 0 10px rgba(255, 0, 0, 0);
|
||||
}
|
||||
100% {
|
||||
box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.voice-message .play-button {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-color);
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .voice-message .play-button,
|
||||
[data-theme="dark"] .voice-message .share-button {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.voice-message-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.voice-progress-container {
|
||||
flex-grow: 1;
|
||||
height: 4px;
|
||||
background-color: var(--text-color-muted);
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
margin: 0 0.5rem;
|
||||
}
|
||||
|
||||
.share-button {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--text-color);
|
||||
font-size: 1.2rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.voice-progress {
|
||||
height: 100%;
|
||||
width: 0;
|
||||
background-color: var(--text-color);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .voice-progress {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
/* Custom scrollbar for webkit browsers */
|
||||
.chat-body::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.chat-body::-webkit-scrollbar-track {
|
||||
background: var(--surface-color);
|
||||
}
|
||||
|
||||
.chat-body::-webkit-scrollbar-thumb {
|
||||
background-color: #555;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
/* Theme Panel */
|
||||
.theme-panel {
|
||||
position: absolute;
|
||||
top: 70px;
|
||||
right: 20px;
|
||||
background-color: var(--surface-color);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
padding: 1rem;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
z-index: 100;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.theme-panel.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.theme-panel h5 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#emoji-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-color-muted);
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
|
||||
#emoji-panel {
|
||||
height: 280px;
|
||||
background: var(--surface-color);
|
||||
border-top: 1px solid var(--border-color);
|
||||
padding: 10px;
|
||||
overflow-y: auto;
|
||||
display: none; /* Hidden by default */
|
||||
}
|
||||
|
||||
#emoji-panel.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.emoji-categories {
|
||||
display: flex;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.category-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-color-muted);
|
||||
padding: 10px 15px;
|
||||
cursor: pointer;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.category-btn.active {
|
||||
border-bottom: 2px solid var(--primary-color);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.emoji-grid, .sticker-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.sticker-grid {
|
||||
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
|
||||
}
|
||||
|
||||
.emoji-grid span, .sticker-grid img {
|
||||
cursor: pointer;
|
||||
font-size: 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sticker-grid img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.message-content.image-message {
|
||||
padding: 0;
|
||||
background-color: transparent;
|
||||
border-radius: 15px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.message-content.image-message img {
|
||||
max-width: 250px;
|
||||
display: block;
|
||||
height: auto;
|
||||
}
|
||||
535
index.php
535
index.php
@ -1,150 +1,407 @@
|
||||
<?php
|
||||
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>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>New Style</title>
|
||||
<?php
|
||||
// Read project preview data from environment
|
||||
$projectDescription = $_SERVER['PROJECT_DESCRIPTION'] ?? '';
|
||||
$projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
?>
|
||||
<?php if ($projectDescription): ?>
|
||||
<!-- Meta description -->
|
||||
<meta name="description" content='<?= htmlspecialchars($projectDescription) ?>' />
|
||||
<!-- Open Graph meta tags -->
|
||||
<meta property="og:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<!-- Twitter meta tags -->
|
||||
<meta property="twitter:description" content="<?= htmlspecialchars($projectDescription) ?>" />
|
||||
<?php endif; ?>
|
||||
<?php if ($projectImageUrl): ?>
|
||||
<!-- Open Graph image -->
|
||||
<meta property="og:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<!-- Twitter image -->
|
||||
<meta property="twitter:image" content="<?= htmlspecialchars($projectImageUrl) ?>" />
|
||||
<?php endif; ?>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chatterly</title>
|
||||
<meta name="description" content="Built with Flatlogic Generator">
|
||||
<meta name="keywords" content="chatterly, chat app, messaging, instant messaging, mobile chat, group chat, media sharing, real-time communication, Built with Flatlogic Generator">
|
||||
<meta property="og:title" content="Chatterly">
|
||||
<meta property="og:description" content="Built with Flatlogic Generator">
|
||||
<meta property="og:image" content="">
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:image" content="">
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<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>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<div class="card">
|
||||
<h1>Analyzing your requirements and generating your website…</h1>
|
||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||
<span class="sr-only">Loading…</span>
|
||||
|
||||
<div class="mobile-chat-container">
|
||||
<header class="chat-header">
|
||||
<div class="d-flex align-items-center">
|
||||
<a href="#" class="text-white me-3"><i class="bi bi-arrow-left"></i></a>
|
||||
<img src="https://i.pravatar.cc/40?u=jane" alt="Avatar" class="avatar">
|
||||
<div class="ms-3">
|
||||
<h1 class="h6 mb-0">Jane Doe</h1>
|
||||
<p class="small text-white-50 mb-0">online</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a href="#" class="text-white"><i class="bi bi-camera-video"></i></a>
|
||||
<a href="#" class="text-white ms-3"><i class="bi bi-telephone"></i></a>
|
||||
<a href="#" class="text-white ms-3" id="settings-button"><i class="bi bi-gear"></i></a>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="chat-body">
|
||||
<div class="message-day-divider">
|
||||
<span>Today</span>
|
||||
</div>
|
||||
|
||||
<div class="message received">
|
||||
<div class="message-bubble">
|
||||
<p class="mb-0">Hey! How's it going?</p>
|
||||
<span class="message-time">10:00 AM</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="message sent">
|
||||
<div class="message-bubble">
|
||||
<p class="mb-0">Pretty good! Just working on a new project. You?</p>
|
||||
<span class="message-time">10:01 AM</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="message received">
|
||||
<div class="message-bubble">
|
||||
<p class="mb-0">Same here. This is a mockup of the chat interface.</p>
|
||||
<span class="message-time">10:02 AM</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="message received">
|
||||
<div class="message-bubble">
|
||||
<p class="mb-0">What do you think?</p>
|
||||
<span class="message-time">10:02 AM</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="message sent">
|
||||
<div class="message-bubble">
|
||||
<p class="mb-0">Looks great! The dark mode is really nice.</p>
|
||||
<span class="message-time">10:03 AM</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="message sent">
|
||||
<div class="message-bubble">
|
||||
<p class="mb-0">And the primary color #0D6EFD for my messages looks cool.</p>
|
||||
<span class="message-time">10:03 AM</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="message sent">
|
||||
<div class="message-bubble voice-message">
|
||||
<i class="bi bi-play-circle-fill"></i>
|
||||
<div class="voice-progress"></div>
|
||||
<span class="message-time">10:05 AM</span>
|
||||
</div>
|
||||
<p class="hint"><?= ($_SERVER['HTTP_HOST'] ?? '') === 'appwizzy.com' ? 'AppWizzy' : '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>
|
||||
</main>
|
||||
<footer>
|
||||
Page updated: <?= htmlspecialchars($now) ?> (UTC)
|
||||
</footer>
|
||||
|
||||
<div class="chat-footer">
|
||||
<textarea id="message-input" class="form-control" placeholder="Type a message..."></textarea>
|
||||
<button id="emoji-btn" class="btn btn-secondary"><i class="bi bi-emoji-smile"></i></button>
|
||||
<button id="attachment-btn" class="btn btn-secondary"><i class="bi bi-paperclip"></i></button>
|
||||
<input type="file" id="attachment-input" style="display: none;" accept="image/*,video/*">
|
||||
<button id="mic-btn" class="btn btn-primary mic-button"><i class="bi bi-mic-fill"></i></button>
|
||||
<button id="send-button" class="btn btn-primary send-button" style="display: none;"><i class="bi bi-send-fill"></i></button>
|
||||
</div>
|
||||
|
||||
<div class="theme-panel" id="theme-panel">
|
||||
<h5>Theme</h5>
|
||||
<button class="btn btn-sm btn-light" id="light-theme-button">Light</button>
|
||||
<button class="btn btn-sm btn-dark" id="dark-theme-button">Dark</button>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
// Theme switcher logic
|
||||
const settingsButton = document.getElementById('settings-button');
|
||||
const themePanel = document.getElementById('theme-panel');
|
||||
const lightThemeButton = document.getElementById('light-theme-button');
|
||||
const darkThemeButton = document.getElementById('dark-theme-button');
|
||||
|
||||
settingsButton.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
themePanel.classList.toggle('show');
|
||||
});
|
||||
|
||||
function setTheme(theme) {
|
||||
document.body.dataset.theme = theme;
|
||||
localStorage.setItem('theme', theme);
|
||||
themePanel.classList.remove('show');
|
||||
}
|
||||
|
||||
lightThemeButton.addEventListener('click', () => setTheme('light'));
|
||||
darkThemeButton.addEventListener('click', () => setTheme('dark'));
|
||||
|
||||
// Apply saved theme on load
|
||||
const savedTheme = localStorage.getItem('theme') || 'dark';
|
||||
document.body.dataset.theme = savedTheme;
|
||||
|
||||
// Hide theme panel if clicked outside
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!themePanel.contains(e.target) && !settingsButton.contains(e.target)) {
|
||||
themePanel.classList.remove('show');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Existing scripts for message input and voice recording
|
||||
const messageInput = document.getElementById('message-input');
|
||||
const sendButton = document.getElementById('send-button');
|
||||
const micButton = document.getElementById('mic-btn');
|
||||
|
||||
messageInput.addEventListener('input', () => {
|
||||
if (messageInput.value.trim() !== '') {
|
||||
sendButton.style.display = 'block';
|
||||
micButton.style.display = 'none';
|
||||
} else {
|
||||
sendButton.style.display = 'none';
|
||||
micButton.style.display = 'block';
|
||||
}
|
||||
});
|
||||
|
||||
const chatBody = document.querySelector('.chat-body');
|
||||
let mediaRecorder;
|
||||
let audioChunks = [];
|
||||
let voiceMessages = []; // To store voice message blobs
|
||||
|
||||
micButton.addEventListener('mousedown', async () => {
|
||||
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
|
||||
alert('Your browser does not support audio recording.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
mediaRecorder = new MediaRecorder(stream);
|
||||
mediaRecorder.start();
|
||||
audioChunks = [];
|
||||
|
||||
mediaRecorder.addEventListener('dataavailable', event => {
|
||||
audioChunks.push(event.data);
|
||||
});
|
||||
|
||||
micButton.classList.add('recording');
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error accessing microphone:', err);
|
||||
alert('Could not access your microphone. Please check your browser permissions.');
|
||||
}
|
||||
});
|
||||
|
||||
micButton.addEventListener('mouseup', () => {
|
||||
if (mediaRecorder && mediaRecorder.state === 'recording') {
|
||||
mediaRecorder.stop();
|
||||
micButton.classList.remove('recording');
|
||||
|
||||
mediaRecorder.addEventListener('stop', () => {
|
||||
const audioBlob = new Blob(audioChunks, { type: 'audio/webm' });
|
||||
const audioUrl = URL.createObjectURL(audioBlob);
|
||||
const voiceMessageId = voiceMessages.push(audioBlob) - 1;
|
||||
|
||||
const messageTime = new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
|
||||
|
||||
const voiceMessageHTML = `
|
||||
<div class="message sent">
|
||||
<div class="message-bubble voice-message" data-voice-id="${voiceMessageId}">
|
||||
<audio src="${audioUrl}" style="display:none;"></audio>
|
||||
<div class="voice-message-controls">
|
||||
<button class="play-button btn"><i class="bi bi-play-circle-fill"></i></button>
|
||||
<div class="voice-progress-container">
|
||||
<div class="voice-progress"></div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="share-button btn"><i class="bi bi-share-fill"></i></button>
|
||||
<span class="message-time">${messageTime}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
chatBody.insertAdjacentHTML('beforeend', voiceMessageHTML);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
chatBody.addEventListener('click', async (e) => {
|
||||
const playButton = e.target.closest('.play-button');
|
||||
const shareButton = e.target.closest('.share-button');
|
||||
|
||||
if (playButton) {
|
||||
const voiceMessage = playButton.closest('.voice-message');
|
||||
const audio = voiceMessage.querySelector('audio');
|
||||
const playIcon = playButton.querySelector('i');
|
||||
|
||||
if (audio.paused) {
|
||||
audio.play();
|
||||
playIcon.classList.remove('bi-play-circle-fill');
|
||||
playIcon.classList.add('bi-pause-circle-fill');
|
||||
} else {
|
||||
audio.pause();
|
||||
playIcon.classList.remove('bi-pause-circle-fill');
|
||||
playIcon.classList.add('bi-play-circle-fill');
|
||||
}
|
||||
|
||||
audio.addEventListener('ended', () => {
|
||||
playIcon.classList.remove('bi-pause-circle-fill');
|
||||
playIcon.classList.add('bi-play-circle-fill');
|
||||
voiceMessage.querySelector('.voice-progress').style.width = `0%`;
|
||||
});
|
||||
|
||||
audio.addEventListener('timeupdate', () => {
|
||||
const progress = (audio.currentTime / audio.duration) * 100;
|
||||
voiceMessage.querySelector('.voice-progress').style.width = `${progress}%`;
|
||||
});
|
||||
}
|
||||
|
||||
if (shareButton) {
|
||||
const voiceMessage = shareButton.closest('.voice-message');
|
||||
const voiceId = voiceMessage.dataset.voiceId;
|
||||
const audioBlob = voiceMessages[voiceId];
|
||||
|
||||
if (!audioBlob) {
|
||||
alert('Could not find the audio to share.');
|
||||
return;
|
||||
}
|
||||
|
||||
const audioFile = new File([audioBlob], `chatterly-voice-${new Date().toISOString()}.webm`, {
|
||||
type: audioBlob.type,
|
||||
});
|
||||
|
||||
if (navigator.canShare && navigator.canShare({ files: [audioFile] })) {
|
||||
try {
|
||||
await navigator.share({
|
||||
files: [audioFile],
|
||||
title: 'Voice Message',
|
||||
text: 'Listen to my voice message from Chatterly.',
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error sharing:', error);
|
||||
}
|
||||
} else {
|
||||
// Fallback for browsers that don't support sharing files
|
||||
const link = document.createElement('a');
|
||||
link.href = URL.createObjectURL(audioBlob);
|
||||
link.download = `chatterly-voice-${new Date().toISOString()}.webm`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Emoji panel logic
|
||||
const emojiBtn = document.getElementById('emoji-btn');
|
||||
const emojiPanel = document.getElementById('emoji-panel');
|
||||
const emojiGrid = document.getElementById('emojis');
|
||||
const stickerGrid = document.getElementById('stickers');
|
||||
const categoryBtns = document.querySelectorAll('.category-btn');
|
||||
|
||||
emojiBtn.addEventListener('click', () => {
|
||||
emojiPanel.classList.toggle('show');
|
||||
});
|
||||
|
||||
const emojis = ['😀', '😂', '😍', '🤔', '👍', '❤️', '🎉', '🔥', '💯', '🙏', '😎', '😢', '😡', '🤯', '😴', '👋'];
|
||||
emojis.forEach(emoji => {
|
||||
const emojiEl = document.createElement('span');
|
||||
emojiEl.textContent = emoji;
|
||||
emojiGrid.appendChild(emojiEl);
|
||||
});
|
||||
|
||||
const stickers = [
|
||||
'https://picsum.photos/id/10/80/80',
|
||||
'https://picsum.photos/id/20/80/80',
|
||||
'https://picsum.photos/id/30/80/80',
|
||||
'https://picsum.photos/id/40/80/80',
|
||||
'https://picsum.photos/id/50/80/80',
|
||||
'https://picsum.photos/id/60/80/80',
|
||||
];
|
||||
stickers.forEach(stickerUrl => {
|
||||
const stickerEl = document.createElement('img');
|
||||
stickerEl.src = stickerUrl;
|
||||
stickerGrid.appendChild(stickerEl);
|
||||
});
|
||||
|
||||
categoryBtns.forEach(btn => {
|
||||
btn.addEventListener('click', () => {
|
||||
categoryBtns.forEach(b => b.classList.remove('active'));
|
||||
btn.classList.add('active');
|
||||
if (btn.dataset.category === 'emojis') {
|
||||
emojiGrid.classList.remove('hidden');
|
||||
stickerGrid.classList.add('hidden');
|
||||
} else {
|
||||
emojiGrid.classList.add('hidden');
|
||||
stickerGrid.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function sendMessage(content) {
|
||||
const messageTime = new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
|
||||
const message = `
|
||||
<div class="message sent">
|
||||
<div class="message-bubble">
|
||||
${content}
|
||||
<span class="message-time">${messageTime}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
chatBody.insertAdjacentHTML('beforeend', message);
|
||||
chatBody.scrollTop = chatBody.scrollHeight;
|
||||
emojiPanel.classList.remove('show');
|
||||
}
|
||||
|
||||
emojiGrid.addEventListener('click', e => {
|
||||
if (e.target.tagName === 'SPAN') {
|
||||
sendMessage(`<p class="mb-0">${e.target.textContent}</p>`);
|
||||
}
|
||||
});
|
||||
|
||||
stickerGrid.addEventListener('click', e => {
|
||||
if (e.target.tagName === 'IMG') {
|
||||
sendMessage(`<img src="${e.target.src}" style="max-width: 100px; height: auto; display: block;">`);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
const mediaBtn = document.querySelector('.media-btn');
|
||||
const mediaInput = document.getElementById('media-input');
|
||||
const chatMessages = document.querySelector('.chat-messages');
|
||||
|
||||
if (mediaBtn) {
|
||||
mediaBtn.addEventListener('click', () => {
|
||||
if (mediaInput) {
|
||||
mediaInput.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (mediaInput) {
|
||||
mediaInput.addEventListener('change', (event) => {
|
||||
const file = event.target.files[0];
|
||||
if (file && file.type.startsWith('image/')) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
const imageSrc = e.target.result;
|
||||
createImageMessage(imageSrc);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createImageMessage(imageSrc) {
|
||||
const messageId = 'msg-' + new Date().getTime();
|
||||
const messageHTML = `
|
||||
<div class="message-bubble sent" id="${messageId}">
|
||||
<div class="message-content image-message">
|
||||
<img src="${imageSrc}" alt="Image message">
|
||||
</div>
|
||||
<div class="message-timestamp">${new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}</div>
|
||||
</div>
|
||||
`;
|
||||
if (chatMessages) {
|
||||
chatMessages.insertAdjacentHTML('beforeend', messageHTML);
|
||||
chatMessages.scrollTop = chatMessages.scrollHeight;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user