HedronCreeper commited on
Commit
a14cf21
·
verified ·
1 Parent(s): ab6af8b

Update static/index.html

Browse files
Files changed (1) hide show
  1. static/index.html +42 -59
static/index.html CHANGED
@@ -25,17 +25,12 @@
25
  -webkit-text-fill-color: transparent;
26
  letter-spacing: -1px;
27
  }
28
- p.sub {
29
- color: #555570;
30
- font-size: 0.9rem;
31
- margin-top: -1.5rem;
32
- text-align: center;
33
- }
34
  .row {
35
  display: flex;
36
  gap: 1.5rem;
37
  width: 100%;
38
- max-width: 800px;
39
  flex-wrap: wrap;
40
  }
41
  .card {
@@ -49,13 +44,7 @@
49
  flex-direction: column;
50
  gap: 1rem;
51
  }
52
- .card h2 {
53
- font-size: 1rem;
54
- font-weight: 600;
55
- color: #a0a0c0;
56
- letter-spacing: 0.05em;
57
- text-transform: uppercase;
58
- }
59
  textarea, input[type="file"] {
60
  width: 100%;
61
  background: #080810;
@@ -67,14 +56,10 @@
67
  outline: none;
68
  transition: border-color 0.2s;
69
  resize: vertical;
70
- min-height: 100px;
71
  }
72
  textarea:focus { border-color: #7c3aed; }
73
- input[type="file"] {
74
- min-height: unset;
75
- cursor: pointer;
76
- padding: 0.6rem;
77
- }
78
  button {
79
  width: 100%;
80
  padding: 0.75rem;
@@ -88,30 +73,16 @@
88
  transition: opacity 0.2s;
89
  }
90
  button:hover { opacity: 0.85; }
91
- .status {
92
- font-size: 0.8rem;
93
- color: #555570;
94
- text-align: center;
95
- min-height: 1em;
96
- }
97
- .preview {
98
- text-align: center;
99
- }
100
- .preview img {
101
  image-rendering: pixelated;
102
- width: 128px;
103
- height: 128px;
104
  border-radius: 8px;
105
  border: 1px solid #222238;
106
  }
107
- .download {
108
- display: inline-block;
109
- margin-top: 0.5rem;
110
- font-size: 0.8rem;
111
- color: #a78bfa;
112
- cursor: pointer;
113
- text-decoration: underline;
114
- }
115
  .decoded-text {
116
  background: #080810;
117
  border: 1px solid #222238;
@@ -121,18 +92,19 @@
121
  color: #e0e0f0;
122
  word-break: break-all;
123
  display: none;
 
124
  }
125
  </style>
126
  </head>
127
  <body>
128
  <h1>ChromaCode</h1>
129
- <p class="sub">Encode text into colour. Decode it back.</p>
130
 
131
  <div class="row">
132
  <div class="card">
133
  <h2>Encode</h2>
134
- <textarea id="encodeInput" placeholder="Type anything..."></textarea>
135
- <button onclick="encodeText()">Generate ChromaCode</button>
136
  <div class="status" id="encodeStatus"></div>
137
  <div class="preview" id="encodePreview"></div>
138
  </div>
@@ -140,13 +112,15 @@
140
  <div class="card">
141
  <h2>Decode</h2>
142
  <input type="file" id="decodeFile" accept="image/png">
143
- <button onclick="decodeImage()">Decode Image</button>
144
  <div class="status" id="decodeStatus"></div>
145
  <div class="decoded-text" id="decodedText"></div>
146
  </div>
147
  </div>
148
 
149
  <script>
 
 
150
  async function encodeText() {
151
  const text = document.getElementById("encodeInput").value.trim();
152
  if (!text) return;
@@ -154,6 +128,7 @@
154
  const preview = document.getElementById("encodePreview");
155
  status.textContent = "Encoding...";
156
  preview.innerHTML = "";
 
157
  const res = await fetch("/encode", {
158
  method: "POST",
159
  headers: { "Content-Type": "application/json" },
@@ -162,31 +137,39 @@
162
  const data = await res.json();
163
  if (data.image) {
164
  const src = "data:image/png;base64," + data.image;
165
- preview.innerHTML = `
166
- <img src="${src}" alt="ChromaCode">
167
- <br>
168
- <a class="download" onclick="downloadImage('${src}')">Download PNG</a>
169
- `;
170
- status.textContent = "Done!";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  } else {
172
  status.textContent = "Error: " + (data.error || "Unknown");
173
  }
174
  }
175
 
176
- function downloadImage(src) {
177
- const a = document.createElement("a");
178
- a.href = src;
179
- a.download = "chromacode.png";
180
- a.click();
181
- }
182
-
183
  async function decodeImage() {
184
  const file = document.getElementById("decodeFile").files[0];
185
  if (!file) return;
186
  const status = document.getElementById("decodeStatus");
187
  const output = document.getElementById("decodedText");
188
- status.textContent = "Decoding...";
189
  output.style.display = "none";
 
190
  const form = new FormData();
191
  form.append("file", file);
192
  const res = await fetch("/decode", { method: "POST", body: form });
@@ -194,7 +177,7 @@
194
  if (data.text) {
195
  output.textContent = data.text;
196
  output.style.display = "block";
197
- status.textContent = "Decoded!";
198
  } else {
199
  status.textContent = "Error: " + (data.error || "Unknown");
200
  }
 
25
  -webkit-text-fill-color: transparent;
26
  letter-spacing: -1px;
27
  }
28
+ p.sub { color: #555570; font-size: 0.9rem; margin-top: -1.5rem; text-align: center; }
 
 
 
 
 
29
  .row {
30
  display: flex;
31
  gap: 1.5rem;
32
  width: 100%;
33
+ max-width: 820px;
34
  flex-wrap: wrap;
35
  }
36
  .card {
 
44
  flex-direction: column;
45
  gap: 1rem;
46
  }
47
+ .card h2 { font-size: 0.85rem; font-weight: 600; color: #a0a0c0; letter-spacing: 0.08em; text-transform: uppercase; }
 
 
 
 
 
 
48
  textarea, input[type="file"] {
49
  width: 100%;
50
  background: #080810;
 
56
  outline: none;
57
  transition: border-color 0.2s;
58
  resize: vertical;
59
+ min-height: 110px;
60
  }
61
  textarea:focus { border-color: #7c3aed; }
62
+ input[type="file"] { min-height: unset; cursor: pointer; padding: 0.6rem; }
 
 
 
 
63
  button {
64
  width: 100%;
65
  padding: 0.75rem;
 
73
  transition: opacity 0.2s;
74
  }
75
  button:hover { opacity: 0.85; }
76
+ .status { font-size: 0.8rem; color: #555570; text-align: center; min-height: 1em; }
77
+ .preview { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
78
+ .preview canvas {
 
 
 
 
 
 
 
79
  image-rendering: pixelated;
80
+ width: 150px;
81
+ height: 150px;
82
  border-radius: 8px;
83
  border: 1px solid #222238;
84
  }
85
+ .download { font-size: 0.8rem; color: #a78bfa; cursor: pointer; text-decoration: underline; }
 
 
 
 
 
 
 
86
  .decoded-text {
87
  background: #080810;
88
  border: 1px solid #222238;
 
92
  color: #e0e0f0;
93
  word-break: break-all;
94
  display: none;
95
+ white-space: pre-wrap;
96
  }
97
  </style>
98
  </head>
99
  <body>
100
  <h1>ChromaCode</h1>
101
+ <p class="sub">Steganography. Hidden in plain sight.</p>
102
 
103
  <div class="row">
104
  <div class="card">
105
  <h2>Encode</h2>
106
+ <textarea id="encodeInput" placeholder="Type a message or paragraph..."></textarea>
107
+ <button onclick="encodeText()">Hide in Image</button>
108
  <div class="status" id="encodeStatus"></div>
109
  <div class="preview" id="encodePreview"></div>
110
  </div>
 
112
  <div class="card">
113
  <h2>Decode</h2>
114
  <input type="file" id="decodeFile" accept="image/png">
115
+ <button onclick="decodeImage()">Extract Message</button>
116
  <div class="status" id="decodeStatus"></div>
117
  <div class="decoded-text" id="decodedText"></div>
118
  </div>
119
  </div>
120
 
121
  <script>
122
+ let lastImageSrc = null;
123
+
124
  async function encodeText() {
125
  const text = document.getElementById("encodeInput").value.trim();
126
  if (!text) return;
 
128
  const preview = document.getElementById("encodePreview");
129
  status.textContent = "Encoding...";
130
  preview.innerHTML = "";
131
+
132
  const res = await fetch("/encode", {
133
  method: "POST",
134
  headers: { "Content-Type": "application/json" },
 
137
  const data = await res.json();
138
  if (data.image) {
139
  const src = "data:image/png;base64," + data.image;
140
+ lastImageSrc = src;
141
+ const canvas = document.createElement("canvas");
142
+ canvas.width = 25;
143
+ canvas.height = 25;
144
+ const ctx = canvas.getContext("2d");
145
+ const img = new window.Image();
146
+ img.onload = () => ctx.drawImage(img, 0, 0);
147
+ img.src = src;
148
+ preview.appendChild(canvas);
149
+ const dl = document.createElement("span");
150
+ dl.className = "download";
151
+ dl.textContent = "Download PNG";
152
+ dl.onclick = () => {
153
+ const a = document.createElement("a");
154
+ a.href = src;
155
+ a.download = "chromacode.png";
156
+ a.click();
157
+ };
158
+ preview.appendChild(dl);
159
+ status.textContent = "Encoded! Looks like a normal image.";
160
  } else {
161
  status.textContent = "Error: " + (data.error || "Unknown");
162
  }
163
  }
164
 
 
 
 
 
 
 
 
165
  async function decodeImage() {
166
  const file = document.getElementById("decodeFile").files[0];
167
  if (!file) return;
168
  const status = document.getElementById("decodeStatus");
169
  const output = document.getElementById("decodedText");
170
+ status.textContent = "Extracting...";
171
  output.style.display = "none";
172
+
173
  const form = new FormData();
174
  form.append("file", file);
175
  const res = await fetch("/decode", { method: "POST", body: form });
 
177
  if (data.text) {
178
  output.textContent = data.text;
179
  output.style.display = "block";
180
+ status.textContent = "Message extracted!";
181
  } else {
182
  status.textContent = "Error: " + (data.error || "Unknown");
183
  }