Spaces:
Running
// ========== GLOBAL CONFIG ==========
Browse filesconst app = {
version: "1.0.0",
darkMode: false,
user: null,
tiers: ["Prompts", "Standard Images", "High-Quality Images", "Videos"]
};
// ========== THEME HANDLER ==========
const themeToggle = document.querySelector("#theme-toggle");
themeToggle?.addEventListener("click", () => {
document.body.classList.toggle("dark");
app.darkMode = !app.darkMode;
localStorage.setItem("darkMode", app.darkMode);
});
// Load saved theme
window.addEventListener("DOMContentLoaded", () => {
const savedMode = localStorage.getItem("darkMode");
if (savedMode === "true") document.body.classList.add("dark");
loadGallery();
loadTestimonials();
});
// ========== AUTHENTICATION ==========
async function loginUser(email, password) {
// Example: integrate Firebase or Supabase here
console.log(`Logging in ${email}`);
// Placeholder logic
app.user = { email, tier: "Standard Images" };
updateUIForUser();
}
async function signupUser(email, password, tier) {
console.log(`Signing up ${email} for ${tier}`);
app.user = { email, tier };
updateUIForUser();
}
function logoutUser() {
app.user = null;
updateUIForUser();
}
function updateUIForUser() {
const userDisplay = document.querySelector("#user-display");
if (app.user) {
userDisplay.textContent = `Welcome, ${app.user.email} (${app.user.tier})`;
} else {
userDisplay.textContent = "Guest Mode";
}
}
// ========== GALLERY HANDLER ==========
async function loadGallery() {
const gallery = document.querySelector(".gallery");
if (!gallery) return;
gallery.innerHTML = "<p>Loading your AI masterpieces...</p>";
// Example fetch (you’ll hook to your backend or Firestore)
const images = [
{ src: "ai1.jpg", title: "Urban Jungle", quality: "HD" },
{ src: "ai2.jpg", title: "Neon Dreams", quality: "4K" }
];
gallery.innerHTML = images
.map(
(img) => `
<div class="gallery-item">
<img src="${img.src}" alt="${img.title}" />
<div class="overlay">
<h3>${img.title}</h3>
<span>${img.quality}</span>
</div>
</div>`
)
.join("");
}
// ========== TESTIMONIALS ==========
async function loadTestimonials() {
const container = document.querySelector(".testimonials");
if (!container) return;
const testimonials = [
{ name: "Maya", text: "This AI changed my brand visuals overnight!" },
{ name: "Rico", text: "The realism and motion are beyond perfect." },
{ name: "Ava", text: "I tested others — nothing compares to this quality!" }
];
container.innerHTML = testimonials
.map(
(t) => `
<div class="testimonial-card">
<p>"${t.text}"</p>
<h4>- ${t.name}</h4>
</div>`
)
.join("");
}
// ========== BEFORE/AFTER FEATURE ==========
function initBeforeAfter() {
const slider = document.querySelector(".before-after-slider");
if (!slider) return;
const before = slider.querySelector(".before");
const after = slider.querySelector(".after");
const handle = slider.querySelector(".handle");
let isDragging = false;
handle.addEventListener("mousedown", () => (isDragging = true));
window.addEventListener("mouseup", () => (isDragging = false));
window.addEventListener("mousemove", (e) => {
if (!isDragging) return;
const rect = slider.getBoundingClientRect();
const offsetX = e.clientX - rect.left;
const percent = Math.min(Math.max(offsetX / rect.width, 0), 1);
before.style.width = `${percent * 100}%`;
handle.style.left = `${percent * 100}%`;
});
}
// ========== PROMPT GENERATOR ==========
function generatePromptPack(count = 100) {
const basePrompts = [
"Cinematic portrait, ultra-detailed lighting",
"Abstract fusion of neon and shadow",
"Real-world wildlife with surreal landscapes"
];
const prompts = Array.from({ length: count }, () =>
basePrompts[Math.floor(Math.random() * basePrompts.length)]
);
return prompts;
}
// ========== SUBSCRIPTION HANDLER ==========
function showSubscriptionTiers() {
const section = document.querySelector(".pricing");
if (!section) return;
const tiers = [
{ name: "Prompts", price: "$10.99", perks: ["100 AI Prompts"] },
{
name: "Standard Images",
price: "$300",
perks: ["10 HD AI Images", "Access to Prompt Tools"]
},
{
name: "High-Quality Images",
price: "$1200",
perks: ["20 4K Images", "Custom Style Blends"]
},
{
name: "Video + Ads",
price: "$6300",
perks: ["AI Video Creation", "Ad Creative Assistance"]
}
];
section.innerHTML = tiers
.map(
(tier) => `
<div class="tier-card">
<h2>${tier.name}</h2>
<p class="price">${tier.price}</p>
<ul>${tier.perks.map((p) => `<li>${p}</li>`).join("")}</ul>
<button onclick="purchaseTier('${tier.name}')">Subscribe</button>
</div>`
)
.join("");
}
function purchaseTier(tierName) {
alert(`Subscribed to ${tierName} successfully!`);
app.user = { ...app.user, tier: tierName };
updateUIForUser();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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
}
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
}
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
tabs.forEach(tab => {
|
| 48 |
-
tab.addEventListener('click', function() {
|
| 49 |
-
const tabId = this.getAttribute('data-processor-tab');
|
| 50 |
-
|
| 51 |
-
// Update active tab
|
| 52 |
-
tabs.forEach(t => t.classList.remove('bg-accent-red', 'bg-accent-green', 'bg-accent-blue');
|
| 53 |
-
this.classList.add(this.getAttribute('data-tab-color'));
|
| 54 |
-
|
| 55 |
-
// Show corresponding processor section
|
| 56 |
-
document.querySelectorAll('.processor-section').forEach(section => {
|
| 57 |
-
section.classList.remove('active');
|
| 58 |
-
});
|
| 59 |
-
|
| 60 |
-
const targetSection = document.getElementById(`${tabId}-processor`);
|
| 61 |
-
if (targetSection) {
|
| 62 |
-
targetSection.classList.add('active');
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
| 129 |
}
|
|
|
|
| 130 |
}
|
| 131 |
|
| 132 |
-
// Initialize
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
});
|
| 151 |
|
| 152 |
-
card.addEventListener('mouseleave',
|
| 153 |
-
|
| 154 |
});
|
| 155 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
}
|
| 157 |
|
| 158 |
-
//
|
| 159 |
-
|
|
|
|
|
|
| 1 |
+
=== GLOBAL CONFIG ==========
|
| 2 |
+
const app = {
|
| 3 |
+
version: "1.0.0",
|
| 4 |
+
darkMode: false,
|
| 5 |
+
user: null,
|
| 6 |
+
tiers: ["Prompts", "Standard Images", "High-Quality Images", "Videos"]
|
| 7 |
+
};
|
| 8 |
+
|
| 9 |
+
// ========== THEME HANDLER ==========
|
| 10 |
+
const themeToggle = document.querySelector("#theme-toggle");
|
| 11 |
+
themeToggle?.addEventListener("click", () => {
|
| 12 |
+
document.body.classList.toggle("dark");
|
| 13 |
+
app.darkMode = !app.darkMode;
|
| 14 |
+
localStorage.setItem("darkMode", app.darkMode);
|
| 15 |
});
|
| 16 |
|
| 17 |
+
// Load saved theme
|
| 18 |
+
window.addEventListener("DOMContentLoaded", () => {
|
| 19 |
+
const savedMode = localStorage.getItem("darkMode");
|
| 20 |
+
if (savedMode === "true") document.body.classList.add("dark");
|
| 21 |
+
loadGallery();
|
| 22 |
+
loadTestimonials();
|
| 23 |
+
});
|
| 24 |
|
| 25 |
+
// ========== AUTHENTICATION ==========
|
| 26 |
+
async function loginUser(email, password) {
|
| 27 |
+
// Example: integrate Firebase or Supabase here
|
| 28 |
+
console.log(`Logging in ${email}`);
|
| 29 |
+
// Placeholder logic
|
| 30 |
+
app.user = { email, tier: "Standard Images" };
|
| 31 |
+
updateUIForUser();
|
| 32 |
}
|
| 33 |
|
| 34 |
+
async function signupUser(email, password, tier) {
|
| 35 |
+
console.log(`Signing up ${email} for ${tier}`);
|
| 36 |
+
app.user = { email, tier };
|
| 37 |
+
updateUIForUser();
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function logoutUser() {
|
| 41 |
+
app.user = null;
|
| 42 |
+
updateUIForUser();
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
function updateUIForUser() {
|
| 46 |
+
const userDisplay = document.querySelector("#user-display");
|
| 47 |
+
if (app.user) {
|
| 48 |
+
userDisplay.textContent = `Welcome, ${app.user.email} (${app.user.tier})`;
|
| 49 |
+
} else {
|
| 50 |
+
userDisplay.textContent = "Guest Mode";
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
// ========== GALLERY HANDLER ==========
|
| 55 |
+
async function loadGallery() {
|
| 56 |
+
const gallery = document.querySelector(".gallery");
|
| 57 |
+
if (!gallery) return;
|
| 58 |
+
gallery.innerHTML = "<p>Loading your AI masterpieces...</p>";
|
| 59 |
+
|
| 60 |
+
// Example fetch (you'll hook to your backend or Firestore)
|
| 61 |
+
const images = [
|
| 62 |
+
{ src: "ai1.jpg", title: "Urban Jungle", quality: "HD" },
|
| 63 |
+
{ src: "ai2.jpg", title: "Neon Dreams", quality: "4K" }
|
| 64 |
+
];
|
| 65 |
+
|
| 66 |
+
gallery.innerHTML = images
|
| 67 |
+
.map(
|
| 68 |
+
(img) => `
|
| 69 |
+
<div class="gallery-item">
|
| 70 |
+
<img src="${img.src}" alt="${img.title}" />
|
| 71 |
+
<div class="overlay">
|
| 72 |
+
<h3>${img.title}</h3>
|
| 73 |
+
<span>${img.quality}</span>
|
| 74 |
+
</div>
|
| 75 |
+
</div>`
|
| 76 |
+
)
|
| 77 |
+
.join("");
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// ========== TESTIMONIALS ==========
|
| 81 |
+
async function loadTestimonials() {
|
| 82 |
+
const container = document.querySelector(".testimonials");
|
| 83 |
+
if (!container) return;
|
| 84 |
+
const testimonials = [
|
| 85 |
+
{ name: "Maya", text: "This AI changed my brand visuals overnight!" },
|
| 86 |
+
{ name: "Rico", text: "The realism and motion are beyond perfect." },
|
| 87 |
+
{ name: "Ava", text: "I tested others — nothing compares to this quality!" }
|
| 88 |
+
];
|
| 89 |
+
container.innerHTML = testimonials
|
| 90 |
+
.map(
|
| 91 |
+
(t) => `
|
| 92 |
+
<div class="testimonial-card">
|
| 93 |
+
<p>"${t.text}"</p>
|
| 94 |
+
<h4>- ${t.name}</h4>
|
| 95 |
+
</div>`
|
| 96 |
+
)
|
| 97 |
+
.join("");
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
// ========== BEFORE/AFTER FEATURE ==========
|
| 101 |
+
function initBeforeAfter() {
|
| 102 |
+
const slider = document.querySelector(".before-after-slider");
|
| 103 |
+
if (!slider) return;
|
| 104 |
+
|
| 105 |
+
const before = slider.querySelector(".before");
|
| 106 |
+
const after = slider.querySelector(".after");
|
| 107 |
+
const handle = slider.querySelector(".handle");
|
| 108 |
+
|
| 109 |
+
let isDragging = false;
|
| 110 |
+
|
| 111 |
+
handle.addEventListener("mousedown", () => (isDragging = true));
|
| 112 |
+
window.addEventListener("mouseup", () => (isDragging = false));
|
| 113 |
+
window.addEventListener("mousemove", (e) => {
|
| 114 |
+
if (!isDragging) return;
|
| 115 |
+
const rect = slider.getBoundingClientRect();
|
| 116 |
+
const offsetX = e.clientX - rect.left;
|
| 117 |
+
const percent = Math.min(Math.max(offsetX / rect.width, 0), 1);
|
| 118 |
+
before.style.width = `${percent * 100}%`;
|
| 119 |
+
handle.style.left = `${percent * 100}%`;
|
| 120 |
+
});
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
// ========== PROMPT GENERATOR ==========
|
| 124 |
+
function generatePromptPack(count = 100) {
|
| 125 |
+
const basePrompts = [
|
| 126 |
+
"Cinematic portrait, ultra-detailed lighting",
|
| 127 |
+
"Abstract fusion of neon and shadow",
|
| 128 |
+
"Real-world wildlife with surreal landscapes"
|
| 129 |
+
];
|
| 130 |
+
const prompts = Array.from({ length: count }, () =>
|
| 131 |
+
basePrompts[Math.floor(Math.random() * basePrompts.length)]
|
| 132 |
+
);
|
| 133 |
+
return prompts;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
// ========== SUBSCRIPTION HANDLER ==========
|
| 137 |
+
function showSubscriptionTiers() {
|
| 138 |
+
const section = document.querySelector(".pricing");
|
| 139 |
+
if (!section) return;
|
| 140 |
+
const tiers = [
|
| 141 |
+
{ name: "Prompts", price: "$10.99", perks: ["100 AI Prompts"] },
|
| 142 |
+
{
|
| 143 |
+
name: "Standard Images",
|
| 144 |
+
price: "$300",
|
| 145 |
+
perks: ["10 HD AI Images", "Access to Prompt Tools"]
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
name: "High-Quality Images",
|
| 149 |
+
price: "$1200",
|
| 150 |
+
perks: ["20 4K Images", "Custom Style Blends"]
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
name: "Video + Ads",
|
| 154 |
+
price: "$6300",
|
| 155 |
+
perks: ["AI Video Creation", "Ad Creative Assistance"]
|
| 156 |
}
|
| 157 |
+
];
|
| 158 |
+
|
| 159 |
+
section.innerHTML = tiers
|
| 160 |
+
.map(
|
| 161 |
+
(tier) => `
|
| 162 |
+
<div class="tier-card">
|
| 163 |
+
<h2>${tier.name}</h2>
|
| 164 |
+
<p class="price">${tier.price}</p>
|
| 165 |
+
<ul>${tier.perks.map((p) => `<li>${p}</li>`).join("")}</ul>
|
| 166 |
+
<button onclick="purchaseTier('${tier.name}')">Subscribe</button>
|
| 167 |
+
</div>`
|
| 168 |
+
)
|
| 169 |
+
.join("");
|
| 170 |
}
|
| 171 |
|
| 172 |
+
function purchaseTier(tierName) {
|
| 173 |
+
alert(`Subscribed to ${tierName} successfully!`);
|
| 174 |
+
app.user = { ...app.user, tier: tierName };
|
| 175 |
+
updateUIForUser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
}
|
| 177 |
|
| 178 |
+
// Initialize
|
| 179 |
+
window.addEventListener("load", () => {
|
| 180 |
+
initBeforeAfter();
|
| 181 |
+
showSubscriptionTiers();
|
| 182 |
+
});
|
| 183 |
+
=======
|
| 184 |
+
// ========== GLOBAL CONFIG ==========
|
| 185 |
+
const app = {
|
| 186 |
+
version: "1.0.0",
|
| 187 |
+
darkMode: false,
|
| 188 |
+
user: null,
|
| 189 |
+
tiers: ["Prompts", "Standard Images", "High-Quality Images", "Videos"]
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
// ========== THEME HANDLER ==========
|
| 193 |
+
const themeToggle = document.querySelector("#theme-toggle");
|
| 194 |
+
themeToggle?.addEventListener("click", () => {
|
| 195 |
+
document.body.classList.toggle("dark");
|
| 196 |
+
app.darkMode = !app.darkMode;
|
| 197 |
+
localStorage.setItem("darkMode", app.darkMode);
|
| 198 |
+
});
|
| 199 |
+
|
| 200 |
+
// Load saved theme
|
| 201 |
+
window.addEventListener("DOMContentLoaded", () => {
|
| 202 |
+
const savedMode = localStorage.getItem("darkMode");
|
| 203 |
+
if (savedMode === "true") document.body.classList.add("dark");
|
| 204 |
+
loadGallery();
|
| 205 |
+
loadTestimonials();
|
| 206 |
+
});
|
| 207 |
+
|
| 208 |
+
// ========== AUTHENTICATION ==========
|
| 209 |
+
async function loginUser(email, password) {
|
| 210 |
+
// Example: integrate Firebase or Supabase here
|
| 211 |
+
console.log(`Logging in ${email}`);
|
| 212 |
+
// Placeholder logic
|
| 213 |
+
app.user = { email, tier: "Standard Images" };
|
| 214 |
+
updateUIForUser();
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
async function signupUser(email, password, tier) {
|
| 218 |
+
console.log(`Signing up ${email} for ${tier}`);
|
| 219 |
+
app.user = { email, tier };
|
| 220 |
+
updateUIForUser();
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
function logoutUser() {
|
| 224 |
+
app.user = null;
|
| 225 |
+
updateUIForUser();
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
function updateUIForUser() {
|
| 229 |
+
const userDisplay = document.querySelector("#user-display");
|
| 230 |
+
if (app.user) {
|
| 231 |
+
userDisplay.textContent = `Welcome, ${app.user.email} (${app.user.tier})`;
|
| 232 |
+
} else {
|
| 233 |
+
userDisplay.textContent = "Guest Mode";
|
| 234 |
+
}
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
// ========== GALLERY HANDLER ==========
|
| 238 |
+
async function loadGallery() {
|
| 239 |
+
const gallery = document.querySelector(".gallery");
|
| 240 |
+
if (!gallery) return;
|
| 241 |
+
gallery.innerHTML = "<p>Loading your AI masterpieces...</p>";
|
| 242 |
+
|
| 243 |
+
// Example fetch (you'll hook to your backend or Firestore)
|
| 244 |
+
const images = [
|
| 245 |
+
{ src: "http://static.photos/technology/320x240/1", title: "Urban Jungle", quality: "HD" },
|
| 246 |
+
{ src: "http://static.photos/abstract/320x240/2", title: "Neon Dreams", quality: "4K" },
|
| 247 |
+
{ src: "http://static.photos/minimal/320x240/3", title: "Digital Art", quality: "HD" },
|
| 248 |
+
{ src: "http://static.photos/gradient/320x240/4", title: "Color Fusion", quality: "4K" }
|
| 249 |
+
];
|
| 250 |
+
|
| 251 |
+
gallery.innerHTML = images
|
| 252 |
+
.map(
|
| 253 |
+
(img) => `
|
| 254 |
+
<div class="gallery-item">
|
| 255 |
+
<img src="${img.src}" alt="${img.title}" />
|
| 256 |
+
<div class="overlay">
|
| 257 |
+
<h3>${img.title}</h3>
|
| 258 |
+
<span>${img.quality}</span>
|
| 259 |
+
</div>
|
| 260 |
+
</div>`
|
| 261 |
+
)
|
| 262 |
+
.join("");
|
| 263 |
+
}
|
| 264 |
+
|
| 265 |
+
// ========== TESTIMONIALS ==========
|
| 266 |
+
async function loadTestimonials() {
|
| 267 |
+
const container = document.querySelector(".testimonials");
|
| 268 |
+
if (!container) return;
|
| 269 |
+
const testimonials = [
|
| 270 |
+
{ name: "Maya", text: "This AI changed my brand visuals overnight!" },
|
| 271 |
+
{ name: "Rico", text: "The realism and motion are beyond perfect." },
|
| 272 |
+
{ name: "Ava", text: "I tested others — nothing compares to this quality!" }
|
| 273 |
+
];
|
| 274 |
+
container.innerHTML = testimonials
|
| 275 |
+
.map(
|
| 276 |
+
(t) => `
|
| 277 |
+
<div class="testimonial-card">
|
| 278 |
+
<p>"${t.text}"</p>
|
| 279 |
+
<h4>- ${t.name}</h4>
|
| 280 |
+
</div>`
|
| 281 |
+
)
|
| 282 |
+
.join("");
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
// ========== BEFORE/AFTER FEATURE ==========
|
| 286 |
+
function initBeforeAfter() {
|
| 287 |
+
const slider = document.querySelector(".before-after-slider");
|
| 288 |
+
if (!slider) return;
|
| 289 |
+
|
| 290 |
+
const before = slider.querySelector(".before");
|
| 291 |
+
const after = slider.querySelector(".after");
|
| 292 |
+
const handle = slider.querySelector(".handle");
|
| 293 |
+
|
| 294 |
+
let isDragging = false;
|
| 295 |
+
|
| 296 |
+
handle.addEventListener("mousedown", () => (isDragging = true));
|
| 297 |
+
window.addEventListener("mouseup", () => (isDragging = false));
|
| 298 |
+
window.addEventListener("mousemove", (e) => {
|
| 299 |
+
if (!isDragging) return;
|
| 300 |
+
const rect = slider.getBoundingClientRect();
|
| 301 |
+
const offsetX = e.clientX - rect.left;
|
| 302 |
+
const percent = Math.min(Math.max(offsetX / rect.width, 0), 1);
|
| 303 |
+
before.style.width = `${percent * 100}%`;
|
| 304 |
+
handle.style.left = `${percent * 100}%`;
|
| 305 |
+
});
|
| 306 |
+
}
|
| 307 |
+
|
| 308 |
+
// ========== PROMPT GENERATOR ==========
|
| 309 |
+
function generatePromptPack(count = 100) {
|
| 310 |
+
const basePrompts = [
|
| 311 |
+
"Cinematic portrait, ultra-detailed lighting",
|
| 312 |
+
"Abstract fusion of neon and shadow",
|
| 313 |
+
"Real-world wildlife with surreal landscapes"
|
| 314 |
+
];
|
| 315 |
+
const prompts = Array.from({ length: count }, () =>
|
| 316 |
+
basePrompts[Math.floor(Math.random() * basePrompts.length)]
|
| 317 |
+
);
|
| 318 |
+
return prompts;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
// ========== SUBSCRIPTION HANDLER ==========
|
| 322 |
+
function showSubscriptionTiers() {
|
| 323 |
+
const section = document.querySelector(".pricing");
|
| 324 |
+
if (!section) return;
|
| 325 |
+
const tiers = [
|
| 326 |
+
{ name: "Prompts", price: "$10.99", perks: ["100 AI Prompts"] },
|
| 327 |
+
{
|
| 328 |
+
name: "Standard Images",
|
| 329 |
+
price: "$300",
|
| 330 |
+
perks: ["10 HD AI Images", "Access to Prompt Tools"]
|
| 331 |
+
},
|
| 332 |
+
{
|
| 333 |
+
name: "High-Quality Images",
|
| 334 |
+
price: "$1200",
|
| 335 |
+
perks: ["20 4K Images", "Custom Style Blends"]
|
| 336 |
+
},
|
| 337 |
+
{
|
| 338 |
+
name: "Video + Ads",
|
| 339 |
+
price: "$6300",
|
| 340 |
+
perks: ["AI Video Creation", "Ad Creative Assistance"]
|
| 341 |
}
|
| 342 |
+
];
|
| 343 |
+
|
| 344 |
+
section.innerHTML = tiers
|
| 345 |
+
.map(
|
| 346 |
+
(tier) => `
|
| 347 |
+
<div class="tier-card">
|
| 348 |
+
<h2>${tier.name}</h2>
|
| 349 |
+
<p class="price">${tier.price}</p>
|
| 350 |
+
<ul>${tier.perks.map((p) => `<li>${p}</li>`).join("")}</ul>
|
| 351 |
+
<button onclick="purchaseTier('${tier.name}')">Subscribe</button>
|
| 352 |
+
</div>`
|
| 353 |
+
)
|
| 354 |
+
.join("");
|
| 355 |
}
|
| 356 |
|
| 357 |
+
function purchaseTier(tierName) {
|
| 358 |
+
alert(`Subscribed to ${tierName} successfully!`);
|
| 359 |
+
app.user = { ...app.user, tier: tierName };
|
| 360 |
+
updateUIForUser();
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
// ========== SHOPPING CART FUNCTIONALITY ==========
|
| 364 |
+
class ShoppingCart {
|
| 365 |
+
constructor() {
|
| 366 |
+
this.items = JSON.parse(localStorage.getItem('cart')) || [];
|
| 367 |
+
}
|
| 368 |
+
|
| 369 |
+
addItem(item) {
|
| 370 |
+
this.items.push(item);
|
| 371 |
+
this.saveToLocalStorage();
|
| 372 |
+
this.updateCartCount();
|
| 373 |
+
}
|
| 374 |
+
|
| 375 |
+
removeItem(index) {
|
| 376 |
+
this.items.splice(index, 1);
|
| 377 |
+
this.saveToLocalStorage();
|
| 378 |
+
this.updateCartCount();
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
saveToLocalStorage() {
|
| 382 |
+
localStorage.setItem('cart', JSON.stringify(this.items));
|
| 383 |
+
}
|
| 384 |
+
|
| 385 |
+
updateCartCount() {
|
| 386 |
+
const count = this.items.length;
|
| 387 |
+
const cartCountElement = document.getElementById('cart-count');
|
| 388 |
+
if (cartCountElement) {
|
| 389 |
+
cartCountElement.textContent = count;
|
| 390 |
+
count > 0 ? cartCountElement.classList.remove('hidden') : cartCountElement.classList.add('hidden');
|
| 391 |
}
|
| 392 |
+
}
|
| 393 |
}
|
| 394 |
|
| 395 |
+
// Initialize cart on page load
|
| 396 |
+
window.cart = new ShoppingCart();
|
| 397 |
+
window.cart.updateCartCount();
|
| 398 |
+
|
| 399 |
+
// Initialize tooltips
|
| 400 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 401 |
+
// Lazy loading for images
|
| 402 |
+
const lazyImages = document.querySelectorAll('img[data-src]');
|
| 403 |
+
|
| 404 |
+
const lazyLoad = (target) => {
|
| 405 |
+
const io = new IntersectionObserver((entries, observer) => {
|
| 406 |
+
entries.forEach(entry => {
|
| 407 |
+
if (entry.isIntersecting) {
|
| 408 |
+
const img = entry.target;
|
| 409 |
+
img.src = img.dataset.src;
|
| 410 |
+
observer.unobserve(img);
|
| 411 |
+
}
|
| 412 |
+
});
|
| 413 |
+
});
|
| 414 |
+
io.observe(target);
|
| 415 |
+
};
|
| 416 |
+
|
| 417 |
+
lazyImages.forEach(lazyLoad);
|
| 418 |
+
|
| 419 |
+
// Add subtle tilt effect to cards on mousemove
|
| 420 |
+
document.querySelectorAll('.card-tilt').forEach(card => {
|
| 421 |
+
card.addEventListener('mousemove', (e) => {
|
| 422 |
+
const x = e.clientX - card.getBoundingClientRect().left;
|
| 423 |
+
const y = e.clientY - card.getBoundingClientRect().top;
|
| 424 |
+
const midX = card.clientWidth / 2;
|
| 425 |
+
const midY = card.clientHeight / 2;
|
| 426 |
+
const angleX = (midY - y) / 15;
|
| 427 |
+
const angleY = (x - midX) / 15;
|
| 428 |
|
| 429 |
+
card.style.transform = `perspective(1000px) rotateX(${angleX}deg) rotateY(${angleY}deg)`;
|
| 430 |
+
});
|
| 431 |
+
|
| 432 |
+
card.addEventListener('mouseleave', () => {
|
| 433 |
+
card.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg)`;
|
| 434 |
+
});
|
| 435 |
+
});
|
| 436 |
+
});
|
| 437 |
+
|
| 438 |
+
// Initialize
|
| 439 |
+
window.addEventListener("load", () => {
|
| 440 |
+
initBeforeAfter();
|
| 441 |
+
showSubscriptionTiers();
|
| 442 |
+
});
|
| 443 |
+
Initialize tooltips
|
| 444 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 445 |
+
// Lazy loading for images
|
| 446 |
+
const lazyImages = document.querySelectorAll('img[data-src]');
|
| 447 |
+
|
| 448 |
+
const lazyLoad = (target) => {
|
| 449 |
+
const io = new IntersectionObserver((entries, observer) => {
|
| 450 |
+
entries.forEach(entry => {
|
| 451 |
+
if (entry.isIntersecting) {
|
| 452 |
+
const img = entry.target;
|
| 453 |
+
img.src = img.dataset.src;
|
| 454 |
+
observer.unobserve(img);
|
| 455 |
+
}
|
| 456 |
+
});
|
| 457 |
+
});
|
| 458 |
+
io.observe(target);
|
| 459 |
+
};
|
| 460 |
+
|
| 461 |
+
lazyImages.forEach(lazyLoad);
|
| 462 |
+
|
| 463 |
+
// Add subtle tilt effect to cards on mousemove
|
| 464 |
+
document.querySelectorAll('.card-tilt').forEach(card => {
|
| 465 |
+
card.addEventListener('mousemove', (e) => {
|
| 466 |
+
const x = e.clientX - card.getBoundingClientRect().left;
|
| 467 |
+
const y = e.clientY - card.getBoundingClientRect().top;
|
| 468 |
+
const midX = card.clientWidth / 2;
|
| 469 |
+
const midY = card.clientHeight / 2;
|
| 470 |
+
const angleX = (midY - y) / 15;
|
| 471 |
+
const angleY = (x - midX) / 15;
|
| 472 |
+
|
| 473 |
+
card.style.transform = `perspective(1000px) rotateX(${angleX}deg) rotateY(${angleY}deg)`;
|
| 474 |
});
|
| 475 |
|
| 476 |
+
card.addEventListener('mouseleave', () => {
|
| 477 |
+
card.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg)';
|
| 478 |
});
|
| 479 |
});
|
| 480 |
+
});
|
| 481 |
+
|
| 482 |
+
// Shopping cart functionality
|
| 483 |
+
class ShoppingCart {
|
| 484 |
+
constructor() {
|
| 485 |
+
this.items = JSON.parse(localStorage.getItem('cart')) || [];
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
addItem(item) {
|
| 489 |
+
this.items.push(item);
|
| 490 |
+
this.saveToLocalStorage();
|
| 491 |
+
this.updateCartCount();
|
| 492 |
+
}
|
| 493 |
+
|
| 494 |
+
removeItem(index) {
|
| 495 |
+
this.items.splice(index, 1);
|
| 496 |
+
this.saveToLocalStorage();
|
| 497 |
+
this.updateCartCount();
|
| 498 |
+
}
|
| 499 |
+
|
| 500 |
+
saveToLocalStorage() {
|
| 501 |
+
localStorage.setItem('cart', JSON.stringify(this.items));
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
updateCartCount() {
|
| 505 |
+
const count = this.items.length;
|
| 506 |
+
const cartCountElement = document.getElementById('cart-count');
|
| 507 |
+
if (cartCountElement) {
|
| 508 |
+
cartCountElement.textContent = count;
|
| 509 |
+
count > 0 ? cartCountElement.classList.remove('hidden') : cartCountElement.classList.add('hidden');
|
| 510 |
+
}
|
| 511 |
+
}
|
| 512 |
}
|
| 513 |
|
| 514 |
+
// Initialize cart on page load
|
| 515 |
+
window.cart = new ShoppingCart();
|
| 516 |
+
window.cart.updateCartCount();
|