about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <{ID}+{username}@users.noreply.github.com>2025-02-10 16:52:03 -0500
committerelioat <{ID}+{username}@users.noreply.github.com>2025-02-10 16:52:03 -0500
commit445a6619ecda4210b1b0454c4332360f37396fd1 (patch)
tree4993ee136927f7e56dc2c7468722d57f85199248
parentb14fa3e07e3641d56173f8948fc0db34cc943180 (diff)
downloadtour-445a6619ecda4210b1b0454c4332360f37396fd1.tar.gz
*
-rw-r--r--html/ccc/index.html71
1 files changed, 66 insertions, 5 deletions
diff --git a/html/ccc/index.html b/html/ccc/index.html
index 2b3b0cd..b3ebfa2 100644
--- a/html/ccc/index.html
+++ b/html/ccc/index.html
@@ -4,6 +4,7 @@
     <meta charset="UTF-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Color Contrast Checker</title>
+    <meta name="description" content="Give it a list of colors, find accessible combinations.">
     <style>
         body { font-family: Arial, sans-serif; padding: 20px; }
         .color-input { margin-bottom: 10px; width: 100%; height: 100px; }
@@ -21,6 +22,15 @@
             margin: 1rem 0;
             grid-column: 1 / -1;
         }
+        .warning {
+            color: #856404;
+            background-color: #fff3cd;
+            border: 1px solid #ffeeba;
+            padding: 1rem;
+            border-radius: 4px;
+            margin: 1rem 0;
+            grid-column: 1 / -1;
+        }
     </style>
 </head>
 <body>
@@ -50,6 +60,7 @@
     </footer>
     
     <script>
+        // ===== Initialization and URL Parameter Handling =====
         window.addEventListener('load', () => {
             const urlParams = new URLSearchParams(window.location.search);
             const colors = urlParams.get('colors');
@@ -57,8 +68,14 @@
                 document.getElementById('colors').value = decodeURIComponent(colors);
                 updateColors();
             }
+
+            // Only create test UI if tests parameter is present and true
+            if (urlParams.get('tests') === 'true' || urlParams.get('tests') === 't') {
+                createTestUI();
+            }
         });
 
+        // ===== Share Functionality =====
         function shareColors() {
             const colors = document.getElementById('colors').value;
             if (!colors) return;
@@ -75,6 +92,7 @@
             });
         }
 
+        // ===== Color Parsing and Conversion =====
         function parseColor(color) {
             // Remove all whitespace and convert to lowercase
             const originalColor = color; // Store original format
@@ -150,6 +168,7 @@
             return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
         }
 
+        // ===== Contrast Calculation and WCAG Compliance =====
         function getContrastRatio(color1, color2) {
             function luminance(r, g, b) {
                 let a = [r, g, b].map(v => {
@@ -189,6 +208,7 @@
             return "Fail";
         }
 
+        // ===== UI Generation and Updates =====
         function createColorBox(color1, color2, contrast, level, accessible, showGlow) {
             const classes = ["color-box"];
             if (!accessible) classes.push("failing");
@@ -208,12 +228,13 @@
 
         function updateColors() {
             const input = document.getElementById("colors").value;
+            const results = document.getElementById("results");
             
             // First split by newlines
             const colorLines = input.split(/\n+/).map(line => line.trim()).filter(line => line);
             
             // Then process each line to handle both comma-separated values and rgb/rgba formats
-            const colors = colorLines.flatMap(line => {
+            let colors = colorLines.flatMap(line => {
                 // Temporary replace commas in rgb/rgba values with a special marker
                 line = line.replace(/rgba?\([^)]+\)/g, match => match.replace(/,/g, '|'));
                 
@@ -223,7 +244,28 @@
                     .filter(color => color);
             });
 
-            const results = document.getElementById("results");
+            // Clear any existing warnings
+            document.querySelectorAll('.warning').forEach(el => el.remove());
+
+            // Deduplicate colors by converting to a standard format and back
+            colors = [...new Set(colors.map(color => {
+                try {
+                    const parsed = parseColor(color);
+                    return parsed.originalFormat;
+                } catch (error) {
+                    return color; // Keep invalid colors for error handling
+                }
+            }))];
+
+            const duplicates = findDuplicateColors(colors);
+            if (duplicates.length > 0) {
+                console.warn('Duplicate colors found:', duplicates);
+                // Show warning in UI
+                const warning = document.createElement('div');
+                warning.className = 'warning';
+                warning.textContent = `Duplicate colors found (${duplicates.join(', ')})`;
+                results.insertAdjacentElement('beforebegin', warning);
+            }
 
             try {
                 const colorCombinations = colors.flatMap((color1, i) => 
@@ -256,6 +298,27 @@
             }
         }
 
+        function findDuplicateColors(colors) {
+            const seen = new Map();
+            const duplicates = new Set();
+
+            colors.forEach(color => {
+                try {
+                    const parsed = parseColor(color);
+                    const normalized = `rgb(${parsed.r},${parsed.g},${parsed.b},${parsed.a})`;
+                    
+                    if (seen.has(normalized)) {
+                        duplicates.add(color);
+                    }
+                    seen.set(normalized, color);
+                } catch (error) {
+                    // Ignore invalid colors
+                }
+            });
+
+            return Array.from(duplicates);
+        }
+
         function updateVisibility() {
             let hideFails = document.getElementById("toggleFails").checked;
             
@@ -264,6 +327,7 @@
             });
         }
 
+        // ===== Testing Functions =====
         function runContrastTests() {
             const testCases = [
                 {
@@ -494,9 +558,6 @@
                 <p>Validation Tests: ${validationResults.passed}/${validationResults.total} passed</p>
             `;
         }
-
-        // Initialize test UI when page loads
-        window.addEventListener('load', createTestUI);
     </script>
 </body>
 </html>
0 committer Ben Morrison <ben@gbmor.dev> 2019-05-21 18:59:56 -0400 runtime bugs related to api output' href='/gbmor/getwtxt/commit/init.go?h=v0.4.9&id=4f0847bb24a5df77f88c883461491a2f6fd955d7'>4f0847b ^
f2d85b6 ^
1f8b2ce ^
06cffd8 ^
06cffd8 ^
920306c ^
c896e6b ^
5310d08 ^
06cffd8 ^

f2d85b6 ^
1f8b2ce ^
f2d85b6 ^




bd23ef0 ^

f2d85b6 ^
67864b2 ^
cf6c849 ^





f2d85b6 ^


06cffd8 ^
cf6c849 ^




















06cffd8 ^
1f8b2ce ^
06cffd8 ^
c5cf0e1 ^
06cffd8 ^
c5cf0e1 ^
c5cf0e1 ^




06cffd8 ^

cd635e6 ^






c5cf0e1 ^





cd635e6 ^
c5cf0e1 ^
cd635e6 ^

c5cf0e1 ^
cd635e6 ^

c5cf0e1 ^
cd635e6 ^

bded77f ^

cd635e6 ^
bded77f ^
c5cf0e1 ^
cd635e6 ^

c5cf0e1 ^
cd635e6 ^

c5cf0e1 ^
cd635e6 ^


c5cf0e1 ^
cd635e6 ^




c5cf0e1 ^
cd635e6 ^

06cffd8 ^



cd635e6 ^
bd23ef0 ^
cd635e6 ^
313ab71 ^


a0be15e ^
cd635e6 ^
a0be15e ^
1f8b2ce ^
a0be15e ^
a0be15e ^
1f8b2ce ^
313ab71 ^



bd23ef0 ^
d083ce6 ^
1f8b2ce ^
bd23ef0 ^
1f8b2ce ^



313ab71 ^
1f8b2ce ^

1f8b2ce ^
711012e ^
cd635e6 ^
06cffd8 ^



cd635e6 ^

d083ce6 ^
1f8b2ce ^
cd635e6 ^
1f8b2ce ^
cd635e6 ^
c5cf0e1 ^
cd635e6 ^




c5cf0e1 ^
cd635e6 ^




c5cf0e1 ^
cd635e6 ^
a0be15e ^
06cffd8 ^
a0be15e ^
1f8b2ce ^
920306c ^



b29e1c1 ^
bd23ef0 ^
cd635e6 ^


bd23ef0 ^




c896e6b ^

b29e1c1 ^
bd23ef0 ^

5310d08 ^







5310d08 ^
c896e6b ^
cd635e6 ^
c896e6b ^
cd635e6 ^
b29e1c1 ^
c896e6b ^



cd635e6 ^
d083ce6 ^
5310d08 ^

cd635e6 ^
b29e1c1 ^
d083ce6 ^
efa99ed ^

c896e6b ^
5310d08 ^




1f8b2ce ^

cf6c849 ^
1f8b2ce ^






bd23ef0 ^
cf6c849 ^
bd23ef0 ^




c5cf0e1 ^

cf6c849 ^
c5cf0e1 ^
21939ad ^
c5cf0e1 ^
cf6c849 ^

21939ad ^
cf6c849 ^































































































1f8b2ce ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406