Spaces:
Running
Running
Upload 4 files
Browse files- dashboard.html +5 -1
- script.js +153 -74
- styles.css +21 -0
dashboard.html
CHANGED
|
@@ -33,7 +33,8 @@
|
|
| 33 |
<a href="#" class="nav-link">Trade</a>
|
| 34 |
<a href="#" class="nav-link">Buy Crypto</a>
|
| 35 |
<a href="#" class="nav-link">Terms of Use</a>
|
| 36 |
-
|
|
|
|
| 37 |
</div>
|
| 38 |
</header>
|
| 39 |
|
|
@@ -282,6 +283,9 @@
|
|
| 282 |
</div>
|
| 283 |
</div>
|
| 284 |
|
|
|
|
|
|
|
|
|
|
| 285 |
<script src="script.js"></script>
|
| 286 |
</body>
|
| 287 |
</html>
|
|
|
|
| 33 |
<a href="#" class="nav-link">Trade</a>
|
| 34 |
<a href="#" class="nav-link">Buy Crypto</a>
|
| 35 |
<a href="#" class="nav-link">Terms of Use</a>
|
| 36 |
+
<button class="btn-logout" onclick="logout()">Logout</button>
|
| 37 |
+
</nav>
|
| 38 |
</div>
|
| 39 |
</header>
|
| 40 |
|
|
|
|
| 283 |
</div>
|
| 284 |
</div>
|
| 285 |
|
| 286 |
+
<!-- Notification -->
|
| 287 |
+
<div id="notification" class="notification"></div>
|
| 288 |
+
|
| 289 |
<script src="script.js"></script>
|
| 290 |
</body>
|
| 291 |
</html>
|
script.js
CHANGED
|
@@ -33,13 +33,19 @@ function initAuth() {
|
|
| 33 |
}
|
| 34 |
|
| 35 |
function switchToRegister() {
|
| 36 |
-
document.getElementById("loginForm")
|
| 37 |
-
document.getElementById("
|
|
|
|
|
|
|
|
|
|
| 38 |
}
|
| 39 |
|
| 40 |
function switchToLogin() {
|
| 41 |
-
document.getElementById("
|
| 42 |
-
document.getElementById("
|
|
|
|
|
|
|
|
|
|
| 43 |
}
|
| 44 |
|
| 45 |
function handleLogin(e) {
|
|
@@ -48,21 +54,26 @@ function handleLogin(e) {
|
|
| 48 |
const email = document.getElementById("loginEmail").value
|
| 49 |
const password = document.getElementById("loginPassword").value
|
| 50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 52 |
|
| 53 |
-
// Find user by email
|
| 54 |
const userEntry = Object.entries(users).find(
|
| 55 |
-
([
|
| 56 |
)
|
| 57 |
|
| 58 |
if (userEntry) {
|
| 59 |
-
const [
|
| 60 |
-
currentUser =
|
| 61 |
-
localStorage.setItem("cryptovault_current_user",
|
| 62 |
showNotification("Login successful!", "success")
|
| 63 |
setTimeout(() => {
|
| 64 |
window.location.href = "dashboard.html"
|
| 65 |
-
},
|
| 66 |
} else {
|
| 67 |
showNotification("Invalid email or password!", "error")
|
| 68 |
}
|
|
@@ -74,12 +85,28 @@ function handleRegister(e) {
|
|
| 74 |
const email = document.getElementById("registerEmail").value
|
| 75 |
const password = document.getElementById("registerPassword").value
|
| 76 |
const confirmPassword = document.getElementById("confirmPassword").value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
if (password !== confirmPassword) {
|
| 79 |
showNotification("Passwords do not match!", "error")
|
| 80 |
return
|
| 81 |
}
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 84 |
|
| 85 |
// Check if email already exists
|
|
@@ -113,7 +140,7 @@ function handleRegister(e) {
|
|
| 113 |
|
| 114 |
setTimeout(() => {
|
| 115 |
switchToLogin()
|
| 116 |
-
},
|
| 117 |
}
|
| 118 |
|
| 119 |
// Dashboard functions
|
|
@@ -121,12 +148,27 @@ function initDashboard() {
|
|
| 121 |
currentUser = localStorage.getItem("cryptovault_current_user")
|
| 122 |
|
| 123 |
if (!currentUser) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
window.location.href = "index.html"
|
| 125 |
return
|
| 126 |
}
|
| 127 |
|
|
|
|
| 128 |
updateDashboard()
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
// Update BTC price periodically
|
| 132 |
setInterval(updateBTCPrice, 5000)
|
|
@@ -141,15 +183,34 @@ function updateDashboard() {
|
|
| 141 |
return
|
| 142 |
}
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
| 148 |
const usdValue = (userData.btcBalance * BTC_PRICE).toFixed(2)
|
| 149 |
-
document.getElementById("usdBalance")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
}
|
| 151 |
|
| 152 |
-
function
|
| 153 |
const promoCode = document.getElementById("promoCode").value.trim()
|
| 154 |
|
| 155 |
if (!promoCode) {
|
|
@@ -160,6 +221,11 @@ function redeemPromo() {
|
|
| 160 |
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 161 |
const userData = users[currentUser]
|
| 162 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
if (userData.redeemedCodes.includes(promoCode)) {
|
| 164 |
showNotification("Promo code already used!", "error")
|
| 165 |
return
|
|
@@ -180,63 +246,69 @@ function redeemPromo() {
|
|
| 180 |
}
|
| 181 |
}
|
| 182 |
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
|
|
|
| 190 |
}
|
|
|
|
| 191 |
|
| 192 |
-
|
| 193 |
-
document.getElementById("
|
|
|
|
|
|
|
|
|
|
| 194 |
}
|
| 195 |
|
| 196 |
function closeWithdrawModal() {
|
| 197 |
-
document.getElementById("withdrawModal")
|
| 198 |
-
|
|
|
|
|
|
|
| 199 |
}
|
| 200 |
|
| 201 |
-
function
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
}
|
| 204 |
|
| 205 |
-
|
| 206 |
-
document.
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
withdrawForm.addEventListener("submit", (e) => {
|
| 210 |
-
e.preventDefault()
|
| 211 |
-
|
| 212 |
-
const walletAddress = document.getElementById("walletAddress").value
|
| 213 |
-
const walletType = document.getElementById("walletType").value
|
| 214 |
-
const amount = Number.parseFloat(document.getElementById("withdrawAmount").value)
|
| 215 |
-
|
| 216 |
-
if (!walletAddress || !walletType || !amount) {
|
| 217 |
-
showNotification("Please fill all fields!", "error")
|
| 218 |
-
return
|
| 219 |
-
}
|
| 220 |
-
|
| 221 |
-
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 222 |
-
const userData = users[currentUser]
|
| 223 |
-
|
| 224 |
-
if (amount > userData.btcBalance) {
|
| 225 |
-
showNotification("Insufficient balance!", "error")
|
| 226 |
-
return
|
| 227 |
-
}
|
| 228 |
-
|
| 229 |
-
closeWithdrawModal()
|
| 230 |
-
document.getElementById("verificationModal").style.display = "block"
|
| 231 |
-
})
|
| 232 |
}
|
| 233 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 234 |
|
| 235 |
function copyAddress() {
|
| 236 |
-
const address = "
|
| 237 |
-
navigator.clipboard
|
| 238 |
-
|
| 239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
}
|
| 241 |
|
| 242 |
function logout() {
|
|
@@ -315,27 +387,34 @@ function updateBTCPrice() {
|
|
| 315 |
// Notification system
|
| 316 |
function showNotification(message, type = "info") {
|
| 317 |
const notification = document.getElementById("notification")
|
| 318 |
-
if (!notification)
|
|
|
|
|
|
|
|
|
|
| 319 |
|
| 320 |
notification.textContent = message
|
| 321 |
-
notification.className = `notification ${type}`
|
| 322 |
-
notification.classList.add("show")
|
| 323 |
|
| 324 |
setTimeout(() => {
|
| 325 |
notification.classList.remove("show")
|
| 326 |
}, 3000)
|
| 327 |
}
|
| 328 |
|
| 329 |
-
//
|
| 330 |
-
|
| 331 |
-
const
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
if (event.target === withdrawModal) {
|
| 335 |
-
closeWithdrawModal()
|
| 336 |
}
|
|
|
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
}
|
|
|
|
| 33 |
}
|
| 34 |
|
| 35 |
function switchToRegister() {
|
| 36 |
+
const loginForm = document.getElementById("loginForm")
|
| 37 |
+
const landingPage = document.getElementById("landingPage")
|
| 38 |
+
|
| 39 |
+
if (loginForm) loginForm.classList.remove("active")
|
| 40 |
+
if (landingPage) landingPage.classList.add("active")
|
| 41 |
}
|
| 42 |
|
| 43 |
function switchToLogin() {
|
| 44 |
+
const loginForm = document.getElementById("loginForm")
|
| 45 |
+
const landingPage = document.getElementById("landingPage")
|
| 46 |
+
|
| 47 |
+
if (landingPage) landingPage.classList.remove("active")
|
| 48 |
+
if (loginForm) loginForm.classList.add("active")
|
| 49 |
}
|
| 50 |
|
| 51 |
function handleLogin(e) {
|
|
|
|
| 54 |
const email = document.getElementById("loginEmail").value
|
| 55 |
const password = document.getElementById("loginPassword").value
|
| 56 |
|
| 57 |
+
if (!email || !password) {
|
| 58 |
+
showNotification("Please fill in all fields!", "error")
|
| 59 |
+
return
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 63 |
|
| 64 |
+
// Find user by email
|
| 65 |
const userEntry = Object.entries(users).find(
|
| 66 |
+
([key, userData]) => userData.email === email && userData.password === password,
|
| 67 |
)
|
| 68 |
|
| 69 |
if (userEntry) {
|
| 70 |
+
const [userKey] = userEntry
|
| 71 |
+
currentUser = userKey
|
| 72 |
+
localStorage.setItem("cryptovault_current_user", userKey)
|
| 73 |
showNotification("Login successful!", "success")
|
| 74 |
setTimeout(() => {
|
| 75 |
window.location.href = "dashboard.html"
|
| 76 |
+
}, 1500)
|
| 77 |
} else {
|
| 78 |
showNotification("Invalid email or password!", "error")
|
| 79 |
}
|
|
|
|
| 85 |
const email = document.getElementById("registerEmail").value
|
| 86 |
const password = document.getElementById("registerPassword").value
|
| 87 |
const confirmPassword = document.getElementById("confirmPassword").value
|
| 88 |
+
const termsChecked = document.getElementById("termsCheck").checked
|
| 89 |
+
|
| 90 |
+
if (!email || !password || !confirmPassword) {
|
| 91 |
+
showNotification("Please fill in all fields!", "error")
|
| 92 |
+
return
|
| 93 |
+
}
|
| 94 |
|
| 95 |
if (password !== confirmPassword) {
|
| 96 |
showNotification("Passwords do not match!", "error")
|
| 97 |
return
|
| 98 |
}
|
| 99 |
|
| 100 |
+
if (!termsChecked) {
|
| 101 |
+
showNotification("You must agree to the terms!", "error")
|
| 102 |
+
return
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
if (password.length < 6) {
|
| 106 |
+
showNotification("Password must be at least 6 characters!", "error")
|
| 107 |
+
return
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 111 |
|
| 112 |
// Check if email already exists
|
|
|
|
| 140 |
|
| 141 |
setTimeout(() => {
|
| 142 |
switchToLogin()
|
| 143 |
+
}, 1500)
|
| 144 |
}
|
| 145 |
|
| 146 |
// Dashboard functions
|
|
|
|
| 148 |
currentUser = localStorage.getItem("cryptovault_current_user")
|
| 149 |
|
| 150 |
if (!currentUser) {
|
| 151 |
+
console.log("No current user found, redirecting to login")
|
| 152 |
+
window.location.href = "index.html"
|
| 153 |
+
return
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 157 |
+
if (!users[currentUser]) {
|
| 158 |
+
console.log("User data not found, redirecting to login")
|
| 159 |
+
localStorage.removeItem("cryptovault_current_user")
|
| 160 |
window.location.href = "index.html"
|
| 161 |
return
|
| 162 |
}
|
| 163 |
|
| 164 |
+
console.log("Dashboard initialized for user:", currentUser)
|
| 165 |
updateDashboard()
|
| 166 |
+
|
| 167 |
+
// Initialize other dashboard features if elements exist
|
| 168 |
+
const tradingChart = document.getElementById("tradingChart")
|
| 169 |
+
if (tradingChart) {
|
| 170 |
+
initTradingChart()
|
| 171 |
+
}
|
| 172 |
|
| 173 |
// Update BTC price periodically
|
| 174 |
setInterval(updateBTCPrice, 5000)
|
|
|
|
| 183 |
return
|
| 184 |
}
|
| 185 |
|
| 186 |
+
// Update balance displays
|
| 187 |
+
const btcBalanceElements = document.querySelectorAll(
|
| 188 |
+
"#btcBalance, #spotBalance, #btcSpotBalance, #btcAvailableBalance, #btcTotalBalance",
|
| 189 |
+
)
|
| 190 |
+
btcBalanceElements.forEach((element) => {
|
| 191 |
+
if (element) {
|
| 192 |
+
element.textContent =
|
| 193 |
+
userData.btcBalance.toFixed(6) +
|
| 194 |
+
(element.id.includes("spot") || element.id.includes("Total") || element.id.includes("Available") ? " BTC" : "")
|
| 195 |
+
}
|
| 196 |
+
})
|
| 197 |
|
| 198 |
const usdValue = (userData.btcBalance * BTC_PRICE).toFixed(2)
|
| 199 |
+
const usdBalanceElement = document.getElementById("usdBalance")
|
| 200 |
+
if (usdBalanceElement) {
|
| 201 |
+
usdBalanceElement.textContent = usdValue
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
// Update spot balance USD display
|
| 205 |
+
const spotUsdElements = document.querySelectorAll(".spot-usd, .balance-usd-small")
|
| 206 |
+
spotUsdElements.forEach((element) => {
|
| 207 |
+
if (element) {
|
| 208 |
+
element.textContent = `$${usdValue}`
|
| 209 |
+
}
|
| 210 |
+
})
|
| 211 |
}
|
| 212 |
|
| 213 |
+
function redeemPromoCode() {
|
| 214 |
const promoCode = document.getElementById("promoCode").value.trim()
|
| 215 |
|
| 216 |
if (!promoCode) {
|
|
|
|
| 221 |
const users = JSON.parse(localStorage.getItem("cryptovault_users") || "{}")
|
| 222 |
const userData = users[currentUser]
|
| 223 |
|
| 224 |
+
if (!userData) {
|
| 225 |
+
logout()
|
| 226 |
+
return
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
if (userData.redeemedCodes.includes(promoCode)) {
|
| 230 |
showNotification("Promo code already used!", "error")
|
| 231 |
return
|
|
|
|
| 246 |
}
|
| 247 |
}
|
| 248 |
|
| 249 |
+
// Modal functions
|
| 250 |
+
function showDepositModal() {
|
| 251 |
+
const modal = document.getElementById("depositModal")
|
| 252 |
+
if (modal) {
|
| 253 |
+
modal.style.display = "block"
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
|
| 257 |
+
function closeDepositModal() {
|
| 258 |
+
const modal = document.getElementById("depositModal")
|
| 259 |
+
if (modal) {
|
| 260 |
+
modal.style.display = "none"
|
| 261 |
}
|
| 262 |
+
}
|
| 263 |
|
| 264 |
+
function showWithdrawModal() {
|
| 265 |
+
const modal = document.getElementById("withdrawModal")
|
| 266 |
+
if (modal) {
|
| 267 |
+
modal.style.display = "block"
|
| 268 |
+
}
|
| 269 |
}
|
| 270 |
|
| 271 |
function closeWithdrawModal() {
|
| 272 |
+
const modal = document.getElementById("withdrawModal")
|
| 273 |
+
if (modal) {
|
| 274 |
+
modal.style.display = "none"
|
| 275 |
+
}
|
| 276 |
}
|
| 277 |
|
| 278 |
+
function showTransferModal() {
|
| 279 |
+
// Show activation modal instead for demo purposes
|
| 280 |
+
const modal = document.getElementById("activationModal")
|
| 281 |
+
if (modal) {
|
| 282 |
+
modal.style.display = "block"
|
| 283 |
+
}
|
| 284 |
}
|
| 285 |
|
| 286 |
+
function closeActivationModal() {
|
| 287 |
+
const modal = document.getElementById("activationModal")
|
| 288 |
+
if (modal) {
|
| 289 |
+
modal.style.display = "none"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
function processWithdraw() {
|
| 294 |
+
// Show activation modal for demo purposes
|
| 295 |
+
closeWithdrawModal()
|
| 296 |
+
const modal = document.getElementById("activationModal")
|
| 297 |
+
if (modal) {
|
| 298 |
+
modal.style.display = "block"
|
| 299 |
+
}
|
| 300 |
+
}
|
| 301 |
|
| 302 |
function copyAddress() {
|
| 303 |
+
const address = "1J8Be2eVqDAvEQDqRqPfropJSrmxLZYG"
|
| 304 |
+
navigator.clipboard
|
| 305 |
+
.writeText(address)
|
| 306 |
+
.then(() => {
|
| 307 |
+
showNotification("Address copied to clipboard!", "success")
|
| 308 |
+
})
|
| 309 |
+
.catch(() => {
|
| 310 |
+
showNotification("Failed to copy address", "error")
|
| 311 |
+
})
|
| 312 |
}
|
| 313 |
|
| 314 |
function logout() {
|
|
|
|
| 387 |
// Notification system
|
| 388 |
function showNotification(message, type = "info") {
|
| 389 |
const notification = document.getElementById("notification")
|
| 390 |
+
if (!notification) {
|
| 391 |
+
console.log("Notification:", message)
|
| 392 |
+
return
|
| 393 |
+
}
|
| 394 |
|
| 395 |
notification.textContent = message
|
| 396 |
+
notification.className = `notification ${type} show`
|
|
|
|
| 397 |
|
| 398 |
setTimeout(() => {
|
| 399 |
notification.classList.remove("show")
|
| 400 |
}, 3000)
|
| 401 |
}
|
| 402 |
|
| 403 |
+
// Password toggle function
|
| 404 |
+
function togglePassword(fieldId) {
|
| 405 |
+
const field = document.getElementById(fieldId)
|
| 406 |
+
if (field) {
|
| 407 |
+
field.type = field.type === "password" ? "text" : "password"
|
|
|
|
|
|
|
| 408 |
}
|
| 409 |
+
}
|
| 410 |
|
| 411 |
+
// Close modals when clicking outside
|
| 412 |
+
window.onclick = (event) => {
|
| 413 |
+
const modals = ["depositModal", "withdrawModal", "activationModal"]
|
| 414 |
+
modals.forEach((modalId) => {
|
| 415 |
+
const modal = document.getElementById(modalId)
|
| 416 |
+
if (modal && event.target === modal) {
|
| 417 |
+
modal.style.display = "none"
|
| 418 |
+
}
|
| 419 |
+
})
|
| 420 |
}
|
styles.css
CHANGED
|
@@ -365,6 +365,22 @@ body {
|
|
| 365 |
color: #00d4ff;
|
| 366 |
}
|
| 367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
.btn-nav {
|
| 369 |
background: #4c51bf;
|
| 370 |
color: white;
|
|
@@ -903,6 +919,11 @@ body {
|
|
| 903 |
font-size: 14px;
|
| 904 |
}
|
| 905 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 906 |
.payment-methods {
|
| 907 |
display: grid;
|
| 908 |
grid-template-columns: 1fr 1fr;
|
|
|
|
| 365 |
color: #00d4ff;
|
| 366 |
}
|
| 367 |
|
| 368 |
+
.btn-logout {
|
| 369 |
+
background: transparent;
|
| 370 |
+
color: #8892b0;
|
| 371 |
+
border: none;
|
| 372 |
+
font-size: 14px;
|
| 373 |
+
cursor: pointer;
|
| 374 |
+
transition: color 0.3s ease;
|
| 375 |
+
padding: 8px 16px;
|
| 376 |
+
border-radius: 6px;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
.btn-logout:hover {
|
| 380 |
+
color: #00d4ff;
|
| 381 |
+
background: rgba(0, 212, 255, 0.1);
|
| 382 |
+
}
|
| 383 |
+
|
| 384 |
.btn-nav {
|
| 385 |
background: #4c51bf;
|
| 386 |
color: white;
|
|
|
|
| 919 |
font-size: 14px;
|
| 920 |
}
|
| 921 |
|
| 922 |
+
.deposit-note {
|
| 923 |
+
color: #8892b0;
|
| 924 |
+
font-size: 14px;
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
.payment-methods {
|
| 928 |
display: grid;
|
| 929 |
grid-template-columns: 1fr 1fr;
|