Spaces:
Running
Running
Download index.html from Scape/ica-code-wizard: direct link, hf CLI and curl.
- Browser
- Download file 6.22 kB
-
https://huggingface.co/spaces/Scape/ica-code-wizard/resolve/main/index.html
- Command line
-
hf download hf://spaces/Scape/ica-code-wizard/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Scape/ica-code-wizard/resolve/main/index.html
6.22 kB
| <html lang="ru"> | |
| <head> | |
| <meta charset="utf-8" /> | |
| <meta name="viewport" content="width=device-width,initial-scale=1" /> | |
| <title>ICA Code Wizard 🔮</title> | |
| <style> | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial; | |
| padding: 24px; | |
| max-width: 640px; | |
| margin: 36px auto; | |
| color: #111; | |
| background: #f7f7f8; | |
| } | |
| .card { | |
| background: #fff; | |
| padding: 18px; | |
| border-radius: 12px; | |
| box-shadow: 0 6px 18px rgba(0,0,0,0.06); | |
| } | |
| label { display:block; margin-bottom:8px; font-weight:600 } | |
| input[type="text"] { | |
| width:100%; | |
| padding:10px 12px; | |
| font-size:16px; | |
| border:1px solid #ddd; | |
| border-radius:8px; | |
| box-sizing:border-box; | |
| } | |
| .row { display:flex; gap:8px; margin-top:12px; } | |
| button { | |
| padding:10px 14px; | |
| font-size:15px; | |
| border-radius:8px; | |
| border: none; | |
| cursor: pointer; | |
| background:#2563eb; | |
| color:white; | |
| } | |
| button.secondary { background:#6b7280; } | |
| pre { | |
| background:#111827; | |
| color:#f9fafb; | |
| padding:12px; | |
| border-radius:8px; | |
| overflow-x:auto; | |
| margin-top:12px; | |
| font-size:16px; | |
| } | |
| .hint { color:#6b7280; margin-top:8px; font-size:13px } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="card"> | |
| <h1>ICA Code Wizard 🔮</h1> | |
| <p class="hint">Введи магическую переменную (например <code>0170</code>) и нажми «Сгенерировать».</p> | |
| <label for="inputVar">Магическая переменная 🔢✨</label> | |
| <input id="inputVar" type="text" value="0170" /> | |
| <div class="row"> | |
| <button id="btnGen">✨ Сгенерировать</button> | |
| <button id="btnCopy" class="secondary" title="Копировать результат">📋 Копировать</button> | |
| <button id="btnAuto" class="secondary" title="Генерировать автоматически при загрузке">⚡ Авто</button> | |
| </div> | |
| <label style="margin-top:14px">Результат</label> | |
| <pre id="result">✨ Жду твою магию...</pre> | |
| <p class="hint">Магический алгоритм: <code>SHA-256("C673_ICA" + ввод + MM + DD)</code>, затем берем подстроку хэша с позиции <code>день+1</code> по <code>день+13</code> ✨</p> | |
| </div> | |
| <script> | |
| async function sha256Hex(message) { | |
| const data = new TextEncoder().encode(message); | |
| const hashBuffer = await crypto.subtle.digest("SHA-256", data); | |
| const bytes = new Uint8Array(hashBuffer); | |
| return Array.from(bytes, b => ("0" + b.toString(16)).slice(-2)).join(""); | |
| } | |
| function getMMDD(date = new Date()) { | |
| const mm = String(date.getMonth() + 1).padStart(2, "0"); | |
| const dd = String(date.getDate()).padStart(2, "0"); | |
| return { mm, dd, date }; | |
| } | |
| async function generateCode(inputValue) { | |
| // prepare input | |
| const trimmed = String(inputValue ?? "").trim(); | |
| if (trimmed.length === 0) { | |
| throw new Error("Пустая строка. Введите переменную."); | |
| } | |
| const { mm, dd, date } = getMMDD(); | |
| const base = "C673_ICA" + trimmed + mm + dd; | |
| const hex = await sha256Hex(base); | |
| // расчет индексов как в оригинале: substring(day+1, day+13) | |
| // substring uses indices where end is exclusive. | |
| const day = date.getDate(); | |
| const start = day + 1; | |
| const end = day + 13; | |
| // защитимся от выхода за длину | |
| const safeStart = Math.max(0, Math.min(start, hex.length)); | |
| const safeEnd = Math.max(safeStart, Math.min(end, hex.length)); | |
| const res = hex.substring(safeStart, safeEnd); | |
| return { base, hex, res, mm, dd, start: safeStart, end: safeEnd }; | |
| } | |
| const inputEl = document.getElementById("inputVar"); | |
| const resEl = document.getElementById("result"); | |
| const btnGen = document.getElementById("btnGen"); | |
| const btnCopy = document.getElementById("btnCopy"); | |
| const btnAuto = document.getElementById("btnAuto"); | |
| let autoOn = false; | |
| async function doGenerate(showErrors = true) { | |
| try { | |
| btnGen.disabled = true; | |
| resEl.textContent = "Генерация…"; | |
| const info = await generateCode(inputEl.value); | |
| resEl.textContent = info.res || "Пустой результат (проверь ввод/дату)"; | |
| btnGen.disabled = false; | |
| return info; | |
| } catch (e) { | |
| btnGen.disabled = false; | |
| resEl.textContent = "Ошибка: " + (e.message || e); | |
| if (showErrors) console.error(e); | |
| } | |
| } | |
| btnGen.addEventListener("click", () => doGenerate()); | |
| btnCopy.addEventListener("click", async () => { | |
| const text = resEl.textContent || ""; | |
| if (!text || text.startsWith("Ошибка") || text === "Генерация…") { | |
| return; | |
| } | |
| try { | |
| await navigator.clipboard.writeText(text); | |
| btnCopy.textContent = "Скопировано!"; | |
| setTimeout(() => btnCopy.textContent = "Копировать", 1400); | |
| } catch { | |
| btnCopy.textContent = "Не удалось"; | |
| setTimeout(() => btnCopy.textContent = "Копировать", 1400); | |
| } | |
| }); | |
| btnAuto.addEventListener("click", () => { | |
| autoOn = !autoOn; | |
| btnAuto.textContent = autoOn ? "Авто: вкл" : "Авто"; | |
| if (autoOn) doGenerate(false); | |
| }); | |
| // allow pressing Enter in input to generate | |
| inputEl.addEventListener("keydown", (e) => { | |
| if (e.key === "Enter") { | |
| e.preventDefault(); | |
| doGenerate(); | |
| } | |
| }); | |
| // generate on load once | |
| window.addEventListener("load", () => { | |
| // короткая задержка для красоты | |
| setTimeout(() => doGenerate(false), 120); | |
| }); | |
| </script> | |
| <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script> | |
| </body> | |
| </html> | |