This commit is contained in:
Omar Najjar 2024-07-07 16:12:05 +10:00
parent 3680a77239
commit 28b465543c

View file

@ -39,7 +39,7 @@
padding: 20px;
border-radius: 10px;
background: rgba(20, 20, 20, 0.8);
border: 1px solid #fff; /* Added white thin border */
border: 1px solid #fff;
box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
margin-top: 20px;
}
@ -75,8 +75,8 @@
background-color: #222;
color: #fff;
margin-top: 10px;
font-weight: 300; /* Lighter font */
line-height: 1.5; /* Taller text */
font-weight: 300;
line-height: 1.5;
}
.avatars img {
width: 60px;
@ -97,8 +97,8 @@
max-width: 600px;
height: 300px;
border-radius: 10px;
margin: 0 auto; /* Centers the video frame */
overflow: hidden; /* Ensures no overflow from the video */
margin: 0 auto;
overflow: hidden;
}
.live-indicator {
position: absolute;
@ -111,7 +111,7 @@
padding: 5px 10px;
border-radius: 5px;
animation: flash 1s infinite;
z-index: 20; /* Ensures it is above the video */
z-index: 20;
}
.countdown {
position: absolute;
@ -121,7 +121,7 @@
font-size: 48px;
font-weight: 700;
z-index: 10;
color: #FFF; /* Ensures visibility on top of any background */
color: #FFF;
}
.bet-buttons {
display: flex;
@ -165,7 +165,7 @@
}
95% {
box-shadow: var(--neon-shadow);
border-color: var (--primary-neon);
border-color: var(--primary-neon);
}
95.01% {
box-shadow: none;
@ -197,7 +197,7 @@
cursor: pointer;
display: flex;
align-items: center;
z-index: 30; /* Ensures it is above other elements */
z-index: 30;
}
.live-chat-btn:hover {
background-color: #0056b3;
@ -211,13 +211,13 @@
height: 50%;
max-height: 400px;
background: rgba(0, 0, 0, 0.8);
border: 1px solid #fff; /* Added white thin border */
border: 1px solid #fff;
border-radius: 10px;
padding: 10px;
display: none;
flex-direction: column;
z-index: 40; /* Ensures it is above the chat button */
overflow-y: scroll; /* Enable scrolling */
z-index: 40;
overflow-y: scroll;
}
.live-chat-popup.active {
display: flex;
@ -259,6 +259,14 @@
margin-bottom: 5px;
border-radius: 5px;
}
.floating-bet {
position: absolute;
font-size: 24px;
font-weight: bold;
color: #fff;
pointer-events: none;
transition: all 1.5s ease-out;
}
</style>
</head>
<body>
@ -300,15 +308,15 @@
<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" id="betLionBtn" onclick="placeBet(0)">Bet Lion</button>
<button class="btn-confirm" id="betBuffaloBtn" onclick="placeBet(1)">Bet Buffalo</button>
<button class="btn-place" id="btnLion" onclick="placeBet('Lion')">Bet Lion</button>
<button class="btn-confirm" id="btnBuffalo" onclick="placeBet('Buffalo')">Bet Buffalo</button>
</div>
<div>
<p>Total Bets on Lion: <span id="totalBetsLion">0</span></p>
<p>Total Bets on Buffalo: <span id="totalBetsBuffalo">0</span></p>
<div class="bet-info">
<p>Total Bets on Lion: $<span id="totalBetsLion">0</span></p>
<p>Total Bets on Buffalo: $<span id="totalBetsBuffalo">0</span></p>
<p>Your Potential Payout: $<span id="potentialPayout">0</span></p>
</div>
</div>
@ -323,9 +331,10 @@
</div>
<script>
const WORKER_URL = 'https://instinct-api.yazdani.dev/user'; // Updated API URL
const WORKER_URL = 'https://instinct-api.yazdani.dev';
let userEmail = '';
let defaultBetSize = 0;
let eventID = 95; // Default event ID
async function navigateTo(pageId) {
document.querySelectorAll('.page').forEach(page => {
@ -340,7 +349,7 @@
generateRandomAvatars();
} else if (pageId === 'page5') {
userEmail = document.getElementById('email').value;
defaultBetSize = document.getElementById('defaultBetSize').value;
defaultBetSize = parseFloat(document.getElementById('defaultBetSize').value);
startCountdown(5);
await fetchUserBalance();
await fetchTotalBets();
@ -361,7 +370,6 @@
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?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%;';
@ -369,7 +377,6 @@
iframe.allowfullscreen = true;
videoFrame.appendChild(iframe);
// Listen for the end of the first video
iframe.onload = function () {
var firstVideo = iframe.contentWindow.document.querySelector('video');
if (firstVideo) {
@ -383,9 +390,7 @@
}
function playEndingVideo(videoFrame) {
// Remove the first video
videoFrame.innerHTML = '';
// Add the ending video
var iframe = document.createElement('iframe');
iframe.src = "https://customer-0sb72e7akfw9m0dg.cloudflarestream.com/ea82c3f795b5a68a78ef3d44c85a689f/watch/iframe?preload=true&autoplay=true";
iframe.style.cssText = 'border: none; position: absolute; top: 0; left: 0; height: 100%; width: 100%;';
@ -413,7 +418,7 @@
async function fetchUserData() {
const email = document.getElementById('email').value;
const response = await fetch(`${WORKER_URL}?email=${encodeURIComponent(email)}`, { method: 'GET' });
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 || '';
@ -426,7 +431,7 @@
async function saveUserData() {
if (document.getElementById('bypassValidation').checked) {
navigateTo('page3'); // Skip validation and navigate to next page
navigateTo('page3');
return;
}
@ -435,13 +440,13 @@
name: document.getElementById('name').value,
phone: document.getElementById('phone').value
};
const response = await fetch('https://instinct-api.yazdani.dev/signup', {
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
navigateTo('page3');
} else {
console.error('Failed to save user data');
}
@ -452,39 +457,37 @@
}
async function placeBet(team) {
const response = await fetch('https://instinct-api.yazdani.dev/bet', {
const betAmount = defaultBetSize;
const response = await fetch(`${WORKER_URL}/bet`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: userEmail,
team: team,
amount: defaultBetSize
event: eventID,
team: team === 'Lion' ? 0 : 1,
amount: betAmount
})
});
if (response.ok) {
console.log('Bet placed successfully');
animateBetAmount(team, defaultBetSize);
await fetchUserBalance();
await fetchTotalBets();
displayFloatingBet(betAmount);
} else {
console.error('Failed to place bet');
}
}
async function fetchUserBalance() {
const response = await fetch(`${WORKER_URL}?email=${encodeURIComponent(userEmail)}`, { method: 'GET' });
const response = await fetch(`${WORKER_URL}/user?email=${encodeURIComponent(userEmail)}`, { method: 'GET' });
if (response.ok) {
const userData = await response.json();
document.getElementById('userBalance').textContent = userData.user.balance || '0';
// Disable bet buttons if balance is insufficient
const betLionBtn = document.getElementById('betLionBtn');
const betBuffaloBtn = document.getElementById('betBuffaloBtn');
const betButtons = document.querySelectorAll('.bet-buttons button');
if (userData.user.balance < defaultBetSize) {
betLionBtn.disabled = true;
betBuffaloBtn.disabled = true;
betButtons.forEach(button => button.disabled = true);
} else {
betLionBtn.disabled = false;
betBuffaloBtn.disabled = false;
betButtons.forEach(button => button.disabled = false);
}
} else {
console.error('Failed to fetch user balance');
@ -492,7 +495,7 @@
}
async function fetchTotalBets() {
const response = await fetch(`https://instinct-api.yazdani.dev/totals?event=95`, { method: 'GET' });
const response = await fetch(`${WORKER_URL}/totals?event=${eventID}`, { method: 'GET' });
if (response.ok) {
const totals = await response.json();
const totalBetsLion = totals.bets.find(bet => bet.team === 0)?.total || 0;
@ -506,7 +509,7 @@
function generateRandomAvatars() {
const avatarsContainer = document.querySelector('.avatars');
avatarsContainer.innerHTML = ''; // Clear existing avatars
avatarsContainer.innerHTML = '';
for (let i = 0; i < 4; i++) {
const avatarId = Math.floor(Math.random() * 1000000);
@ -518,27 +521,30 @@
}
}
function animateBetAmount(team, amount) {
const betButton = team === 0 ? document.getElementById('betLionBtn') : document.getElementById('betBuffaloBtn');
const betAnimation = document.createElement('div');
betAnimation.textContent = `$${amount}`;
betAnimation.style.position = 'absolute';
betAnimation.style.color = 'yellow';
betAnimation.style.top = `${betButton.getBoundingClientRect().top}px`;
betAnimation.style.left = `${betButton.getBoundingClientRect().left}px`;
betAnimation.style.zIndex = 1000;
betAnimation.style.transition = 'all 1s ease-out';
document.body.appendChild(betAnimation);
function displayFloatingBet(amount) {
const betElement = document.createElement('div');
betElement.classList.add('floating-bet');
betElement.textContent = `+ $${amount}`;
document.body.appendChild(betElement);
const startPos = {
x: window.innerWidth / 2 - betElement.offsetWidth / 2,
y: window.innerHeight / 2
};
betElement.style.left = `${startPos.x}px`;
betElement.style.top = `${startPos.y}px`;
setTimeout(() => {
betAnimation.style.transform = `translateY(-100px)`;
betAnimation.style.opacity = 0;
betElement.style.transform = `translateY(-200px)`;
betElement.style.opacity = '0';
}, 100);
setTimeout(() => {
betAnimation.remove();
}, 1100);
document.body.removeChild(betElement);
}, 1600);
}
// Add to Home Screen Prompt
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
@ -566,7 +572,6 @@
});
}
// Service Worker Registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/instinct/service-worker.js').then((registration) => {