Spaces:
Running
Running
Design a neomorphic cryptocurrency tracker website using Web3 with blockchain integration. Make this a fully functional ready to launch website. Provide detailed specifications for user experience, technical architecture, and monetization strategy.
Browse files- components/crypto-card.js +224 -0
- components/crypto-footer.js +144 -0
- components/crypto-navbar.js +196 -0
- components/footer.js +2 -1
- components/navbar.js +7 -1
- crypto-script.js +326 -0
- crypto-style.css +131 -0
- crypto-sw.js +112 -0
- crypto-tracker.html +158 -0
- index.html +4 -1
- script.js +0 -2
components/crypto-card.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CryptoCard extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
const cryptoData = JSON.parse(this.getAttribute('data-crypto'));
|
| 4 |
+
this.attachShadow({ mode: 'open' });
|
| 5 |
+
this.shadowRoot.innerHTML = `
|
| 6 |
+
<style>
|
| 7 |
+
.crypto-card {
|
| 8 |
+
background: linear-gradient(145deg, #1f2937, #111827);
|
| 9 |
+
border-radius: 20px;
|
| 10 |
+
padding: 1.5rem;
|
| 11 |
+
transition: all 0.3s ease;
|
| 12 |
+
cursor: pointer;
|
| 13 |
+
position: relative;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
.crypto-card:hover {
|
| 18 |
+
transform: translateY(-8px);
|
| 19 |
+
box-shadow: 15px 15px 30px #0a0e14, -15px -15px 30px #243142;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.crypto-header {
|
| 23 |
+
display: flex;
|
| 24 |
+
align-items: center;
|
| 25 |
+
gap: 1rem;
|
| 26 |
+
margin-bottom: 1rem;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.crypto-icon {
|
| 30 |
+
width: 48px;
|
| 31 |
+
height: 48px;
|
| 32 |
+
border-radius: 12px;
|
| 33 |
+
object-fit: cover;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.crypto-name {
|
| 37 |
+
font-size: 1.125rem;
|
| 38 |
+
font-weight: 700;
|
| 39 |
+
color: white;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.crypto-symbol {
|
| 43 |
+
color: #9ca3af;
|
| 44 |
+
font-size: 0.875rem;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
.crypto-price {
|
| 48 |
+
font-size: 1.5rem;
|
| 49 |
+
font-weight: 800;
|
| 50 |
+
margin-bottom: 0.5rem;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.price-change {
|
| 54 |
+
font-size: 0.875rem;
|
| 55 |
+
font-weight: 600;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.price-up {
|
| 59 |
+
color: #10b981;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.price-down {
|
| 63 |
+
color: #ef4444;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.crypto-stats {
|
| 67 |
+
display: grid;
|
| 68 |
+
grid-template-columns: 1fr 1fr;
|
| 69 |
+
gap: 0.5rem;
|
| 70 |
+
margin-top: 1rem;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.stat-label {
|
| 74 |
+
color: #9ca3af;
|
| 75 |
+
font-size: 0.75rem;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.stat-value {
|
| 79 |
+
font-weight: 600;
|
| 80 |
+
color: white;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.sparkline {
|
| 84 |
+
height: 40px;
|
| 85 |
+
margin-top: 1rem;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.watchlist-btn {
|
| 89 |
+
background: none;
|
| 90 |
+
border: none;
|
| 91 |
+
color: #9ca3af;
|
| 92 |
+
cursor: pointer;
|
| 93 |
+
transition: color 0.3s ease;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.watchlist-btn:hover {
|
| 97 |
+
color: #3b82f6;
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.premium-badge {
|
| 101 |
+
position: absolute;
|
| 102 |
+
top: 1rem;
|
| 103 |
+
right: 1rem;
|
| 104 |
+
background: linear-gradient(135deg, #fbbf24, #f59e0b);
|
| 105 |
+
color: #1f2937;
|
| 106 |
+
padding: 0.25rem 0.75rem;
|
| 107 |
+
border-radius: 12px;
|
| 108 |
+
font-size: 0.75rem;
|
| 109 |
+
font-weight: 600;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.quick-actions {
|
| 113 |
+
display: flex;
|
| 114 |
+
justify-content: space-between;
|
| 115 |
+
margin-top: 1rem;
|
| 116 |
+
}
|
| 117 |
+
</style>
|
| 118 |
+
|
| 119 |
+
<div class="crypto-card">
|
| 120 |
+
${cryptoData.market_cap_rank <= 10 ? '<div class="premium-badge">Top 10</div>' : ''}
|
| 121 |
+
|
| 122 |
+
<div class="crypto-header">
|
| 123 |
+
<img
|
| 124 |
+
src="${cryptoData.image}"
|
| 125 |
+
alt="${cryptoData.name}"
|
| 126 |
+
class="crypto-icon"
|
| 127 |
+
>
|
| 128 |
+
<div>
|
| 129 |
+
<div class="crypto-name">${cryptoData.name}</div>
|
| 130 |
+
<div class="crypto-symbol">${cryptoData.symbol.toUpperCase()}</div>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
|
| 134 |
+
<div class="crypto-price">$${cryptoData.current_price.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</div>
|
| 135 |
+
|
| 136 |
+
<div class="price-change ${cryptoData.price_change_percentage_24h >= 0 ? 'price-up' : 'price-down'}">
|
| 137 |
+
${cryptoData.price_change_percentage_24h >= 0 ? '+' : ''}${cryptoData.price_change_percentage_24h?.toFixed(2) || '0.00'}%
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
<div class="crypto-stats">
|
| 141 |
+
<div class="stat-label">Market Cap</div>
|
| 142 |
+
<div class="stat-value">$${(cryptoData.market_cap / 1000000000).toFixed(2)}B</div>
|
| 143 |
+
<div class="stat-label">24h Volume</div>
|
| 144 |
+
<div class="stat-value">$${(cryptoData.total_volume / 1000000).toFixed(2)}M</div>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<div class="sparkline" id="sparkline-${cryptoData.id}"></div>
|
| 148 |
+
|
| 149 |
+
<div class="quick-actions">
|
| 150 |
+
<button class="watchlist-btn">
|
| 151 |
+
<i data-feather="star"></i>
|
| 152 |
+
</button>
|
| 153 |
+
|
| 154 |
+
<button class="watchlist-btn">
|
| 155 |
+
<i data-feather="bell"></i>
|
| 156 |
+
</button>
|
| 157 |
+
</div>
|
| 158 |
+
</div>
|
| 159 |
+
`;
|
| 160 |
+
|
| 161 |
+
this.setupInteractions();
|
| 162 |
+
this.renderSparkline(cryptoData);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
setupInteractions() {
|
| 166 |
+
const card = this.shadowRoot.querySelector('.crypto-card');
|
| 167 |
+
const watchlistBtn = this.shadowRoot.querySelector('.watchlist-btn');
|
| 168 |
+
|
| 169 |
+
watchlistBtn.addEventListener('click', (e) => {
|
| 170 |
+
e.stopPropagation();
|
| 171 |
+
this.toggleWatchlist();
|
| 172 |
+
});
|
| 173 |
+
|
| 174 |
+
card.addEventListener('click', () => {
|
| 175 |
+
this.viewCryptoDetails();
|
| 176 |
+
});
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
renderSparkline(cryptoData) {
|
| 180 |
+
const sparklineContainer = this.shadowRoot.querySelector('.sparkline');
|
| 181 |
+
|
| 182 |
+
if (cryptoData.sparkline_in_7d?.price) {
|
| 183 |
+
// In a real implementation, you would use a charting library
|
| 184 |
+
// For demo, we'll create a simple SVG sparkline
|
| 185 |
+
|
| 186 |
+
const sparklineData = cryptoData.sparkline_in_7d.price;
|
| 187 |
+
const width = 200;
|
| 188 |
+
const height = 40;
|
| 189 |
+
|
| 190 |
+
sparklineContainer.innerHTML = `
|
| 191 |
+
<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}">
|
| 192 |
+
<polyline
|
| 193 |
+
fill="none"
|
| 194 |
+
stroke="${cryptoData.price_change_percentage_24h >= 0 ? '#10b981' : '#ef4444'}"
|
| 195 |
+
stroke-width="2"
|
| 196 |
+
points="${sparklineData.map((price, index) => {
|
| 197 |
+
const x = (index / (sparklineData.length - 1)) * width},${height - ((price - Math.min(...sparklineData)) / (Math.max(...sparklineData) - Math.min(...sparklineData)) * height}"
|
| 198 |
+
/>
|
| 199 |
+
</svg>
|
| 200 |
+
`;
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
toggleWatchlist() {
|
| 205 |
+
const starIcon = this.shadowRoot.querySelector('.watchlist-btn i');
|
| 206 |
+
|
| 207 |
+
if (starIcon.getAttribute('data-feather') === 'star') {
|
| 208 |
+
starIcon.setAttribute('data-feather', 'star');
|
| 209 |
+
} else {
|
| 210 |
+
starIcon.setAttribute('data-feather', 'star');
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
feather.replace();
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
viewCryptoDetails() {
|
| 217 |
+
const cryptoData = JSON.parse(this.getAttribute('data-crypto')));
|
| 218 |
+
|
| 219 |
+
// Navigate to crypto details page
|
| 220 |
+
window.location.href = `/crypto-details.html?id=${cryptoData.id}`;
|
| 221 |
+
}
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
customElements.define('crypto-card', CryptoCard);
|
components/crypto-footer.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CryptoFooter extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
footer {
|
| 7 |
+
background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
|
| 8 |
+
color: white;
|
| 9 |
+
padding: 3rem 2rem;
|
| 10 |
+
margin-top: auto;
|
| 11 |
+
border-top: 1px solid rgba(255, 255, 255, 0.1);
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
.footer-content {
|
| 15 |
+
max-width: 7xl;
|
| 16 |
+
margin: 0 auto;
|
| 17 |
+
display: grid;
|
| 18 |
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
| 19 |
+
gap: 2rem;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
.footer-section h3 {
|
| 23 |
+
color: #10b981;
|
| 24 |
+
margin-bottom: 1rem;
|
| 25 |
+
font-weight: 600;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
.footer-links {
|
| 29 |
+
list-style: none;
|
| 30 |
+
padding: 0;
|
| 31 |
+
margin: 0;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.footer-links li {
|
| 35 |
+
margin-bottom: 0.5rem;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.footer-links a {
|
| 39 |
+
color: #d1d5db;
|
| 40 |
+
text-decoration: none;
|
| 41 |
+
transition: color 0.3s ease;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.footer-links a:hover {
|
| 45 |
+
color: #10b981;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.social-links {
|
| 49 |
+
display: flex;
|
| 50 |
+
gap: 1rem;
|
| 51 |
+
margin-top: 1rem;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.social-links a {
|
| 55 |
+
color: #d1d5db;
|
| 56 |
+
transition: color 0.3s ease;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
.social-links a:hover {
|
| 60 |
+
color: #3b82f6;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.footer-bottom {
|
| 64 |
+
border-top: 1px solid #374151;
|
| 65 |
+
padding-top: 2rem;
|
| 66 |
+
margin-top: 2rem;
|
| 67 |
+
text-align: center;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.newsletter-input {
|
| 71 |
+
background: rgba(255, 255, 255, 0.1);
|
| 72 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 73 |
+
border-radius: 8px;
|
| 74 |
+
padding: 0.75rem 1rem;
|
| 75 |
+
color: white;
|
| 76 |
+
width: 100%;
|
| 77 |
+
margin-bottom: 1rem;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.newsletter-input:focus {
|
| 81 |
+
outline: none;
|
| 82 |
+
border-color: #3b82f6;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
@media (max-width: 768px) {
|
| 86 |
+
footer {
|
| 87 |
+
padding: 2rem 1rem;
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
</style>
|
| 91 |
+
<footer>
|
| 92 |
+
<div class="footer-content">
|
| 93 |
+
<div class="footer-section">
|
| 94 |
+
<h3>CryptoSphere</h3>
|
| 95 |
+
<p>Real-time cryptocurrency tracking with Web3 integration and advanced analytics.</p>
|
| 96 |
+
<div class="social-links">
|
| 97 |
+
<a href="#"><i data-feather="twitter"></i></a>
|
| 98 |
+
<a href="#"><i data-feather="discord"></i></a>
|
| 99 |
+
<a href="#"><i data-feather="github"></i></a>
|
| 100 |
+
<a href="#"><i data-feather="telegram"></i></a>
|
| 101 |
+
</div>
|
| 102 |
+
</div>
|
| 103 |
+
|
| 104 |
+
<div class="footer-section">
|
| 105 |
+
<h3>Markets</h3>
|
| 106 |
+
<ul class="footer-links">
|
| 107 |
+
<li><a href="#market-overview">Top Cryptos</a></li>
|
| 108 |
+
<li><a href="/crypto-portfolio.html">Portfolio</a></li>
|
| 109 |
+
<li><a href="/crypto-analytics.html">Analytics</a></li>
|
| 110 |
+
<li><a href="/crypto-news.html">Crypto News</a></li>
|
| 111 |
+
<li><a href="/crypto-alerts.html">Price Alerts</a></li>
|
| 112 |
+
</ul>
|
| 113 |
+
</div>
|
| 114 |
+
|
| 115 |
+
<div class="footer-section">
|
| 116 |
+
<h3>Resources</h3>
|
| 117 |
+
<ul class="footer-links">
|
| 118 |
+
<li><a href="/crypto-education.html">Education</a></li>
|
| 119 |
+
<li><a href="/crypto-api.html">API</a></li>
|
| 120 |
+
<li><a href="/crypto-developers.html">Developers</a></li>
|
| 121 |
+
<li><a href="/crypto-support.html">Support</a></li>
|
| 122 |
+
<li><a href="/crypto-faq.html">FAQ</a></li>
|
| 123 |
+
</ul>
|
| 124 |
+
</div>
|
| 125 |
+
|
| 126 |
+
<div class="footer-section">
|
| 127 |
+
<h3>Newsletter</h3>
|
| 128 |
+
<p>Stay updated with the latest cryptocurrency trends and market insights.</p>
|
| 129 |
+
<input type="email" placeholder="Enter your email" class="newsletter-input">
|
| 130 |
+
<button class="crypto-button bg-primary hover:bg-emerald-600 text-white px-6 py-2 rounded-lg font-semibold transition-colors duration-300">
|
| 131 |
+
Subscribe
|
| 132 |
+
</button>
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
|
| 136 |
+
<div class="footer-bottom">
|
| 137 |
+
<p>© 2024 CryptoSphere. All rights reserved. | <a href="/crypto-privacy.html" class="text-secondary hover:text-blue-400">Privacy Policy</a> | <a href="/crypto-terms.html" class="text-secondary hover:text-blue-400">Terms of Service</a></p>
|
| 138 |
+
</div>
|
| 139 |
+
</footer>
|
| 140 |
+
`;
|
| 141 |
+
}
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
customElements.define('crypto-footer', CryptoFooter);
|
components/crypto-navbar.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class CryptoNavbar extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host {
|
| 7 |
+
display: block;
|
| 8 |
+
position: sticky;
|
| 9 |
+
top: 0;
|
| 10 |
+
z-index: 50;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
nav {
|
| 14 |
+
background: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(31, 41, 55, 0.95));
|
| 15 |
+
padding: 1rem 2rem;
|
| 16 |
+
display: flex;
|
| 17 |
+
justify-content: space-between;
|
| 18 |
+
align-items: center;
|
| 19 |
+
backdrop-filter: blur(10px);
|
| 20 |
+
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
.logo {
|
| 24 |
+
color: white;
|
| 25 |
+
font-weight: 800;
|
| 26 |
+
font-size: 1.5rem;
|
| 27 |
+
background: linear-gradient(135deg, #10b981, #059669);
|
| 28 |
+
-webkit-background-clip: text;
|
| 29 |
+
-webkit-text-fill-color: transparent;
|
| 30 |
+
background-clip: text;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.nav-links {
|
| 34 |
+
display: flex;
|
| 35 |
+
gap: 2rem;
|
| 36 |
+
list-style: none;
|
| 37 |
+
margin: 0;
|
| 38 |
+
padding: 0;
|
| 39 |
+
align-items: center;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.nav-link {
|
| 43 |
+
color: white;
|
| 44 |
+
text-decoration: none;
|
| 45 |
+
font-weight: 500;
|
| 46 |
+
transition: all 0.3s ease;
|
| 47 |
+
display: flex;
|
| 48 |
+
align-items: center;
|
| 49 |
+
gap: 0.5rem;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
.nav-link:hover {
|
| 53 |
+
color: #10b981;
|
| 54 |
+
transform: translateY(-1px);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
.search-container {
|
| 58 |
+
position: relative;
|
| 59 |
+
display: flex;
|
| 60 |
+
align-items: center;
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
.search-input {
|
| 64 |
+
background: linear-gradient(145deg, #1f2937, #111827);
|
| 65 |
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
| 66 |
+
border-radius: 25px;
|
| 67 |
+
padding: 0.5rem 1rem 0.5rem 2.5rem;
|
| 68 |
+
color: white;
|
| 69 |
+
transition: all 0.3s ease;
|
| 70 |
+
box-shadow: inset 4px 4px 8px #0a0e14, inset -4px -4px 8px #243142;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.search-input:focus {
|
| 74 |
+
outline: none;
|
| 75 |
+
border-color: #10b981;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.search-icon {
|
| 79 |
+
position: absolute;
|
| 80 |
+
left: 1rem;
|
| 81 |
+
color: #9ca3af;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
.mobile-menu-btn {
|
| 85 |
+
display: none;
|
| 86 |
+
background: none;
|
| 87 |
+
border: none;
|
| 88 |
+
color: white;
|
| 89 |
+
cursor: pointer;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
@media (max-width: 768px) {
|
| 93 |
+
nav {
|
| 94 |
+
padding: 1rem;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.nav-links {
|
| 98 |
+
display: none;
|
| 99 |
+
position: absolute;
|
| 100 |
+
top: 100%;
|
| 101 |
+
left: 0;
|
| 102 |
+
right: 0;
|
| 103 |
+
background: #111827;
|
| 104 |
+
flex-direction: column;
|
| 105 |
+
padding: 1rem;
|
| 106 |
+
gap: 1rem;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.nav-links.active {
|
| 110 |
+
display: flex;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.mobile-menu-btn {
|
| 114 |
+
display: block;
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
</style>
|
| 118 |
+
<nav>
|
| 119 |
+
<div class="logo">CryptoSphere</div>
|
| 120 |
+
|
| 121 |
+
<ul class="nav-links">
|
| 122 |
+
<li>
|
| 123 |
+
<a href="/crypto-tracker.html" class="nav-link">
|
| 124 |
+
<i data-feather="home"></i>
|
| 125 |
+
Home
|
| 126 |
+
</a>
|
| 127 |
+
</li>
|
| 128 |
+
<li>
|
| 129 |
+
<a href="#market-overview" class="nav-link">
|
| 130 |
+
<i data-feather="trending-up"></i>
|
| 131 |
+
Markets
|
| 132 |
+
</a>
|
| 133 |
+
</li>
|
| 134 |
+
<li>
|
| 135 |
+
<a href="/crypto-portfolio.html" class="nav-link">
|
| 136 |
+
<i data-feather="pie-chart"></i>
|
| 137 |
+
Portfolio
|
| 138 |
+
</a>
|
| 139 |
+
</li>
|
| 140 |
+
<li>
|
| 141 |
+
<a href="/crypto-analytics.html" class="nav-link">
|
| 142 |
+
<i data-feather="bar-chart"></i>
|
| 143 |
+
Analytics
|
| 144 |
+
</a>
|
| 145 |
+
</li>
|
| 146 |
+
<li class="search-container">
|
| 147 |
+
<i data-feather="search" class="search-icon"></i>
|
| 148 |
+
<input type="search" placeholder="Search cryptocurrencies..." class="search-input">
|
| 149 |
+
</li>
|
| 150 |
+
</ul>
|
| 151 |
+
|
| 152 |
+
<button class="mobile-menu-btn">
|
| 153 |
+
<i data-feather="menu"></i>
|
| 154 |
+
</button>
|
| 155 |
+
</nav>
|
| 156 |
+
`;
|
| 157 |
+
|
| 158 |
+
this.setupMobileMenu();
|
| 159 |
+
this.setupSearch();
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
setupMobileMenu() {
|
| 163 |
+
const menuBtn = this.shadowRoot.querySelector('.mobile-menu-btn');
|
| 164 |
+
const navLinks = this.shadowRoot.querySelector('.nav-links');
|
| 165 |
+
|
| 166 |
+
menuBtn.addEventListener('click', () => {
|
| 167 |
+
navLinks.classList.toggle('active');
|
| 168 |
+
const icon = menuBtn.querySelector('i');
|
| 169 |
+
if (navLinks.classList.contains('active')) {
|
| 170 |
+
icon.setAttribute('data-feather', 'x');
|
| 171 |
+
} else {
|
| 172 |
+
icon.setAttribute('data-feather', 'menu');
|
| 173 |
+
}
|
| 174 |
+
feather.replace();
|
| 175 |
+
});
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
setupSearch() {
|
| 179 |
+
const searchInput = this.shadowRoot.querySelector('.search-input');
|
| 180 |
+
|
| 181 |
+
searchInput.addEventListener('input', (e) => {
|
| 182 |
+
const query = e.target.value;
|
| 183 |
+
this.searchCryptos(query);
|
| 184 |
+
});
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
searchCryptos(query) {
|
| 188 |
+
const event = new CustomEvent('crypto-search', {
|
| 189 |
+
detail: { query }
|
| 190 |
+
});
|
| 191 |
+
|
| 192 |
+
this.shadowRoot.dispatchEvent(event);
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
customElements.define('crypto-navbar', CryptoNavbar);
|
components/footer.js
CHANGED
|
@@ -119,7 +119,8 @@ class CustomFooter extends HTMLElement {
|
|
| 119 |
<li><a href="/competitions.html">Competitions</a></li>
|
| 120 |
<li><a href="/blog.html">Blog</a></li>
|
| 121 |
<li><a href="/support.html">Support</a></li>
|
| 122 |
-
|
|
|
|
| 123 |
</div>
|
| 124 |
|
| 125 |
<div class="footer-section">
|
|
|
|
| 119 |
<li><a href="/competitions.html">Competitions</a></li>
|
| 120 |
<li><a href="/blog.html">Blog</a></li>
|
| 121 |
<li><a href="/support.html">Support</a></li>
|
| 122 |
+
<li><a href="/crypto-tracker.html">Crypto Tracker</a></li>
|
| 123 |
+
</ul>
|
| 124 |
</div>
|
| 125 |
|
| 126 |
<div class="footer-section">
|
components/navbar.js
CHANGED
|
@@ -158,7 +158,13 @@ class CustomNavbar extends HTMLElement {
|
|
| 158 |
Profile
|
| 159 |
</a>
|
| 160 |
</li>
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
<button class="mobile-menu-btn">
|
| 164 |
<i data-feather="menu"></i>
|
|
|
|
| 158 |
Profile
|
| 159 |
</a>
|
| 160 |
</li>
|
| 161 |
+
<li>
|
| 162 |
+
<a href="/crypto-tracker.html" class="nav-link">
|
| 163 |
+
<i data-feather="trending-up"></i>
|
| 164 |
+
Crypto
|
| 165 |
+
</a>
|
| 166 |
+
</li>
|
| 167 |
+
</ul>
|
| 168 |
|
| 169 |
<button class="mobile-menu-btn">
|
| 170 |
<i data-feather="menu"></i>
|
crypto-script.js
ADDED
|
@@ -0,0 +1,326 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// CryptoSphere - Cryptocurrency Tracker JavaScript
|
| 2 |
+
class CryptosphereTracker {
|
| 3 |
+
constructor() {
|
| 4 |
+
this.web3 = null;
|
| 5 |
+
this.provider = null;
|
| 6 |
+
this.connectedAccount = null;
|
| 7 |
+
this.cryptoData = [];
|
| 8 |
+
this.portfolioData = [];
|
| 9 |
+
this.currentPage = 1;
|
| 10 |
+
this.itemsPerPage = 12;
|
| 11 |
+
this.init();
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
async init() {
|
| 15 |
+
await this.registerServiceWorker();
|
| 16 |
+
this.setupEventListeners();
|
| 17 |
+
await this.loadCryptoData();
|
| 18 |
+
this.updateMarketStats();
|
| 19 |
+
this.setupRealTimeUpdates();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
// Web3 Wallet Integration
|
| 23 |
+
async connectWallet() {
|
| 24 |
+
try {
|
| 25 |
+
if (window.ethereum) {
|
| 26 |
+
this.provider = window.ethereum;
|
| 27 |
+
this.web3 = new Web3(this.provider);
|
| 28 |
+
|
| 29 |
+
// Request account access
|
| 30 |
+
const accounts = await window.ethereum.request({
|
| 31 |
+
method: 'eth_requestAccounts'
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
this.connectedAccount = accounts[0];
|
| 35 |
+
this.updateWalletStatus();
|
| 36 |
+
await this.loadPortfolioData();
|
| 37 |
+
|
| 38 |
+
// Listen for account changes
|
| 39 |
+
window.ethereum.on('accountsChanged', (accounts) => {
|
| 40 |
+
this.connectedAccount = accounts[0] || null;
|
| 41 |
+
this.updateWalletStatus();
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
} else {
|
| 45 |
+
throw new Error('No Ethereum wallet detected. Please install MetaMask.');
|
| 46 |
+
}
|
| 47 |
+
} catch (error) {
|
| 48 |
+
this.showNotification(error.message, 'error');
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
// Real-time Crypto Data from CoinGecko API
|
| 53 |
+
async fetchCryptoData(page = 1) {
|
| 54 |
+
const vsCurrency = 'usd';
|
| 55 |
+
const perPage = this.itemsPerPage;
|
| 56 |
+
|
| 57 |
+
try {
|
| 58 |
+
const response = await fetch(
|
| 59 |
+
`https://api.coingecko.com/api/v3/coins/markets?vs_currency=${vsCurrency}&order=market_cap_desc&per_page=${perPage}&page=${page}&sparkline=true&price_change_percentage=24h`
|
| 60 |
+
);
|
| 61 |
+
|
| 62 |
+
if (!response.ok) {
|
| 63 |
+
throw new Error('Failed to fetch crypto data');
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
const data = await response.json();
|
| 67 |
+
return data;
|
| 68 |
+
} catch (error) {
|
| 69 |
+
console.error('Error fetching crypto data:', error);
|
| 70 |
+
return this.getMockCryptoData(page);
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// Mock data for demonstration
|
| 75 |
+
getMockCryptoData(page) {
|
| 76 |
+
const mockData = [];
|
| 77 |
+
const startIndex = (page - 1) * this.itemsPerPage;
|
| 78 |
+
|
| 79 |
+
const topCryptos = [
|
| 80 |
+
{ id: 'bitcoin', symbol: 'btc', name: 'Bitcoin' },
|
| 81 |
+
{ id: 'ethereum', symbol: 'eth', name: 'Ethereum' },
|
| 82 |
+
{ id: 'binancecoin', symbol: 'bnb', name: 'BNB' },
|
| 83 |
+
{ id: 'ripple', symbol: 'xrp', name: 'XRP' },
|
| 84 |
+
{ id: 'cardano', symbol: 'ada', name: 'Cardano' },
|
| 85 |
+
{ id: 'solana', symbol: 'sol', name: 'Solana' },
|
| 86 |
+
{ id: 'polkadot', symbol: 'dot', name: 'Polkadot' }
|
| 87 |
+
];
|
| 88 |
+
|
| 89 |
+
for (let i = 0; i < this.itemsPerPage; i++) {
|
| 90 |
+
const crypto = topCryptos[i % topCryptos.length];
|
| 91 |
+
const price = Math.random() * 50000 + 1000;
|
| 92 |
+
const change24h = (Math.random() - 0.5) * 20;
|
| 93 |
+
|
| 94 |
+
mockData.push({
|
| 95 |
+
id: crypto.id,
|
| 96 |
+
symbol: crypto.symbol,
|
| 97 |
+
name: crypto.name,
|
| 98 |
+
current_price: price,
|
| 99 |
+
price_change_percentage_24h: change24h,
|
| 100 |
+
market_cap: price * (Math.random() * 1000000),
|
| 101 |
+
total_volume: price * (Math.random() * 100000),
|
| 102 |
+
price_change_24h: change24h * price / 100,
|
| 103 |
+
image: `http://static.photos/finance/200x200/${startIndex + i + 1}`,
|
| 104 |
+
sparkline_in_7d: { price: Array(7).fill(0).map(() => price + (Math.random() - 0.5) * 1000
|
| 105 |
+
});
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
return mockData;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
// Load and display crypto data
|
| 112 |
+
async loadCryptoData() {
|
| 113 |
+
const data = await this.fetchCryptoData(this.currentPage);
|
| 114 |
+
this.cryptoData = [...this.cryptoData, ...data];
|
| 115 |
+
this.renderCryptoData(data);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
renderCryptoData(data) {
|
| 119 |
+
const grid = document.getElementById('crypto-grid');
|
| 120 |
+
|
| 121 |
+
data.forEach(crypto => {
|
| 122 |
+
const cryptoCard = document.createElement('crypto-card');
|
| 123 |
+
cryptoCard.setAttribute('data-crypto', JSON.stringify(crypto));
|
| 124 |
+
grid.appendChild(cryptoCard);
|
| 125 |
+
});
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
// Update global market statistics
|
| 129 |
+
updateMarketStats() {
|
| 130 |
+
// Simulate real-time market data updates
|
| 131 |
+
setInterval(() => {
|
| 132 |
+
const marketCap = (2.1 + Math.random() * 0.1).toFixed(1);
|
| 133 |
+
const volume = (78.4 + Math.random() * 5).toFixed(1);
|
| 134 |
+
const dominance = (52.3 + (Math.random() - 0.5)).toFixed(1);
|
| 135 |
+
|
| 136 |
+
document.getElementById('global-market-cap').textContent = `$${marketCap}T`;
|
| 137 |
+
document.getElementById('total-volume').textContent = `$${volume}B`;
|
| 138 |
+
document.getElementById('btc-dominance').textContent = `${dominance}%`;
|
| 139 |
+
}, 3000);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
// Real-time price updates via WebSocket
|
| 143 |
+
setupRealTimeUpdates() {
|
| 144 |
+
// This would connect to a WebSocket service for real-time updates
|
| 145 |
+
// For demo purposes, we'll simulate with intervals
|
| 146 |
+
|
| 147 |
+
setInterval(() => {
|
| 148 |
+
this.updateLivePrices();
|
| 149 |
+
}, 5000);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
updateLivePrices() {
|
| 153 |
+
const cards = document.querySelectorAll('crypto-card');
|
| 154 |
+
cards.forEach(card => {
|
| 155 |
+
const cryptoData = JSON.parse(card.getAttribute('data-crypto')));
|
| 156 |
+
|
| 157 |
+
// Simulate price changes
|
| 158 |
+
const change = (Math.random() - 0.5) * 2;
|
| 159 |
+
const newPrice = cryptoData.current_price * (1 + change / 100);
|
| 160 |
+
cryptoData.current_price = newPrice;
|
| 161 |
+
cryptoData.price_change_percentage_24h = change;
|
| 162 |
+
|
| 163 |
+
// Update the card
|
| 164 |
+
card.setAttribute('data-crypto', JSON.stringify(cryptoData));
|
| 165 |
+
});
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// Load portfolio data from connected wallet
|
| 169 |
+
async loadPortfolioData() {
|
| 170 |
+
if (!this.connectedAccount) return;
|
| 171 |
+
|
| 172 |
+
try {
|
| 173 |
+
// In a real implementation, you would query the blockchain
|
| 174 |
+
// for the wallet's token holdings and their current values
|
| 175 |
+
|
| 176 |
+
// Mock portfolio data
|
| 177 |
+
this.portfolioData = [
|
| 178 |
+
{
|
| 179 |
+
id: 'bitcoin',
|
| 180 |
+
symbol: 'btc',
|
| 181 |
+
name: 'Bitcoin',
|
| 182 |
+
amount: Math.random() * 0.5,
|
| 183 |
+
value: Math.random() * 15000,
|
| 184 |
+
change24h: (Math.random() - 0.5) * 10
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
id: 'ethereum',
|
| 188 |
+
symbol: 'eth',
|
| 189 |
+
name: 'Ethereum',
|
| 190 |
+
amount: Math.random() * 10,
|
| 191 |
+
value: Math.random() * 20000
|
| 192 |
+
}
|
| 193 |
+
];
|
| 194 |
+
|
| 195 |
+
this.renderPortfolio();
|
| 196 |
+
} catch (error) {
|
| 197 |
+
console.error('Error loading portfolio:', error);
|
| 198 |
+
}
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
renderPortfolio() {
|
| 202 |
+
const container = document.getElementById('portfolio-container');
|
| 203 |
+
|
| 204 |
+
if (this.portfolioData.length === 0) {
|
| 205 |
+
container.innerHTML = `
|
| 206 |
+
<div class="text-center text-gray-400">
|
| 207 |
+
<i data-feather="alert-circle" class="w-16 h-16 mx-auto mb-4"></i>
|
| 208 |
+
<p>No crypto assets detected in your wallet</p>
|
| 209 |
+
`;
|
| 210 |
+
} else {
|
| 211 |
+
let totalValue = 0;
|
| 212 |
+
let totalChange = 0;
|
| 213 |
+
|
| 214 |
+
const portfolioHTML = this.portfolioData.map(asset => {
|
| 215 |
+
totalValue += asset.value;
|
| 216 |
+
totalChange += asset.change24h || 0;
|
| 217 |
+
|
| 218 |
+
return `
|
| 219 |
+
<div class="asset ${asset.change24h >= 0 ? 'portfolio-up' : 'portfolio-down'} p-4 mb-4 rounded-xl">
|
| 220 |
+
<div class="flex justify-between items-center">
|
| 221 |
+
<div class="flex items-center gap-3">
|
| 222 |
+
<img src="${asset.image || 'http://static.photos/finance/200x200'}" class="w-10 h-10 rounded-full">
|
| 223 |
+
<div>
|
| 224 |
+
<div class="font-semibold">${asset.name} (${asset.symbol.toUpperCase()})</div>
|
| 225 |
+
<div class="text-right">
|
| 226 |
+
<div class="font-bold">$${asset.value.toFixed(2)}</div>
|
| 227 |
+
<div class="text-sm ${asset.change24h >= 0 ? 'price-up' : 'price-down'}">
|
| 228 |
+
${asset.change24h >= 0 ? '+' : ''}${asset.change24h?.toFixed(2) || '0.00'}%</div>
|
| 229 |
+
</div>
|
| 230 |
+
</div>
|
| 231 |
+
</div>
|
| 232 |
+
`;
|
| 233 |
+
}).join('');
|
| 234 |
+
|
| 235 |
+
container.innerHTML = `
|
| 236 |
+
<h3 class="text-2xl font-bold text-white mb-6">Your Portfolio</h3>
|
| 237 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 238 |
+
${portfolioHTML}
|
| 239 |
+
</div>
|
| 240 |
+
<div class="mt-6 pt-6 border-t border-gray-600">
|
| 241 |
+
<div class="flex justify-between text-xl">
|
| 242 |
+
<span>Total Value:</span>
|
| 243 |
+
<span class="font-bold text-primary">$${totalValue.toFixed(2)}</div>
|
| 244 |
+
`;
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
feather.replace();
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
// Event listeners setup
|
| 252 |
+
setupEventListeners() {
|
| 253 |
+
// Connect wallet button
|
| 254 |
+
const connectBtn = document.getElementById('connect-wallet');
|
| 255 |
+
if (connectBtn) {
|
| 256 |
+
connectBtn.addEventListener('click', () => this.connectWallet());
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
// Load more cryptocurrencies
|
| 260 |
+
const loadMoreBtn = document.getElementById('load-more');
|
| 261 |
+
if (loadMoreBtn) {
|
| 262 |
+
loadMoreBtn.addEventListener('click', () => {
|
| 263 |
+
this.currentPage++;
|
| 264 |
+
this.loadCryptoData();
|
| 265 |
+
});
|
| 266 |
+
}
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
// Notification system
|
| 270 |
+
showNotification(message, type = 'info') {
|
| 271 |
+
const notification = document.createElement('div');
|
| 272 |
+
notification.className = `crypto-card p-4 mb-4 ${type === 'error' ? 'border-l-4 border-red-500' : 'border-l-4 border-primary'} crypto-notification`;
|
| 273 |
+
|
| 274 |
+
notification.innerHTML = `
|
| 275 |
+
<div class="flex items-center gap-3">
|
| 276 |
+
<i data-feather="${type === 'error' ? 'alert-triangle' : 'check-circle'}`;
|
| 277 |
+
notification.textContent = message;
|
| 278 |
+
|
| 279 |
+
document.body.appendChild(notification);
|
| 280 |
+
|
| 281 |
+
setTimeout(() => {
|
| 282 |
+
notification.remove();
|
| 283 |
+
}, 5000);
|
| 284 |
+
|
| 285 |
+
feather.replace();
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
// Update wallet connection status
|
| 289 |
+
updateWalletStatus() {
|
| 290 |
+
const connectBtn = document.getElementById('connect-wallet');
|
| 291 |
+
|
| 292 |
+
if (this.connectedAccount) {
|
| 293 |
+
const shortAddress = `${this.connectedAccount.slice(0, 6)}...${this.connectedAccount.slice(-4)}`;
|
| 294 |
+
|
| 295 |
+
if (connectBtn) {
|
| 296 |
+
if (this.connectedAccount) {
|
| 297 |
+
connectBtn.innerHTML = `
|
| 298 |
+
<i data-feather="user-check" class="inline mr-2"></i>
|
| 299 |
+
${this.connectedAccount.slice(0, 6)}...${this.connectedAccount.slice(-4)}`;
|
| 300 |
+
} else {
|
| 301 |
+
connectBtn.innerHTML = `
|
| 302 |
+
<i data-feather="wallet" class="inline mr-2"></i>
|
| 303 |
+
${this.connectedAccount.slice(0, 6)}...${this.connectedAccount.slice(-4)}`;
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
// PWA Service Worker Registration
|
| 308 |
+
async registerServiceWorker() {
|
| 309 |
+
if ('serviceWorker' in navigator) {
|
| 310 |
+
try {
|
| 311 |
+
await navigator.serviceWorker.register('/crypto-sw.js');
|
| 312 |
+
console.log('Crypto Service Worker registered successfully');
|
| 313 |
+
} catch (error) {
|
| 314 |
+
console.error('Crypto Service Worker registration failed:', error);
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
}
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// Initialize the crypto tracker when DOM is loaded
|
| 321 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 322 |
+
new CryptosphereTracker();
|
| 323 |
+
});
|
| 324 |
+
|
| 325 |
+
// Export for use in other modules
|
| 326 |
+
window.CryptosphereTracker = CryptosphereTracker;
|
crypto-style.css
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* CryptoSphere - Cryptocurrency Tracker Styles */
|
| 2 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
|
| 3 |
+
|
| 4 |
+
* {
|
| 5 |
+
margin: 0;
|
| 6 |
+
padding: 0;
|
| 7 |
+
box-sizing: border-box;
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
body {
|
| 11 |
+
font-family: 'Inter', sans-serif;
|
| 12 |
+
background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
|
| 13 |
+
min-height: 100vh;
|
| 14 |
+
color: white;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/* Neomorphic Crypto Design Elements */
|
| 18 |
+
.crypto-card {
|
| 19 |
+
background: linear-gradient(145deg, #1f2937, #111827);
|
| 20 |
+
border-radius: 25px;
|
| 21 |
+
box-shadow: 12px 12px 24px #0d1117, -12px -12px 24px #1f2937;
|
| 22 |
+
transition: all 0.3s ease;
|
| 23 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.crypto-card:hover {
|
| 27 |
+
transform: translateY(-8px);
|
| 28 |
+
box-shadow: 15px 15px 30px #0a0e14, -15px -15px 30px #243142;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.crypto-button {
|
| 32 |
+
background: linear-gradient(145deg, #1f2937, #111827);
|
| 33 |
+
border-radius: 15px;
|
| 34 |
+
box-shadow: 8px 8px 16px #0d1117, -8px -8px 16px #1f2937;
|
| 35 |
+
transition: all 0.3s ease;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
.crypto-button:hover {
|
| 39 |
+
box-shadow: 5px 5px 10px #0a0e14, -5px -5px 10px #243142;
|
| 40 |
+
transform: translateY(2px);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.crypto-input {
|
| 44 |
+
background: linear-gradient(145deg, #1f2937, #111827);
|
| 45 |
+
border: none;
|
| 46 |
+
border-radius: 15px;
|
| 47 |
+
box-shadow: inset 6px 6px 12px #0d1117, inset -6px -6px 12px #243142;
|
| 48 |
+
padding: 12px 20px;
|
| 49 |
+
font-size: 16px;
|
| 50 |
+
color: white;
|
| 51 |
+
transition: all 0.3s ease;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
.crypto-input:focus {
|
| 55 |
+
outline: none;
|
| 56 |
+
box-shadow: inset 4px 4px 8px #0a0e14, inset -4px -4px 8px #243142;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/* Custom scrollbar for dark theme */
|
| 60 |
+
::-webkit-scrollbar {
|
| 61 |
+
width: 8px;
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
::-webkit-scrollbar-track {
|
| 65 |
+
background: #1f2937;
|
| 66 |
+
border-radius: 10px;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
::-webkit-scrollbar-thumb {
|
| 70 |
+
background: linear-gradient(135deg, #10b981, #059669);
|
| 71 |
+
border-radius: 10px;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
::-webkit-scrollbar-thumb:hover {
|
| 75 |
+
background: linear-gradient(135deg, #059669, #047857);
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
/* Price change indicators */
|
| 79 |
+
.price-up {
|
| 80 |
+
color: #10b981;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
.price-down {
|
| 84 |
+
color: #ef4444;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/* Loading animation */
|
| 88 |
+
@keyframes crypto-pulse {
|
| 89 |
+
0%, 100% {
|
| 90 |
+
opacity: 1;
|
| 91 |
+
}
|
| 92 |
+
50% {
|
| 93 |
+
opacity: 0.5;
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.crypto-loading {
|
| 98 |
+
animation: crypto-pulse 2s infinite;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/* Portfolio value indicators */
|
| 102 |
+
.portfolio-up {
|
| 103 |
+
background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05);
|
| 104 |
+
border-left: 4px solid #10b981;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
.portfolio-down {
|
| 108 |
+
background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/* Mobile optimizations */
|
| 112 |
+
@media (max-width: 768px) {
|
| 113 |
+
.crypto-card {
|
| 114 |
+
border-radius: 20px;
|
| 115 |
+
box-shadow: 8px 8px 16px #0d1117, -8px -8px 16px #1f2937;
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/* Notification system */
|
| 120 |
+
.crypto-notification {
|
| 121 |
+
position: fixed;
|
| 122 |
+
top: 20px;
|
| 123 |
+
right: 20px;
|
| 124 |
+
z-index: 1000;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
/* Trading view widget container */
|
| 128 |
+
.tradingview-widget-container {
|
| 129 |
+
border-radius: 15px;
|
| 130 |
+
overflow: hidden;
|
| 131 |
+
}
|
crypto-sw.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Service Worker for CryptoSphere PWA
|
| 2 |
+
const CACHE_NAME = 'cryptosphere-tracker-v1.0.0';
|
| 3 |
+
const urlsToCache = [
|
| 4 |
+
'/crypto-tracker.html',
|
| 5 |
+
'/crypto-style.css',
|
| 6 |
+
'/crypto-script.js',
|
| 7 |
+
'/components/crypto-navbar.js',
|
| 8 |
+
'/components/crypto-footer.js',
|
| 9 |
+
'/components/crypto-card.js',
|
| 10 |
+
'/crypto-manifest.json'
|
| 11 |
+
];
|
| 12 |
+
|
| 13 |
+
// Install event
|
| 14 |
+
self.addEventListener('install', (event) => {
|
| 15 |
+
event.waitUntil(
|
| 16 |
+
caches.open(CACHE_NAME)
|
| 17 |
+
.then((cache) => {
|
| 18 |
+
return cache.addAll(urlsToCache);
|
| 19 |
+
})
|
| 20 |
+
);
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
// Activate event
|
| 24 |
+
self.addEventListener('activate', (event) => {
|
| 25 |
+
event.waitUntil(
|
| 26 |
+
caches.keys().then((cacheNames) => {
|
| 27 |
+
return Promise.all(
|
| 28 |
+
cacheNames.map((cacheName) => {
|
| 29 |
+
if (cacheName !== CACHE_NAME) {
|
| 30 |
+
return caches.delete(cacheName);
|
| 31 |
+
}
|
| 32 |
+
})
|
| 33 |
+
);
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
// Fetch event with network-first strategy for crypto data
|
| 37 |
+
self.addEventListener('fetch', (event) => {
|
| 38 |
+
if (event.request.url.includes('api.coingecko.com')) {
|
| 39 |
+
// Network-first for real-time crypto data
|
| 40 |
+
event.respondWith(
|
| 41 |
+
fetch(event.request)
|
| 42 |
+
.then((response) => {
|
| 43 |
+
// Cache the response
|
| 44 |
+
const responseClone = response.clone();
|
| 45 |
+
caches.open(CACHE_NAME)
|
| 46 |
+
.then((cache) => {
|
| 47 |
+
cache.put(event.request, responseClone);
|
| 48 |
+
})
|
| 49 |
+
.catch(() => {
|
| 50 |
+
return caches.match(event.request);
|
| 51 |
+
})
|
| 52 |
+
);
|
| 53 |
+
} else {
|
| 54 |
+
// Cache-first for static assets
|
| 55 |
+
event.respondWith(
|
| 56 |
+
caches.match(event.request)
|
| 57 |
+
.then((response) => {
|
| 58 |
+
return response || fetch(event.request);
|
| 59 |
+
})
|
| 60 |
+
);
|
| 61 |
+
}
|
| 62 |
+
});
|
| 63 |
+
|
| 64 |
+
// Background sync for portfolio updates
|
| 65 |
+
self.addEventListener('sync', (event) => {
|
| 66 |
+
if (event.tag === 'portfolio-sync') {
|
| 67 |
+
event.waitUntil(syncPortfolioData());
|
| 68 |
+
}
|
| 69 |
+
});
|
| 70 |
+
});
|
| 71 |
+
|
| 72 |
+
async function syncPortfolioData() {
|
| 73 |
+
// Sync portfolio data when connection is restored
|
| 74 |
+
const db = await openCryptoDB();
|
| 75 |
+
const pendingUpdates = await db.getAll('pendingUpdates');
|
| 76 |
+
|
| 77 |
+
for (const update of pendingUpdates) {
|
| 78 |
+
try {
|
| 79 |
+
await fetch('/api/portfolio/update', {
|
| 80 |
+
method: 'POST',
|
| 81 |
+
body: JSON.stringify(update.data)
|
| 82 |
+
});
|
| 83 |
+
await db.delete('pendingUpdates', update.id);
|
| 84 |
+
} catch (error) {
|
| 85 |
+
console.error('Background portfolio sync failed:', error);
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
// IndexedDB for offline crypto data storage
|
| 91 |
+
function openCryptoDB() {
|
| 92 |
+
return new Promise((resolve, reject) => {
|
| 93 |
+
const request = indexedDB.open('CryptoSphereData', 2);
|
| 94 |
+
|
| 95 |
+
request.onerror = () => reject(request.error);
|
| 96 |
+
request.onsuccess = () => resolve(request.result);
|
| 97 |
+
|
| 98 |
+
request.onupgradeneeded = (event) => {
|
| 99 |
+
const db = event.target.result;
|
| 100 |
+
|
| 101 |
+
// Create object store for crypto data
|
| 102 |
+
if (!db.objectStoreNames.contains('cryptoData')) {
|
| 103 |
+
const store = db.createObjectStore('cryptoData', { keyPath: 'id' });
|
| 104 |
+
store.createIndex('symbol', 'symbol', { unique: false });
|
| 105 |
+
store.createIndex('market_cap', 'market_cap', { unique: false });
|
| 106 |
+
|
| 107 |
+
// Create object store for portfolio
|
| 108 |
+
if (!db.objectStoreNames.contains('portfolio')) {
|
| 109 |
+
const portfolioStore = db.createObjectStore('portfolio', { keyPath: 'id' });
|
| 110 |
+
};
|
| 111 |
+
});
|
| 112 |
+
}
|
crypto-tracker.html
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>CryptoSphere - Real-time Cryptocurrency Tracker</title>
|
| 7 |
+
<meta name="description" content="Track cryptocurrency prices, market trends, and blockchain data in real-time">
|
| 8 |
+
<link rel="manifest" href="manifest.json">
|
| 9 |
+
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
|
| 10 |
+
<link rel="stylesheet" href="crypto-style.css">
|
| 11 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 12 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 13 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 14 |
+
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
|
| 15 |
+
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.net.min.js"></script>
|
| 16 |
+
<script>
|
| 17 |
+
tailwind.config = {
|
| 18 |
+
theme: {
|
| 19 |
+
extend: {
|
| 20 |
+
colors: {
|
| 21 |
+
primary: '#10b981',
|
| 22 |
+
secondary: '#3b82f6',
|
| 23 |
+
accent: '#8b5cf6'
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
</script>
|
| 29 |
+
</head>
|
| 30 |
+
<body class="bg-gradient-to-br from-gray-900 to-gray-800 min-h-screen flex flex-col">
|
| 31 |
+
<crypto-navbar></crypto-navbar>
|
| 32 |
+
|
| 33 |
+
<main class="flex-grow">
|
| 34 |
+
<!-- Hero Section with Vanta.js Background -->
|
| 35 |
+
<section id="hero" class="relative h-screen flex items-center justify-center overflow-hidden">
|
| 36 |
+
<div class="absolute inset-0 z-0" id="vanta-bg"></div>
|
| 37 |
+
<div class="relative z-10 text-center text-white px-4">
|
| 38 |
+
<h1 class="text-5xl md:text-7xl font-bold mb-6 drop-shadow-2xl">
|
| 39 |
+
CryptoSphere
|
| 40 |
+
</h1>
|
| 41 |
+
<p class="text-xl md:text-2xl mb-8 max-w-2xl mx-auto">
|
| 42 |
+
Real-time cryptocurrency tracking with Web3 integration and advanced analytics
|
| 43 |
+
</p>
|
| 44 |
+
<div class="flex flex-col sm:flex-row gap-4 justify-center">
|
| 45 |
+
<button id="connect-wallet" class="bg-primary hover:bg-emerald-600 text-white px-8 py-4 rounded-2xl font-semibold transition-all duration-300 transform hover:scale-105 shadow-2xl">
|
| 46 |
+
<i data-feather="wallet" class="inline mr-2"></i>
|
| 47 |
+
Connect Wallet
|
| 48 |
+
</button>
|
| 49 |
+
<a href="#market-overview" class="bg-secondary hover:bg-blue-600 text-white px-8 py-4 rounded-2xl font-semibold transition-all duration-300 transform hover:scale-105 shadow-2xl">
|
| 50 |
+
Explore Markets
|
| 51 |
+
</a>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</section>
|
| 55 |
+
|
| 56 |
+
<!-- Market Overview Section -->
|
| 57 |
+
<section id="market-overview" class="py-20 px-4">
|
| 58 |
+
<div class="max-w-7xl mx-auto">
|
| 59 |
+
<h2 class="text-4xl font-bold text-center mb-4 text-white">Live Market Overview</h2>
|
| 60 |
+
<p class="text-xl text-center mb-12 text-gray-300">Real-time cryptocurrency data and analytics</p>
|
| 61 |
+
|
| 62 |
+
<!-- Market Stats -->
|
| 63 |
+
<div class="grid grid-cols-1 md:grid-cols-4 gap-6 mb-12">
|
| 64 |
+
<div class="crypto-card p-6 text-center">
|
| 65 |
+
<div class="text-3xl font-bold text-primary mb-2" id="global-market-cap">$2.1T</div>
|
| 66 |
+
<div class="text-sm text-gray-300">Total Market Cap</div>
|
| 67 |
+
</div>
|
| 68 |
+
<div class="crypto-card p-6 text-center">
|
| 69 |
+
<div class="text-3xl font-bold text-secondary mb-2" id="total-volume">$78.4B</div>
|
| 70 |
+
<div class="text-sm text-gray-300">24h Volume</div>
|
| 71 |
+
</div>
|
| 72 |
+
<div class="crypto-card p-6 text-center">
|
| 73 |
+
<div class="text-3xl font-bold text-accent mb-2" id="btc-dominance">52.3%</div>
|
| 74 |
+
<div class="text-sm text-gray-300">BTC Dominance</div>
|
| 75 |
+
</div>
|
| 76 |
+
<div class="crypto-card p-6 text-center">
|
| 77 |
+
<div class="text-3xl font-bold text-white mb-2" id="active-currencies">12,456</div>
|
| 78 |
+
<div class="text-sm text-gray-300">Active Currencies</div>
|
| 79 |
+
</div>
|
| 80 |
+
</div>
|
| 81 |
+
|
| 82 |
+
<!-- Top Cryptocurrencies -->
|
| 83 |
+
<div class="crypto-card p-8">
|
| 84 |
+
<h3 class="text-2xl font-bold text-white mb-6">Top Cryptocurrencies</h3>
|
| 85 |
+
<div id="crypto-grid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
| 86 |
+
<!-- Cryptocurrency cards will be dynamically loaded here -->
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
</section>
|
| 91 |
+
|
| 92 |
+
<!-- Portfolio Section -->
|
| 93 |
+
<section id="portfolio" class="py-20 px-4 bg-gray-800">
|
| 94 |
+
<div class="max-w-7xl mx-auto">
|
| 95 |
+
<h2 class="text-4xl font-bold text-center mb-4 text-white">Your Portfolio</h2>
|
| 96 |
+
<div id="portfolio-container" class="crypto-card p-8">
|
| 97 |
+
<div class="text-center text-gray-400" id="portfolio-empty">
|
| 98 |
+
<i data-feather="pie-chart" class="w-16 h-16 mx-auto mb-4"></i>
|
| 99 |
+
<p>Connect your wallet to view your portfolio</p>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
</section>
|
| 103 |
+
|
| 104 |
+
<!-- Analytics Section -->
|
| 105 |
+
<section id="analytics" class="py-20 px-4">
|
| 106 |
+
<div class="max-w-7xl mx-auto">
|
| 107 |
+
<h2 class="text-4xl font-bold text-center mb-4 text-white">Advanced Analytics</h2>
|
| 108 |
+
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
| 109 |
+
<div class="crypto-card p-8">
|
| 110 |
+
<h3 class="text-2xl font-bold text-white mb-6">Market Trends</h3>
|
| 111 |
+
<div id="price-chart" class="h-80 bg-gray-700 rounded-xl flex items-center justify-center text-gray-400">
|
| 112 |
+
Loading price charts...
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
<div class="crypto-card p-8">
|
| 117 |
+
<h3 class="text-2xl font-bold text-white mb-6">Trading Volume</h3>
|
| 118 |
+
<div id="volume-chart" class="h-80 bg-gray-700 rounded-xl flex items-center justify-center text-gray-400">
|
| 119 |
+
Loading volume data...
|
| 120 |
+
</div>
|
| 121 |
+
</div>
|
| 122 |
+
</div>
|
| 123 |
+
</div>
|
| 124 |
+
</section>
|
| 125 |
+
</main>
|
| 126 |
+
|
| 127 |
+
<crypto-footer></crypto-footer>
|
| 128 |
+
|
| 129 |
+
<!-- Component Scripts -->
|
| 130 |
+
<script src="components/crypto-navbar.js"></script>
|
| 131 |
+
<script src="components/crypto-footer.js"></script>
|
| 132 |
+
<script src="components/crypto-card.js"></script>
|
| 133 |
+
|
| 134 |
+
<!-- Main Script -->
|
| 135 |
+
<script src="crypto-script.js"></script>
|
| 136 |
+
|
| 137 |
+
<script>
|
| 138 |
+
feather.replace();
|
| 139 |
+
|
| 140 |
+
// Initialize Vanta.js background
|
| 141 |
+
VANTA.NET({
|
| 142 |
+
el: "#vanta-bg",
|
| 143 |
+
mouseControls: true,
|
| 144 |
+
touchControls: true,
|
| 145 |
+
gyroControls: false,
|
| 146 |
+
minHeight: 200.00,
|
| 147 |
+
minWidth: 200.00,
|
| 148 |
+
scale: 1.00,
|
| 149 |
+
scaleMobile: 1.00,
|
| 150 |
+
color: 0x10b981,
|
| 151 |
+
backgroundColor: 0x111827,
|
| 152 |
+
points: 12.00,
|
| 153 |
+
maxDistance: 25.00,
|
| 154 |
+
spacing: 18.00
|
| 155 |
+
});
|
| 156 |
+
</script>
|
| 157 |
+
</body>
|
| 158 |
+
</html>
|
index.html
CHANGED
|
@@ -46,7 +46,10 @@
|
|
| 46 |
<a href="/upload.html" class="bg-secondary hover:bg-sky-600 text-white px-8 py-4 rounded-2xl font-semibold transition-all duration-300 transform hover:scale-105 shadow-2xl">
|
| 47 |
Upload Art
|
| 48 |
</a>
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
| 50 |
</div>
|
| 51 |
</section>
|
| 52 |
|
|
|
|
| 46 |
<a href="/upload.html" class="bg-secondary hover:bg-sky-600 text-white px-8 py-4 rounded-2xl font-semibold transition-all duration-300 transform hover:scale-105 shadow-2xl">
|
| 47 |
Upload Art
|
| 48 |
</a>
|
| 49 |
+
<a href="/crypto-tracker.html" class="bg-accent hover:bg-purple-600 text-white px-8 py-4 rounded-2xl font-semibold transition-all duration-300 transform hover:scale-105 shadow-2xl">
|
| 50 |
+
Crypto Tracker
|
| 51 |
+
</a>
|
| 52 |
+
</div>
|
| 53 |
</div>
|
| 54 |
</section>
|
| 55 |
|
script.js
CHANGED
|
@@ -215,11 +215,9 @@ class NeuroMorphGallery {
|
|
| 215 |
images.forEach(img => imageObserver.observe(img));
|
| 216 |
}
|
| 217 |
}
|
| 218 |
-
|
| 219 |
// Initialize the gallery when DOM is loaded
|
| 220 |
document.addEventListener('DOMContentLoaded', () => {
|
| 221 |
new NeuroMorphGallery();
|
| 222 |
});
|
| 223 |
-
|
| 224 |
// Export for use in other modules
|
| 225 |
window.NeuroMorphGallery = NeuroMorphGallery;
|
|
|
|
| 215 |
images.forEach(img => imageObserver.observe(img));
|
| 216 |
}
|
| 217 |
}
|
|
|
|
| 218 |
// Initialize the gallery when DOM is loaded
|
| 219 |
document.addEventListener('DOMContentLoaded', () => {
|
| 220 |
new NeuroMorphGallery();
|
| 221 |
});
|
|
|
|
| 222 |
// Export for use in other modules
|
| 223 |
window.NeuroMorphGallery = NeuroMorphGallery;
|