instinct/index.html
Omar Najjar 11ed9e259c x
2024-07-07 00:20:07 +10:00

460 lines
17 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Instinct App</title>
<link rel="canonical" href="https://kingomarnajjar.github.io/instinct/" />
<link rel="manifest" href="/instinct/manifest.json">
<link rel="shortcut icon" type="image/x-icon" href="favicon/favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Syne:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--primary-neon: rgba(0, 255, 0, 0.9);
--light-neon: rgba(0, 255, 0, 0.7);
--pulse-neon: rgba(0, 255, 0, 0.5);
--bright-neon: rgba(0, 255, 0, 1);
--off-neon: #333;
--neon-shadow: 0 0 7px 4px var(--light-neon), 0 0 7px 4px var(--light-neon) inset;
--neon-shadow-pulse: 0 0 8px 5px var(--pulse-neon), 0 0 8px 5px var(--pulse-neon) inset;
--neon-shadow-bright: 0 0 8px 4px var(--bright-neon), 0 0 8px 4px var(--bright-neon) inset;
--neon-shadow-text: 0 0 7px var(--primary-neon);
}
body {
font-family: 'Syne', sans-serif;
background-color: #000;
color: #fff;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
margin: 0;
}
.page {
display: none;
text-align: center;
width: 80%;
max-width: 600px;
padding: 20px;
border-radius: 10px;
background: rgba(20, 20, 20, 0.8);
border: 1px solid #fff; /* Added white thin border */
box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
margin-top: 20px;
}
.page.active {
display: block;
}
.btn-place, .btn-confirm {
cursor: pointer;
padding: 10px 20px;
border-radius: 5px;
color: white;
border: 1px solid #fff;
background: transparent;
font-size: 16px;
font-weight: bold;
margin-top: 10px;
transition: background-color 0.2s ease, color 0.2s ease;
position: relative;
text-transform: uppercase;
box-shadow: var(--neon-shadow);
animation: flicker 10s linear infinite;
}
.btn-place:hover, .btn-confirm:hover {
color: var(--primary-neon);
border-color: var(--primary-neon);
text-shadow: var(--neon-shadow-text);
}
input[type="email"], input[type="text"], input[type="tel"], textarea {
width: calc(100% - 40px);
padding: 10px;
border-radius: 5px;
border: 1px solid #fff;
background-color: #222;
color: #fff;
margin-top: 10px;
font-weight: 300; /* Lighter font */
line-height: 1.5; /* Taller text */
}
.avatars img {
width: 60px;
height: 60px;
margin: 10px;
cursor: pointer;
border-radius: 50%;
border: 2px solid transparent;
transition: transform 0.2s, border-color 0.2s;
}
.avatars img:hover {
transform: scale(1.1);
border-color: #fff;
}
.video-frame {
position: relative;
width: 100%;
max-width: 600px;
height: 300px;
border-radius: 10px;
margin: 0 auto; /* Centers the video frame */
overflow: hidden; /* Ensures no overflow from the video */
}
.live-indicator {
position: absolute;
top: 10px;
right: 10px;
font-size: 18px;
font-weight: bold;
color: #fff;
background-color: #ff0000;
padding: 5px 10px;
border-radius: 5px;
animation: flash 1s infinite;
z-index: 20; /* Ensures it is above the video */
}
.countdown {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 48px;
font-weight: 700;
z-index: 10;
color: #FFF; /* Ensures visibility on top of any background */
}
.bet-buttons {
display: flex;
justify-content: space-around;
margin: 20px 0;
}
@keyframes flash {
0%, 50%, 100% {
opacity: 1;
}
25%, 75% {
opacity: 0;
}
}
@keyframes flicker {
0% {
box-shadow: var(--neon-shadow);
}
45% {
box-shadow: var(--neon-shadow-pulse);
}
90% {
box-shadow: var(--neon-shadow);
border-color: var(--primary-neon);
color: var(--primary-neon);
text-shadow: var(--neon-shadow-text);
}
90.01% {
box-shadow: none;
border-color: var(--off-neon);
color: var(--off-neon);
text-shadow: none;
}
94% {
box-shadow: none;
border-color: var(--off-neon);
}
94.01% {
box-shadow: var(--neon-shadow);
border-color: var(--primary-neon);
}
95% {
box-shadow: var(--neon-shadow);
border-color: var(--primary-neon);
}
95.01% {
box-shadow: none;
border-color: var(--off-neon);
}
95.5% {
box-shadow: none;
border-color: var(--off-neon);
}
95.51% {
box-shadow: var(--neon-shadow-bright);
border-color: var(--primary-neon);
}
100% {
box-shadow: var(--neon-shadow);
border-color: var(--primary-neon);
}
}
.live-chat-btn {
position: fixed;
bottom: 20px;
right: 20px;
font-size: 18px;
font-weight: bold;
color: #fff;
background-color: #007bff;
padding: 10px 15px;
border-radius: 50px;
cursor: pointer;
display: flex;
align-items: center;
z-index: 30; /* Ensures it is above other elements */
}
.live-chat-btn:hover {
background-color: #0056b3;
}
.live-chat-popup {
position: fixed;
bottom: 80px;
right: 20px;
width: calc(100% - 40px);
max-width: 400px;
height: 50%;
max-height: 400px;
background: rgba(0, 0, 0, 0.8);
border: 1px solid #fff; /* Added white thin border */
border-radius: 10px;
padding: 10px;
display: none;
flex-direction: column;
z-index: 40; /* Ensures it is above the chat button */
}
.live-chat-popup.active {
display: flex;
}
.live-chat-popup .chat-messages {
flex: 1;
overflow-y: auto;
margin-bottom: 10px;
}
.live-chat-popup .chat-input {
display: flex;
align-items: center;
}
.live-chat-popup .chat-input textarea {
flex: 1;
margin-right: 10px;
padding: 5px;
border-radius: 5px;
border: 1px solid #fff;
background-color: #222;
color: #fff;
resize: none;
}
.live-chat-popup .chat-input button {
padding: 10px 20px;
border-radius: 5px;
color: white;
border: 1px solid #fff;
background: #007bff;
cursor: pointer;
}
.live-chat-popup .chat-input button:hover {
background: #0056b3;
}
.live-chat-popup .message {
color: #fff;
background: rgba(255, 255, 255, 0.1);
padding: 5px;
margin-bottom: 5px;
border-radius: 5px;
}
</style>
</head>
<body>
<!-- Page 1: Email Input -->
<div id="page1" class="page active">
<h1 class="text-2xl font-bold text-center mb-4">Instinct</h1>
<input type="email" id="email" placeholder="Enter your email" required>
<button class="btn-place" onclick="navigateTo('page2')">Enter</button>
<!-- Toggle for validation bypass -->
<label>
<input type="checkbox" id="bypassValidation" /> Bypass validation for testing
</label>
</div>
<!-- Page 2: User Info -->
<div id="page2" class="page">
<h1 class="text-2xl font-bold text-center mb-4">Welcome, <span id="userEmail"></span></h1>
<h2 class="text-xl text-center mb-4">Setup your account</h2>
<input type="text" id="name" placeholder="Name" required>
<input type="tel" id="phone" placeholder="Phone" required>
<button class="btn-place" onclick="saveUserData()">Next</button>
</div>
<!-- Page 3: Avatar Selection -->
<div id="page3" class="page">
<h2 class="text-xl text-center mb-4">Choose your avatar</h2>
<div class="avatars flex justify-center gap-4">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRYGG5wQxwQh8ZwAf-6K84NnUZ_lngQxgMSiw&s" alt="Avatar 1" onclick="selectAvatar('avatar1')">
<img src="https://cdn.icon-icons.com/icons2/1368/PNG/512/-avatar_89781.png" alt="Avatar 2" onclick="selectAvatar('avatar2')">
<img src="https://icons.iconarchive.com/icons/iconarchive/incognito-animals/512/Bear-Avatar-icon.png" alt="Avatar 3" onclick="selectAvatar('avatar3')">
<img src="https://icons.iconarchive.com/icons/iconarchive/incognito-animals/512/Lama-Avatar-icon.png" alt="Avatar 4" onclick="selectAvatar('avatar4')">
</div>
<button class="btn-place" onclick="navigateTo('page4')">Next</button>
</div>
<!-- Page 4: Video and Bet Buttons -->
<div id="page4" class="page">
<div class="video-frame mb-4">
<div class="countdown" id="countdown">5</div>
<div class="live-indicator">LIVE</div>
<!-- iframe is now dynamically added by the script to control timing -->
</div>
<div class="bet-buttons">
<button class="btn-place" onclick="bet('Lion')">Bet Lion</button>
<button class="btn-confirm" onclick="bet('Buffalo')">Bet Buffalo</button>
</div>
</div>
<div class="live-chat-btn" onclick="toggleChatPopup()">💬 Live Chat</div>
<div class="live-chat-popup" id="liveChatPopup">
<div class="chat-messages" id="liveMessages"></div>
<div class="chat-input">
<textarea id="chatBox" placeholder="Type your message..." onkeydown="if(event.keyCode==13){sendChatMessage(event)}"></textarea>
<button onclick="sendChatMessage(event)">Send</button>
</div>
</div>
<script>
const WORKER_URL = 'https://instinct-api.yazdani.dev'; // Replace with your worker URL
async function navigateTo(pageId) {
document.querySelectorAll('.page').forEach(page => {
page.classList.remove('active');
});
document.getElementById(pageId).classList.add('active');
if (pageId === 'page2') {
if (!document.getElementById('bypassValidation').checked) {
await fetchUserData();
}
} else if (pageId === 'page4') {
startCountdown(5);
}
}
function startCountdown(duration) {
var timer = duration, seconds;
var countdownElement = document.getElementById('countdown');
var videoFrame = document.querySelector('.video-frame');
countdownElement.style.display = 'block';
countdownElement.textContent = duration;
var countdownTimer = setInterval(function () {
seconds = parseInt(timer % 60, 10);
countdownElement.textContent = seconds;
if (--timer < 0) {
countdownElement.style.display = 'none';
clearInterval(countdownTimer);
// Only create and display the video after the countdown finishes
var iframe = document.createElement('iframe');
iframe.src = "https://customer-0sb72e7akfw9m0dg.cloudflarestream.com/7d7cb4e7e6ead747b72073c3824a9d3f/iframe?muted=true&preload=true&autoplay=true&poster=https%3A%2F%2Fcustomer-0sb72e7akfw9m0dg.cloudflarestream.com%2F7d7cb4e7e6ead747b72073c3824a9d3f%2Fthumbnails%2Fthumbnail.jpg%3Ftime%3D%26height%3D600&controls=false";
iframe.style.cssText = 'border: none; position: absolute; top: 0; left: 0; height: 100%; width: 100%;';
iframe.allow = "accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;";
iframe.allowfullscreen = true;
videoFrame.appendChild(iframe);
}
}, 1000);
}
function toggleChatPopup() {
var chatPopup = document.getElementById('liveChatPopup');
chatPopup.classList.toggle('active');
}
function sendChatMessage(event) {
event.preventDefault();
var message = document.getElementById('chatBox').value.trim();
if (message) {
var messageElement = document.createElement('div');
messageElement.classList.add('message');
messageElement.textContent = message;
document.getElementById('liveMessages').appendChild(messageElement);
document.getElementById('chatBox').value = ''; // Clear the input after sending
}
}
async function fetchUserData() {
const email = document.getElementById('email').value;
const response = await fetch(`${WORKER_URL}/user?email=${encodeURIComponent(email)}`, { method: 'GET' });
if (response.ok) {
const userData = await response.json();
document.getElementById('name').value = userData.name || '';
document.getElementById('phone').value = userData.phone || '';
document.getElementById('userEmail').textContent = userData.email || '';
} else {
console.error('Failed to fetch user data');
}
}
async function saveUserData() {
if (document.getElementById('bypassValidation').checked) {
navigateTo('page3'); // Skip validation and navigate to next page
return;
}
const userData = {
name: document.getElementById('name').value,
email: document.getElementById('email').value,
phone: document.getElementById('phone').value
};
const response = await fetch(`${WORKER_URL}/signup`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userData)
});
if (response.ok) {
navigateTo('page3'); // Navigate to the next page after saving data
} else {
console.error('Failed to save user data');
}
}
function selectAvatar(avatarId) {
console.log('Selected avatar:', avatarId);
}
function bet(option) {
console.log('Bet on:', option);
}
// Add to Home Screen Prompt
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
deferredPrompt = e;
showInstallPromotion();
});
function showInstallPromotion() {
const installBtn = document.createElement('button');
installBtn.textContent = 'Add to Home Screen';
installBtn.className = 'install-btn';
document.body.appendChild(installBtn);
installBtn.addEventListener('click', () => {
installBtn.style.display = 'none';
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the A2HS prompt');
} else {
console.log('User dismissed the A2HS prompt');
}
deferredPrompt = null;
});
});
}
// Service Worker Registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/instinct/service-worker.js').then((registration) => {
console.log('Service Worker registered with scope:', registration.scope);
}, (err) => {
console.log('Service Worker registration failed:', err);
});
});
}
</script>
</body>
</html>