-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbig-diffr.html
More file actions
1932 lines (1633 loc) · 79.9 KB
/
big-diffr.html
File metadata and controls
1932 lines (1633 loc) · 79.9 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="en">
<head>
<!-- Michael Kupietz. demos@michaelkupietz.com
version history:
2025aug30 - first public demo posted.
todo: look for the near-duplicate functions on create and load by searching for "view diff" and consolidate into one function
-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Big Diffr</title>
<style>
:root {
--strikethrough-deleted: none; /* Default: no strikethrough */
--underline-inserted: none; /* Default: no underline */
}
.word-removed,
.diff-line-removed .diff-line-content .line-content {
text-decoration: var(--strikethrough-deleted);
}
.word-added,
.diff-line-added .diff-line-content .line-content {
text-decoration: var(--underline-inserted);
}
.leading-white-space {text-decoration: none;}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.notes-input::placeholder {
color: #ccc;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #f5f5f5;
padding: 20px;
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
overflow: clip; /* needs this for sticky on global actions */
}
.header {
background: #2563eb;
color: white;
padding: 20px;
text-align: center;
}
.floatright {
position:absolute;
top:4px;
right:4px;
}
.global-actions {
background: #f8fafc;
padding: 15px 20px;
border-bottom: 1px solid #e5e7eb;
display: flex;
gap: 10px;
justify-content: center;
flex-wrap: wrap;
align-items: center;
position: sticky;
top: 0;
z-index: 15;
}
.settings-panel {
background: #fef3c7;
border: 1px solid #fbbf24;
border-radius: 6px;
padding: 20px;
margin: 10px 20px;
display: none;
position:fixed;
top:5px;
left:5px;
z-index:20;
max-height:95vh;
overflow-y:auto;
width:98vw;
}
.settings-panel.open {
display: block;
}
.settings-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(50px /* 350px */, 1fr));
gap: 20px;
margin-top: 15px;
}
.setting-group {
background: white;
padding: 15px;
border-radius: 4px;
border: 1px solid #e5e7eb;
}
.setting-group h4 {
margin-bottom: 15px;
color: #374151;
font-size: 16px;
font-weight: 600;
}
.setting-item {
margin-bottom: 15px;
}
.setting-item:last-child {
margin-bottom: 0;
}
.setting-item label {
display: block;
font-size: 14px;
font-weight: 500;
color: #374151;
margin-bottom: 5px;
}
.setting-description {
font-size: 12px;
color: #6b7280;
margin-bottom: 8px;
line-height: 1.4;
}
.setting-controls {
display: flex;
align-items: center;
gap: 10px;
}
.setting-controls input[type="range"] {
flex: 1;
min-width: 120px;
}
.setting-controls input[type="number"] {
width: 60px;
padding: 4px 6px;
border: 1px solid #d1d5db;
border-radius: 3px;
font-size: 12px;
}
.setting-controls input[type="checkbox"] {
transform: scale(1.2);
}
.value-display {
font-size: 12px;
color: #6b7280;
min-width: 35px;
text-align: right;
font-weight: 600;
}
.version-section {
padding: 20px;
border-bottom: 1px solid #e5e7eb;
}
.version-section:last-child {
border-bottom: none;
}
.version-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.version-title {
font-size: 18px;
font-weight: 600;
color: #374151;
}
.version-actions {
display: flex;
gap: 10px;
}
.btn {
padding: 8px 16px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: background-color 0.2s;
display: flex;
align-items: center;
gap: 6px;
}
.btn-primary {
background: #2563eb;
color: white;
}
.btn-primary:hover {
background: #1d4ed8;
}
.btn-secondary {
background: #6b7280;
color: white;
}
.btn-secondary:hover {
background: #4b5563;
}
.btn-settings {
background: #059669;
color: white;
}
.btn-intro {
border-radius: 4px;
font-family: inherit;
font-size: 14px;
color:white;
background: #fe3038;}
.btn-intro:hover {background: #e02a28;
}
.btn-close {
background: transparent;
}
.btn-close:hover {
background: #f9dccc;
}
.btn-settings:hover {
background: #047857;
}
.btn-settings.active {
background: #dc2626;
}
.btn-danger {
background: #dc2626;
color: white;
}
.btn-danger:hover {
background: #b91c1c;
}
.notes-section {
margin-bottom: 15px;
}
.notes-section label {
display: block;
margin-bottom: 5px;
color: #374151;
font-weight: 500;
font-size: 14px;
}
.notes-input {
width: 100%;
padding: 10px;
border: 1px solid #d1d5db;
border-radius: 4px;
font-family: inherit;
font-size: 14px;
background: #fefce8;
border-color: #eab308;
height: calc(1.2em + 20px);
}
.notes-input:focus {
outline: none;
border-color: #ca8a04;
box-shadow: 0 0 0 1px #ca8a04;
}
.input-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
margin-bottom: 20px;
}
.input-section {
display: flex;
flex-direction: column;
}
.input-section h3 {
margin-bottom: 10px;
color: #374151;
font-weight: 600;
}
.text-input {
width: 100%;
height: 250px;
padding: 15px;
border: 2px solid #d1d5db;
border-radius: 6px;
font-family: 'Courier New', monospace;
font-size: 14px;
line-height: 1.5;
resize: vertical;
transition: border-color 0.2s;
}
.text-input:focus {
outline: none;
border-color: #2563eb;
}
.text-input[readonly] {
background: #f9fafb;
color: #6b7280;
}
.diff-details {
margin-top: 15px;
}
.diff-details:has(> .diff-output > .diff-header) > summary {
background: #f3f4ff;
color: #374151;
border: 1px solid #d1d5db;
}
.diff-details summary {
cursor: pointer;
padding: 10px;
background: #fafbfc;
border-radius: 4px;
font-weight: 600;
color: #ccc;
user-select: none;
}
.diff-details summary:hover {
background: #e5e7eb;
}
.diff-details[open] summary {
border-radius: 4px 4px 0 0;
border-bottom: 1px solid #d1d5db;
}
.diff-output {
background: #f9fafb;
border: 1px solid #d1d5db;
border-top: none;
border-radius: 0 0 4px 4px;
padding: 15px;
font-family: 'Courier New', monospace;
/* font-size: 14px; */
font-size: 13px;
/* line-height: 1.6; */
line-height: 1;
min-height: 100px;
white-space: pre-wrap;
word-wrap: break-word;
}
.diff-line {
/* margin: 4px 0; */
margin: 1px 0;
padding: 4px 12px;
position: relative;
padding-right: 30px;
}
.diff-line-added {
/* background-color: #dcfce7; */
background-color: #bafcd6;
padding: 4px 8px;
border-radius: 3px;
border-left: 4px solid #16a34a;
padding-right: 30px;
}
.diff-line-removed {
background-color: #fecaca;
padding: 4px 8px;
border-radius: 3px;
border-left: 4px solid #dc2626;
padding-right: 30px;
}
.diff-line-modified {
/* background-color: #f0f9ff; */
/* background-color: #fff9ee; */
/* background-color: #cceeff; eoeoff */
/* background-color: #e4edff; */
background-color: #ffffe4;
padding: 4px 8px;
border-radius: 3px;
/* border-left: 4px solid #3b82f6 */
/* border-left: 4px solid #f6bb3b; */
/* border-left: 4px solid #3bbbf6; */
border-left: 4px solid #f6bb3b;
padding-right: 30px;
}
.diff-prefix {
font-weight: bold;
margin-right: 8px;
display: inline-block;
min-width: 12px;
}
.diff-equal {color:#ccc;}
.diff-insert {color:#0c0;}
.diff-delete {color:#c00;}
.word-added {
/* background-color: #dcfce7; */
background-color: #bafcd6;
/* color: white; */
/* padding: 1px 4px; */
/* border-radius: 3px; */
/* font-weight: 600; */
}
.word-removed {
/* background-color: #fecaca; */
background-color: #fecaca;
/* color: white; */
/* padding: 1px 4px; */
/* border-radius: 3px; */
/* font-weight: 600; */
}
.diff-info-icon {
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
width: 16px;
height: 16px;
background: #6b7280;
color: white;
border-radius: 50%;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
opacity: 0.7;
z-index: 10;
}
.diff-info-icon:hover {
opacity: 1;
background: #374151;
}
.tooltip {
position: fixed;
background: #374151;
color: white;
padding: 8px 12px;
border-radius: 6px;
font-size: 11px;
line-height: 1.3;
z-index: 9999;
max-width: 300px;
white-space: normal;
display: none;
box-shadow: 0 4px 6px rgba(0,0,0,0.3);
pointer-events: none;
}
.tooltip.show {
display: block;
}
.empty-state {
color: #9ca3af;
font-style: italic;
text-align: center;
padding: 20px;
}
.no-changes {
color: #16a34a;
font-style: italic;
text-align: center;
padding: 20px;
}
.hidden-input {
position: absolute;
left: -9999px;
opacity: 0;
}
@media (max-width: 768px) {
.input-grid {
grid-template-columns: 1fr;
}
body {
padding: 10px;
}
.text-input {
height: 200px;
}
.global-actions {
flex-direction: column;
align-items: center;
}
.settings-grid {
grid-template-columns: 1fr;
}
}
.diff-line-numbers {
display: table-cell;
width: 1px;
padding: 0 8px 0 4px;
color: #999;
font-size: 0.9em;
text-align: right;
vertical-align: top;
white-space: nowrap;
user-select: none;
border-right: 1px solid #e0e0e0;
}
.left-num, .right-num {
display: inline-block;
width: 30px;
text-align: right;
}
.left-num:after {
content: " |";
color: #ccc;
}
.diff-line-content {
display: table-cell;
padding-left: 8px;
width: 100%;
vertical-align: top;
}
.diff-header {border-bottom:1px solid #333;font-size:.8em;font-family:'courier new',courier,mono;position:relative;font-weight:400;}
.diff-output {
display: table;
width: 100%;
}
/* Textarea line numbers */
.textarea-container {
position: relative;
display: flex;
}
.line-numbers {
position: absolute;
left: 0;
top: 0;
width: 40px;
padding: 8px 4px;
background: #f8f9fa;
border-right: 1px solid #e0e0e0;
color: #999;
font-family: monospace;
font-size: 0.9em;
line-height: 1.4;
text-align: right;
user-select: none;
pointer-events: none;
white-space: pre;
overflow: hidden;
}
.textarea-with-numbers {
padding-left: 50px !important;
margin: 0;
}
.container-unchanged > div:not(*:first-child):not(*:last-child):not(*:nth-child(2)) {
display: none;
}
.container-unchanged > div:nth-child(2):not(:last-child) > * {
opacity: 0;
}
.container-unchanged > div:nth-child(2):not(:last-child)::before {
content: "\22EE";
position: absolute;
width: 100%;
text-align: center;
margin-left: -12px;
font-weight: 900;
background: #ccc;
border-radius: 50%;
box-shadow: inset 2px 2px 4px #999;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Big Diffr</h1>
<p>Compare consecutive revisions with smart inline diffing - ignores whitespace and blank lines </p>
</div>
<div class="global-actions">
<button class="btn btn-settings" onclick="toggleSettings()" id="settingsBtn">⚙️ Settings</button>
<button class="btn btn-primary" onclick="saveState()">💾 Save Session</button>
<button class="btn btn-secondary" onclick="loadState()">📁 Load Session</button>
<button class="btn btn-secondary" onclick="sampleFileLoad(sampleData)">🎬 Load With Demo Data</button>
<!-- SPACER span style="display:inline-block;flex-grow:2"> </span -->
<button class="btn btn-secondary" onclick="toggleInstructions()">🕹 Instructions</button>
<input type="file" id="fileInput" class="hidden-input" accept=".json" onchange="handleFileLoad(event)">
</div>
<div class="settings-panel" id="instructionsPanel">
<button class="btn btn-close floatright" onclick="toggleInstructions()" id="instructionsClose">❌</button>
<h3 style="margin-bottom: 15px; color: #374151;display:inline-block">Big Diffr</h3> - quickly see the differences between many consecutive revisions of your text or code. <p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
The idea is, if you have an automated process, such as an LLM, working on your code, every time it spits out a new version, you can never be completely sure what changes it has actually made, unless you check the entire output line-by-line. This makes that easy</p> <p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">In fact, this tool was developed because I learned that the hard way: I used Anthropic's Claude to help add new features to existing code of mine, but I didn't discover until much later on that it had also silently changed or removed other important parts of my code, which weren't at all related to what I was using it to work on. </p>
<div style="margin: 15px; padding:15px; color: #6b7280; font-size: 14px; background:white;border:1px solid gray;"><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;"> <b style="color: #374151;display:inline">Quick Start, for people who just want to quickly demo this:</b></p>
<p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">1. Just hit the red ❌ at upper right to close this box</p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">2. click <button class="btn btn-secondary" style="display:inline-block;" onclick="sampleFileLoad(sampleData)">🎬 Load With Demo Data</button></p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">3. Click the various lines where it says <b>▶︎ View Differences</b> to see the differences between various successive versions of the sample data.</p> </div>
<details><summary> <h3 style="margin-bottom: 15px; color: #374151;display:inline">Detailed Instructions:</h3> (click to open)</summary>
<p style="margin-block: 15px; color: #6b7280; font-size: 14px;">Add your original code in the blank marked <b>Original Text
</b>, and the first revision in the blank marked <b>Version 1</b>. When both have been entered, you will see a <b>▶︎ View Differences</b> line below them... you can click on this to open the diff and see all the differences between them.</p> <p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">Also, your <b>Version 1</b> will automatically be added as the starting revision on a new line below, ready for you to paste in <b>Version 2</b> and see the further changes as you create more revisions. </p> <p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">This way, every time an LLM generates a new revision to your code, you can paste it in and easily see everything it changed—whether it made only the revisions it said it would, or also made other changes you didn't ask for.</p>
<h3 style="margin-bottom: 15px; color: #374151;">Customizing the settings:</h3>
<p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">On occasion, the diff algorithm will indicate minor changes showing an entire line removed and another entire line inserted, as follows: </p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
<span class="diff-line-removed"><span class="word-removed">- Here is one line, mostly the same as the other one.</span></span></p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
<span class="diff-line-added"><span class="word-added">+ Here is another line, mostly the same as the other one.</span></span></p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
I gave the algorithm the ability to decide, if two lines are similar enough, to compress the changes into a single line, as follows:</p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
<span class="diff-line-modified">± Here is <span class="word-removed">one</span><span class="word-added">another</span> line, mostly the same as the other one.</span></p><p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
Because there is no "one size fits all" way of doing this, you can see and tweak the parameters the algorithm uses to decide whether changes should be shown by removing and adding complete lines in their entirety, or inline in a single line, by hitting the <button class="btn btn-settings" onclick="toggleSettings()" style="display:inline-block" id="settingsBtn">⚙️ Settings</button>
button at top.</p>
<h3 style="margin-bottom: 15px; color: #374151;">Saving and Reloading Sessions:</h3>
<p style="margin-block: 15px; color: #6b7280; font-size: 14px;"> In case you need to interrupt your work, you can save or reloads the entire state of the app, including all currently entered revisions, with the <button class="btn btn-primary" style="display:inline-block">💾 Save Session</button> and <button class="btn btn-secondary" style="display:inline-block">📁 Load Session</button> buttons.</p>
</details>
</div>
<div class="settings-panel" id="settingsPanel">
<button class="btn btn-close floatright" onclick="toggleSettings()" id="settingsClose">❌</button>
<h3 style="margin-bottom: 15px; color: #374151;">Inline Diff Settings</h3>
<p style="margin-bottom: 15px; color: #6b7280; font-size: 14px;">
These settings control when changed lines are merged and displayed as a single line with<span class="word-added"> all</span><span class="word-removed"> changes</span><span class="word-added"> indicated</span><span class="word-removed"> inline</span> vs. shown separately as entire lines <span class="word-removed">- deleted</span> or <span class="word-added">+ inserted</span>. <strong>Hover your mouse on the <span class="diff-info-icon" style="position:static !important;display:inline-block;text-align;padding-inline: 4.5px;transform:none;">ℹ</span> icons</strong> on the right side of a diff line to see why it merged or not.
</p>
<div class="settings-grid">
<div class="setting-group">
<h4>Content Similarity</h4>
<div class="setting-item">
<label>Length similarity threshold</label>
<div class="setting-description">
How similar in length two lines must be to consider merging them. Lower values are more permissive. Set to 0% to ignore length differences entirely.
</div>
<div class="setting-controls">
<input type="range" id="lengthRatio" min="0" max="100" step="1" value="10" oninput="updateSetting('lengthRatio')">
<span class="value-display" id="lengthRatioValue">10%</span>
</div>
</div>
<div class="setting-item">
<label>Shared words requirement</label>
<div class="setting-description">
Minimum percentage of words that must be shared between lines. Lower values are more permissive. Set to 0% to merge lines even with no common words.
</div>
<div class="setting-controls">
<input type="range" id="wordSimilarity" min="0" max="100" step="1" value="5" oninput="updateSetting('wordSimilarity')">
<span class="value-display" id="wordSimilarityValue">5%</span>
</div>
</div>
<div class="setting-item">
<label>Character difference tolerance</label>
<div class="setting-description">
How different two lines can be character-wise and still merge. Higher values allow merging lines that look very different but have similar meaning (like "obj.method()" vs "object.method()").
</div>
<div class="setting-controls">
<input type="range" id="charDifference" min="0" max="100" step="1" value="95" oninput="updateSetting('charDifference')">
<span class="value-display" id="charDifferenceValue">95%</span>
</div>
</div>
</div>
<div class="setting-group">
<h4>Structure Matching (beta)</h4>
<div class="setting-item">
<label><input type="checkbox" id="prefixSuffixCheck" onchange="updateSetting('prefixSuffixCheck')"> Require similar beginnings or endings</label>
<div class="setting-description">
Lines must start similarly OR end similarly to be merged. Good for catching function calls with different parameters. Leave unchecked to be more permissive.
</div>
<!-- div class="setting-controls">
checkbox moved from here
</div -->
</div>
<div class="setting-item">
<label>Beginning similarity length</label>
<div class="setting-description">
How many characters from the start of lines to compare for structural similarity.
</div>
<div class="setting-controls">
<input type="number" id="prefixLength" min="0" max="1000" value="15" oninput="updateSetting('prefixLength')">
<span class="value-display">chars</span>
</div>
</div>
<div class="setting-item">
<label>Ending similarity length</label>
<div class="setting-description">
How many characters from the end of lines to compare for structural similarity.
</div>
<div class="setting-controls">
<input type="number" id="suffixLength" min="0" max="1000" value="10" oninput="updateSetting('suffixLength')">
<span class="value-display">chars</span>
</div>
</div>
</div>
<div class="setting-group">
<h4>Advanced Options (beta)</h4>
<div class="setting-item">
<label><input type="checkbox" id="patternCheck" onchange="updateSetting('patternCheck')"> Check abstract patterns</label>
<div class="setting-description">
Compare the overall structure of lines (ignoring specific words/numbers). Helps catch similar code patterns. More CPU intensive.
</div>
<!-- div class="setting-controls">
checkbox moved from here
</div -->
</div>
<div class="setting-item">
<label>Pattern fallback threshold</label>
<div class="setting-description">
When pattern matching is enabled, minimum word similarity required if patterns don't match exactly.
</div>
<div class="setting-controls">
<input type="range" id="fallbackThreshold" min="0" max="100" step="1" value="80" oninput="updateSetting('fallbackThreshold')">
<span class="value-display" id="fallbackThresholdValue">80%</span>
</div>
</div>
<div class="setting-item">
<label>Max highlighting groups</label>
<div class="setting-description">
Maximum number of insert/delete changes allowed to be merged and shown inline in a single line. Lines with more than this number of internal changes will always show as separate added/removed lines instead. Higher values allow more complex inline diffs (ie, harder to read).
</div>
<div class="setting-controls">
<input type="number" id="maxChangeGroups" min="0" max="1000" value="5" oninput="updateSetting('maxChangeGroups')">
<span class="value-display">groups</span>
</div>
</div>
</div>
</div> <div class="settings-grid"><div class="setting-group"><label>Visual Options: </label>
<input type="checkbox" id="strikethroughDeleted">
<span>Show <span class="word-removed" style="xtext-decoration:#900 line-through !important;">Strike-Through</span> on deleted text</span> <input type="checkbox" id="underlineInserted">
<span>Show <span class="word-added" style="xtext-decoration:#090 wavy underline !important;">Wavy Underline</span> on inserted text</span>
</div> </div>
</div>
<div id="versionsContainer">
<!-- Initial version will be added by JavaScript -->
</div>
</div>
<script>
let versionCounter = 1;
let versions = [];
let globalTooltip = null;
let isRestoringState = false;
let lastRenderedRow="";
// FIXED: Very loose defaults with full 0-100% range
let diffSettings = {
lengthRatio: 0.1, // 10%
prefixLength: 15,
suffixLength: 10,
wordSimilarity: 0.05, // 5%
charDifference: 0.95, // 95%
fallbackThreshold: 0.8,
maxChangeGroups: 5,
patternCheck: false,
prefixSuffixCheck: false
};
const sampleData = {
"timestamp": "2025-08-19T02:36:37.563Z",
"versionCounter": 4,
"versions": [
{
"id": 1,
"originalText": "function addDetailsPreview() {\n\nglobal $selectors;\n\nglobal $avoid;\n\n?> <script id=\"ktwp-details-excerpt\">\npgsql\n\n document.querySelectorAll('<?php echo $selectors; ?>').forEach(details => {\n // Get the summary element\n const summary = details.querySelectorAll('summary<?php echo ($avoid==''?'':(','.$avoid)); ?>');\n if (!summary) return;\n\n // Get all text content, excluding the summary\n let allText = Array.from(details.childNodes)\n // .filter(node => node !== summary) // Exclude summary\n .filter(node => !Array.from(summary).includes(node))\n .map(node => node.textContent || '')\n .join(' ')\n .trim();\n allText = allText.replace(/<\\!--.*?-->/g, \"\"); /* get rid of comments */\n // If there's text content, create and append the preview\n if (allText) {\n const preview = document.createElement('span');\n preview.className = 'detailspreview';\n // Limit to 250 characters and add ellipsis\n preview.textContent = (allText.length > 250 ? \n allText.substring(0, 247) + '...' : \n allText);\n details.querySelector('summary').appendChild(preview);\n\t\t\tdetails.querySelector('summary').classList.add('ktwp-details-preview-added-summary');\n\t\t\tdetails.classList.add('ktwp-details-preview-added');\n }\n });\n<\/script>\n\n<?php\n\n}",
"modifiedText": "function addDetailsPreview() {\nglobal $selectors;\nglobal $avoid;\n ?> <script id=\"ktwp-details-excerpt\">\n document.querySelectorAll('<?php echo $selectors; ?>').forEach(details => {\n // Get the summary element\n const summary = details.querySelector('summary');\n if (!summary) return;\n\n // Create a clone of the details element to work with\n const detailsClone = details.cloneNode(true);\n \n // Remove the summary from the clone\n const summaryClone = detailsClone.querySelector('summary');\n if (summaryClone) summaryClone.remove();\n \n // Remove elements matching the avoid selector\n <?php if ($avoid): ?>\n detailsClone.querySelectorAll('<?php echo $avoid; ?>').forEach(el => el.remove());\n <?php endif; ?>\n \n // Get the text content from the remaining elements\n let allText = detailsClone.textContent || '';\n allText = allText.replace(/\\s+/g, ' ').trim(); // Normalize whitespace\n\n // If there's text content, create and append the preview\n if (allText) {\n const preview = document.createElement('span');\n preview.className = 'detailspreview';\n // Limit to 250 characters and add ellipsis\n preview.textContent = (allText.length > 250 ? \n allText.substring(0, 247) + '...' : \n allText);\n summary.appendChild(preview);\n summary.classList.add('ktwp-details-preview-added-summary');\n details.classList.add('ktwp-details-preview-added');\n }\n });\n <\/script>\n<?php \n}",
"notes": "",
"isFirst": true
},
{
"id": 2,
"originalText": "function addDetailsPreview() {\nglobal $selectors;\nglobal $avoid;\n ?> <script id=\"ktwp-details-excerpt\">\n document.querySelectorAll('<?php echo $selectors; ?>').forEach(details => {\n // Get the summary element\n const summary = details.querySelector('summary');\n if (!summary) return;\n\n // Create a clone of the details element to work with\n const detailsClone = details.cloneNode(true);\n \n // Remove the summary from the clone\n const summaryClone = detailsClone.querySelector('summary');\n if (summaryClone) summaryClone.remove();\n \n // Remove elements matching the avoid selector\n <?php if ($avoid): ?>\n detailsClone.querySelectorAll('<?php echo $avoid; ?>').forEach(el => el.remove());\n <?php endif; ?>\n \n // Get the text content from the remaining elements\n let allText = detailsClone.textContent || '';\n allText = allText.replace(/\\s+/g, ' ').trim(); // Normalize whitespace\n\n // If there's text content, create and append the preview\n if (allText) {\n const preview = document.createElement('span');\n preview.className = 'detailspreview';\n // Limit to 250 characters and add ellipsis\n preview.textContent = (allText.length > 250 ? \n allText.substring(0, 247) + '...' : \n allText);\n summary.appendChild(preview);\n summary.classList.add('ktwp-details-preview-added-summary');\n details.classList.add('ktwp-details-preview-added');\n }\n });\n <\/script>\n<?php \n}",
"modifiedText": "function addDetailsPreview() {\nglobal $selectors;\nglobal $avoid;\n ?> <script id=\"ktwp-details-excerpt\">\n function generatePreviews() {\n // This will find ALL details elements matching your selector\n document.querySelectorAll('<?php echo $selectors; ?>').forEach(details => {\n // Skip if already processed - prevents duplicate previews\n if (details.classList.contains('ktwp-details-preview-added')) return;\n \n const summary = details.querySelector('summary');\n if (!summary) return;\n\n const detailsClone = details.cloneNode(true);\n const summaryClone = detailsClone.querySelector('summary');\n if (summaryClone) summaryClone.remove();\n \n <?php if ($avoid): ?>\n detailsClone.querySelectorAll('<?php echo $avoid; ?>').forEach(el => el.remove());\n <?php endif; ?>\n \n let allText = detailsClone.textContent || '';\n allText = allText.replace(/\\s+/g, ' ').trim();\n\n if (allText) {\n const preview = document.createElement('span');\n preview.className = 'detailspreview';\n preview.textContent = (allText.length > 250 ? \n allText.substring(0, 247) + '...' : \n allText);\n summary.appendChild(preview);\n summary.classList.add('ktwp-details-preview-added-summary');\n details.classList.add('ktwp-details-preview-added'); // This prevents re-processing\n }\n });\n }\n\n // Process any existing content immediately\n generatePreviews();\n\n // Watch for new content being added to ANY part of the page\n const observer = new MutationObserver(() => {\n generatePreviews(); // Will check all details elements, but only process new ones\n });\n\n observer.observe(document.body, {\n childList: true, // Watch for new elements being added\n subtree: true // Watch the entire document tree\n });\n <\/script>\n<?php \n}",
"notes": "",
"isFirst": false
},
{
"id": 3,
"originalText": "function addDetailsPreview() {\nglobal $selectors;\nglobal $avoid;\n ?> <script id=\"ktwp-details-excerpt\">\n function generatePreviews() {\n // This will find ALL details elements matching your selector\n document.querySelectorAll('<?php echo $selectors; ?>').forEach(details => {\n // Skip if already processed - prevents duplicate previews\n if (details.classList.contains('ktwp-details-preview-added')) return;\n \n const summary = details.querySelector('summary');\n if (!summary) return;\n\n const detailsClone = details.cloneNode(true);\n const summaryClone = detailsClone.querySelector('summary');\n if (summaryClone) summaryClone.remove();\n \n <?php if ($avoid): ?>\n detailsClone.querySelectorAll('<?php echo $avoid; ?>').forEach(el => el.remove());\n <?php endif; ?>\n \n let allText = detailsClone.textContent || '';\n allText = allText.replace(/\\s+/g, ' ').trim();\n\n if (allText) {\n const preview = document.createElement('span');\n preview.className = 'detailspreview';\n preview.textContent = (allText.length > 250 ? \n allText.substring(0, 247) + '...' : \n allText);\n summary.appendChild(preview);\n summary.classList.add('ktwp-details-preview-added-summary');\n details.classList.add('ktwp-details-preview-added'); // This prevents re-processing\n }\n });\n }\n\n // Process any existing content immediately\n generatePreviews();\n\n // Watch for new content being added to ANY part of the page\n const observer = new MutationObserver(() => {\n generatePreviews(); // Will check all details elements, but only process new ones\n });\n\n observer.observe(document.body, {\n childList: true, // Watch for new elements being added\n subtree: true // Watch the entire document tree\n });\n <\/script>\n<?php \n}",
"modifiedText": "",
"notes": "",
"isFirst": false
}
]
};
/* beginning strikethrough */
// Get the strikethrough checkbox
const strikethroughCheckbox = document.getElementById('strikethroughDeleted');
function applyStrikethroughSetting() {
const isEnabled = strikethroughCheckbox.checked;
// Set the CSS variable
document.documentElement.style.setProperty(
'--strikethrough-deleted',
isEnabled ? '#900 line-through' : 'none'
);
// Save to localStorage
localStorage.setItem('strikethroughDeleted', isEnabled);
}
// Load saved setting on page load
const savedStrikethrough = localStorage.getItem('strikethroughDeleted');
if (savedStrikethrough !== null) {
strikethroughCheckbox.checked = savedStrikethrough === 'true';
} else {
// Default to checked if no saved setting
strikethroughCheckbox.checked = false;
}
// Apply the initial setting
applyStrikethroughSetting();
// Listen for checkbox changes
strikethroughCheckbox.addEventListener('change', applyStrikethroughSetting);
/* done with strikethrough */
/* beginning inserting underline */
// Get the underline checkbox
const underlineCheckbox = document.getElementById('underlineInserted');
function applyunderlineSetting() {
const isEnabled = underlineCheckbox.checked;
// Set the CSS variable
document.documentElement.style.setProperty(
'--underline-inserted',
isEnabled ? '#090 wavy underline' : 'none'
);
// Save to localStorage
localStorage.setItem('underlineInserted', isEnabled);
}
// Load saved setting on page load
const savedunderline = localStorage.getItem('underlineInserted');
if (savedunderline !== null) {
underlineCheckbox.checked = savedunderline === 'true';
} else {
// Default to checked if no saved setting
underlineCheckbox.checked = false;
}
// Apply the initial setting
applyunderlineSetting();
// Listen for checkbox changes
underlineCheckbox.addEventListener('change', applyunderlineSetting);
/* done with insertion underlline */
function toggleSettings() {
const panel = document.getElementById('settingsPanel');
const btn = document.getElementById('settingsBtn');
if (panel.classList.contains('open')) {
panel.classList.remove('open');
btn.classList.remove('active');
btn.innerHTML = '⚙️ Settings';
} else {
panel.classList.add('open');
btn.classList.add('active');
btn.innerHTML = '❌ Close Settings';
}
}
function toggleInstructions() {
const panel = document.getElementById('instructionsPanel');
const btn = document.getElementById('instructionsBtn');
if (panel.classList.contains('open')) {
panel.classList.remove('open');
btn.classList.remove('active');
btn.innerHTML = '⚙️ Settings';
} else {
panel.classList.add('open');
btn.classList.add('active');
btn.innerHTML = '❌ Close Instructions';
}
}
// FIXED: Handle 0-100 range and actually recalculate
function updateSetting(settingName) {
const element = document.getElementById(settingName);
let value;
if (element.type === 'checkbox') {
value = element.checked;
} else if (element.type === 'number') {
value = parseInt(element.value);
} else {
// Convert 0-100 slider to 0-1 decimal
value = parseFloat(element.value) / 100;
}
diffSettings[settingName] = value;
console.log(`${settingName} changed to ${value} (${Math.round(value*100)}%)`);
// Update display
if (element.type === 'range') {
const displayElement = document.getElementById(settingName + 'Value');
if (displayElement) {
displayElement.textContent = element.value + '%';
}
}
// Force recalculation
versions.forEach((version, index) => {
updateDiff(index);
});
}
// FIXED: Tooltip functions with debug
function showTooltip(event, content) {
console.log('Showing tooltip');
if (!globalTooltip) {
globalTooltip = document.createElement('div');
globalTooltip.className = 'tooltip';
document.body.appendChild(globalTooltip);
}