$pages = [

(function(){ function boot() { const term = document.getElementById('bootcoin-terminal'); if (!term) return; const speed = 50; let keyListenerAttached = false; let bgEventsTimer = null; const cursor = document.createElement('span'); cursor.className = 'cursor'; term.appendChild(cursor); const scrollToBottom = () => { term.scrollTop = term.scrollHeight; }; const makeLine = (cls='line') => { const el=document.createElement('span'); el.className=cls; term.insertBefore(el, cursor); return el; }; function typeText(text, onDone){ const row = makeLine('line'); let i=0; (function tick(){ if(i=lines.length) return onDone&&onDone(); typeText(lines[idx++], ()=>setTimeout(next,300)); })(); } function blockchainProgress(onDone){ const row = makeLine('line'); let p=0; (function step(){ if(p<=100){ const blocks=Math.floor(p/2); row.textContent=`[${'#'.repeat(blocks)}${'.'.repeat(50-blocks)}] ${p}% Connecting to blockchain...`; p+=Math.floor(Math.random()*5)+1; scrollToBottom(); setTimeout(step,100); } else { row.textContent=`[${'#'.repeat(50)}] 100% Connection established!`; setTimeout(onDone,500); } })(); } function deployContract(onDone){ const logs=[ "Compiling smart contract...", "Contract compiled successfully.", "Estimating gas...", "Sending deployment transaction...", "Transaction hash: 0x"+Math.random().toString(16).slice(2,18), "Waiting for confirmation...", "Deployment confirmed!", "Smart contract address: 0x1234abcd5678ef90" ]; let i=0; (function next(){ if(i>=logs.length) return onDone&&onDone(); typeText(logs[i++], ()=>setTimeout(next,300)); })(); } function startBlockchainEvents(){ stopBlockchainEvents(); bgEventsTimer = setInterval(()=>{ const variants=[ ()=>`New block mined: #${Math.floor(Math.random()*100000)}`, ()=>`Transaction received: 0x${Math.random().toString(16).slice(2,14)}`, ()=>`Node synced: node-${Math.floor(Math.random()*64)+1}`, ()=>`Gas price updated: ${Math.floor(Math.random()*100)+50} Gwei` ]; const msg = variants[Math.floor(Math.random()*variants.length)](); const row = makeLine('line muted'); row.textContent = msg; scrollToBottom(); }, 3000 + Math.random()*3000); } function stopBlockchainEvents(){ if(bgEventsTimer){ clearInterval(bgEventsTimer); bgEventsTimer=null; } } function attachInput(){ if(keyListenerAttached) return; keyListenerAttached=true; const inputLine = makeLine('input-line'); let buffer=''; term.addEventListener('keydown', (e)=>{ if(e.key.length===1 && !e.ctrlKey && !e.metaKey && !e.altKey){ buffer+=e.key; inputLine.textContent=buffer; e.preventDefault(); } else if(e.key==='Backspace'){ buffer=buffer.slice(0,-1); inputLine.textContent=buffer; e.preventDefault(); } else if(e.key==='Enter'){ const echo = makeLine('line'); echo.textContent='> '+buffer; const cmd = buffer.trim().toLowerCase(); buffer=''; inputLine.textContent=''; handleCommand(cmd); e.preventDefault(); } scrollToBottom(); }); } function handleCommand(cmd){ let out=''; switch(cmd){ case 'help': out="Available commands: help, status, wallet"; break; case 'status': out="Bootcoin blockchain: OK\nNodes: 12\nTransactions today: 2345"; break; case 'wallet': out="Wallet balance: 1234 BOOT"; break; case '': out=""; break; default: out="Command not found. Type 'help' for list of commands."; } const parts = out.split('\n'); let i=0; (function next(){ if(i>=parts. length) return; typeText(parts[i++], next); })(); } term.addEventListener('pointerdown', ()=>term.focus(), {passive:true}); window.addEventListener('beforeunload', stopBlockchainEvents); // Boot sequence typeLines(["Bootcoin AI v1.0","Initializing..."], ()=>{ blockchainProgress(()=>{ deployContract(()=>{ typeLines(["Loading wallet...","Welcome to Bootcoin!","Type 'help' to see commands."], ()=>{ attachInput(); startBlockchainEvents(); }); }); }); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', boot); } else { boot(); } })();