-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeme-archivar_1.html
More file actions
2079 lines (1924 loc) · 94.7 KB
/
Copy pathmeme-archivar_1.html
File metadata and controls
2079 lines (1924 loc) · 94.7 KB
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Meme Archivar · Gemini</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap">
<style>
:root{
--bg-deep:oklch(0.13 0.02 280);
--bg-elev-1:oklch(0.95 0.005 280 / 0.04);
--bg-elev-2:oklch(0.95 0.005 280 / 0.06);
--bg-elev-3:oklch(0.95 0.005 280 / 0.08);
--border-1:oklch(0.95 0.005 280 / 0.06);
--border-2:oklch(0.95 0.005 280 / 0.10);
--text-primary:oklch(0.95 0.005 280);
--text-secondary:oklch(0.75 0.02 280);
--text-tertiary:oklch(0.65 0.02 280);
--text-quiet:oklch(0.55 0.02 280);
--accent:oklch(0.7 0.18 300);
--accent-soft:oklch(0.7 0.18 300 / 0.15);
--accent-glow:oklch(0.7 0.18 300 / 0.4);
--red:oklch(0.65 0.2 25);
--amber:oklch(0.80 0.15 80);
--green:oklch(0.75 0.18 145);
--blue:oklch(0.70 0.15 240);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
margin:0;background:var(--bg-deep);color:var(--text-primary);
font-family:Inter,system-ui,sans-serif;font-size:13.5px;line-height:1.5;
overflow:hidden;
}
::selection{background:oklch(0.7 0.18 300 / 0.35);color:oklch(0.95 0.005 280)}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--bg-elev-3);border-radius:3px}
::-webkit-scrollbar-thumb:hover{background:var(--accent)}
.mono{font-family:"JetBrains Mono",ui-monospace,monospace}
.nano{font-family:"JetBrains Mono",monospace;font-size:9.5px;letter-spacing:1.4px;
text-transform:uppercase;color:var(--text-quiet)}
.glass{background:var(--bg-elev-1);border:1px solid var(--border-2);
backdrop-filter:blur(20px);border-radius:12px}
/* ---------- shell ---------- */
#shell{position:relative;z-index:1;height:100%;display:flex;flex-direction:column}
#topbar{height:62px;flex:0 0 62px;display:flex;align-items:center;gap:14px;padding:0 20px;
background:var(--bg-elev-1);backdrop-filter:blur(20px);border-bottom:1px solid var(--border-1)}
#topbar .brand{font-weight:600;font-size:15px;letter-spacing:-0.2px}
#topbar .brand span{color:var(--accent)}
.pill{font-family:"JetBrains Mono",monospace;font-size:10px;letter-spacing:.8px;
padding:3px 9px;border-radius:99px;background:var(--bg-elev-2);border:1px solid var(--border-2);
color:var(--text-tertiary);white-space:nowrap}
.pill.on{color:var(--accent);border-color:var(--accent-soft);background:var(--accent-soft)}
.grow{flex:1}
#mid{flex:1;display:flex;min-height:0}
#rail{width:252px;flex:0 0 252px;overflow-y:auto;padding:16px;border-right:1px solid var(--border-1);
background:var(--bg-elev-1);backdrop-filter:blur(20px)}
#splitter{width:5px;cursor:col-resize;background:transparent;flex:0 0 5px}
#splitter:hover{background:var(--accent-soft)}
#main{flex:1;overflow-y:auto;padding:24px 28px 40px;min-width:0}
#logcard{height:216px;flex:0 0 216px;display:flex;flex-direction:column;
border-top:1px solid var(--border-1);background:var(--bg-elev-1);backdrop-filter:blur(20px)}
/* ---------- rail ---------- */
.rail-group{margin-bottom:20px}
.rail-group>.nano{margin-bottom:9px;display:block}
.field{margin-bottom:11px}
.field label{display:block;font-size:11px;color:var(--text-tertiary);margin-bottom:4px}
input[type=text],input[type=password],input[type=number],select,textarea{
width:100%;background:var(--bg-elev-2);color:var(--text-primary);
border:1px solid var(--border-2);border-radius:8px;padding:7px 9px;
font-family:Inter,sans-serif;font-size:12.5px;outline:none;transition:border-color .15s ease,box-shadow .15s ease}
input:focus,select:focus,textarea:focus{border-color:var(--accent);
box-shadow:0 0 0 3px oklch(0.7 0.18 300 / 0.18)}
textarea{font-family:"JetBrains Mono",monospace;font-size:12px;line-height:1.55;resize:vertical}
select option{background:#1b1526;color:#eee}
.row2{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.check{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-secondary);
margin-bottom:8px;cursor:pointer}
.check input{accent-color:var(--accent);width:14px;height:14px;cursor:pointer}
.hint{font-size:10.5px;color:var(--text-quiet);line-height:1.45;margin-top:5px}
/* ---------- buttons ---------- */
button{font-family:Inter,sans-serif;font-size:12.5px;font-weight:500;cursor:pointer;
background:var(--bg-elev-2);color:var(--text-primary);border:1px solid var(--border-2);
border-radius:8px;padding:7px 13px;transition:all .15s ease}
button:hover:not(:disabled){background:var(--bg-elev-3);border-color:var(--border-2);transform:translateY(-1px)}
button:disabled{opacity:.4;cursor:not-allowed}
button.primary{background:var(--accent);border-color:transparent;color:oklch(0.16 0.02 300);
font-weight:600;box-shadow:0 6px 20px var(--accent-glow)}
button.primary:hover:not(:disabled){background:oklch(0.75 0.18 300)}
button.ghost{background:transparent}
button.tiny{font-size:11px;padding:4px 9px}
button.danger{color:var(--red);border-color:oklch(0.65 0.2 25 / 0.3)}
/* ---------- cards ---------- */
.card{background:var(--bg-elev-1);border:1px solid var(--border-2);backdrop-filter:blur(20px);
border-radius:12px;padding:18px;margin-bottom:18px}
.card>h2{margin:0 0 3px;font-size:14px;font-weight:600;display:flex;align-items:center;gap:8px}
.card>h2 .ic{color:var(--accent)}
.card>.sub{margin:0 0 14px;font-size:11.5px;color:var(--text-quiet)}
.drop{border:1px dashed var(--border-2);border-radius:10px;padding:22px;text-align:center;
background:var(--bg-elev-1);transition:all .15s ease}
.drop.over{border-color:var(--accent);background:var(--accent-soft)}
.kv{display:flex;flex-wrap:wrap;gap:7px;margin-top:12px}
/* ---------- prompts ---------- */
.prompt-block{margin-bottom:16px}
.prompt-head{display:flex;align-items:center;gap:10px;margin-bottom:6px}
.prompt-head .grow{flex:1}
.warnchip{display:none;font-family:"JetBrains Mono",monospace;font-size:10px;color:var(--amber);
border:1px solid oklch(0.8 0.15 80 / 0.35);background:oklch(0.8 0.15 80 / 0.10);
padding:3px 8px;border-radius:6px;margin-top:6px}
.warnchip.show{display:inline-block}
.saved{font-size:10px;color:var(--green);opacity:0;transition:opacity .3s ease}
.saved.show{opacity:.85}
/* ---------- progress ---------- */
#progress-wrap{display:none;margin-top:14px}
#progress-wrap.show{display:block}
.progress-head{display:flex;justify-content:space-between;font-family:"JetBrains Mono",monospace;
font-size:10.5px;color:var(--text-tertiary);margin-bottom:6px}
.progress-track{height:1px;background:var(--border-1);overflow:hidden}
.progress-fill{height:100%;background:var(--accent);width:0%;transition:width .2s ease}
.progress-fill.done{background:var(--green)}
/* ---------- stats ---------- */
#stats-card{display:none}
#stats-card.show{display:block}
.stat-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media(max-width:820px){.stat-grid{grid-template-columns:1fr}}
.sub-card{background:var(--bg-elev-1);border:1px solid var(--border-1);border-radius:10px;padding:14px}
.sub-card>.nano{display:block;margin-bottom:10px}
.donut-wrap{display:flex;gap:14px;align-items:center;flex-wrap:wrap}
.legend{display:flex;flex-direction:column;gap:5px;font-size:11px}
.legend i{display:inline-block;width:9px;height:9px;border-radius:2px;margin-right:7px}
.hbar-row{display:grid;grid-template-columns:118px 1fr 34px;gap:9px;align-items:center;
font-size:11px;margin-bottom:6px}
.hbar-label{color:var(--text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.hbar-track{height:7px;background:var(--bg-elev-2);border-radius:4px;overflow:hidden}
.hbar-fill{height:100%;border-radius:4px;transition:width .3s ease}
.hbar-value{font-family:"JetBrains Mono",monospace;color:var(--text-tertiary);text-align:right}
/* ---------- results ---------- */
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:14px}
.res{display:grid;grid-template-columns:132px 1fr;gap:14px;padding:14px;margin-bottom:12px;
background:var(--bg-elev-1);border:1px solid var(--border-1);border-radius:10px}
@media(max-width:640px){.res{grid-template-columns:1fr}}
.res img{width:132px;height:132px;object-fit:cover;border-radius:8px;background:#000;
border:1px solid var(--border-2)}
.res h3{margin:0 0 3px;font-size:13.5px;font-weight:600}
.res .fname{font-family:"JetBrains Mono",monospace;font-size:10.5px;color:var(--text-quiet);
word-break:break-all;margin-bottom:8px}
.res p{margin:0 0 8px;font-size:12.5px;color:var(--text-secondary)}
.res p b{color:var(--text-primary);font-weight:600}
.badges{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:9px}
.validation-block{margin-top:14px;padding:12px 14px;border-radius:10px;border:1px solid var(--border-1);
background:oklch(0.95 0.005 280 / 0.03);border-left-width:3px}
.validation-block.ok{border-left-color:oklch(0.75 0.18 145 / 0.8)}
.validation-block.warn{border-left-color:oklch(0.8 0.15 80 / 0.8)}
.validation-block.danger{border-left-color:oklch(0.65 0.2 25 / 0.8)}
.validation-block.neutral{border-left-color:var(--text-quiet)}
.validation-block ul{margin:6px 0 0;padding-left:18px;font-size:12px;color:var(--text-secondary)}
/* ---------- log ---------- */
#loghead{display:flex;align-items:center;gap:10px;padding:8px 16px;border-bottom:1px solid var(--border-1)}
#logbody{flex:1;overflow-y:auto;padding:8px 16px 12px;font-family:"JetBrains Mono",monospace;
font-size:11px;line-height:1.62}
.lg{display:flex;gap:10px}
.lg .t{color:var(--text-quiet);flex:0 0 92px}
.lg.info .m{color:var(--blue)}
.lg.ok .m{color:var(--green)}
.lg.warn .m{color:var(--amber)}
.lg.err .m{color:var(--red)}
.lg.debug .m{color:var(--text-quiet)}
</style>
</head>
<body>
<div style="position:fixed;width:600px;height:600px;border-radius:50%;
background:radial-gradient(circle,oklch(0.4 0.18 300/.5),transparent 70%);
top:-200px;left:-100px;filter:blur(60px);pointer-events:none;z-index:0"></div>
<div style="position:fixed;width:700px;height:700px;border-radius:50%;
background:radial-gradient(circle,oklch(0.4 0.16 240/.4),transparent 70%);
bottom:-300px;right:-200px;filter:blur(80px);pointer-events:none;z-index:0"></div>
<div style="position:fixed;inset:0;opacity:0.03;pointer-events:none;z-index:0;
background-image:url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%22100%22 height=%22100%22><filter id=%22n%22><feTurbulence baseFrequency=%220.9%22/></filter><rect width=%22100%22 height=%22100%22 filter=%22url(%23n)%22/></svg>')"></div>
<div id="shell">
<div id="topbar">
<div class="brand">◈ Meme <span>Archivar</span></div>
<span class="pill mono" id="pill-model">gemini-3-flash-preview</span>
<span class="pill mono" id="pill-state">IDLE</span>
<span class="pill mono" id="pill-count">0 BILDER</span>
<span class="grow"></span>
<span class="pill mono" id="pill-build">v1.5.0</span>
</div>
<div id="mid">
<div id="rail">
<div class="rail-group">
<span class="nano">◉ Verbindung</span>
<div class="field">
<label for="apikey">Gemini API-Key</label>
<input type="password" id="apikey" placeholder="AIza…" autocomplete="off">
<div class="hint">Bleibt im Browser (localStorage), geht nur an Google.</div>
</div>
<div class="field">
<label for="model">Modell</label>
<select id="model">
<option value="gemini-3-flash-preview" selected>gemini-3-flash-preview (Free Tier)</option>
<option value="gemini-3.1-flash-lite-preview">gemini-3.1-flash-lite-preview (schnell)</option>
<option value="gemini-3.1-pro-preview">gemini-3.1-pro-preview (bestes Wissen, kostenpflichtig)</option>
</select>
</div>
</div>
<div class="rail-group">
<span class="nano">◇ Ausführung</span>
<div class="row2">
<div class="field">
<label for="concurrency">Parallel</label>
<input type="number" id="concurrency" value="4" min="1" max="16">
</div>
<div class="field">
<label for="retries">Retries</label>
<input type="number" id="retries" value="2" min="0" max="6">
</div>
</div>
<div class="field">
<label for="thinking">Thinking-Level</label>
<select id="thinking">
<option value="minimal">minimal</option>
<option value="low" selected>low</option>
<option value="medium">medium</option>
<option value="high">high</option>
</select>
</div>
<div class="field">
<label for="imgpx">Bildkante an Gemini (px)</label>
<input type="number" id="imgpx" value="768" min="256" max="1600" step="64">
<div class="hint">Verkleinert vor dem Senden. Spart Tokens, kostet bei Memes nichts.</div>
</div>
<div class="field">
<label for="limit">Nur die ersten N Bilder (0 = alle)</label>
<input type="number" id="limit" value="0" min="0">
</div>
<label class="check"><input type="checkbox" id="only-missing" checked>
Nur Bilder ohne Text analysieren</label>
<label class="check"><input type="checkbox" id="grounding">
Google-Suche zur Recherche</label>
<div class="hint">Genauere Datierung, aber langsamer und teurer. Für einen kuratierten
Teil sinnvoll, für 8.000 Bilder eher nicht.</div>
<label class="check" style="margin-top:8px"><input type="checkbox" id="makerchecker">
Maker-Checker (2. Prüf-Durchlauf)</label>
</div>
<div class="rail-group">
<span class="nano">▣ Galerie-Ausgabe</span>
<div class="field">
<label for="site-title">Titel der Seite</label>
<input type="text" id="site-title" value="The Meme Archive">
</div>
<div class="row2">
<div class="field">
<label for="thumbpx">Thumbnail px</label>
<input type="number" id="thumbpx" value="320" min="120" max="600" step="20">
</div>
<div class="field">
<label for="pagesize">Bilder/Seite</label>
<input type="number" id="pagesize" value="60" min="12" max="200">
</div>
</div>
<div class="field">
<label for="maxside">Originale verkleinern auf px (0 = aus)</label>
<input type="number" id="maxside" value="0" min="0" max="4000" step="100">
</div>
</div>
<div class="rail-group">
<span class="nano">⌕ Sitzung</span>
<button class="tiny ghost" id="btn-export-run" style="width:100%;margin-bottom:6px">⤓ Lauf als JSON sichern</button>
<button class="tiny ghost" id="btn-import-run" style="width:100%">↗ Lauf-JSON laden (Resume)</button>
<input type="file" id="import-file" accept=".json" style="display:none">
<div class="hint">Das JSON ist deine Sicherung. Texte kommen nach dem erneuten
Auswählen des Ordners per Hash wieder an die richtigen Bilder.</div>
</div>
</div>
<div id="splitter"></div>
<div id="main">
<div class="card">
<h2><span class="ic">◐</span> 1 · Bilder-Ordner</h2>
<p class="sub">Der Ordner wird nur im Browser gelesen. Unterordner werden mitgenommen,
Duplikate per SHA-256 erkannt.</p>
<div class="drop" id="drop">
<button class="primary" id="btn-pick">Ordner auswählen</button>
<input type="file" id="folder-input" webkitdirectory directory multiple style="display:none">
<div class="hint" style="margin-top:10px">
Alternativ Dateien hierher ziehen. Erkannt werden jpg, png, gif, webp, bmp, tif.
</div>
</div>
<div class="kv" id="input-summary"></div>
</div>
<div class="card">
<h2><span class="ic">✎</span> 2 · Prompts</h2>
<p class="sub">Beides geht wörtlich so an das Modell. Änderungen werden lokal gespeichert.</p>
<div class="prompt-block">
<div class="prompt-head">
<span class="nano">Maker-Prompt · Bildbeschreibung</span>
<span class="grow"></span>
<span class="saved" id="saved-maker">gespeichert</span>
<button class="tiny ghost" id="reset-maker">Reset</button>
</div>
<textarea id="p-maker" style="min-height:220px"></textarea>
<div class="warnchip" id="warn-maker">Platzhalter {filename} fehlt — wird beim Senden angehängt.</div>
</div>
<div class="prompt-block">
<div class="prompt-head">
<span class="nano">Checker-Prompt · Prüfung</span>
<span class="grow"></span>
<span class="saved" id="saved-checker">gespeichert</span>
<button class="tiny ghost" id="reset-checker">Reset</button>
</div>
<textarea id="p-checker" style="min-height:180px"></textarea>
<div class="warnchip" id="warn-checker">Platzhalter {pairs} fehlt — wird beim Senden angehängt.</div>
</div>
</div>
<div class="card">
<h2><span class="ic">▶</span> 3 · Analyse</h2>
<p class="sub">Ein Aufruf pro Bild. Ergebnisse erscheinen live, der Lauf ist jederzeit abbrechbar.</p>
<div class="toolbar">
<button class="primary" id="btn-run" disabled>▶ Texte erzeugen</button>
<button id="btn-validate" disabled>◬ Prüfdurchlauf</button>
<button class="danger" id="btn-cancel" style="display:none">■ Abbrechen</button>
</div>
<div id="progress-wrap">
<div class="progress-head"><span id="prog-label">bereit</span><span id="prog-num"></span></div>
<div class="progress-track"><div class="progress-fill" id="prog-fill"></div></div>
</div>
</div>
<div class="card" id="stats-card">
<h2><span class="ic">⬡</span> Verteilung</h2>
<p class="sub">Über alle fertigen Analysen.</p>
<div class="stat-grid" id="stat-grid"></div>
</div>
<div class="card">
<h2><span class="ic">▣</span> 4 · Galerie schreiben</h2>
<p class="sub">Erzeugt Thumbnails, kopiert die Bilder und schreibt eine fertige statische
Seite im Web-Look der 90er. Der Ordner geht anschließend 1:1 per SFTP hoch.</p>
<div class="toolbar">
<button class="primary" id="btn-build-dir" disabled>▣ In Zielordner schreiben</button>
<button id="btn-build-zip" disabled>⤓ Als ZIP herunterladen</button>
</div>
<div class="toolbar">
<button id="btn-refresh-dir" disabled>↻ Nur Seite + Texte aktualisieren</button>
<button class="tiny ghost" id="btn-dl-index">⤓ index.html einzeln</button>
<button class="tiny ghost" id="btn-dl-data" disabled>⤓ data.json einzeln</button>
</div>
<div class="hint">Der Zielordner funktioniert in Chrome und Edge und schreibt direkt auf
die Platte — für 2 GB der richtige Weg. Der ZIP-Download hält alles im
Arbeitsspeicher und ist nur für kleinere Bestände gedacht.
<br>„Nur Seite aktualisieren" schreibt index.html, data.json und die Nebendateien neu,
ohne die Bilder anzufassen — für neue Texte oder einen neuen Titel. Die beiden
Einzel-Downloads sind der Notausgang, falls der Browser beim Ordnerzugriff zickt:
Datei einfach per SFTP in den Galerie-Ordner legen.</div>
</div>
<div class="card">
<h2><span class="ic">◈</span> 5 · Ergebnisse</h2>
<div class="toolbar">
<select id="filter" style="width:auto;min-width:200px">
<option value="all">alle</option>
<option value="done">fertig</option>
<option value="pending">offen</option>
<option value="error">Fehler</option>
<option value="flagged">rechtlich prüfen</option>
<option value="issues">Prüfung beanstandet</option>
</select>
<input type="text" id="search" placeholder="suchen…" style="width:auto;flex:1;min-width:160px">
<button class="tiny ghost" id="btn-md">⤓ Markdown</button>
<button class="tiny ghost" id="btn-csv">⤓ CSV</button>
</div>
<div id="results"></div>
</div>
</div>
</div>
<div id="logcard">
<div id="loghead">
<span class="nano">⌕ Konsole</span>
<span class="pill mono" id="log-count">0</span>
<span class="grow"></span>
<label class="check" style="margin:0"><input type="checkbox" id="autoscroll" checked> autoscroll</label>
<button class="tiny ghost" id="btn-clearlog">leeren</button>
</div>
<div id="logbody"></div>
</div>
</div>
<script>
"use strict";
/* ============================================================ helpers */
const $ = id => document.getElementById(id);
const sleep = ms => new Promise(r => setTimeout(r, ms));
const esc = s => String(s == null ? "" : s).replace(/[&<>"]/g,
c => ({ "&":"&","<":"<",">":">","\"":""" }[c]));
const IMG_EXT = /\.(jpe?g|png|gif|webp|bmp|tiff?|jfif)$/i;
const ANIM_EXT = /\.(gif|webp)$/i;
function human(n){
const u = ["B","KB","MB","GB","TB"]; let i = 0;
while (n >= 1024 && i < u.length - 1) { n /= 1024; i++; }
return (i === 0 ? n.toFixed(0) : n.toFixed(1)) + " " + u[i];
}
const state = {
files: [], // {file, rel, name, dir, hash, size}
results: [], // {item, analysis, validation, error, validationError}
running: false,
cancel: false,
resumed: 0,
saved: new Map(), // hash -> {analysis, validation} aus geladenem Lauf-JSON
};
/* ============================================================ log */
const logbody = $("logbody");
let logN = 0;
const l = {
line(level, msg){
const now = new Date();
const t = now.toTimeString().slice(0,8) + "." +
String(now.getMilliseconds()).padStart(3,"0");
const d = document.createElement("div");
d.className = "lg " + level;
d.innerHTML = '<span class="t">' + t + '</span><span class="m">' + esc(msg) + '</span>';
logbody.appendChild(d);
logN++; $("log-count").textContent = logN;
if (logbody.children.length > 3000) logbody.removeChild(logbody.firstChild);
if ($("autoscroll").checked) logbody.scrollTop = logbody.scrollHeight;
},
info(m){ this.line("info", m); },
ok(m){ this.line("ok", m); },
warn(m){ this.line("warn", m); },
err(m){ this.line("err", m); },
debug(m){ this.line("debug", m); },
};
/* ============================================================ prompts */
const DEFAULT_MAKER_PROMPT =
`You are an internet historian and archivist specialising in the visual culture of the
early web (roughly 1993 to 2010): Usenet, IRC, GeoCities, eBaum's World, Something Awful,
4chan, YTMND, Newgrounds, early YouTube, German boards like Mediengestalter or Krautchan.
You are looking at ONE image from a private archive of old memes and funny pictures.
Write for a reader who was not there — someone born after 2005 who needs the joke and the
context explained without condescension.
Filename: {filename}
Folder: {folder}
Use the filename as a hint, never as a fact. Old archives are full of misleading names.
Produce:
1. title — a short, plain English title for the image (max 8 words). If the image IS a
known meme, use its established name (e.g. "All Your Base Are Belong To Us").
2. summary — one or two sentences describing literally what is visible.
3. explanation — 2 to 4 sentences: what the joke is, why people found it funny, what the
image was typically used to express in a conversation.
4. historical_context — 3 to 6 sentences: where it came from, roughly when it appeared,
which community or site spread it, what technology or event made it possible, and what
it says about the internet of that moment. Name concrete sites, games, films, or events
where you can.
5. known_meme_name — the canonical name if this is a documented meme, otherwise "".
6. origin_year — best estimate as a year or range, e.g. "1999" or "2003-2005", or "unknown".
7. era — the bucket the image most likely belongs to.
8. category — the visual form of the image.
9. confidence — how sure you are of the identification and dating.
10. content_flags — legal and safety review flags. Be strict and literal here; this list is
used to decide what a human must look at before publishing. Use "none" only when no
other flag applies.
RULES
- Write everything in English, plain and concrete. No marketing tone, no "in today's
digital landscape". Short sentences.
- Never invent a specific origin you are not reasonably sure of. If you do not recognise
the image, say so in the explanation, set known_meme_name to "", origin_year to
"unknown", and confidence to "low". A truthful "this appears to be an unremarkable
photoshop from an unknown forum" is far more useful than an invented backstory.
- Describe offensive content factually and flag it. Do not reproduce slurs; refer to them.
- Do not moralise. The archive documents what people actually posted, including material
that has aged badly. Explaining why something was considered funny in 2002 is not
endorsing it.`;
const DEFAULT_CHECKER_PROMPT =
`You are a fact-checking editor reviewing an internet historian's work before publication.
You receive image analyses (you cannot see the images themselves, only the filenames and
the written analysis). Audit each one for claims that are likely wrong.
Look specifically for:
- Invented origin stories. A confident specific claim ("created by user X on Something
Awful in March 2001") for an image that is probably unidentifiable is the single most
common failure. Flag it.
- Dating that contradicts itself or the described technology (a smartphone screenshot
dated 2001, a meme dated before the site that hosted it existed).
- A known_meme_name that does not match the described content.
- Confidence that is out of line with the evidence: a detailed origin story paired with
"high" confidence but no identifiable meme, or a well-known meme marked "low".
- content_flags that look incomplete given the description — especially identifiable
people, and material that would be illegal to publish in Germany.
Be precise and sparing. If an analysis is sound, say so with verdict "confirmed" and an
empty issues list. Do not invent problems to look thorough. Use "uncertain" when you
genuinely cannot judge without seeing the image.
Analyses to audit:
{pairs}`;
/* ============================================================ schemas */
const ERA = ["pre-1995","1995-1999","2000-2004","2005-2009","2010-2014","2015+","unknown"];
const CATEGORY = ["image macro","reaction image","photoshop edit","drawing or webcomic",
"animated gif","screenshot","ascii or text","photograph","banner or advertisement","other"];
const FLAGS = ["none","identifiable_person","nazi_symbol","nudity","gore","slur",
"minor_depicted","copyrighted_character","other_legal_risk"];
const MAKER_SCHEMA = {
type: "object",
properties: {
title: { type: "string" },
summary: { type: "string" },
explanation: { type: "string" },
historical_context: { type: "string" },
known_meme_name: { type: "string" },
origin_year: { type: "string" },
era: { type: "string", enum: ERA },
category: { type: "string", enum: CATEGORY },
confidence: { type: "string", enum: ["high","medium","low"] },
content_flags: { type: "array", items: { type: "string", enum: FLAGS } },
},
required: ["title","summary","explanation","historical_context","era","category",
"confidence","content_flags"],
};
const VALIDATE_SCHEMA = {
type: "object",
properties: {
validations: {
type: "array",
items: {
type: "object",
properties: {
item_id: { type: "string" },
verdict: { type: "string",
enum: ["confirmed","minor_corrections","major_issues","incorrect","uncertain"] },
issues: { type: "array", items: { type: "string" } },
corrections: { type: "string" },
confidence_check: { type: "string", enum: ["appropriate","too_high","too_low"] },
reviewer_notes: { type: "string" },
},
required: ["item_id","verdict","issues","corrections","confidence_check","reviewer_notes"],
},
},
},
required: ["validations"],
};
/* ============================================================ colors */
const ERA_COLORS = {
"pre-1995":"oklch(0.55 0.02 280)", "1995-1999":"oklch(0.7 0.18 300)",
"2000-2004":"oklch(0.70 0.15 240)", "2005-2009":"oklch(0.75 0.18 145)",
"2010-2014":"oklch(0.80 0.15 80)", "2015+":"oklch(0.65 0.20 25)",
"unknown":"oklch(0.45 0.02 280)",
};
const CONF_COLORS = { high:"oklch(0.75 0.18 145)", medium:"oklch(0.80 0.15 80)",
low:"oklch(0.65 0.20 25)" };
const VALIDATION_COLORS = {
confirmed:"oklch(0.75 0.18 145)", minor_corrections:"oklch(0.80 0.15 80)",
major_issues:"oklch(0.65 0.20 50)", incorrect:"oklch(0.65 0.20 25)",
uncertain:"oklch(0.55 0.02 280)",
};
const FLAG_COLOR = "oklch(0.65 0.20 25)";
const PALETTE = ["oklch(0.7 0.18 300)","oklch(0.70 0.15 240)","oklch(0.75 0.18 145)",
"oklch(0.80 0.15 80)","oklch(0.65 0.20 25)","oklch(0.65 0.12 330)",
"oklch(0.60 0.10 200)","oklch(0.55 0.02 280)"];
/* ============================================================ persistence */
const LS = {
get(k, d){ try { const v = localStorage.getItem(k); return v === null ? d : v; }
catch(e){ return d; } },
set(k, v){ try { localStorage.setItem(k, v); } catch(e){} },
};
function initPrompt(id, defVal, lsKey, placeholder, warnId, savedId){
const ta = $(id);
ta.value = LS.get(lsKey, defVal);
const check = () => $(warnId).classList.toggle("show", !ta.value.includes(placeholder));
let timer = null;
ta.addEventListener("input", () => {
LS.set(lsKey, ta.value); check();
$(savedId).classList.add("show");
clearTimeout(timer); timer = setTimeout(() => $(savedId).classList.remove("show"), 1200);
});
check();
}
initPrompt("p-maker", DEFAULT_MAKER_PROMPT, "ma.maker", "{filename}", "warn-maker", "saved-maker");
initPrompt("p-checker", DEFAULT_CHECKER_PROMPT, "ma.checker", "{pairs}", "warn-checker", "saved-checker");
$("reset-maker").onclick = () => { $("p-maker").value = DEFAULT_MAKER_PROMPT;
LS.set("ma.maker", DEFAULT_MAKER_PROMPT); $("warn-maker").classList.remove("show");
l.info("Maker-Prompt zurückgesetzt"); };
$("reset-checker").onclick = () => { $("p-checker").value = DEFAULT_CHECKER_PROMPT;
LS.set("ma.checker", DEFAULT_CHECKER_PROMPT); $("warn-checker").classList.remove("show");
l.info("Checker-Prompt zurückgesetzt"); };
["apikey","model","concurrency","retries","thinking","imgpx","limit","site-title",
"thumbpx","pagesize","maxside"].forEach(id => {
const el = $(id);
el.value = LS.get("ma." + id, el.value);
el.addEventListener("input", () => LS.set("ma." + id, el.value));
el.addEventListener("change", () => LS.set("ma." + id, el.value));
});
["only-missing","grounding","makerchecker"].forEach(id => {
const el = $(id);
el.checked = LS.get("ma." + id, el.checked ? "1" : "0") === "1";
el.addEventListener("change", () => LS.set("ma." + id, el.checked ? "1" : "0"));
});
$("model").addEventListener("change", () => $("pill-model").textContent = $("model").value);
$("pill-model").textContent = $("model").value;
/* ============================================================ splitter */
(function(){
const rail = $("rail"), sp = $("splitter");
const w = parseInt(LS.get("ma.railw", "252"), 10);
if (w >= 200 && w <= 460) { rail.style.width = w + "px"; rail.style.flexBasis = w + "px"; }
let drag = false;
sp.addEventListener("mousedown", e => { drag = true; e.preventDefault();
document.body.style.cursor = "col-resize"; });
window.addEventListener("mousemove", e => {
if (!drag) return;
const nw = Math.min(460, Math.max(200, e.clientX));
rail.style.width = nw + "px"; rail.style.flexBasis = nw + "px";
});
window.addEventListener("mouseup", () => {
if (!drag) return; drag = false; document.body.style.cursor = "";
LS.set("ma.railw", String(parseInt(rail.style.width, 10) || 252));
});
})();
/* ============================================================ input */
async function sha256(buf){
const d = await crypto.subtle.digest("SHA-256", buf);
return Array.from(new Uint8Array(d)).map(b => b.toString(16).padStart(2,"0")).join("");
}
async function ingest(fileList){
const files = Array.from(fileList).filter(f => IMG_EXT.test(f.name));
if (!files.length) { l.err("Keine Bilddateien gefunden."); return; }
l.info("Ordner eingelesen: " + files.length + " Bilddateien, prüfe auf Duplikate…");
files.sort((a, b) => {
const pa = a.webkitRelativePath || a.name, pb = b.webkitRelativePath || b.name;
const da = (pa.match(/\//g) || []).length, db = (pb.match(/\//g) || []).length;
return da - db || pa.length - pb.length || pa.localeCompare(pb);
});
const seen = new Set();
const out = [];
let dupes = 0, bytes = 0;
for (let i = 0; i < files.length; i++) {
const f = files[i];
let hash;
try { hash = await sha256(await f.arrayBuffer()); }
catch (e) { l.err("Lesefehler " + f.name + ": " + e.message); continue; }
if (seen.has(hash)) { dupes++; continue; }
seen.add(hash);
let rel = f.webkitRelativePath || f.name;
const cut = rel.indexOf("/");
if (cut > -1) rel = rel.slice(cut + 1); // obersten Ordnernamen abschneiden
const dir = rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : "";
out.push({ file: f, rel, name: f.name, dir, hash, size: f.size });
bytes += f.size;
if (i % 200 === 0 && i) l.debug("… " + i + " von " + files.length + " gehasht");
}
state.files = out;
state.results = out.map(item => {
const prev = state.saved.get(item.hash);
return { item,
analysis: prev ? prev.analysis : null,
validation: prev ? prev.validation : null,
error: null, validationError: null };
});
const restored = state.results.filter(r => r.analysis).length;
if (restored) l.ok(restored + " Texte aus dem geladenen Lauf wieder zugeordnet");
l.ok("Bereit: " + out.length + " Bilder, " + human(bytes) + ", " + dupes + " Duplikate verworfen");
$("pill-count").textContent = out.length + " BILDER";
$("input-summary").innerHTML =
'<span class="pill">' + out.length + ' Bilder</span>' +
'<span class="pill">' + human(bytes) + '</span>' +
'<span class="pill">' + dupes + ' Duplikate verworfen</span>' +
(restored ? '<span class="pill on">' + restored + ' Texte aus Resume</span>' : '');
updateButtons(); renderResults(); renderStats();
}
$("btn-pick").onclick = () => $("folder-input").click();
$("folder-input").addEventListener("change", e => { if (e.target.files.length) ingest(e.target.files); });
const drop = $("drop");
["dragenter","dragover"].forEach(ev => drop.addEventListener(ev, e => {
e.preventDefault(); drop.classList.add("over"); }));
["dragleave","drop"].forEach(ev => drop.addEventListener(ev, e => {
e.preventDefault(); drop.classList.remove("over"); }));
drop.addEventListener("drop", e => { if (e.dataTransfer.files.length) ingest(e.dataTransfer.files); });
/* ============================================================ image scaling */
async function scaleToBlob(file, maxSide, type, quality){
let bmp;
try { bmp = await createImageBitmap(file); }
catch (e) { throw new Error("nicht dekodierbar: " + e.message); }
const scale = Math.min(1, maxSide / Math.max(bmp.width, bmp.height));
const w = Math.max(1, Math.round(bmp.width * scale));
const h = Math.max(1, Math.round(bmp.height * scale));
const cv = new OffscreenCanvas(w, h);
const ctx = cv.getContext("2d");
ctx.drawImage(bmp, 0, 0, w, h);
const blob = await cv.convertToBlob({ type, quality });
const dims = { w: bmp.width, h: bmp.height };
bmp.close();
return { blob, dims, out: { w, h } };
}
async function squareThumb(file, size, quality){
const bmp = await createImageBitmap(file);
const side = Math.min(bmp.width, bmp.height);
const sx = (bmp.width - side) / 2, sy = (bmp.height - side) / 2;
const cv = new OffscreenCanvas(size, size);
cv.getContext("2d").drawImage(bmp, sx, sy, side, side, 0, 0, size, size);
const blob = await cv.convertToBlob({ type: "image/webp", quality });
const dims = { w: bmp.width, h: bmp.height };
bmp.close();
return { blob, dims };
}
const blobToBase64 = blob => new Promise((res, rej) => {
const fr = new FileReader();
fr.onload = () => res(String(fr.result).split(",")[1]);
fr.onerror = () => rej(new Error("FileReader"));
fr.readAsDataURL(blob);
});
/* ============================================================ Gemini */
const stripFences = s => s.replace(/^\s*```(?:json)?/i, "").replace(/```\s*$/i, "").trim();
function extractJson(text){
const trim = String(text).trim();
try { return JSON.parse(trim); } catch(e){}
const stripped = stripFences(trim);
try { return JSON.parse(stripped); } catch(e){}
const s = stripped.indexOf("{"), e2 = stripped.lastIndexOf("}");
if (s >= 0 && e2 > s) { try { return JSON.parse(stripped.slice(s, e2 + 1)); } catch(e){} }
throw new Error("konnte kein JSON aus der Antwort lesen");
}
async function llmOnce(parts, schema){
const key = $("apikey").value.trim();
if (!key) throw new Error("kein API-Key eingetragen");
const model = $("model").value;
const grounding = $("grounding").checked;
const body = {
contents: [{ role: "user", parts }],
generationConfig: {
thinkingConfig: { thinkingLevel: $("thinking").value },
},
};
if (grounding) body.tools = [{ googleSearch: {} }];
else {
body.generationConfig.responseMimeType = "application/json";
body.generationConfig.responseJsonSchema = schema;
}
const res = await fetch(
"https://generativelanguage.googleapis.com/v1beta/models/" + model + ":generateContent",
{ method: "POST",
headers: { "Content-Type": "application/json", "x-goog-api-key": key },
body: JSON.stringify(body) });
if (!res.ok) {
let detail = "";
try { detail = (await res.text()).slice(0, 400); } catch(e){}
throw new Error("HTTP " + res.status + " " + detail);
}
const data = await res.json();
const cand = (data.candidates || [])[0];
if (!cand) throw new Error("keine Antwort (evtl. Safety-Filter)");
const text = (cand.content && cand.content.parts || []).map(p => p.text || "").join("\n");
if (!text.trim()) throw new Error("leere Antwort (finishReason: " + (cand.finishReason || "?") + ")");
return text;
}
async function llm(parts, schema, label){
const retries = Math.max(0, parseInt($("retries").value, 10) || 0);
let attempt = 0;
while (true) {
if (state.cancel) throw new Error("abgebrochen");
try {
const t0 = performance.now();
const text = await llmOnce(parts, schema);
l.debug(label + " ← " + (text.length / 1024).toFixed(1) + "kb in " +
Math.round(performance.now() - t0) + "ms");
return text;
} catch (e) {
attempt++;
if (attempt > retries || /abgebrochen|kein API-Key/.test(e.message)) throw e;
const wait = 500 * Math.pow(2, attempt - 1);
l.warn(label + " fehlgeschlagen (" + e.message.slice(0,160) + ") — Retry " +
attempt + "/" + retries + " in " + wait + "ms");
await sleep(wait);
}
}
}
async function runPool(tasks, limit, onProgress){
const results = new Array(tasks.length);
let done = 0, next = 0;
const workers = Array.from({ length: Math.min(limit, tasks.length) }, async () => {
while (next < tasks.length) {
const i = next++;
if (state.cancel) { results[i] = { cancelled: true }; done++; onProgress && onProgress(done, tasks.length); continue; }
try { results[i] = await tasks[i](); }
catch (e) { results[i] = { error: e }; }
done++; onProgress && onProgress(done, tasks.length);
}
});
await Promise.all(workers);
return results;
}
/* ============================================================ progress */
let hideTimer = null;
function showProgress(phase, done, total){
clearTimeout(hideTimer);
$("progress-wrap").classList.add("show");
$("prog-label").textContent = phase;
$("prog-num").textContent = done + " / " + total;
const pct = total ? (done / total) * 100 : 0;
$("prog-fill").style.width = pct + "%";
$("prog-fill").classList.toggle("done", done >= total && total > 0);
if (done >= total) hideTimer = setTimeout(() => $("progress-wrap").classList.remove("show"), 900);
}
function setRunning(on, phaseLabel){
state.running = on;
$("btn-cancel").style.display = on ? "" : "none";
$("pill-state").textContent = on ? phaseLabel : (state.resumed ?
"RESUMED · " + state.results.filter(r=>r.analysis).length + " ANALYSIERT · " +
state.results.filter(r=>r.validation).length + " GEPRÜFT" : "IDLE");
$("pill-state").classList.toggle("on", on);
updateButtons();
}
function updateButtons(){
const have = state.files.length > 0;
const analyzed = state.results.filter(r => r.analysis).length;
$("btn-run").disabled = !have || state.running;
$("btn-validate").disabled = !analyzed || state.running;
$("btn-build-dir").disabled = !have || state.running;
$("btn-build-zip").disabled = !have || state.running;
$("btn-refresh-dir").disabled = !have || state.running;
$("btn-dl-index").disabled = state.running;
$("btn-dl-data").disabled = state.running || !state.results.some(r => r.entry);
}
/* ============================================================ Maker */
function buildMakerPrompt(item){
let tpl = $("p-maker").value;
if (!tpl.trim()) tpl = DEFAULT_MAKER_PROMPT;
if (!tpl.includes("{filename}")) tpl += "\n\nFilename: {filename}";
if (!tpl.includes("{folder}")) tpl += "\nFolder: {folder}";
if ($("grounding").checked) {
tpl += "\n\nReturn ONLY a single JSON object with these keys: title, summary, " +
"explanation, historical_context, known_meme_name, origin_year, era (" + ERA.join(" | ") +
"), category (" + CATEGORY.join(" | ") + "), confidence (high | medium | low), " +
"content_flags (array from: " + FLAGS.join(" | ") + "). No markdown, no commentary.";
}
return tpl.replace("{filename}", item.name).replace("{folder}", item.dir || "(root)");
}
$("btn-run").onclick = async () => {
if (!$("apikey").value.trim()) { l.err("Bitte zuerst einen Gemini API-Key eintragen."); return; }
const onlyMissing = $("only-missing").checked;
const limit = parseInt($("limit").value, 10) || 0;
let idxs = state.results.map((r, i) => i).filter(i => !onlyMissing || !state.results[i].analysis);
if (limit > 0 && idxs.length > limit) {
l.warn("Begrenzung aktiv: nur die ersten " + limit + " von " + idxs.length +
" offenen Bildern werden analysiert");
idxs = idxs.slice(0, limit);
}
if (!idxs.length) { l.warn("Nichts zu tun — alle ausgewählten Bilder haben bereits einen Text."); return; }
state.cancel = false;
setRunning(true, "ANALYSE");
const conc = Math.max(1, parseInt($("concurrency").value, 10) || 4);
const px = Math.max(256, parseInt($("imgpx").value, 10) || 768);
l.info("Analyse startet: " + idxs.length + " Bilder, " + conc + " parallel, Modell " +
$("model").value + ", Grounding " + ($("grounding").checked ? "an" : "aus"));
const tasks = idxs.map((idx, n) => async () => {
const r = state.results[idx];
r.error = null;
const label = "[" + (n + 1) + "/" + idxs.length + "] " + r.item.name;
try {
const scaled = await scaleToBlob(r.item.file, px, "image/jpeg", 0.85);
const b64 = await blobToBase64(scaled.blob);
r.item.w = scaled.dims.w; r.item.h = scaled.dims.h;
const parts = [
{ inline_data: { mime_type: "image/jpeg", data: b64 } },
{ text: buildMakerPrompt(r.item) },
];
l.debug(label + " → " + human(scaled.blob.size) + " Bild");
const text = await llm(parts, MAKER_SCHEMA, label);
const obj = extractJson(text);
if (!obj.title) throw new Error("Antwort ohne title-Feld");
if (!Array.isArray(obj.content_flags)) obj.content_flags = [];
r.analysis = obj;
l.ok(label + " ✓ " + (obj.known_meme_name || obj.title) +
" · " + obj.era + " · " + obj.confidence);
} catch (e) {
r.error = e.message;
l.err(label + " ✗ " + e.message.slice(0, 240));
}
});
await runPool(tasks, conc, (d, t) => { showProgress("Bilder analysiert", d, t);
renderResults(); renderStats(); });
idxs.forEach(i => { const r = state.results[i];
if (!r.analysis && !r.error) r.error = "abgebrochen"; });
const ok = state.results.filter(r => r.analysis).length;
const bad = state.results.filter(r => r.error).length;
l.ok("Analyse fertig — " + ok + " mit Text, " + bad + " Fehler");
setRunning(false);
renderResults(); renderStats();
if ($("makerchecker").checked && ok && !state.cancel) {
l.info("Maker-Checker ist aktiv — starte Prüfdurchlauf");
await runValidation();
}
};
/* ============================================================ Checker */
function formatPairs(pairs){
return pairs.map((p, i) =>
"=== ITEM " + p.id + " ===\n" +
"Filename: " + p.item.name + "\n" +
"Folder: " + (p.item.dir || "(root)") + "\n\n" +
"ANALYSIS TO AUDIT:\n" + JSON.stringify(p.analysis, null, 1)
).join("\n\n");
}
function buildCheckerPrompt(pairs){
let tpl = $("p-checker").value;
if (!tpl.trim()) tpl = DEFAULT_CHECKER_PROMPT;
if (!tpl.includes("{pairs}")) tpl += "\n\nAnalyses to audit:\n\n{pairs}";
if ($("grounding").checked) {
tpl += "\n\nReturn ONLY a JSON object {\"validations\":[{item_id, verdict, issues, " +
"corrections, confidence_check, reviewer_notes}]} — verdict one of confirmed | " +
"minor_corrections | major_issues | incorrect | uncertain, confidence_check one of " +
"appropriate | too_high | too_low. No markdown.";
}
return tpl.replace("{pairs}", formatPairs(pairs));
}
async function runValidation(){
const idxs = state.results.map((r, i) => i).filter(i => state.results[i].analysis);
if (!idxs.length) { l.warn("Nichts zu prüfen."); return; }
idxs.forEach(i => { state.results[i].validation = null; state.results[i].validationError = null; });
state.cancel = false;
setRunning(true, "PRÜFUNG");
const conc = Math.max(1, parseInt($("concurrency").value, 10) || 4);
const CH = 6;
const chunks = [];
for (let i = 0; i < idxs.length; i += CH) chunks.push(idxs.slice(i, i + CH));