app code
app code
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Premium Ad Viewing App</title>
<style>
:root {
--primary-color: #2c3e50;
--accent-color: #3498db;
--text-color: #333;
--background-color: #f5f6fa;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(--background-color);
color: var(--text-color);
}
/* Sign In Page */
.sign-in-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 2rem;
background: linear-gradient(135deg, #2c3e50, #3498db);
}
.sign-in-box {
background: white;
padding: 2rem;
border-radius: 10px;
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
width: 100%;
max-width: 400px;
}
.auth-button {
width: 100%;
padding: 12px;
margin: 8px 0;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 1rem;
transition: all 0.3s ease;
}
/* Video Feed */
.video-feed {
padding: 1rem;
height: calc(100vh - 60px);
overflow-y: auto;
}
.video-card {
background: white;
border-radius: 10px;
margin-bottom: 1rem;
overflow: hidden;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.video-player {
width: 100%;
aspect-ratio: 16/9;
background: #000;
}
.video-info {
padding: 1rem;
}
.progress-bar {
height: 4px;
background: #ddd;
margin-top: 0.5rem;
}
.progress {
height: 100%;
background: var(--accent-color);
width: 0;
transition: width 0.3s linear;
}
/* Bottom Navigation */
.bottom-nav {
position: fixed;
bottom: 0;
width: 100%;
height: 60px;
background: white;
display: flex;
justify-content: space-around;
align-items: center;
box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}
.nav-item {
display: flex;
flex-direction: column;
align-items: center;
text-decoration: none;
color: var(--text-color);
padding: 0.5rem;
}
.nav-item.active {
color: var(--accent-color);
}
/* Premium Section */
.premium-container {
padding: 2rem;
text-align: center;
}
.premium-card {
background: white;
padding: 2rem;
border-radius: 10px;
margin: 1rem 0;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.upgrade-button {
background: var(--accent-color);
color: white;
padding: 1rem 2rem;
border: none;
border-radius: 25px;
font-size: 1.1rem;
cursor: pointer;
transition: transform 0.2s ease;
}
/* Profile Section */
.profile-container {
padding: 2rem;
}
.earnings-card {
background: white;
padding: 1.5rem;
border-radius: 10px;
margin-bottom: 1rem;
}
.settings-option {
padding: 1rem;
border-bottom: 1px solid #eee;
display: flex;
justify-content: space-between;
align-items: center;
}
/* Achievement Notification */
.achievement-notification {
position: fixed;
top: 20px;
left: 50%;
transform: translateX(-50%);
background: white;
padding: 1rem 2rem;
border-radius: 25px;
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
animation: slideIn 0.5s ease;
}
@keyframes slideIn {
from {
transform: translate(-50%, -100%);
opacity: 0;
}
to {
transform: translate(-50%, 0);
opacity: 1;
}
}
.fade-out {
opacity: 0;
transition: opacity 0.5s ease;
}
</style>
</head>
<body>
<div id="signInPage" class="sign-in-container">
<div class="sign-in-box">
<h2>Welcome Back</h2>
<button class="auth-button" style="background: #4285f4; color: white;">
Continue with Google
</button>
<button class="auth-button" style="background: #000; color: white;">
Continue with Apple
</button>
<button class="auth-button" style="background: #e4e6eb; color: #333;">
Continue with Email
</button>
</div>
</div>
<nav class="bottom-nav">
<a href="#home" class="nav-item active">
<span>🏠</span>
<span>Home</span>
</a>
<a href="#premium" class="nav-item">
<span>⭐</span>
<span>Premium</span>
</a>
<a href="#profile" class="nav-item">
<span>👤</span>
<span>Profile</span>
</a>
</nav>
</div>
</body>
</html>
<script>
// Global variables
let totalEarnings = 0;
let adsWatched = 0;
</script>
<script>
// Add guest login button to sign-in box
const signInBox = document.querySelector('.sign-in-box');
const guestButton = document.createElement('button');
guestButton.className = 'auth-button';
guestButton.style.background = '#808080';
guestButton.style.color = 'white';
guestButton.textContent = 'Continue as Guest';
guestButton.addEventListener('click', () => {
document.getElementById('signInPage').style.display = 'none';
document.getElementById('mainApp').style.display = 'block';
});
signInBox.appendChild(guestButton);
</script>
<script>
// Handle home section content
const homeSection = document.querySelector('.video-feed');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: var(--background-color);
color: var(--text-color);
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
.ad-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-top: 20px;
}
.ad-card {
background: white;
border-radius: 10px;
padding: 15px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.ad-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
}
.watch-btn {
background: var(--accent-color);
color: white;
border: none;
padding: 8px 15px;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s ease;
}
.watch-btn:hover {
background: #2980b9;
}
</style>
</head>
<body>
<div class="container">
<h1>Premium Ads</h1>
<div class="ad-grid">
<div class="ad-card">
<div class="ad-header">
<h3>Premium Ad #1</h3>
<span>30s</span>
</div>
<button class="watch-btn">Watch Now</button>
</div>
<div class="ad-card">
<div class="ad-header">
<h3>Premium Ad #2</h3>
<span>45s</span>
</div>
<button class="watch-btn">Watch Now</button>
</div>
</div>
</div>
</body>
</html>
<script>
// Add interactivity to watch buttons
document.querySelectorAll('.watch-btn').forEach(button => {
button.addEventListener('click', function() {
const adTitle = this.parentElement.querySelector('h3').textContent;
const duration = this.parentElement.querySelector('span').textContent;
alert(`Starting ${adTitle}\nDuration: ${duration}`);
// Simulate ad watching
this.textContent = 'Watching...';
setTimeout(() => {
this.textContent = 'Watched ✓';
this.style.background = '#27ae60';
this.disabled = true;
}, 2000);
});
});
document.querySelector('.container').appendChild(addNewAdBtn);
let adCounter = 3;
addNewAdBtn.addEventListener('click', () => {
const newAd = document.createElement('div');
newAd.className = 'ad-card';
newAd.innerHTML = `
<div class="ad-header">
<h3>Premium Ad #${adCounter}</h3>
<span>${Math.floor(Math.random() * 30 + 30)}s</span>
</div>
<button class="watch-btn">Watch Now</button>
`;
adGrid.appendChild(newAd);
adCounter++;
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
</script>
<script>
// Create video player modal
const videoModal = document.createElement('div');
videoModal.style.cssText = `
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
`;
videoPlayer.innerHTML = `
<h3 style="margin-bottom: 15px">${randomAd.title}</h3>
<div style="background: #f0f0f0; height: 400px; display: flex;
align-items: center; justify-content: center;">
<p>Simulated Video Ad Playing</p>
</div>
<div style="margin-top: 15px">
<div class="progress-bar" style="height: 5px; background: #eee;
border-radius: 5px;">
<div class="progress" style="width: 0%; height: 100%;
background: #3498db; border-radius: 5px;"></div>
</div>
<p style="text-align: right; margin-top: 5px">Time remaining:
<span class="timer">30</span>s</p>
</div>
`;
videoModal.style.display = 'flex';
videoModal.appendChild(videoPlayer);
document.body.appendChild(videoModal);
if (timeLeft <= 0) {
clearInterval(countdown);
videoModal.style.display = 'none';
this.textContent = 'Watched ✓';
this.style.background = '#27ae60';
this.disabled = true;
// Modify the existing alert in the countdown interval to update total earnings
const originalAlert = alert;
window.alert = function(message) {
if (message.includes('You earned')) {
const amount = message.match(/\$([0-9.]+)/)[1];
updateEarnings(amount);
}
originalAlert(message);
};
</script>
<script>
// Create ads watched counter display
const adsWatchedDisplay = document.createElement('div');
adsWatchedDisplay.style.cssText = `
position: fixed;
top: 70px;
right: 20px;
background: #3498db;
color: white;
padding: 10px 20px;
border-radius: 5px;
font-weight: bold;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
`;
adsWatchedDisplay.innerHTML = `Ads Watched: <span id="adsWatched">0</span>`;
document.body.appendChild(adsWatchedDisplay);
// Start watching ad
this.textContent = 'Watching...';
this.disabled = true;
// Simulate ad completion after 2 seconds
setTimeout(() => {
// Calculate random earnings between $0.10 and $0.50
const earnings = (Math.random() * 0.4 + 0.1).toFixed(2);
document.querySelector('.container').appendChild(addNewAdBtn);
let adCounter = 3;
addNewAdBtn.addEventListener('click', () => {
const newAd = document.createElement('div');
newAd.className = 'ad-card';
newAd.innerHTML = `
<div class="ad-header">
<h3>Premium Ad #${adCounter}</h3>
<span>${Math.floor(Math.random() * 30 + 30)}s</span>
</div>
<button class="watch-btn">Watch Now</button>
`;
adGrid.appendChild(newAd);
adCounter++;
this.textContent = 'Watching...';
this.disabled = true;
setTimeout(() => {
const earnings = (Math.random() * 0.4 + 0.1).toFixed(2);
this.textContent = 'Watched ✓';
this.style.background = '#27ae60';
alert(`Ad completed! ${adTitle}`);
alert(`You earned $${earnings}!`);
}, 2000);
});
});
</script>
<script>
// Handle premium section content and navigation
const premiumSection = document.createElement('div');
premiumSection.className = 'premium-section';
premiumSection.style.display = 'none';
premiumSection.innerHTML = `
<div class="premium-container" style="padding: 20px;">
<div class="premium-header" style="
background: linear-gradient(135deg, #8e44ad, #9b59b6);
color: white;
padding: 30px;
border-radius: 15px;
text-align: center;
margin-bottom: 30px;
transform: translateY(0);
transition: transform 0.3s ease;
">
<h2 style="margin: 0; font-size: 28px;">Premium Features</h2>
<p style="margin: 10px 0;">Unlock exclusive benefits and earn more!
</p>
</div>
document.querySelector('.video-feed').appendChild(premiumSection);
card.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
this.style.boxShadow = '0 4px 15px rgba(0,0,0,0.1)';
});
});
upgradeBtn.addEventListener('mouseleave', function() {
this.style.transform = 'scale(1)';
this.style.background = '#8e44ad';
});
setTimeout(() => {
showConfetti();
this.innerHTML = '✨ Premium Activated! ✨';
this.style.background = '#27ae60';
}, 2000);
});
// Sound effects
function playHoverSound() {
const hoverSound = new
Audio('data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYW
N0BAAAAAAAAABkYXRhAAAAAA==');
hoverSound.volume = 0.2;
hoverSound.play().catch(() => {});
}
function playClickSound() {
const clickSound = new
Audio('data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBIAAAABAAEAQB8AAEAfAAABAAgAAABmYW
N0BAAAAAAAAABkYXRhAAAAAA==');
clickSound.volume = 0.3;
clickSound.play().catch(() => {});
}
// Confetti animation
function showConfetti() {
const confettiCount = 200;
const colors = ['#9b59b6', '#3498db', '#e74c3c', '#2ecc71', '#f1c40f'];
document.body.appendChild(confetti);
document.querySelector('.home-container').style.display = 'none';
premiumSection.style.display = 'block';
// Entrance animation
premiumSection.querySelector('.premium-header').style.transform =
'translateY(-20px)';
setTimeout(() => {
premiumSection.querySelector('.premium-header').style.transform =
'translateY(0)';
}, 100);
});
document.querySelector('a[href="#home"]').addEventListener('click', function(e)
{
e.preventDefault();
document.querySelectorAll('.nav-item').forEach(item =>
item.classList.remove('active'));
this.classList.add('active');
premiumSection.style.display = 'none';
document.querySelector('.home-container').style.display = 'block';
});
</script>
<script>
// Create profile section
const profileSection = document.createElement('div');
profileSection.className = 'profile-section';
profileSection.style.display = 'none';
profileSection.innerHTML = `
<div class="profile-container" style="padding: 20px;">
<div class="profile-header" style="
background: linear-gradient(135deg, #2c3e50, #34495e);
color: white;
padding: 30px;
border-radius: 15px;
text-align: center;
margin-bottom: 30px;
">
<div class="profile-avatar" style="
width: 100px;
height: 100px;
background: #95a5a6;
border-radius: 50%;
margin: 0 auto 15px;
display: flex;
align-items: center;
justify-content: center;
font-size: 40px;
color: white;
">👤</div>
<h2 style="margin: 0;">Guest User</h2>
<p style="margin: 10px 0; opacity: 0.8;">Member since ${new
Date().toLocaleDateString()}</p>
</div>
document.querySelector('.video-feed').appendChild(profileSection);
document.querySelector('.home-container').style.display = 'none';
premiumSection.style.display = 'none';
profileSection.style.display = 'block';
// Update profile stats with current values
document.getElementById('profileEarnings').textContent =
totalEarnings.toFixed(2);
document.getElementById('profileAdsWatched').textContent = adsWatched;
});
</script>
<script>
// Dark mode functionality
const darkModeToggle = document.querySelector('.switch
input[type="checkbox"]');
body.dark-mode .welcome-banner,
body.dark-mode .premium-header {
background: linear-gradient(135deg, #1a1a1a, #2c3e50);
}
body.dark-mode .stat-card,
body.dark-mode .feature-card,
body.dark-mode .ad-card,
body.dark-mode .setting-item {
background: #2c2c2c;
color: #fff;
border-color: #3a3a3a;
}
body.dark-mode .bottom-nav {
background: #2c2c2c;
}
body.dark-mode .nav-item {
color: #fff;
}
body.dark-mode .nav-item.active {
background: #3a3a3a;
}
`;
document.head.appendChild(darkModeStyles);
darkModeOption.innerHTML = `
<div>
<h3 style="margin: 0;">Dark Mode</h3>
<p style="margin: 5px 0 0; font-size: 0.9em; color: #666;">Switch
to dark theme</p>
</div>
<label class="switch" style="
position: relative;
display: inline-block;
width: 60px;
height: 34px;
">
<input type="checkbox" id="darkModeToggle" style="
opacity: 0;
width: 0;
height: 0;
">
<span class="slider" style="
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 34px;
"></span>
</label>
`;
.dark-mode .watch-btn {
background: #34495e;
color: #fff;
}
.dark-mode .watch-btn:disabled {
background: #27ae60;
}
.dark-mode .feature-card {
background: #2c3e50;
color: #fff;
}
.dark-mode .welcome-banner {
background: linear-gradient(135deg, #1a252f, #2980b9);
}
.dark-mode .stat-card {
background: #2c3e50;
color: #fff;
}
.dark-mode .settings-container {
background: #2c3e50;
color: #fff;
}
.dark-mode .video-modal {
background: rgba(0, 0, 0, 0.9);
}
.dark-mode .video-container {
background: #2c3e50;
}
.dark-mode .bottom-nav {
background: #2c3e50;
}
.dark-mode .nav-item {
color: #fff;
}
.dark-mode .nav-item.active {
background: #34495e;
}
`;
document.head.appendChild(darkModeStyles);
</script>
<script>
// Additional dark mode styles for remaining elements
const additionalDarkModeStyles = document.createElement('style');
additionalDarkModeStyles.textContent = `
.dark-mode .ad-card {
background: #34495e;
color: #fff;
}
.dark-mode .ad-header {
background: #2c3e50;
color: #fff;
}
.dark-mode .watch-btn {
background: #3498db;
color: #fff;
}
.dark-mode .watch-btn:disabled {
background: #27ae60;
color: #fff;
}
.dark-mode #addNewAdBtn {
background: #2c3e50;
color: #fff;
}
.dark-mode .sign-in-box {
background: #2c3e50;
color: #fff;
}
.dark-mode .auth-button {
border: 1px solid rgba(255,255,255,0.2);
}
.dark-mode .earnings-display,
.dark-mode .ads-watched-display {
background: #34495e;
color: #fff;
}
.dark-mode .video-feed {
background: #1a252f;
}
`;
document.head.appendChild(additionalDarkModeStyles);
</script>
<script>
// Handle profile section content
const profileSection = document.createElement('div');
profileSection.className = 'profile-section';
profileSection.style.display = 'none';
profileSection.innerHTML = `
<div class="profile-container" style="padding: 20px;">
<div class="profile-header" style="
background: linear-gradient(135deg, #2c3e50, #34495e);
color: white;
padding: 30px;
border-radius: 15px;
text-align: center;
margin-bottom: 30px;
">
<h2 style="margin: 0; font-size: 28px;">My Profile</h2>
<p style="margin: 10px 0;">View your stats and achievements</p>
</div>
// Navigation handling
document.querySelectorAll('.nav-item').forEach(navItem => {
navItem.addEventListener('click', function(e) {
e.preventDefault();
.dark-mode .profile-header,
.dark-mode .premium-header {
background: linear-gradient(135deg, #2c3e50, #34495e);
}
`;
document.head.appendChild(darkModeStyles);
</script>
<script>
// Add achievement system
const achievements = {
firstAd: { name: 'First Steps', description: 'Watch your first ad', reward:
0.50, unlocked: false },
tenAds: { name: 'Getting Started', description: 'Watch 10 ads', reward:
2.00, unlocked: false },
fiftyAds: { name: 'Ad Enthusiast', description: 'Watch 50 ads', reward:
5.00, unlocked: false },
hundredDollars: { name: 'Big Earner', description: 'Earn $100 total',
reward: 10.00, unlocked: false }
};
function unlockAchievement(achievementId) {
const achievement = achievements[achievementId];
achievement.unlocked = true;
updateEarnings(achievement.reward);
function showAchievementNotification(achievement) {
const notification = document.createElement('div');
notification.style.cssText = `
background: linear-gradient(135deg, #2c3e50, #3498db);
color: white;
padding: 15px 25px;
border-radius: 10px;
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 15px;
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
animation: slideIn 0.5s ease, glow 2s infinite;
opacity: 0;
transform: translateY(-20px);
`;
notification.innerHTML = `
<div style="font-size: 2em;">${achievement.icon}</div>
<div>
<h3 style="margin: 0; font-size: 1.2em;">Achievement Unlocked!</h3>
<p style="margin: 5px 0;">${achievement.name}</p>
<p style="margin: 0; color: #2ecc71;">+$$
{achievement.reward.toFixed(2)}</p>
</div>
`;
notificationContainer.appendChild(notification);
// Animate in
requestAnimationFrame(() => {
notification.style.opacity = '1';
notification.style.transform = 'translateY(0)';
});
// Play sound
achievementSound.play();
function unlockAchievement(achievementId) {
const achievement = achievements[achievementId];
if (!achievement.unlocked) {
achievement.unlocked = true;
totalEarnings += achievement.reward;
document.getElementById('earnings').textContent =
totalEarnings.toFixed(2);
showAchievementNotification(achievement);
// Save progress
localStorage.setItem('achievements', JSON.stringify(achievements));
localStorage.setItem('totalEarnings', totalEarnings);
}
}