Spaces:
Running
Running
File size: 25,354 Bytes
aef5466 47efe4f b17623d 47efe4f aef5466 b17623d aef5466 b17623d aef5466 b17623d aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f b17623d 47efe4f b17623d 47efe4f b17623d 47efe4f b17623d 47efe4f b17623d 47efe4f b17623d 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 47efe4f aef5466 b17623d aef5466 b17623d aef5466 47efe4f aef5466 47efe4f aef5466 4d0e030 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QuantumCode Nexus</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/qiskit.js@latest/dist/qiskit.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/theme/dracula.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/javascript/javascript.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/country-flag-emoji-json@1.0.2/dist/by-code.json"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');
:root {
--primary: #7c3aed;
--secondary: #10b981;
--accent: #ec4899;
--dark: #0f172a;
--light: #f8fafc;
}
body {
font-family: 'Space Grotesk', sans-serif;
background-color: var(--dark);
color: var(--light);
overflow-x: hidden;
}
.gradient-text {
background: linear-gradient(90deg, var(--primary), var(--accent));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
}
.code-editor {
font-family: 'Fira Code', monospace;
background: rgba(15, 23, 42, 0.8);
border: 1px solid rgba(124, 58, 237, 0.3);
border-radius: 0.5rem;
}
.quantum-particle {
position: absolute;
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--primary);
opacity: 0.6;
animation: float 15s infinite linear;
}
@keyframes float {
0% { transform: translate(0, 0); opacity: 0; }
10% { opacity: 0.6; }
90% { opacity: 0.6; }
100% { transform: translate(var(--tx, 100px), var(--ty, -100px)); opacity: 0; }
}
.output-line {
border-left: 3px solid;
padding-left: 1rem;
margin-bottom: 0.5rem;
}
.output-line.info { border-color: #3b82f6; color: #bfdbfe; }
.output-line.success { border-color: var(--secondary); color: #a7f3d0; }
.output-line.warning { border-color: #f59e0b; color: #fef08a; }
.output-line.error { border-color: #ef4444; color: #fecaca; }
.nav-item {
transition: all 0.2s ease;
border-left: 3px solid transparent;
}
.nav-item:hover, .nav-item.active {
background: rgba(124, 58, 237, 0.1);
border-left-color: var(--primary);
}
.quantum-card {
background: rgba(15, 23, 42, 0.6);
border: 1px solid rgba(124, 58, 237, 0.3);
transition: all 0.3s ease;
}
.quantum-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px -5px rgba(124, 58, 237, 0.3);
}
</style>
</head>
<body class="min-h-screen">
<div id="quantum-bg" class="fixed inset-0 -z-10"></div>
<!-- Particles -->
<div id="particles"></div>
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex justify-between items-center mb-12">
<div class="flex items-center space-x-2">
<div class="w-10 h-10 rounded-full bg-gradient-to-br from-purple-600 to-pink-500 flex items-center justify-center">
<span class="text-white font-bold text-xl">α</span>
</div>
<h1 class="text-2xl font-bold gradient-text">QuantumCode Nexus</h1>
</div>
<nav class="hidden md:flex space-x-6">
<a href="#" class="text-gray-300 hover:text-white transition">Docs</a>
<a href="#" class="text-gray-300 hover:text-white transition">Examples</a>
<a href="#" class="text-gray-300 hover:text-white transition">Community</a>
<a href="#" class="text-gray-300 hover:text-white transition">Blog</a>
</nav>
<button class="md:hidden text-gray-300">
<i data-feather="menu"></i>
</button>
</header>
<!-- Main Content -->
<main class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Sidebar -->
<aside class="lg:col-span-1 bg-gray-900 bg-opacity-50 rounded-xl p-6 backdrop-blur-lg border border-gray-800">
<div class="mb-8">
<h2 class="text-xl font-semibold mb-4 gradient-text">Quantum Playground</h2>
<p class="text-gray-400">Experiment with quantum computing concepts in a global collaborative environment.</p>
</div>
<div class="space-y-1 mb-8">
<h3 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-2">EXPLORE</h3>
<a href="#" class="nav-item active block px-4 py-2 text-white">
<div class="flex items-center space-x-3">
<i data-feather="cpu"></i>
<span>Quantum Simulator</span>
</div>
</a>
<a href="#" class="nav-item block px-4 py-2 text-gray-400 hover:text-white">
<div class="flex items-center space-x-3">
<i data-feather="globe"></i>
<span>Global Network</span>
</div>
</a>
<a href="#" class="nav-item block px-4 py-2 text-gray-400 hover:text-white">
<div class="flex items-center space-x-3">
<i data-feather="database"></i>
<span>Quantum Database</span>
</div>
</a>
<a href="#" class="nav-item block px-4 py-2 text-gray-400 hover:text-white">
<div class="flex items-center space-x-3">
<i data-feather="users"></i>
<span>Collaborate</span>
</div>
</a>
</div>
<div class="space-y-1 mb-8">
<h3 class="text-sm font-semibold text-gray-500 uppercase tracking-wider mb-2">LEARN</h3>
<a href="#" class="nav-item block px-4 py-2 text-gray-400 hover:text-white">
<div class="flex items-center space-x-3">
<i data-feather="book"></i>
<span>Tutorials</span>
</div>
</a>
<a href="#" class="nav-item block px-4 py-2 text-gray-400 hover:text-white">
<div class="flex items-center space-x-3">
<i data-feather="code"></i>
<span>API Reference</span>
</div>
</a>
<a href="#" class="nav-item block px-4 py-2 text-gray-400 hover:text-white">
<div class="flex items-center space-x-3">
<i data-feather="video"></i>
<span>Video Guides</span>
</div>
</a>
</div>
<div class="p-4 bg-gray-800 rounded-lg">
<h3 class="text-sm font-semibold mb-2 text-gray-300">Global Stats</h3>
<div class="space-y-3">
<div class="flex justify-between items-center">
<span class="text-gray-400">Developers Online</span>
<span class="font-medium">12,487</span>
</div>
<div class="flex justify-between items-center">
<span class="text-gray-400">Countries</span>
<span class="font-medium">89</span>
</div>
<div class="flex justify-between items-center">
<span class="text-gray-400">Quantum Circuits</span>
<span class="font-medium">42,156</span>
</div>
</div>
</div>
</aside>
<!-- Editor Section -->
<section class="lg:col-span-2 space-y-8">
<div class="quantum-card rounded-xl p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-xl font-semibold gradient-text">Quantum Editor</h2>
<div class="flex space-x-2">
<button class="px-4 py-2 bg-purple-600 hover:bg-purple-700 rounded-lg text-white flex items-center space-x-2">
<i data-feather="play"></i>
<span>Run</span>
</button>
<button class="px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded-lg text-white flex items-center space-x-2">
<i data-feather="share-2"></i>
<span>Share</span>
</button>
</div>
</div>
<div class="code-editor p-4 mb-6">
<textarea id="quantum-code" class="w-full h-64 bg-transparent outline-none resize-none text-gray-300 font-mono text-sm" spellcheck="false">// Quantum Hello World in JavaScript-like syntax
function quantumHello() {
// Create superposition of states
const states = ['|0⟩', '|1⟩', '|+⟩', '|-⟩'];
const qubit = quantum.superposition(states);
// Apply quantum gates
quantum.hadamard(qubit);
quantum.phase(qubit, Math.PI/4);
// Measure the qubit
const result = quantum.measure(qubit);
// Entangle with other qubits globally
quantum.entangle('global-network', qubit);
console.log(`Measured state: ${result}`);
return result;
}
// Execute the quantum circuit
quantumHello();</textarea>
</div>
<div class="flex items-center space-x-4 text-sm text-gray-400">
<div class="flex items-center space-x-1">
<i data-feather="cpu" class="w-4 h-4"></i>
<span>Quantum Simulator v2.4.1</span>
</div>
<div class="flex items-center space-x-1">
<i data-feather="globe" class="w-4 h-4"></i>
<span>Connected to 89 nodes</span>
</div>
</div>
</div>
<!-- Output Section -->
<div class="quantum-card rounded-xl p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold gradient-text">Quantum Output</h2>
<button class="px-3 py-1 bg-gray-700 hover:bg-gray-600 rounded-lg text-white flex items-center space-x-1 text-sm">
<i data-feather="trash-2" class="w-4 h-4"></i>
<span>Clear</span>
</button>
</div>
<div class="bg-gray-900 rounded-lg p-4 h-48 overflow-y-auto">
<div class="output-line info">QuantumCode Nexus v2.4.1 initialized</div>
<div class="output-line success">Quantum simulator ready</div>
<div class="output-line info">Type Ctrl+Enter or click Run to execute</div>
</div>
</div>
<!-- Global Network -->
<div class="quantum-card rounded-xl p-6">
<h2 class="text-xl font-semibold gradient-text mb-6">Global Quantum Network</h2>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-4">
<!-- These will be populated by JavaScript -->
<div id="country-node-us" class="bg-gray-800 rounded-lg p-4 text-center hover:bg-gray-700 transition">
<div class="text-3xl mb-2">🇺🇸</div>
<div class="font-medium">United States</div>
<div class="text-sm text-gray-400"><span class="node-count">2,145</span> nodes</div>
</div>
<div id="country-node-in" class="bg-gray-800 rounded-lg p-4 text-center hover:bg-gray-700 transition">
<div class="text-3xl mb-2">🇮🇳</div>
<div class="font-medium">India</div>
<div class="text-sm text-gray-400"><span class="node-count">1,876</span> nodes</div>
</div>
<div id="country-node-de" class="bg-gray-800 rounded-lg p-4 text-center hover:bg-gray-700 transition">
<div class="text-3xl mb-2">🇩🇪</div>
<div class="font-medium">Germany</div>
<div class="text-sm text-gray-400"><span class="node-count">943</span> nodes</div>
</div>
<div id="country-node-br" class="bg-gray-800 rounded-lg p-4 text-center hover:bg-gray-700 transition">
<div class="text-3xl mb-2">🇧🇷</div>
<div class="font-medium">Brazil</div>
<div class="text-sm text-gray-400"><span class="node-count">782</span> nodes</div>
</div>
<div id="country-node-jp" class="bg-gray-800 rounded-lg p-4 text-center hover:bg-gray-700 transition">
<div class="text-3xl mb-2">🇯🇵</div>
<div class="font-medium">Japan</div>
<div class="text-sm text-gray-400"><span class="node-count">654</span> nodes</div>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="mt-16 pt-8 border-t border-gray-800">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="flex items-center space-x-2 mb-4 md:mb-0">
<div class="w-8 h-8 rounded-full bg-gradient-to-br from-purple-600 to-pink-500 flex items-center justify-center">
<span class="text-white font-bold text-sm">α</span>
</div>
<span class="font-medium">QuantumCode Nexus</span>
</div>
<div class="flex space-x-6">
<a href="#" class="text-gray-400 hover:text-white transition">
<i data-feather="github"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition">
<i data-feather="twitter"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition">
<i data-feather="discord"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition">
<i data-feather="youtube"></i>
</a>
</div>
</div>
<div class="mt-8 text-center text-gray-500 text-sm">
<p>© 2023 QuantumCode Nexus. All qubits reserved.</p>
</div>
</footer>
</div>
<script>
// Initialize Vanta.js globe
VANTA.GLOBE({
el: "#quantum-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x7c3aed,
backgroundColor: 0x0f172a,
size: 1.00
});
// Create floating particles
function createParticles() {
const container = document.getElementById('particles');
for (let i = 0; i < 30; i++) {
const particle = document.createElement('div');
particle.className = 'quantum-particle';
// Random position
const x = Math.random() * 100;
const y = Math.random() * 100;
particle.style.left = `${x}%`;
particle.style.top = `${y}%`;
// Random animation
const tx = (Math.random() - 0.5) * 200;
const ty = (Math.random() - 0.5) * 200;
particle.style.setProperty('--tx', `${tx}px`);
particle.style.setProperty('--ty', `${ty}px`);
particle.style.animationDuration = `${10 + Math.random() * 20}s`;
particle.style.animationDelay = `${Math.random() * 5}s`;
// Random color
const colors = ['#7c3aed', '#ec4899', '#10b981', '#3b82f6'];
particle.style.background = colors[Math.floor(Math.random() * colors.length)];
container.appendChild(particle);
}
}
// Quantum Circuit Execution API
async function executeQuantumCircuit(code) {
try {
const output = [];
// Mock quantum operations
const mockQuantum = {
superposition: (states) => {
output.push(`Created superposition of ${states.length} states`);
return {
id: Math.random().toString(36).substring(7),
states: states
};
},
hadamard: (qubit) => {
output.push(`Applied Hadamard gate to qubit ${qubit.id}`);
},
phase: (qubit, angle) => {
output.push(`Applied phase shift of ${angle} radians to qubit ${qubit.id}`);
},
measure: (qubit) => {
const result = qubit.states[Math.floor(Math.random() * qubit.states.length)];
output.push(`Measured qubit ${qubit.id} → ${result}`);
return result;
},
entangle: (network, qubit) => {
output.push(`Entangled qubit ${qubit.id} with ${network}`);
}
};
// Create a safe execution context
const context = {
quantum: mockQuantum,
console: {
log: (msg) => output.push(`Console: ${msg}`)
}
};
// Execute the code safely
new Function('quantum', 'console', code)(context.quantum, context.console);
return {
output: output,
executionTime: `${(Math.random() * 100 + 50).toFixed(2)}ms`
};
} catch (error) {
console.error("Execution error:", error);
return {
error: `Runtime Error: ${error.message}`,
line: error.stack.split('\n')[1]
};
}
}
// Add syntax highlighting
function setupEditor() {
const textarea = document.getElementById('quantum-code');
const editor = CodeMirror.fromTextArea(textarea, {
mode: 'javascript',
theme: 'dracula',
lineNumbers: true,
indentUnit: 2,
tabSize: 2,
extraKeys: {
'Ctrl-Enter': simulateExecution
}
});
// Store editor instance
window.quantumEditor = editor;
}
// Get online users count
async function getOnlineUsers() {
const response = await axios.get('https://quantum-network.glitch.me/stats');
return response.data;
}
// Simulate quantum execution
async function simulateExecution() {
const output = document.querySelector('.bg-gray-900');
const code = document.querySelector('textarea').value;
// Clear previous output except initial messages
while (output.children.length > 5) {
output.removeChild(output.lastChild);
}
// Add loading state
const loadingLine = document.createElement('div');
loadingLine.className = 'output-line info';
loadingLine.textContent = 'Executing quantum circuit...';
output.appendChild(loadingLine);
try {
const result = await executeQuantumCircuit(code);
if (result.error) {
const errorLine = document.createElement('div');
errorLine.className = 'output-line error';
errorLine.textContent = result.error;
output.appendChild(errorLine);
} else {
const greetingLine = document.createElement('div');
greetingLine.className = 'output-line success';
greetingLine.textContent = `Quantum Greeting: ${result.greeting}`;
output.appendChild(greetingLine);
const countryLine = document.createElement('div');
countryLine.className = 'output-line success';
countryLine.textContent = `Data entangled with ${result.country} (${result.flag})`;
output.appendChild(countryLine);
}
// Update network stats
const stats = await getOnlineUsers();
document.querySelectorAll('.font-medium')[0].textContent = stats.onlineUsers.toLocaleString();
document.querySelectorAll('.font-medium')[1].textContent = stats.countries;
document.querySelectorAll('.font-medium')[2].textContent = stats.circuits.toLocaleString();
} catch (error) {
const errorLine = document.createElement('div');
errorLine.className = 'output-line error';
errorLine.textContent = `Quantum error: ${error.message}`;
output.appendChild(errorLine);
}
// Scroll to bottom
output.scrollTop = output.scrollHeight;
}
// Initialize
document.addEventListener('DOMContentLoaded', async () => {
feather.replace();
createParticles();
setupEditor();
// Run button click handler
document.querySelector('.bg-purple-600').addEventListener('click', simulateExecution);
// Add keyboard shortcut
document.addEventListener('keydown', (e) => {
if (e.ctrlKey && e.key === 'Enter') {
simulateExecution();
}
});
// Mobile menu toggle
document.querySelector('.md\\:hidden').addEventListener('click', () => {
document.querySelector('aside').classList.toggle('hidden');
});
// Load initial stats
try {
const stats = await getOnlineUsers();
document.querySelectorAll('.font-medium')[0].textContent = stats.onlineUsers.toLocaleString();
document.querySelectorAll('.font-medium')[1].textContent = stats.countries;
document.querySelectorAll('.font-medium')[2].textContent = stats.circuits.toLocaleString();
} catch (error) {
console.error("Failed to load stats:", error);
}
});
</script>
</body>
</html>
|