Spaces:
Running
Running
Commit
·
1580150
1
Parent(s):
7f97da4
implemented detection
Browse files- wm_interactive/static/styles.css +264 -96
- wm_interactive/templates/index.html +25 -18
wm_interactive/static/styles.css
CHANGED
@@ -1,89 +1,216 @@
|
|
1 |
body {
|
2 |
-
background-color: #
|
3 |
-
color: #
|
4 |
-
font-family:
|
5 |
line-height: 1.5;
|
6 |
-
padding:
|
|
|
7 |
}
|
8 |
|
9 |
.container {
|
10 |
-
background-color:
|
11 |
-
|
|
|
12 |
padding: 20px;
|
13 |
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
|
14 |
-
max-width: 1200px;
|
15 |
margin: 0 auto;
|
16 |
}
|
17 |
|
18 |
h1 {
|
|
|
19 |
font-size: 24px;
|
20 |
-
|
21 |
-
margin-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
23 |
|
24 |
.input-section textarea {
|
25 |
width: 100%;
|
26 |
-
padding:
|
27 |
-
|
28 |
-
border
|
|
|
29 |
resize: none;
|
30 |
-
font-size:
|
31 |
line-height: 1.5;
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
.input-section #prompt_text {
|
36 |
-
height:
|
|
|
37 |
}
|
38 |
|
39 |
.input-section #user_text {
|
40 |
-
height:
|
41 |
}
|
42 |
|
43 |
.button-container {
|
44 |
display: flex;
|
45 |
-
gap:
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
.token-display {
|
50 |
-
margin:
|
51 |
-
padding:
|
52 |
-
|
53 |
-
border
|
54 |
-
|
55 |
min-height: 100px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
font-size: 14px;
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
.token {
|
61 |
-
display: inline-block;
|
62 |
padding: 2px 4px;
|
63 |
-
margin:
|
64 |
-
border-radius:
|
65 |
-
font-family: monospace;
|
|
|
66 |
position: relative;
|
67 |
cursor: pointer;
|
68 |
}
|
69 |
|
|
|
|
|
|
|
|
|
70 |
.token-tooltip {
|
71 |
visibility: hidden;
|
72 |
position: absolute;
|
73 |
-
z-index:
|
74 |
bottom: 125%;
|
75 |
left: 50%;
|
76 |
transform: translateX(-50%);
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
border-radius:
|
81 |
font-size: 12px;
|
82 |
-
line-height: 1.4;
|
83 |
white-space: nowrap;
|
|
|
84 |
pointer-events: none;
|
85 |
-
font-family: monospace;
|
86 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
|
87 |
}
|
88 |
|
89 |
.token-tooltip::after {
|
@@ -94,96 +221,137 @@ h1 {
|
|
94 |
margin-left: -5px;
|
95 |
border-width: 5px;
|
96 |
border-style: solid;
|
97 |
-
border-color:
|
98 |
}
|
99 |
|
100 |
.token:hover .token-tooltip {
|
101 |
visibility: visible;
|
102 |
}
|
103 |
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
}
|
110 |
|
111 |
-
.
|
112 |
-
|
113 |
-
font-weight: 500;
|
114 |
-
color: #333;
|
115 |
}
|
116 |
|
117 |
-
.
|
118 |
-
color: #
|
119 |
-
font-size: 20px;
|
120 |
-
position: relative;
|
121 |
-
display: inline-flex;
|
122 |
-
align-items: center;
|
123 |
-
gap: 0.5rem;
|
124 |
}
|
125 |
|
126 |
-
.
|
127 |
-
|
128 |
-
color: #
|
129 |
-
|
130 |
}
|
131 |
|
132 |
-
.
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
transform: translateX(-50%);
|
138 |
-
background-color: #333;
|
139 |
-
color: white;
|
140 |
-
padding: 0.5rem;
|
141 |
-
border-radius: 4px;
|
142 |
-
font-size: 0.75rem;
|
143 |
-
width: max-content;
|
144 |
-
max-width: 200px;
|
145 |
-
z-index: 1000;
|
146 |
-
opacity: 0;
|
147 |
-
transition: opacity 0.2s;
|
148 |
}
|
149 |
|
150 |
-
.
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
153 |
}
|
154 |
|
155 |
/* Mobile-specific styles */
|
156 |
@media (max-width: 768px) {
|
157 |
-
body {
|
158 |
-
padding: 10px;
|
159 |
-
}
|
160 |
-
|
161 |
.container {
|
162 |
padding: 15px;
|
163 |
}
|
164 |
|
165 |
-
h1 {
|
166 |
-
font-size: 20px;
|
167 |
-
margin-right: 10px;
|
168 |
-
}
|
169 |
-
|
170 |
.stats-container {
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
.stats-container > div {
|
176 |
-
flex: 0 0 calc(50% - 10px);
|
177 |
-
text-align: center;
|
178 |
}
|
179 |
|
180 |
.stat-value {
|
181 |
font-size: 24px;
|
182 |
-
word-wrap: break-word;
|
183 |
-
overflow-wrap: break-word;
|
184 |
}
|
185 |
|
186 |
.stat-label {
|
187 |
-
font-size:
|
188 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
|
|
1 |
body {
|
2 |
+
background-color: #f7f7f8;
|
3 |
+
color: #1a1a1a;
|
4 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
5 |
line-height: 1.5;
|
6 |
+
padding: 0;
|
7 |
+
margin: 0;
|
8 |
}
|
9 |
|
10 |
.container {
|
11 |
+
background-color: transparent;
|
12 |
+
box-shadow: none;
|
13 |
+
max-width: 1000px;
|
14 |
padding: 20px;
|
|
|
|
|
15 |
margin: 0 auto;
|
16 |
}
|
17 |
|
18 |
h1 {
|
19 |
+
color: #1a1a1a;
|
20 |
font-size: 24px;
|
21 |
+
font-weight: 600;
|
22 |
+
margin-bottom: 30px;
|
23 |
+
}
|
24 |
+
|
25 |
+
.input-section {
|
26 |
+
display: flex;
|
27 |
+
flex-direction: column;
|
28 |
+
gap: 24px;
|
29 |
+
margin-bottom: 30px;
|
30 |
}
|
31 |
|
32 |
.input-section textarea {
|
33 |
width: 100%;
|
34 |
+
padding: 16px;
|
35 |
+
background-color: #ffffff;
|
36 |
+
border: 1px solid #e5e5e5;
|
37 |
+
border-radius: 12px;
|
38 |
resize: none;
|
39 |
+
font-size: 16px;
|
40 |
line-height: 1.5;
|
41 |
+
color: #1a1a1a;
|
42 |
+
transition: border-color 0.2s;
|
43 |
+
}
|
44 |
+
|
45 |
+
.input-section textarea:focus {
|
46 |
+
outline: none;
|
47 |
+
border-color: #10a37f;
|
48 |
+
box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
|
49 |
}
|
50 |
|
51 |
.input-section #prompt_text {
|
52 |
+
height: 80px;
|
53 |
+
padding-right: 52px;
|
54 |
}
|
55 |
|
56 |
.input-section #user_text {
|
57 |
+
height: 160px;
|
58 |
}
|
59 |
|
60 |
.button-container {
|
61 |
display: flex;
|
62 |
+
gap: 12px;
|
63 |
+
justify-content: center;
|
64 |
+
}
|
65 |
+
|
66 |
+
.btn {
|
67 |
+
padding: 8px 16px;
|
68 |
+
font-size: 14px;
|
69 |
+
font-weight: 500;
|
70 |
+
border-radius: 6px;
|
71 |
+
transition: all 0.2s;
|
72 |
+
}
|
73 |
+
|
74 |
+
.btn-primary {
|
75 |
+
background-color: #10a37f;
|
76 |
+
border-color: #10a37f;
|
77 |
+
}
|
78 |
+
|
79 |
+
.btn-primary:hover:not(:disabled) {
|
80 |
+
background-color: #0e8d6e;
|
81 |
+
border-color: #0e8d6e;
|
82 |
+
}
|
83 |
+
|
84 |
+
.btn-secondary {
|
85 |
+
background-color: #40414f;
|
86 |
+
border-color: #565869;
|
87 |
+
color: #ececf1;
|
88 |
+
}
|
89 |
+
|
90 |
+
.btn-secondary:hover:not(:disabled) {
|
91 |
+
background-color: #4a4b5a;
|
92 |
+
border-color: #6b6c7b;
|
93 |
}
|
94 |
|
95 |
.token-display {
|
96 |
+
margin: 24px 0;
|
97 |
+
padding: 16px;
|
98 |
+
background-color: #ffffff;
|
99 |
+
border: 1px solid #e5e5e5;
|
100 |
+
border-radius: 12px;
|
101 |
min-height: 100px;
|
102 |
+
font-size: 15px;
|
103 |
+
line-height: 1.6;
|
104 |
+
}
|
105 |
+
|
106 |
+
.stats-container {
|
107 |
+
display: grid;
|
108 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
109 |
+
gap: 20px;
|
110 |
+
margin-top: 30px;
|
111 |
+
padding: 20px;
|
112 |
+
background-color: #ffffff;
|
113 |
+
border-radius: 12px;
|
114 |
+
border: 1px solid #e5e5e5;
|
115 |
+
}
|
116 |
+
|
117 |
+
.stats-container > div {
|
118 |
+
text-align: center;
|
119 |
+
padding: 16px;
|
120 |
+
border-radius: 8px;
|
121 |
+
background-color: #f7f7f8;
|
122 |
+
}
|
123 |
+
|
124 |
+
.stat-value {
|
125 |
+
font-size: 28px;
|
126 |
+
font-weight: 600;
|
127 |
+
color: #1a1a1a;
|
128 |
+
margin-bottom: 8px;
|
129 |
+
}
|
130 |
+
|
131 |
+
.stat-label {
|
132 |
+
position: relative;
|
133 |
+
color: #6e6e80;
|
134 |
font-size: 14px;
|
135 |
+
display: inline-flex;
|
136 |
+
align-items: center;
|
137 |
+
justify-content: center;
|
138 |
+
gap: 6px;
|
139 |
+
}
|
140 |
+
|
141 |
+
.help-icon {
|
142 |
+
color: #6e6e80;
|
143 |
+
font-size: 12px;
|
144 |
+
opacity: 0.8;
|
145 |
+
transition: opacity 0.2s;
|
146 |
+
cursor: help;
|
147 |
+
}
|
148 |
+
|
149 |
+
.help-tooltip {
|
150 |
+
visibility: hidden;
|
151 |
+
position: absolute;
|
152 |
+
z-index: 1000;
|
153 |
+
bottom: 125%;
|
154 |
+
left: 50%;
|
155 |
+
transform: translateX(-50%);
|
156 |
+
background-color: #1a1a1a;
|
157 |
+
color: #ffffff;
|
158 |
+
padding: 8px 12px;
|
159 |
+
border-radius: 6px;
|
160 |
+
font-size: 12px;
|
161 |
+
width: max-content;
|
162 |
+
max-width: 200px;
|
163 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
164 |
+
pointer-events: none;
|
165 |
+
opacity: 0;
|
166 |
+
transition: opacity 0.2s;
|
167 |
+
}
|
168 |
+
|
169 |
+
.help-tooltip::after {
|
170 |
+
content: "";
|
171 |
+
position: absolute;
|
172 |
+
top: 100%;
|
173 |
+
left: 50%;
|
174 |
+
margin-left: -5px;
|
175 |
+
border-width: 5px;
|
176 |
+
border-style: solid;
|
177 |
+
border-color: #1a1a1a transparent transparent transparent;
|
178 |
+
}
|
179 |
+
|
180 |
+
.help-icon:hover + .help-tooltip {
|
181 |
+
visibility: visible;
|
182 |
+
opacity: 1;
|
183 |
}
|
184 |
|
185 |
.token {
|
|
|
186 |
padding: 2px 4px;
|
187 |
+
margin: 1px;
|
188 |
+
border-radius: 4px;
|
189 |
+
font-family: 'SF Mono', 'Menlo', 'Monaco', Courier, monospace;
|
190 |
+
transition: background-color 0.2s;
|
191 |
position: relative;
|
192 |
cursor: pointer;
|
193 |
}
|
194 |
|
195 |
+
.token:hover {
|
196 |
+
filter: brightness(1.1);
|
197 |
+
}
|
198 |
+
|
199 |
.token-tooltip {
|
200 |
visibility: hidden;
|
201 |
position: absolute;
|
202 |
+
z-index: 1000;
|
203 |
bottom: 125%;
|
204 |
left: 50%;
|
205 |
transform: translateX(-50%);
|
206 |
+
background-color: #1a1a1a;
|
207 |
+
color: #ffffff;
|
208 |
+
padding: 8px 12px;
|
209 |
+
border-radius: 6px;
|
210 |
font-size: 12px;
|
|
|
211 |
white-space: nowrap;
|
212 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
213 |
pointer-events: none;
|
|
|
|
|
214 |
}
|
215 |
|
216 |
.token-tooltip::after {
|
|
|
221 |
margin-left: -5px;
|
222 |
border-width: 5px;
|
223 |
border-style: solid;
|
224 |
+
border-color: #1a1a1a transparent transparent transparent;
|
225 |
}
|
226 |
|
227 |
.token:hover .token-tooltip {
|
228 |
visibility: visible;
|
229 |
}
|
230 |
|
231 |
+
/* Modal styling */
|
232 |
+
.modal-content {
|
233 |
+
background-color: #ffffff;
|
234 |
+
color: #1a1a1a;
|
235 |
+
border: 1px solid #e5e5e5;
|
236 |
}
|
237 |
|
238 |
+
.modal-header {
|
239 |
+
border-bottom-color: #e5e5e5;
|
|
|
|
|
240 |
}
|
241 |
|
242 |
+
.modal-footer {
|
243 |
+
border-top-color: #e5e5e5;
|
|
|
|
|
|
|
|
|
|
|
244 |
}
|
245 |
|
246 |
+
.form-control, .form-select {
|
247 |
+
background-color: #f7f7f8;
|
248 |
+
border-color: #e5e5e5;
|
249 |
+
color: #1a1a1a;
|
250 |
}
|
251 |
|
252 |
+
.form-control:focus, .form-select:focus {
|
253 |
+
background-color: #f7f7f8;
|
254 |
+
border-color: #10a37f;
|
255 |
+
color: #1a1a1a;
|
256 |
+
box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
|
259 |
+
.form-text {
|
260 |
+
color: #6e6e80;
|
261 |
+
}
|
262 |
+
|
263 |
+
.btn-close {
|
264 |
+
filter: none;
|
265 |
}
|
266 |
|
267 |
/* Mobile-specific styles */
|
268 |
@media (max-width: 768px) {
|
|
|
|
|
|
|
|
|
269 |
.container {
|
270 |
padding: 15px;
|
271 |
}
|
272 |
|
|
|
|
|
|
|
|
|
|
|
273 |
.stats-container {
|
274 |
+
grid-template-columns: repeat(2, 1fr);
|
275 |
+
gap: 12px;
|
276 |
+
padding: 12px;
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
|
279 |
.stat-value {
|
280 |
font-size: 24px;
|
|
|
|
|
281 |
}
|
282 |
|
283 |
.stat-label {
|
284 |
+
font-size: 12px;
|
285 |
}
|
286 |
+
|
287 |
+
.help-tooltip {
|
288 |
+
max-width: 160px;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
/* Light scrollbar */
|
293 |
+
::-webkit-scrollbar {
|
294 |
+
width: 8px;
|
295 |
+
height: 8px;
|
296 |
+
}
|
297 |
+
|
298 |
+
::-webkit-scrollbar-track {
|
299 |
+
background: #f7f7f8;
|
300 |
+
}
|
301 |
+
|
302 |
+
::-webkit-scrollbar-thumb {
|
303 |
+
background: #d1d1d1;
|
304 |
+
border-radius: 4px;
|
305 |
+
}
|
306 |
+
|
307 |
+
::-webkit-scrollbar-thumb:hover {
|
308 |
+
background: #a8a8a8;
|
309 |
+
}
|
310 |
+
|
311 |
+
.prompt-container {
|
312 |
+
position: relative;
|
313 |
+
width: 100%;
|
314 |
+
}
|
315 |
+
|
316 |
+
.floating-btn {
|
317 |
+
position: absolute;
|
318 |
+
bottom: 16px;
|
319 |
+
right: 16px;
|
320 |
+
width: 36px;
|
321 |
+
height: 36px;
|
322 |
+
border-radius: 12px;
|
323 |
+
display: flex;
|
324 |
+
align-items: center;
|
325 |
+
justify-content: center;
|
326 |
+
border: none;
|
327 |
+
background-color: #10a37f;
|
328 |
+
color: #ffffff;
|
329 |
+
cursor: pointer;
|
330 |
+
transition: all 0.2s ease;
|
331 |
+
padding: 0;
|
332 |
+
}
|
333 |
+
|
334 |
+
.floating-btn:hover {
|
335 |
+
background-color: #0e8d6e;
|
336 |
+
}
|
337 |
+
|
338 |
+
.floating-btn:disabled {
|
339 |
+
background-color: #565869;
|
340 |
+
cursor: not-allowed;
|
341 |
+
}
|
342 |
+
|
343 |
+
.floating-btn i {
|
344 |
+
font-size: 16px;
|
345 |
+
}
|
346 |
+
|
347 |
+
.floating-btn .stop-icon {
|
348 |
+
display: none;
|
349 |
+
}
|
350 |
+
|
351 |
+
.floating-btn.generating .send-icon {
|
352 |
+
display: none;
|
353 |
+
}
|
354 |
+
|
355 |
+
.floating-btn.generating .stop-icon {
|
356 |
+
display: block;
|
357 |
}
|
wm_interactive/templates/index.html
CHANGED
@@ -66,11 +66,13 @@
|
|
66 |
|
67 |
<!-- Input Form -->
|
68 |
<div class="input-section">
|
69 |
-
<
|
70 |
-
|
71 |
-
|
72 |
-
<button class="btn
|
73 |
-
|
|
|
|
|
74 |
</div>
|
75 |
<textarea id="user_text"
|
76 |
placeholder="Generated text will appear here. Replace or edit this text to see how watermark detection works."></textarea>
|
@@ -119,11 +121,10 @@
|
|
119 |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
120 |
<script>
|
121 |
let debounceTimeout = null;
|
122 |
-
let abortController = null;
|
123 |
const textarea = document.getElementById('user_text');
|
124 |
const promptArea = document.getElementById('prompt_text');
|
125 |
const generateBtn = document.getElementById('generateBtn');
|
126 |
-
const stopBtn = document.getElementById('stopBtn');
|
127 |
const tokenDisplay = document.getElementById('tokenDisplay');
|
128 |
const tokenCount = document.getElementById('tokenCount');
|
129 |
const scoredTokens = document.getElementById('scoredTokens');
|
@@ -143,8 +144,7 @@
|
|
143 |
return;
|
144 |
}
|
145 |
|
146 |
-
generateBtn.
|
147 |
-
stopBtn.disabled = false;
|
148 |
textarea.value = '';
|
149 |
|
150 |
// Create new AbortController for this request
|
@@ -247,8 +247,7 @@
|
|
247 |
}
|
248 |
})
|
249 |
.finally(() => {
|
250 |
-
generateBtn.
|
251 |
-
stopBtn.disabled = true;
|
252 |
abortController = null;
|
253 |
});
|
254 |
}
|
@@ -258,15 +257,19 @@
|
|
258 |
abortController.abort();
|
259 |
abortController = null;
|
260 |
}
|
261 |
-
generateBtn.
|
262 |
-
stopBtn.disabled = true;
|
263 |
}
|
264 |
|
265 |
-
//
|
266 |
-
generateBtn.addEventListener('click',
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
|
269 |
-
// Rest of the existing JavaScript code...
|
270 |
async function updateTokenization() {
|
271 |
const text = textarea.value;
|
272 |
try {
|
@@ -406,7 +409,11 @@
|
|
406 |
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
407 |
e.preventDefault();
|
408 |
if (document.activeElement === promptArea) {
|
409 |
-
generateBtn.
|
|
|
|
|
|
|
|
|
410 |
} else {
|
411 |
applyParamsBtn.click();
|
412 |
}
|
|
|
66 |
|
67 |
<!-- Input Form -->
|
68 |
<div class="input-section">
|
69 |
+
<div class="prompt-container">
|
70 |
+
<textarea id="prompt_text"
|
71 |
+
placeholder="Enter your prompt here to generate text with the model..."></textarea>
|
72 |
+
<button class="floating-btn" id="generateBtn">
|
73 |
+
<i class="bi bi-send-fill send-icon"></i>
|
74 |
+
<i class="bi bi-stop-fill stop-icon"></i>
|
75 |
+
</button>
|
76 |
</div>
|
77 |
<textarea id="user_text"
|
78 |
placeholder="Generated text will appear here. Replace or edit this text to see how watermark detection works."></textarea>
|
|
|
121 |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
122 |
<script>
|
123 |
let debounceTimeout = null;
|
124 |
+
let abortController = null;
|
125 |
const textarea = document.getElementById('user_text');
|
126 |
const promptArea = document.getElementById('prompt_text');
|
127 |
const generateBtn = document.getElementById('generateBtn');
|
|
|
128 |
const tokenDisplay = document.getElementById('tokenDisplay');
|
129 |
const tokenCount = document.getElementById('tokenCount');
|
130 |
const scoredTokens = document.getElementById('scoredTokens');
|
|
|
144 |
return;
|
145 |
}
|
146 |
|
147 |
+
generateBtn.classList.add('generating');
|
|
|
148 |
textarea.value = '';
|
149 |
|
150 |
// Create new AbortController for this request
|
|
|
247 |
}
|
248 |
})
|
249 |
.finally(() => {
|
250 |
+
generateBtn.classList.remove('generating');
|
|
|
251 |
abortController = null;
|
252 |
});
|
253 |
}
|
|
|
257 |
abortController.abort();
|
258 |
abortController = null;
|
259 |
}
|
260 |
+
generateBtn.classList.remove('generating');
|
|
|
261 |
}
|
262 |
|
263 |
+
// Remove BOTH old event listeners and add just one new one
|
264 |
+
generateBtn.addEventListener('click', function(e) {
|
265 |
+
e.preventDefault(); // Prevent any double triggers
|
266 |
+
if (generateBtn.classList.contains('generating')) {
|
267 |
+
stopGeneration();
|
268 |
+
} else {
|
269 |
+
startGeneration();
|
270 |
+
}
|
271 |
+
});
|
272 |
|
|
|
273 |
async function updateTokenization() {
|
274 |
const text = textarea.value;
|
275 |
try {
|
|
|
409 |
if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {
|
410 |
e.preventDefault();
|
411 |
if (document.activeElement === promptArea) {
|
412 |
+
if (generateBtn.classList.contains('generating')) {
|
413 |
+
stopGeneration();
|
414 |
+
} else {
|
415 |
+
startGeneration();
|
416 |
+
}
|
417 |
} else {
|
418 |
applyParamsBtn.click();
|
419 |
}
|