Scape commited on
Commit
de423ab
·
verified ·
1 Parent(s): c2072b6

привет

Browse files
Files changed (2) hide show
  1. README.md +8 -5
  2. index.html +172 -19
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
- title: Ica Code Wizard
3
- emoji: 💻
4
- colorFrom: gray
5
- colorTo: yellow
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
+ title: ICA Code Wizard 🔮
3
+ colorFrom: red
4
+ colorTo: green
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
index.html CHANGED
@@ -1,19 +1,172 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="ru">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
6
+ <title>ICA Code Wizard 🔮</title>
7
+ <style>
8
+ body {
9
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial;
10
+ padding: 24px;
11
+ max-width: 640px;
12
+ margin: 36px auto;
13
+ color: #111;
14
+ background: #f7f7f8;
15
+ }
16
+ .card {
17
+ background: #fff;
18
+ padding: 18px;
19
+ border-radius: 12px;
20
+ box-shadow: 0 6px 18px rgba(0,0,0,0.06);
21
+ }
22
+ label { display:block; margin-bottom:8px; font-weight:600 }
23
+ input[type="text"] {
24
+ width:100%;
25
+ padding:10px 12px;
26
+ font-size:16px;
27
+ border:1px solid #ddd;
28
+ border-radius:8px;
29
+ box-sizing:border-box;
30
+ }
31
+ .row { display:flex; gap:8px; margin-top:12px; }
32
+ button {
33
+ padding:10px 14px;
34
+ font-size:15px;
35
+ border-radius:8px;
36
+ border: none;
37
+ cursor: pointer;
38
+ background:#2563eb;
39
+ color:white;
40
+ }
41
+ button.secondary { background:#6b7280; }
42
+ pre {
43
+ background:#111827;
44
+ color:#f9fafb;
45
+ padding:12px;
46
+ border-radius:8px;
47
+ overflow-x:auto;
48
+ margin-top:12px;
49
+ font-size:16px;
50
+ }
51
+ .hint { color:#6b7280; margin-top:8px; font-size:13px }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <div class="card">
56
+ <h1>ICA Code Wizard 🔮</h1>
57
+ <p class="hint">Введи магическую переменную (например <code>0170</code>) и нажми «Сгенерировать».</p>
58
+ <label for="inputVar">Магическая переменная 🔢✨</label>
59
+ <input id="inputVar" type="text" value="0170" />
60
+
61
+ <div class="row">
62
+ <button id="btnGen">✨ Сгенерировать</button>
63
+ <button id="btnCopy" class="secondary" title="Копировать результат">📋 Копировать</button>
64
+ <button id="btnAuto" class="secondary" title="Генерировать автоматически при загрузке">⚡ Авто</button>
65
+ </div>
66
+
67
+ <label style="margin-top:14px">Результат</label>
68
+ <pre id="result">✨ Жду твою магию...</pre>
69
+ <p class="hint">Магический алгоритм: <code>SHA-256("C673_ICA" + ввод + MM + DD)</code>, затем берем подстроку хэша с позиции <code>день+1</code> по <code>день+13</code> ✨</p>
70
+ </div>
71
+
72
+ <script>
73
+ async function sha256Hex(message) {
74
+ const data = new TextEncoder().encode(message);
75
+ const hashBuffer = await crypto.subtle.digest("SHA-256", data);
76
+ const bytes = new Uint8Array(hashBuffer);
77
+ return Array.from(bytes, b => ("0" + b.toString(16)).slice(-2)).join("");
78
+ }
79
+
80
+ function getMMDD(date = new Date()) {
81
+ const mm = String(date.getMonth() + 1).padStart(2, "0");
82
+ const dd = String(date.getDate()).padStart(2, "0");
83
+ return { mm, dd, date };
84
+ }
85
+
86
+ async function generateCode(inputValue) {
87
+ // prepare input
88
+ const trimmed = String(inputValue ?? "").trim();
89
+ if (trimmed.length === 0) {
90
+ throw new Error("Пустая строка. Введите переменную.");
91
+ }
92
+
93
+ const { mm, dd, date } = getMMDD();
94
+ const base = "C673_ICA" + trimmed + mm + dd;
95
+ const hex = await sha256Hex(base);
96
+
97
+ // расчет индексов как в оригинале: substring(day+1, day+13)
98
+ // substring uses indices where end is exclusive.
99
+ const day = date.getDate();
100
+ const start = day + 1;
101
+ const end = day + 13;
102
+ // защитимся от выхода за длину
103
+ const safeStart = Math.max(0, Math.min(start, hex.length));
104
+ const safeEnd = Math.max(safeStart, Math.min(end, hex.length));
105
+ const res = hex.substring(safeStart, safeEnd);
106
+
107
+ return { base, hex, res, mm, dd, start: safeStart, end: safeEnd };
108
+ }
109
+
110
+ const inputEl = document.getElementById("inputVar");
111
+ const resEl = document.getElementById("result");
112
+ const btnGen = document.getElementById("btnGen");
113
+ const btnCopy = document.getElementById("btnCopy");
114
+ const btnAuto = document.getElementById("btnAuto");
115
+
116
+ let autoOn = false;
117
+
118
+ async function doGenerate(showErrors = true) {
119
+ try {
120
+ btnGen.disabled = true;
121
+ resEl.textContent = "Генерация…";
122
+ const info = await generateCode(inputEl.value);
123
+ resEl.textContent = info.res || "Пустой результат (проверь ввод/дату)";
124
+ btnGen.disabled = false;
125
+ return info;
126
+ } catch (e) {
127
+ btnGen.disabled = false;
128
+ resEl.textContent = "Ошибка: " + (e.message || e);
129
+ if (showErrors) console.error(e);
130
+ }
131
+ }
132
+
133
+ btnGen.addEventListener("click", () => doGenerate());
134
+
135
+ btnCopy.addEventListener("click", async () => {
136
+ const text = resEl.textContent || "";
137
+ if (!text || text.startsWith("Ошибка") || text === "Генерация…") {
138
+ return;
139
+ }
140
+ try {
141
+ await navigator.clipboard.writeText(text);
142
+ btnCopy.textContent = "Скопировано!";
143
+ setTimeout(() => btnCopy.textContent = "Копировать", 1400);
144
+ } catch {
145
+ btnCopy.textContent = "Не удалось";
146
+ setTimeout(() => btnCopy.textContent = "Копировать", 1400);
147
+ }
148
+ });
149
+
150
+ btnAuto.addEventListener("click", () => {
151
+ autoOn = !autoOn;
152
+ btnAuto.textContent = autoOn ? "Авто: вкл" : "Авто";
153
+ if (autoOn) doGenerate(false);
154
+ });
155
+
156
+ // allow pressing Enter in input to generate
157
+ inputEl.addEventListener("keydown", (e) => {
158
+ if (e.key === "Enter") {
159
+ e.preventDefault();
160
+ doGenerate();
161
+ }
162
+ });
163
+
164
+ // generate on load once
165
+ window.addEventListener("load", () => {
166
+ // короткая задержка для красоты
167
+ setTimeout(() => doGenerate(false), 120);
168
+ });
169
+ </script>
170
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
171
+ </body>
172
+ </html>