File size: 26,380 Bytes
f9126f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 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 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Morning Sunshine - Email Notifications</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.email-item {
transition: all 0.3s ease;
}
.email-item:hover {
transform: translateY(-2px);
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.sun-animation {
animation: sunRise 2s ease-in-out infinite alternate;
}
@keyframes sunRise {
0% { transform: translateY(0) rotate(0deg); }
100% { transform: translateY(-5px) rotate(5deg); }
}
.notification-bell {
animation: ring 4s ease infinite;
transform-origin: 50% 0%;
}
@keyframes ring {
0% { transform: rotate(0deg); }
2% { transform: rotate(10deg); }
4% { transform: rotate(-10deg); }
6% { transform: rotate(10deg); }
8% { transform: rotate(-10deg); }
10% { transform: rotate(0deg); }
100% { transform: rotate(0deg); }
}
.unsubscribed {
opacity: 0.6;
background-color: #f3f4f6;
}
.unsubscribed td {
color: #9ca3af !important;
}
</style>
</head>
<body class="bg-gradient-to-br from-blue-50 to-indigo-100 min-h-screen">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex justify-between items-center mb-12">
<div class="flex items-center">
<i class="fas fa-sun text-yellow-400 text-4xl mr-3 sun-animation"></i>
<h1 class="text-3xl font-bold text-indigo-800">Morning Sunshine</h1>
</div>
<div class="relative">
<i class="fas fa-bell text-indigo-600 text-2xl notification-bell"></i>
<span class="absolute -top-2 -right-2 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">3</span>
</div>
</header>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Email Management Section -->
<div class="bg-white rounded-xl shadow-lg p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl font-semibold text-indigo-700">Email Recipients</h2>
<button id="addEmailBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg flex items-center">
<i class="fas fa-plus mr-2"></i> Add Email
</button>
</div>
<!-- Add Email Modal (hidden by default) -->
<div id="addEmailModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold">Add New Email</h3>
<button id="closeModalBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2" for="newEmail">Email Address</label>
<input type="email" id="newEmail" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="example@domain.com">
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2" for="recipientName">Recipient Name (Optional)</label>
<input type="text" id="recipientName" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="John Doe">
</div>
<div class="mb-4">
<label class="flex items-center">
<input type="checkbox" id="subscribeCheckbox" class="rounded text-indigo-600 focus:ring-indigo-500" checked>
<span class="ml-2 text-gray-700">Subscribe to notifications</span>
</label>
</div>
<div class="flex justify-end">
<button id="cancelAddBtn" class="mr-2 px-4 py-2 text-gray-600 hover:text-gray-800">Cancel</button>
<button id="confirmAddBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg">Add Email</button>
</div>
</div>
</div>
<!-- Email List -->
<div class="overflow-hidden rounded-lg border border-gray-200">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Status</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="emailTableBody" class="bg-white divide-y divide-gray-200">
<!-- Email rows will be added here dynamically -->
</tbody>
</table>
</div>
<div class="mt-4 text-sm text-gray-500">
<p><i class="fas fa-info-circle mr-1 text-indigo-500"></i> Only subscribed emails will receive notifications</p>
</div>
</div>
<!-- Notification Sender Section -->
<div class="bg-white rounded-xl shadow-lg p-6">
<h2 class="text-xl font-semibold text-indigo-700 mb-6">Send Good Morning Notification</h2>
<div class="mb-6">
<label class="block text-gray-700 mb-2">Notification Message</label>
<textarea id="notificationMessage" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 h-32" placeholder="Good morning! Wishing you a wonderful day filled with joy and productivity...">Good morning! 🌞 Wishing you a wonderful day filled with joy and productivity.
To unsubscribe from these notifications, click here: <span class="text-indigo-600">[UNSUBSCRIBE_LINK]</span></textarea>
</div>
<div class="mb-6">
<label class="block text-gray-700 mb-2">Schedule Time</label>
<div class="flex items-center">
<select id="scheduleHour" class="px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 mr-2">
<option value="7" selected>7</option>
<option value="8">8</option>
<option value="9">9</option>
</select>
<span class="mr-2">:</span>
<select id="scheduleMinute" class="px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 mr-4">
<option value="0" selected>00</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
<select id="scheduleAmPm" class="px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="AM" selected>AM</option>
<option value="PM">PM</option>
</select>
</div>
</div>
<div class="mb-6">
<label class="flex items-center">
<input type="checkbox" id="includeWeather" class="rounded text-indigo-600 focus:ring-indigo-500" checked>
<span class="ml-2 text-gray-700">Include weather information</span>
</label>
<label class="flex items-center mt-2">
<input type="checkbox" id="includeQuote" class="rounded text-indigo-600 focus:ring-indigo-500" checked>
<span class="ml-2 text-gray-700">Include daily inspirational quote</span>
</label>
</div>
<div class="flex flex-wrap gap-3">
<button id="sendNowBtn" class="bg-gradient-to-r from-yellow-400 to-yellow-500 hover:from-yellow-500 hover:to-yellow-600 text-white px-6 py-3 rounded-lg font-medium flex items-center">
<i class="fas fa-paper-plane mr-2"></i> Send Now
</button>
<button id="scheduleBtn" class="bg-gradient-to-r from-indigo-500 to-purple-600 hover:from-indigo-600 hover:to-purple-700 text-white px-6 py-3 rounded-lg font-medium flex items-center">
<i class="fas fa-clock mr-2"></i> Schedule Daily
</button>
<button id="testBtn" class="border border-indigo-500 text-indigo-600 hover:bg-indigo-50 px-6 py-3 rounded-lg font-medium flex items-center">
<i class="fas fa-vial mr-2"></i> Send Test
</button>
</div>
<div id="statusMessage" class="mt-4 p-3 rounded-lg hidden"></div>
</div>
</div>
<!-- Stats Section -->
<div class="mt-12 bg-white rounded-xl shadow-lg p-6">
<h2 class="text-xl font-semibold text-indigo-700 mb-6">Notification Statistics</h2>
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
<div class="bg-blue-50 p-4 rounded-lg flex items-center">
<div class="bg-blue-100 p-3 rounded-full mr-4">
<i class="fas fa-users text-blue-600 text-xl"></i>
</div>
<div>
<p class="text-sm text-blue-500">Total Recipients</p>
<p id="totalRecipients" class="text-2xl font-bold text-blue-800">0</p>
</div>
</div>
<div class="bg-green-50 p-4 rounded-lg flex items-center">
<div class="bg-green-100 p-3 rounded-full mr-4">
<i class="fas fa-user-check text-green-600 text-xl"></i>
</div>
<div>
<p class="text-sm text-green-500">Subscribed</p>
<p id="subscribedCount" class="text-2xl font-bold text-green-800">0</p>
</div>
</div>
<div class="bg-purple-50 p-4 rounded-lg flex items-center">
<div class="bg-purple-100 p-3 rounded-full mr-4">
<i class="fas fa-paper-plane text-purple-600 text-xl"></i>
</div>
<div>
<p class="text-sm text-purple-500">Notifications Sent</p>
<p id="notificationsSent" class="text-2xl font-bold text-purple-800">0</p>
</div>
</div>
<div class="bg-indigo-50 p-4 rounded-lg flex items-center">
<div class="bg-indigo-100 p-3 rounded-full mr-4">
<i class="fas fa-calendar-check text-indigo-600 text-xl"></i>
</div>
<div>
<p class="text-sm text-indigo-500">Next Scheduled</p>
<p id="nextScheduled" class="text-2xl font-bold text-indigo-800">Not set</p>
</div>
</div>
</div>
</div>
</div>
<script>
// Sample data - in a real app, this would come from a database
let emails = [
{ id: 1, name: "John Doe", email: "john@example.com", subscribed: true },
{ id: 2, name: "Jane Smith", email: "jane@example.com", subscribed: true },
{ id: 3, name: "Mike Johnson", email: "mike@example.com", subscribed: false }
];
// DOM elements
const emailTableBody = document.getElementById('emailTableBody');
const addEmailBtn = document.getElementById('addEmailBtn');
const addEmailModal = document.getElementById('addEmailModal');
const closeModalBtn = document.getElementById('closeModalBtn');
const cancelAddBtn = document.getElementById('cancelAddBtn');
const confirmAddBtn = document.getElementById('confirmAddBtn');
const newEmailInput = document.getElementById('newEmail');
const recipientNameInput = document.getElementById('recipientName');
const subscribeCheckbox = document.getElementById('subscribeCheckbox');
const sendNowBtn = document.getElementById('sendNowBtn');
const scheduleBtn = document.getElementById('scheduleBtn');
const testBtn = document.getElementById('testBtn');
const statusMessage = document.getElementById('statusMessage');
const totalRecipients = document.getElementById('totalRecipients');
const subscribedCount = document.getElementById('subscribedCount');
const notificationsSent = document.getElementById('notificationsSent');
const nextScheduled = document.getElementById('nextScheduled');
const notificationMessage = document.getElementById('notificationMessage');
// Stats
let stats = {
sentCount: 42,
nextSchedule: "Tomorrow 7:00 AM"
};
// Initialize the app
document.addEventListener('DOMContentLoaded', function() {
renderEmailTable();
updateStats();
// Set up event listeners
addEmailBtn.addEventListener('click', showAddEmailModal);
closeModalBtn.addEventListener('click', hideAddEmailModal);
cancelAddBtn.addEventListener('click', hideAddEmailModal);
confirmAddBtn.addEventListener('click', addNewEmail);
sendNowBtn.addEventListener('click', sendNotificationsNow);
scheduleBtn.addEventListener('click', scheduleDailyNotifications);
testBtn.addEventListener('click', sendTestNotification);
});
// Render the email table
function renderEmailTable() {
emailTableBody.innerHTML = '';
if (emails.length === 0) {
emailTableBody.innerHTML = `
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
No email recipients added yet. Click "Add Email" to get started.
</td>
</tr>
`;
return;
}
emails.forEach(email => {
const row = document.createElement('tr');
row.className = `email-item hover:bg-gray-50 ${email.subscribed ? '' : 'unsubscribed'}`;
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">${email.name || '-'}</td>
<td class="px-6 py-4 whitespace-nowrap">${email.email}</td>
<td class="px-6 py-4 whitespace-nowrap">
<label class="inline-flex items-center">
<input type="checkbox" class="rounded text-indigo-600 focus:ring-indigo-500 subscription-toggle"
data-id="${email.id}" ${email.subscribed ? 'checked' : ''}>
<span class="ml-2">${email.subscribed ? 'Subscribed' : 'Unsubscribed'}</span>
</label>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<button onclick="deleteEmail(${email.id})" class="text-red-600 hover:text-red-800 mr-3">
<i class="fas fa-trash-alt"></i>
</button>
<button onclick="editEmail(${email.id})" class="text-indigo-600 hover:text-indigo-800">
<i class="fas fa-edit"></i>
</button>
</td>
`;
emailTableBody.appendChild(row);
});
// Add event listeners to subscription toggles
document.querySelectorAll('.subscription-toggle').forEach(toggle => {
toggle.addEventListener('change', function() {
const id = parseInt(this.getAttribute('data-id'));
toggleSubscription(id, this.checked);
});
});
}
// Toggle subscription status
function toggleSubscription(id, isSubscribed) {
const emailIndex = emails.findIndex(e => e.id === id);
if (emailIndex !== -1) {
emails[emailIndex].subscribed = isSubscribed;
updateStats();
showStatus(`Subscription status updated for ${emails[emailIndex].email}`, 'success');
// Re-render the table to update the styling
renderEmailTable();
}
}
// Show the add email modal
function showAddEmailModal() {
addEmailModal.classList.remove('hidden');
addEmailModal.classList.add('flex');
newEmailInput.focus();
subscribeCheckbox.checked = true;
}
// Hide the add email modal
function hideAddEmailModal() {
addEmailModal.classList.add('hidden');
addEmailModal.classList.remove('flex');
newEmailInput.value = '';
recipientNameInput.value = '';
}
// Add a new email
function addNewEmail() {
const email = newEmailInput.value.trim();
const name = recipientNameInput.value.trim();
const subscribed = subscribeCheckbox.checked;
if (!email) {
showStatus('Please enter an email address', 'error');
return;
}
if (!validateEmail(email)) {
showStatus('Please enter a valid email address', 'error');
return;
}
// Check if email already exists
if (emails.some(e => e.email === email)) {
showStatus('This email is already in the list', 'error');
return;
}
const newEmail = {
id: Date.now(), // Simple unique ID
name: name || null,
email: email,
subscribed: subscribed
};
emails.push(newEmail);
renderEmailTable();
updateStats();
hideAddEmailModal();
showStatus('Email added successfully!', 'success');
}
// Delete an email
function deleteEmail(id) {
if (confirm('Are you sure you want to remove this email recipient?')) {
emails = emails.filter(email => email.id !== id);
renderEmailTable();
updateStats();
showStatus('Email removed successfully', 'success');
}
}
// Edit an email
function editEmail(id) {
const email = emails.find(e => e.id === id);
if (email) {
newEmailInput.value = email.email;
recipientNameInput.value = email.name || '';
subscribeCheckbox.checked = email.subscribed;
showAddEmailModal();
// Remove the email from the list
emails = emails.filter(e => e.id !== id);
}
}
// Validate email format
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
// Send notifications now
function sendNotificationsNow() {
const subscribedEmails = emails.filter(e => e.subscribed);
if (subscribedEmails.length === 0) {
showStatus('No subscribed email recipients to send to', 'error');
return;
}
showStatus('Sending notifications to subscribed recipients...', 'info');
// Replace unsubscribe link placeholder with actual links
const message = notificationMessage.value;
const messagesWithLinks = subscribedEmails.map(email => {
const unsubscribeLink = `https://yourapp.com/unsubscribe?email=${encodeURIComponent(email.email)}`;
return message.replace('[UNSUBSCRIBE_LINK]', unsubscribeLink);
});
// Simulate sending
setTimeout(() => {
stats.sentCount += subscribedEmails.length;
updateStats();
showStatus(`Successfully sent ${subscribedEmails.length} good morning notifications to subscribed recipients!`, 'success');
}, 1500);
}
// Schedule daily notifications
function scheduleDailyNotifications() {
const subscribedEmails = emails.filter(e => e.subscribed);
if (subscribedEmails.length === 0) {
showStatus('No subscribed email recipients to schedule for', 'error');
return;
}
const hour = document.getElementById('scheduleHour').value;
const minute = document.getElementById('scheduleMinute').value;
const ampm = document.getElementById('scheduleAmPm').value;
stats.nextSchedule = `Daily at ${hour}:${minute} ${ampm} (${subscribedEmails.length} recipients)`;
updateStats();
showStatus(`Daily notifications scheduled for ${hour}:${minute} ${ampm} for ${subscribedEmails.length} subscribed recipients`, 'success');
}
// Send test notification
function sendTestNotification() {
const testEmail = "your-email@example.com";
// Check if test email is in the list
const existingEmail = emails.find(e => e.email === testEmail);
if (existingEmail && !existingEmail.subscribed) {
showStatus('Your test email is in the list but unsubscribed', 'error');
return;
}
showStatus('Sending test notification to your email...', 'info');
// Replace unsubscribe link placeholder with actual link
const message = notificationMessage.value;
const unsubscribeLink = `https://yourapp.com/unsubscribe?email=${encodeURIComponent(testEmail)}`;
const messageWithLink = message.replace('[UNSUBSCRIBE_LINK]', unsubscribeLink);
// Simulate sending
setTimeout(() => {
showStatus('Test notification sent successfully! Check your inbox.', 'success');
}, 1000);
}
// Show status message
function showStatus(message, type) {
statusMessage.textContent = message;
statusMessage.className = 'mt-4 p-3 rounded-lg';
switch (type) {
case 'error':
statusMessage.classList.add('bg-red-100', 'text-red-700');
break;
case 'success':
statusMessage.classList.add('bg-green-100', 'text-green-700');
break;
case 'info':
statusMessage.classList.add('bg-blue-100', 'text-blue-700');
break;
default:
statusMessage.classList.add('bg-gray-100', 'text-gray-700');
}
statusMessage.classList.remove('hidden');
// Hide after 5 seconds
setTimeout(() => {
statusMessage.classList.add('hidden');
}, 5000);
}
// Update statistics
function updateStats() {
const subscribedEmails = emails.filter(e => e.subscribed);
totalRecipients.textContent = emails.length;
subscribedCount.textContent = subscribedEmails.length;
notificationsSent.textContent = stats.sentCount;
nextScheduled.textContent = stats.nextSchedule;
}
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Kbala/testspace" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |