UNPKG

krying

Version:

krying — games hub, AI, movies, and tools

81 lines (80 loc) • 4.23 kB
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Kobran - HTML Viewer</title> <link rel="shortcut icon" type="image/png" href="/Kobran.png"> <link rel="stylesheet" href="/assets/kobran-page.css"> <style> body.kobran-page{min-height:100vh;padding:20px 0 40px} .hv-shell{width:min(1200px,calc(100vw - 32px));margin:0 auto;display:grid;grid-template-columns:1fr 1fr;gap:18px} @media(max-width:960px){.hv-shell{grid-template-columns:1fr}} .hv-panel{padding:20px;border-radius:16px;background:rgba(12,10,24,0.82);border:1px solid rgba(183,148,255,0.16);box-shadow:0 24px 80px rgba(0,0,0,0.35);backdrop-filter:blur(16px);min-height:520px;display:flex;flex-direction:column} .hv-head{display:flex;flex-wrap:wrap;align-items:center;gap:12px;margin-bottom:14px} .hv-head h1{margin:0;font-family:"Space Grotesk",Inter,sans-serif;font-size:1.35rem;flex:1} .hv-actions{display:flex;gap:8px;flex-wrap:wrap} .hv-btn{padding:10px 16px;border:0;border-radius:999px;font-weight:700;font-size:0.76rem;letter-spacing:0.06em;text-transform:uppercase;cursor:pointer;color:#fff;background:linear-gradient(135deg,#7c3aed,#b794ff)} .hv-btn--ghost{background:rgba(255,255,255,0.06);border:1px solid rgba(183,148,255,0.2)} #code{flex:1;width:100%;min-height:420px;padding:14px;border-radius:12px;border:1px solid rgba(183,148,255,0.16);background:rgba(0,0,0,0.35);color:#e8e4ff;font:500 13px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;resize:vertical;outline:none} #code:focus{border-color:rgba(183,148,255,0.4);box-shadow:0 0 0 3px rgba(124,92,255,0.12)} .hv-preview-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;color:rgba(255,255,255,0.55);font-size:0.82rem;text-transform:uppercase;letter-spacing:0.08em} #preview{flex:1;width:100%;min-height:420px;border:0;border-radius:12px;background:#fff} .hv-back{display:inline-flex;margin:0 auto 16px;width:min(1200px,calc(100vw - 32px))} </style> </head> <body class="kobran-page"> <div class="kobran-page__glow" aria-hidden="true"></div> <a class="kobran-page__link hv-back" href="/apps/">← Back to Apps</a> <div class="hv-shell"> <section class="hv-panel"> <div class="hv-head"> <h1>HTML Viewer</h1> <div class="hv-actions"> <button type="button" class="hv-btn" id="runBtn">Run</button> <button type="button" class="hv-btn hv-btn--ghost" id="openBtn">New tab</button> </div> </div> <textarea id="code" spellcheck="false"></textarea> </section> <section class="hv-panel"> <div class="hv-preview-head"><span>Live preview</span><span>srcdoc</span></div> <iframe id="preview" sandbox="allow-forms allow-scripts allow-popups allow-same-origin" title="Preview"></iframe> </section> </div> <script> const codeEl = document.getElementById("code"); const preview = document.getElementById("preview"); const sample = `<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Sample Page</title> <style> body{margin:0;font-family:Inter,sans-serif;background:#050508;color:#fff;display:flex;justify-content:center;align-items:center;height:100vh} h1{background:linear-gradient(90deg,#7c3aed,#38bdf8);-webkit-background-clip:text;color:transparent;font-size:2.5rem} </style> </head> <body> <h1>Replace with your code</h1> </body> </html>`; codeEl.value = sample; function updatePreview(){ preview.srcdoc = codeEl.value; } function openInNewTab(){ let html = codeEl.value.trim(); if (!/^<!doctype/i.test(html)) html = "<!doctype html>\n" + html; const url = URL.createObjectURL(new Blob([html], { type: "text/html" })); window.open(url, "_blank"); setTimeout(function(){ URL.revokeObjectURL(url); }, 60000); } document.getElementById("runBtn").onclick = updatePreview; document.getElementById("openBtn").onclick = openInNewTab; codeEl.addEventListener("keydown", function(e){ if ((e.ctrlKey || e.metaKey) && e.key === "Enter") { e.preventDefault(); updatePreview(); } }); updatePreview(); </script> </body> </html>