Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Roam45 authored Nov 1, 2024
1 parent 42df920 commit 6161748
Showing 1 changed file with 101 additions and 48 deletions.
149 changes: 101 additions & 48 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,114 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gambling Games</title>
<link rel="stylesheet" href="styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
<header>
<h1>Gambling Games</h1>
<div id="signupContainer">
<h2>Create an Account</h2>
<input type="text" id="username" placeholder="Username" required>
<input type="password" id="password" placeholder="Password" required>
<button class="btn" onclick="signup()">Sign Up</button>
<div id="signupMessage"></div>
</div>
</header>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-analytics.js";
import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-auth.js";
import { getFirestore, doc, setDoc, getDoc } from "https://www.gstatic.com/firebasejs/9.0.0/firebase-firestore.js";

// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyBMfSTkHYHbceLi1xL8M01v3CeB7QBjpX0",
authDomain: "gamblinggames-53531.firebaseapp.com",
projectId: "gamblinggames-53531",
storageBucket: "gamblinggames-53531.appspot.com",
messagingSenderId: "626974281505",
appId: "1:626974281505:web:4ab370afa26bb03c423860",
measurementId: "G-K7PGD90X6T"
};

<main id="gameContainer">
<div id="gameAreaContainer">
<select id="gameSelector" onchange="loadGame()">
<option value="">Select a Game</option>
<option value="coinFlip">Coin Flip</option>
<option value="diceRoll">Dice Roll</option>
<option value="roulette">Roulette</option>
<option value="poker">Poker</option>
</select>
<div id="gameArea"></div>
<div id="result"></div>
</div>
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const auth = getAuth(app);
const db = getFirestore(app);

<div id="balanceContainer">
<div id="balance">Balance: $<span id="balanceAmount">0</span></div>
</div>
</main>
// Sign Up Function
window.signUp = async function() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;

<section id="leaderboard">
<h2>Leaderboard</h2>
<ul id="leaderboardList"></ul>
</section>
try {
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
const user = userCredential.user;
await setDoc(doc(db, 'users', user.uid), { balance: 100 });
document.getElementById('authMessage').innerText = 'Sign up successful! Welcome!';
document.getElementById('gameContainer').style.display = 'block';
} catch (error) {
document.getElementById('authMessage').innerText = error.message;
}
};

<section id="adminPanel" style="display:none;">
<h2>Admin Panel (RoamDev)</h2>
<input type="text" id="editUsername" placeholder="Username to Edit" required>
<input type="number" id="editBalance" placeholder="New Balance" required>
<button class="btn" onclick="editUser()">Edit User</button>
<div id="adminMessage"></div>
</section>
// Sign In Function
window.signIn = async function() {
const email = document.getElementById('email').value;
const password = document.getElementById('password').value;

try {
const userCredential = await signInWithEmailAndPassword(auth, email, password);
const user = userCredential.user;
document.getElementById('authMessage').innerText = 'Sign in successful!';
document.getElementById('gameContainer').style.display = 'block';
loadUserBalance(user.uid);
} catch (error) {
document.getElementById('authMessage').innerText = error.message;
}
};

// Load User Balance
async function loadUserBalance(uid) {
const userDoc = await getDoc(doc(db, 'users', uid));
if (userDoc.exists()) {
const userData = userDoc.data();
document.getElementById('balanceAmount').innerText = userData.balance;
}
}

// Auth State Listener
auth.onAuthStateChanged((user) => {
if (user) {
loadUserBalance(user.uid);
document.getElementById('gameContainer').style.display = 'block';
} else {
document.getElementById('gameContainer').style.display = 'none';
}
});
</script>
</head>
<body>
<h1>Gambling Games</h1>
<div id="gameContainer" style="display: none;">
<select id="gameSelector" onchange="loadGame()">
<option value="">Select a Game</option>
<option value="coinFlip">Coin Flip</option>
<option value="diceRoll">Dice Roll</option>
<option value="roulette">Roulette</option>
<option value="poker">Poker</option>
</select>
<div id="gameArea"></div>
<div id="result"></div>
</div>

<div id="contact">
<h2>Contact Us</h2>
<p>If you have any questions or feedback, feel free to reach out:</p>
<p>Email: <a href="mailto:[email protected]">[email protected]</a></p>
<p><a href="https://github.com/Roam45/GamblingGames">Provide changes</a></p>
</div>

<div id="authContainer">
<h2>Sign In / Sign Up</h2>
<input type="email" id="email" placeholder="Email" required>
<input type="password" id="password" placeholder="Password" required>
<button onclick="signUp()">Sign Up</button>
<button onclick="signIn()">Sign In</button>
<div id="authMessage"></div>
</div>

<footer>
<div id="contact">
<h2>Contact Us</h2>
<p>If you have any questions or feedback, feel free to reach out:</p>
<p>Email: <a href="mailto:[email protected]">[email protected]</a></p>
<p><a href="https://github.com/Roam45/GamblingGames">Provide changes</a></p>
</div>
<p>&copy; 2024 Gambling Games. All rights reserved.</p>
</footer>

<script src="script.js"></script>
</body>
</html>

0 comments on commit 6161748

Please sign in to comment.