Spaces:
Running
Running
Turn this into a online crypto wallet platform, where users can log in with the username= 'User' and password= 'Password'. Once logged in, a dashboard appears with a balance of $470.000 in Bitcoin and the options to deposit, withdraw. The deposit leads to a deposit page with a placeholder bitcoin address and instructions. The withdrawal button leads to a withdraw page with the amount to be withdrawn, and recipient bitcoin address.
4ed6779 verified Download script.js from Grego322/bitvault-pro: direct link, hf CLI and curl.
- Browser
- Download file 5.25 kB
-
https://huggingface.co/spaces/Grego322/bitvault-pro/resolve/main/script.js
- Command line
-
hf download hf://spaces/Grego322/bitvault-pro/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Grego322/bitvault-pro/resolve/main/script.js
5.25 kB
| // BitVault Pro - Main JavaScript | |
| // Global state | |
| let isLoggedIn = false; | |
| let currentUser = null; | |
| let btcPrice = 66869.57; // Price for $470,000 / 7.0246 BTC | |
| let btcBalance = 7.0246; // BTC amount for $470,000 | |
| let charts = {}; | |
| // DOM Ready | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Check session | |
| if (sessionStorage.getItem('isLoggedIn')) { | |
| isLoggedIn = true; | |
| currentUser = sessionStorage.getItem('currentUser'); | |
| showDashboard(); | |
| } | |
| initializeCharts(); | |
| setupEventListeners(); | |
| feather.replace(); | |
| }); | |
| // Initialize Charts | |
| function initializeCharts() { | |
| // Hero chart | |
| const heroCtx = document.getElementById('heroChart'); | |
| if (heroCtx) { | |
| const heroGradient = heroCtx.getContext('2d').createLinearGradient(0, 0, 0, 200); | |
| heroGradient.addColorStop(0, 'rgba(16, 185, 129, 0.3)'); | |
| heroGradient.addColorStop(1, 'rgba(16, 185, 129, 0)'); | |
| charts.hero = new Chart(heroCtx, { | |
| type: 'line', | |
| data: { | |
| labels: generateTimeLabels(24), | |
| datasets: [{ | |
| label: 'BTC/USD', | |
| data: generatePriceData(64000, 69000, 24), | |
| borderColor: '#10b981', | |
| backgroundColor: heroGradient, | |
| borderWidth: 2, | |
| fill: true, | |
| tension: 0.4, | |
| pointRadius: 0, | |
| pointHoverRadius: 6 | |
| }] | |
| }, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| plugins: { legend: { display: false } }, | |
| scales: { | |
| x: { display: false }, | |
| y: { display: false } | |
| }, | |
| interaction: { | |
| intersect: false, | |
| mode: 'index' | |
| } | |
| } | |
| }); | |
| } | |
| } | |
| // Generate time labels | |
| function generateTimeLabels(count) { | |
| const labels = []; | |
| const now = new Date(); | |
| for (let i = count - 1; i >= 0; i--) { | |
| const time = new Date(now - i * 60 * 60 * 1000); | |
| labels.push(time.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' })); | |
| } | |
| return labels; | |
| } | |
| // Generate price data | |
| function generatePriceData(min, max, count) { | |
| const data = []; | |
| let current = 66869.57; | |
| for (let i = 0; i < count; i++) { | |
| const change = (Math.random() - 0.5) * 2000; | |
| current = Math.max(min, Math.min(max, current + change)); | |
| data.push(current); | |
| } | |
| return data; | |
| } | |
| // Setup event listeners | |
| function setupEventListeners() { | |
| // Login form | |
| const loginForm = document.getElementById('login-form'); | |
| if (loginForm) { | |
| loginForm.addEventListener('submit', handleLogin); | |
| } | |
| // Custom events from web components | |
| document.addEventListener('show-login', showLoginModal); | |
| document.addEventListener('logout', logout); | |
| } | |
| // Handle login | |
| function handleLogin(e) { | |
| e.preventDefault(); | |
| const name = document.getElementById('login-name').value.trim(); | |
| const password = document.getElementById('login-password').value; | |
| if (name === 'User' && password === 'Password') { | |
| isLoggedIn = true; | |
| currentUser = name; | |
| // Store in session | |
| sessionStorage.setItem('isLoggedIn', 'true'); | |
| sessionStorage.setItem('currentUser', name); | |
| hideLoginModal(); | |
| showDashboard(); | |
| } else { | |
| const errorEl = document.getElementById('login-error'); | |
| errorEl.textContent = 'Invalid credentials. Use Username: "User" and Password: "Password"'; | |
| errorEl.classList.remove('hidden'); | |
| setTimeout(() => errorEl.classList.add('hidden'), 5000); | |
| } | |
| } | |
| // Modal functions | |
| function showLoginModal() { | |
| const modal = document.getElementById('login-modal'); | |
| if (modal) modal.classList.remove('hidden'); | |
| } | |
| function hideLoginModal() { | |
| const modal = document.getElementById('login-modal'); | |
| if (modal) modal.classList.add('hidden'); | |
| } | |
| function showDashboard() { | |
| const mainContent = document.getElementById('main-content'); | |
| const dashboard = document.getElementById('dashboard'); | |
| const userNameDisplay = document.getElementById('user-name-display'); | |
| if (mainContent) mainContent.classList.add('hidden'); | |
| if (dashboard) dashboard.classList.remove('hidden'); | |
| if (userNameDisplay) userNameDisplay.textContent = currentUser || 'User'; | |
| feather.replace(); | |
| } | |
| // Scroll to features | |
| function scrollToFeatures() { | |
| const featuresSection = document.getElementById('features-section'); | |
| if (featuresSection) featuresSection.scrollIntoView({ behavior: 'smooth' }); | |
| } | |
| // Logout | |
| function logout() { | |
| isLoggedIn = false; | |
| currentUser = null; | |
| sessionStorage.removeItem('isLoggedIn'); | |
| sessionStorage.removeItem('currentUser'); | |
| const dashboard = document.getElementById('dashboard'); | |
| const mainContent = document.getElementById('main-content'); | |
| if (dashboard) dashboard.classList.add('hidden'); | |
| if (mainContent) mainContent.classList.remove('hidden'); | |
| window.scrollTo({ top: 0, behavior: 'smooth' }); | |
| } | |