-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathECCM.html
More file actions
3526 lines (3037 loc) · 129 KB
/
Copy pathECCM.html
File metadata and controls
3526 lines (3037 loc) · 129 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>
<link type="image/png" sizes="32x32" rel="icon" href="https://img.icons8.com/stickers/32/ethernet-on.png">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ethernet Cable Connection Manager</title>
<style>
:root{--bg:#0f1115;--panel:#171a21;--ink:#e8eaf1;--paper: #0E1117;--muted:#a6adbb;--line:#262a33;--prtPortH: 75px;--portGapFull:9px;--portGapHalf:8px;--portW12:60px;--portW6:60px;--reserved-bg:#555;--elm-page-bg-dark:#0f172a;--elm-page-bg-bright:#ffffff}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}
*,*::before,*::after{box-sizing:border-box}
header{padding:14px 18px;border-bottom:1px solid var(--line);display:flex;align-items:center;gap:12px;flex-wrap:wrap;background:linear-gradient(180deg,#12151b,#10131a)}
header h1{font-size:18px;margin:0;font-weight:650}
.badge{color:var(--muted);font-size:12px;border:1px solid var(--line);padding:2px 8px;border-radius:999px}
.wrap{position:relative;display:grid;grid-template-columns:340px 1fr;gap:0;height:calc(100% - 62px)}
@media (max-width:1024px){.wrap{grid-template-columns:1fr;height:auto}}
aside,main{padding:16px}
aside{border-right:1px solid var(--line);background:var(--panel)}
main{overflow:auto;position:relative}
.card{background:#141821;border:1px solid var(--line);border-radius:10px;padding:12px;margin-bottom:12px}
.card h3{margin:0 0 8px 0;font-size:14px;font-weight:650}
label{display:block;font-size:12px;color:var(--muted);margin:8px 0 4px}
.muted{color:var(--muted)}.small{font-size:12px}
.mini{padding:4px 8px;font-size:12px;border-radius:6px}
.setting-row{display:flex;align-items:center;justify-content:space-between;gap:.75rem;margin:.5rem 0}
.setting-row select{padding:.35rem .5rem;border-radius:.5rem}
input[type=text],input[type=number],select{width:100%;max-width:100%;background:#0f131b;color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:8px 10px;outline:none}
button,.btn{background:#11151d;color:var(--ink);border:1px solid var(--line);padding:8px 10px;border-radius:8px;cursor:pointer;font-weight:600}
button:hover{border-color:#2a2f3b}
.btn-danger{border-color:#3b2222}
.dev-rows{display:flex;flex-direction:column;gap:12px}
.dev-row {
display: grid;
grid-template-columns: repeat(4, minmax(0,1fr));
gap: 12px;
}
.device-wrap{display:block;width:100%}
.device-wrap.full{grid-column:1/-1}
.device-wrap.half {grid-column: span 2}
.device-wrap.quarter {grid-column: span 1;--portW6: 109px;}
.device{background:#131722;border:1px solid var(--line);border-radius:12px;padding:12px;position:relative;width:100%;box-shadow: inset 0 0 0 2px var(--device-border, transparent);}
.device-head{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.device-title{font-size:15px;font-weight:650;display:flex;align-items:center;gap:8px}
.swatch{width:12px;height:12px;border-radius:3px;border:1px solid #0006;display:inline-block}
.device-actions{display:flex;gap:6px;flex-wrap:wrap}
.meta{font-size:12px;color:var(--muted);margin-top:2px}
.meta .inline-controls{margin-left:8px;display:inline-flex;gap:6px}
.ports-rows{display:flex;flex-direction:column;gap:8px;margin-top:10px}
.port-row{display:grid;gap:var(--portGapHalf)}
.port{height: var(--prtPortH) !important;position:relative;border:1px solid var(--line);background:#0f141d;border-radius:10px;padding:4px 6px 6px;cursor:pointer;text-align:center;user-select:none;transition:background .12s}
.port .num{font-size:12px;margin-top:2px;min-height:1.4em}
.port .alias{font-size:12px;margin-top:2px;min-height:1.4em; white-space: nowrap; overflow: hidden; text-align: center; max-width: 100%; }
.port .peer{margin-top:2px;font-size:12px;font-weight:700;min-height:1.4em;white-space: nowrap; overflow: hidden; text-align: center; max-width: 100%;}
.port.selected{}
.port:not(.connected):not(.reserved) .num,.port:not(.connected):not(.reserved) .alias,.port:not(.connected):not(.reserved) .peer{color:#fff}
.port.reserved .num,.port.reserved .alias,.port.reserved .peer{color:#fff!important}
.port .num{ display:inline-flex; align-items:center; justify-content:center; gap:4px; line-height:1;}
.port .num .num-label{ line-height:1; }
.port .ind{ width:5px; height:5px; display:inline-block; border-radius:1px; background: currentColor; opacity:.9; line-height:0; flex:0 0 auto; vertical-align:middle;}
/* Slow link indicator: red cross in a small square */
.port .ind.ind--slow{
width:10px;
height:10px;
border-radius:2px;
background:#ffffff; /* dark theme: white */
color:#e11; /* red cross */
display:inline-flex;
align-items:center;
justify-content:center;
font-size:8px;
font-weight:700;
}
/* Bright theme: red on black */
html.theme-bright .port .ind.ind--slow{
background:#000000;
color:#e11;
}
.slow-warn{
font-size:10px;
line-height:1;
display:inline-block;
vertical-align:middle;
}
.port .ind.vlan-diamond{ transform: rotate(45deg); }
.port .ind.ind--off{ opacity:0; pointer-events:none; }
html.theme-bright .port .ind{ opacity:.8; }
.grid-slim{width:100%;border-collapse:collapse;border:1px solid var(--line);border-radius:8px;overflow:hidden;table-layout:fixed}
.grid-slim th,.grid-slim td{font-size:13px;text-align:left;padding:8px 10px;border-bottom:1px solid var(--line);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.grid-slim th{background:#121722;color:var(--muted);font-weight:600}
.conn-row.highlight td{background:#1e293b }
.conn-row td.deviceA .devName,.conn-row td.deviceB .devName{color:#fff;font-weight:400}
.conn-row.highlight td.deviceA .devName,.conn-row.highlight td.deviceB .devName{color:var(--devColor);font-weight:700}
.conn-row.reserved-row td{background:#121622}
.conn-row.reserved-row:hover td{background:#151b2a}
.color-picker-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.swatch-lg{width:24px;height:24px;border-radius:6px;border:1px solid #0006;display:inline-block}
.color-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;background:#0f141d;border:1px solid var(--line);border-radius:8px;cursor:pointer;font-weight:600;color:var(--ink)}
.color-btn:hover{border-color:#2a2f3b}
.palette-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.5);display:none;align-items:center;justify-content:center;z-index:999}
.palette{background:#141821;border:1px solid var(--line);border-radius:12px;padding:12px;min-width:280px;max-width:90vw}
.palette h4{margin:0 0 10px 0;font-size:14px}
.palette-grid{display:grid;grid-template-columns:repeat(4,36px);gap:8px;justify-content:center}
.chip{width:36px;height:36px;border-radius:8px;border:1px solid rgba(0,0,0,.35);cursor:pointer}
.palette .actions{display:flex;justify-content:flex-end;margin-top:12px}
.modal-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.5);display:none;align-items:center;justify-content:center;z-index:60}
.modal{background:#141821;border:1px solid var(--line);border-radius:12px;padding:14px;min-width:300px;max-width:90vw}
.modal h4{margin:0 0 10px 0;font-size:14px}
.modal .row{display:flex;gap:8px;align-items:center;margin:6px 0}
.modal label{margin:0;color:var(--ink);font-size:13px}
.modal select{background:#0f131b;color:var(--ink);border:1px solid var(--line);border-radius:8px;padding:6px 10px}
.modal .actions{display:flex;gap:8px;justify-content:flex-end;margin-top:12px}
html.theme-bright body,html.theme-bright .card,html.theme-bright aside,html.theme-bright main,html.theme-bright #settingsPanel{background:#fff!important;color:#111!important;border-color:#ccc!important;--muted: #222; --paper: #fff}
html.theme-bright header{background:#fff!important;border-bottom:1px solid #e5e7eb!important;color:#111!important}
html.theme-bright header h1{color:#111!important}
html.theme-bright header .badge{background:#fff!important;color:#444!important;border-color:#e0e6ef!important}
html.theme-bright header button,html.theme-bright header .btn,html.theme-bright header select{background:#fff!important;color:#111!important;border:1px solid #d8dee8!important}
html.theme-bright header button:hover,html.theme-bright header .btn:hover{border-color:#9aa4b2!important}
html.theme-bright .device{background:#fff!important;border-color:#ccc!important}
html.theme-bright .port:not(.connected):not(.reserved){background:#fff!important;color:#000!important}
html.theme-bright .port:not(.connected):not(.reserved) .num,html.theme-bright .port:not(.connected):not(.reserved) .alias,html.theme-bright .port:not(.connected):not(.reserved) .peer{color:#000!important}
html.theme-bright .port.selected{}
html.theme-bright .port.reserved{background:#555!important;color:#fff!important}
html.theme-bright button:not(.chip),html.theme-bright .btn,html.theme-bright input[type="text"],html.theme-bright input[type="number"],html.theme-bright select{background:#fff!important;color:#111!important;border:1px solid #ccc!important}
html.theme-bright button:not(.chip):hover,html.theme-bright .btn:hover{border-color:#888!important}
html.theme-bright .grid-slim th{background:#f6f7f9!important;color:#111!important;border-color:#ccc!important}
html.theme-bright .grid-slim td{background:#fff!important;color:#111!important;border-color:#ddd!important}
html.theme-bright .conn-row.highlight td{background:#e8f0fe!important;color:#000!important}
html.theme-bright .conn-row.reserved-row td{background:#f1f1f1!important;color:#000!important}
html.theme-bright .conn-row.reserved-row:hover td{background:#e0e0e0!important}
html.theme-bright .conn-row td.deviceA .devName,html.theme-bright .conn-row td.deviceB .devName{color:#000!important;font-weight:400}
html.theme-bright .conn-row.highlight td.deviceA .devName,html.theme-bright .conn-row.highlight td.deviceB .devName{color:var(--devColor)!important;font-weight:700}
html.theme-bright .palette{background:#fff!important;border-color:#ccc!important;color:#000!important}
html.theme-bright .palette h4{color:#000!important}
html.theme-bright .palette .chip{border:1px solid rgba(0,0,0,.4)}
html.theme-bright .modal{background:#fff!important;border:1px solid #ccc!important;color:#111!important}
html.theme-bright .modal h4,html.theme-bright .modal label{color:#111!important}
html.theme-bright .modal select{background:#fff!important;color:#111!important;border:1px solid #ccc!important}
.theme-toggle{display:inline-flex;border-radius:10px;overflow:hidden}
.theme-toggle button{padding:6px 12px;border:1px solid var(--line);background:#11151d;color:var(--ink);cursor:pointer;font-weight:600;line-height:1;border-right:none}
.theme-toggle button:first-child{border-top-left-radius:10px;border-bottom-left-radius:10px}
.theme-toggle button:last-child{border-right:1px solid var(--line);border-top-right-radius:10px;border-bottom-right-radius:10px}
.theme-toggle button.active{box-shadow:inset 0 0 0 2px #e5e7eb}
html.theme-bright .theme-toggle button{background:#fff;color:#111;border-color:#ccc}
html.theme-bright .theme-toggle button:last-child{border-right-color:#ccc}
html.theme-bright .theme-toggle button.active{box-shadow:inset 0 0 0 2px #000}
main::-webkit-scrollbar{width:10px}
main::-webkit-scrollbar-track{background:var(--panel)}
main::-webkit-scrollbar-thumb{background-color:#555;border-radius:6px;border:2px solid var(--panel)}
main::-webkit-scrollbar-thumb:hover{background-color:#777}
main{scrollbar-width:thin;scrollbar-color:#555 var(--panel)}
html.theme-bright main::-webkit-scrollbar-track{background:#fff!important}
html.theme-bright main::-webkit-scrollbar-thumb{background-color:#bbb!important;border:2px solid #fff!important}
html.theme-bright main::-webkit-scrollbar-thumb:hover{background-color:#999!important}
html.theme-bright main{scrollbar-color:#bbb #fff!important}
:root{ --hover-bg: #141821; --hover-border: #2b3140; --hover-ink: #e8eaf1;}
html.theme-bright{ --hover-bg: #fffffe; --hover-border: #cfd6e4; --hover-ink: #111;}
.hovercard{ position: fixed; z-index: 9999; display: none; min-width: 220px; max-width: 320px; padding: 8px 10px; font-size: 12px; line-height: 1.3; color: var(--hover-ink); background: var(--hover-bg); border: 1px solid var(--hover-border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); pointer-events: none; white-space: nowrap;}
.hovercard .hc-title{ font-weight: 700; margin-bottom: 4px; }
.hovercard .hc-row{ display:flex; gap:8px; }
.hovercard .hc-k{ color: var(--muted); min-width: 72px; }
.port .spd{ display:inline-block; margin-left:6px; padding:1px 6px; font-size:10px; line-height:1.3; border:1px solid var(--line); border-radius:999px; color: var(--muted); vertical-align:middle;}
.speed-menu{ position: fixed; z-index: 9999; background:#141821; color:#e8eaf1; border:1px solid var(--line); border-radius:8px; padding:6px; box-shadow: 0 8px 24px rgba(0,0,0,.35);}
.speed-menu select{ background:#0f131b; color:#e8eaf1; border:1px solid var(--line); border-radius:6px; padding:6px 8px; font-size:12px;}
html.theme-bright .speed-menu{ background:#fff; color:#111; border-color:#ccc;}
html.theme-bright .speed-menu select{ background:#fff; color:#111; border-color:#ccc;}
.slideover{ position: fixed; inset: 0; z-index: var(--z-overlay, 5000); display: none; font: inherit; color: var(--ink);}
.slideover.is-open{ display:block; }
.slideover__backdrop{ position: absolute; inset: 0; background: var(--overlay, rgba(0,0,0,.35)); /* follows page; override if you have a var */ opacity: 0; transition: opacity .2s ease;}
.slideover.is-open .slideover__backdrop{ opacity: 1; }
.slideover__panel{ position: absolute; top: 0; right: 0; bottom: 0; width: clamp(320px, 36vw, 480px); background: var(--paper); color: var(--ink); border-left: 1px solid var(--line); box-shadow: -12px 0 32px var(--elev, rgba(0,0,0,.28)); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease;}
.slideover.is-open .slideover__panel{ transform: translateX(0); }
.slideover__header,
.slideover__footer{ background: var(--paper); color: var(--ink); padding: 12px 16px;}
.slideover__header{ display:flex; align-items:center; justify-content:space-between; border-bottom: 1px solid var(--line);}
.slideover__footer{ border-top: 1px solid var(--line);}
.slideover__header h2{ margin: 0; font-size: 18px; font-weight: 600; color: var(--ink);}
.slideover__body{ padding: 12px 16px; overflow: auto; flex: 1 1 auto; background: var(--paper); color: var(--ink);}
.slideover__close{ font-size: 28px; line-height: 1; border: 0; background: transparent; color: var(--ink); cursor: pointer;}
@media (prefers-color-scheme: dark){ .slideover__backdrop{ background: var(--overlay-dark, rgba(0,0,0,.6)); }}
@media (prefers-reduced-motion: reduce){ .slideover__backdrop, .slideover__panel{ transition: none; }}
@media print{
.slideover{ display:none !important; }
input[type=range][orient=vertical] { appearance: slider-vertical; width: 8px;}
#customColorPicker input[type=range] { margin: 0 2px;}
#colorPreviewBox { box-shadow: 0 0 6px rgba(0,0,0,0.4);}
#hexOutput:focus { outline: none; border-color: #66ccff;}
#hueBar { border: 1px solid var(--line);}
#hueMarker { transition: top 0.1s ease;}
#colorPreviewBox { transition: background 0.15s ease;}
#hexOutput { width: 80px; font-size: 12px; margin-top: 4px;}
}
.port .peer {
position: relative;
overflow: hidden;
white-space: nowrap;
text-align: center;
max-width: 100%;
}
.port .peer > span {
display: inline-block;
white-space: nowrap;
position: relative;
will-change: transform;
}
/* Enable animation only if .scroll is present */
.port .peer.scroll > span {
display: inline-block;
white-space: nowrap;
position: relative;
will-change: transform;
animation: eccm-peer-bounce 7s ease-in-out infinite;
animation-delay: 2s;
}
/* Keyframes:
0%–100% cycle = 7 seconds:
- 0–40%: scroll to the right
- 40–55%: PAUSE on right (1 second)
- 55–95%: scroll back left
- 95–100%: PAUSE left (0.35s)
*/
@keyframes eccm-peer-bounce {
0% { transform: translateX(0); }
35% { transform: translateX(calc(-1 * var(--peer-diff))); }
50% { transform: translateX(calc(-1 * var(--peer-diff))); }
85% { transform: translateX(0); }
100% { transform: translateX(0); }
}
</style>
</head>
<body>
<header>
<h1>Ethernet Cable Connection Manager</h1>
<span class="badge">1.0.7</span>
<div style="margin-left:auto;display:flex;gap:8px">
<button id="btnSettings" class="btn">Settings</button>
<button id="printSheet">Print layout</button>
<button id="exportDrawIO">Export draw.io</button>
</div>
</header>
<div class="wrap">
<aside>
<!-- Profiles -->
<div class="card">
<h3>Profiles</h3>
<label for="profileSelect">Active profile</label>
<select id="profileSelect"></select>
<div style="display:flex;gap:8px;flex-wrap:wrap;margin-top:8px">
<button id="newProfileBtn">New</button>
<button id="renameProfileBtn">Rename</button>
<button id="duplicateProfileBtn">Duplicate</button>
<button id="deleteProfileBtn" class="btn-danger">Delete</button>
<button id="exportProfileBtn" class="btn">Export</button>
<button id="importProfileBtn" class="btn">Import</button>
<input id="importProfileFile" type="file" accept=".json,application/json" style="display:none">
</div>
<div class="small muted" style="margin-top:6px">
</div>
</div>
<div class="card">
<h3>Add device</h3>
<label for="devName">Name</label>
<input id="devName" type="text" placeholder="e.g. Core Switch A" />
<div class="row">
<div>
<label for="devPorts">Ports</label>
<input id="devPorts" type="number" inputmode="numeric" min="1" max="9999" value="24" />
</div>
</div>
<label>Colour</label>
<div class="color-picker-row">
<button type="button" class="color-btn" id="openPalette">Select colour</button>
<span id="devColorPreview" class="swatch swatch-lg" title="Selected colour"></span>
</div>
<div style="margin-top:10px;display:flex;gap:8px">
<button id="addBtn">Add device</button>
<button id="clearAll" class="btn-danger" title="Delete everything">Clear all devices</button>
</div>
<div class="small muted" style="margin-top:6px">
Click two free ports to connect<br>
<strong>Unlink</strong> in Connections<br>
<strong>Alt-click</strong> a port to set an alias<br>
<strong>CTRL-click</strong> to mark as Reserved.
</div>
</div>
<!-- Backup/restore all profiles -->
<div class="card">
<h3>Backup / Restore (all profiles)</h3>
<div style="display:flex;gap:8px;flex-wrap:wrap">
<button id="backupAllBtn" class="btn">Backup all</button>
<button id="restoreAllBtn" class="btn">Restore all</button>
<input id="restoreAllFile" type="file" accept=".json,application/json" style="display:none">
</div>
<div class="small muted" style="margin-top:6px">Saves or restores every profile on this device.</div>
</div>
<div class="card">
<h3>Find connection</h3>
<input id="searchBox" type="text" placeholder="Filter by device, port, alias, or reserved…" />
<div class="small muted" style="margin-top:6px">Filters the connections table.</div>
</div>
</aside>
<main>
<div class="card">
<h3>Devices</h3>
<div id="devRows" class="dev-rows"></div>
</div>
<div class="card">
<h3>Connections</h3>
<table class="grid-slim" id="connTable">
<thead><tr><th>#</th><th>Device A</th><th>Port</th><th>Alias</th><th>⇄</th><th>Device B</th><th>Port</th><th>Alias</th><th></th></tr></thead>
<tbody id="connBody"></tbody>
</table>
<div class="small muted">Click a row (or a connected port) to highlight both ends.</div>
</div>
</main>
</div>
</aside>
</div>
<!-- Settings Slide-Over (Modal) -->
<div id="settingsModal" class="slideover" aria-hidden="true">
<div class="slideover__backdrop" data-close></div>
<aside class="slideover__panel" role="dialog" aria-modal="true" aria-labelledby="settingsTitle" tabindex="-1">
<header class="slideover__header">
<h3>Settings</h3>
</header>
<div class="slideover__body" id="settingsPanelBody">
<div class="card">
<div class="setting-row" id="themeRow">
<label>Theme</label>
<div class="theme-toggle" role="group" aria-label="Theme">
<button type="button" id="themeDark" data-theme="dark" aria-pressed="false">🌙 Dark</button>
<button type="button" id="themeLight" data-theme="bright" aria-pressed="false">☀️ Light</button>
</div>
</div>
</div>
<div class="card">
<div class="setting-row">
<label for="enablePortRename">Enable Port Renaming</label>
<input id="enablePortRename" type="checkbox" />
</div>
<div class="setting-row">
<label for="maxPorts" style="flex:1;">Maximum ports per device</label>
<input id="maxPorts" type="number" min="0" max="9999" style="flex:1; max-width:120px;" />
</div>
<div class="setting-row">
<label for="portTermMode">Port label</label>
<select id="portTermMode" style="max-width:160px">
<option value="port">Port</option>
<option value="interface">Interface</option>
<option value="custom">Custom</option>
</select>
</div>
<div class="setting-row" id="portTermCustomRow" style="display:none">
<label for="portTermCustom" style="flex:1;">Custom label</label>
<input id="portTermCustom" type="text" placeholder="e.g. Jack" style="flex:1; max-width:160px;" />
</div>
<div style="margin-top:10px;display:flex;gap:8px">
<button id="saveSettingsBtn" class="btn">Save</button>
</div>
</div>
</div>
<footer class="slideover__footer">
<button class="btn" data-close>Close</button>
</footer>
</aside>
</div>
<!-- Palette -->
<div class="palette-backdrop" id="paletteModal">
<div class="palette" role="dialog" aria-modal="true" aria-labelledby="paletteTitle">
<h4 id="paletteTitle">Select colour</h4>
<div style="display:flex;gap:20px;justify-content:center;align-items:flex-start;flex-wrap:wrap">
<div class="palette-grid" id="paletteGrid" style="grid-template-columns:repeat(4,36px)"></div>
</div>
<div class="actions"><button type="button" id="paletteClose">Close</button></div>
</div>
</div>
<!-- Layout modal -->
<div class="modal-backdrop" id="layoutModal">
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="layoutTitle">
<h4 id="layoutTitle">Device layout options</h4>
<div class="row"><label style="min-width:110px">Device</label><span id="layoutDeviceName" class="small muted"></span></div>
<div class="row">
<label style="min-width:110px">Row width</label>
<select id="layoutFullRow">
<option value="auto">Auto (follow rules)</option>
<option value="full">Force full row</option>
<option value="half">Force half width</option>
</select>
</div>
<div class="row" id="optMidWrap">
<label style="min-width:110px">13–24 ports</label>
<select id="layoutMidWrap">
<option value="balanced">Balanced (½ + ½)</option>
<option value="twelve">12 + remainder</option>
</select>
</div>
<div class="row" id="optSmallWrap">
<label style="min-width:110px">≤12 ports</label>
<select id="layoutSmallWrap">
<option value="single">Single row</option>
<option value="split">Split into 2 rows</option>
</select>
</div>
<div class="row" id="optDualLink">
<label style="min-width:110px">Dual link</label>
<select id="layoutDualLink">
<option value="off">Normal</option>
<option value="on">Dual link</option>
</select>
</div>
<div class="row" id="optNumbering">
<label style="min-width:110px">Port numbering</label>
<select id="layoutNumbering">
<option value="row">Left → Right (rows)</option>
<option value="column">Top ↓ Bottom (columns)</option>
<option value="column-bt">Bottom ↑ Top (columns)</option>
</select>
</div>
<div class="actions">
<button type="button" id="layoutCancel">Cancel</button>
<button type="button" id="layoutSave">Save</button>
</div>
</div>
</div>
<!-- Edit Device Modal -->
<div class="modal-backdrop" id="editDeviceModal">
<div class="modal" role="dialog" aria-modal="true" aria-labelledby="editDeviceTitle">
<h4 id="editDeviceTitle">Edit Device</h4>
<div class="row">
<label for="editDevName" style="min-width:100px">Name</label>
<input id="editDevName" type="text" placeholder="Device name" />
</div>
<div class="row">
<label for="editDevPorts" style="min-width:100px">Ports</label>
<input id="editDevPorts" type="number" min="1" max="9999" />
</div>
<div class="row">
<label style="min-width:100px">Colour</label>
<div class="color-picker-row">
<button type="button" class="color-btn" id="editOpenPalette">Select colour</button>
<span id="editDevColorPreview" class="swatch swatch-lg" title="Selected colour"></span>
</div>
</div>
<div class="actions">
<button type="button" id="editDevCancel">Cancel</button>
<button type="button" id="editDevSave" class="btn">Save</button>
</div>
</div>
</div>
<script>
/* ===================== HIGHLIGHT TUNING ===================== */
const HI_OUTLINE = 0; // px: outer white ring
const HI_RING = 5; // px: inner white ring thickness
const HI_BLUR = 0; // px: inner white glow blur
/* ===================== PROFILES STORAGE ===================== */
var STORE_KEY = 'ethcm_profiles_v1';
var OLD_SINGLE_KEY = 'ethcm_v12';
var defaultState = {
devices: [],
links: [],
portAliases: {},
reservedPorts: {},
portSpeeds: {},
portVlans: {},
portLinkedToNames: {}
};
function deepClone(o){ return JSON.parse(JSON.stringify(o)); }
function uid(){ return 'id_' + Math.random().toString(36).slice(2,10); }
var store = (function(){
try{
var raw = localStorage.getItem(STORE_KEY);
if(raw){
var parsed = JSON.parse(raw);
if(parsed && parsed.current && parsed.profiles) return parsed;
}
var oldRaw = localStorage.getItem(OLD_SINGLE_KEY);
if(oldRaw){
var one = JSON.parse(oldRaw);
normalizeState(one);
return { current:'Migrated', profiles:{ 'Migrated': one } };
}
}catch(e){}
return { current:'Default', profiles:{ 'Default': deepClone(defaultState) } };
})();
function normalizeState(st){
st.devices = Array.isArray(st.devices) ? st.devices : [];
st.links = Array.isArray(st.links) ? st.links : [];
st.portAliases = st.portAliases || {};
st.reservedPorts = st.reservedPorts || {};
st.portSpeeds = st.portSpeeds || {};
st.portVlans = st.portVlans || {};
// Safe forward-compat field (won't break anything if unused)
st.portLinkedToNames = st.portLinkedToNames || {};
st.devices.forEach(function(d){
// Device core fields
if (!d.id) d.id = uid();
if (d.name == null) d.name = 'Unnamed';
if (d.color == null) d.color = '#888';
// Port count
if (d.ports == null) d.ports = 1;
// Customer port names (per-port rename)
if (!d.portNames || typeof d.portNames !== 'object') d.portNames = {};
// Device max speed
if (d.maxSpeed === undefined) d.maxSpeed = null;
// Layout defaults
if (d.forceFullRow === undefined) d.forceFullRow = false;
if (d.midWrapMode === undefined) d.midWrapMode = 'balanced';
if (d.smallWrap === undefined) d.smallWrap = false;
if (d.dualLink === undefined) d.dualLink = false;
if (d.numbering === undefined) d.numbering = 'row';
if (d.widthMode === undefined) d.widthMode = 'half';
});
}
function saveStore(){ try{ localStorage.setItem(STORE_KEY, JSON.stringify(store)); }catch(e){} }
/* Active profile reference */
var state = store.profiles[store.current];
/* ===================== DOM HELPERS ===================== */
function $(s){ return document.querySelector(s); }
function $all(s){ return Array.prototype.slice.call(document.querySelectorAll(s)); }
function el(tag, attrs){
var node = document.createElement(tag); attrs = attrs||{};
Object.keys(attrs).forEach(function(k){
var v = attrs[k];
if(k === 'dataset'){ Object.keys(v).forEach(function(dk){ if(v[dk]!==undefined) node.dataset[dk] = v[dk]; }); }
else if(k === 'class'){ node.className = v; }
else if(k.indexOf('on') === 0 && typeof v === 'function'){ node.addEventListener(k.slice(2), v); }
else { node.setAttribute(k, v); }
});
for(var i=2;i<arguments.length;i++){ var c = arguments[i]; if(c==null) continue; node.appendChild(c.nodeType ? c : document.createTextNode(c)); }
return node;
}
function deviceById(id){ for(var i=0;i<state.devices.length;i++){ if(state.devices[i].id===id) return state.devices[i]; } return null; }
function indexById(id){ return state.devices.findIndex(function(d){return d.id===id;}); }
function parsePortKey(k){
// keyFor() format in ECCM is: deviceId:port:sub (sub may be empty)
var parts = String(k).split(':');
return {
deviceId: parts[0],
port: Number(parts[1]),
sub: (parts.length > 2 && parts[2] !== '' ? Number(parts[2]) : null)
};
}
function clearManualPortName(deviceId, port, sub){
var d = deviceById(deviceId);
if (!d || !d.portNames) return false;
var k = keyFor(deviceId, port, sub);
if (k in d.portNames) {
delete d.portNames[k];
// If portNames becomes empty, remove it entirely (keeps storage clean)
if (Object.keys(d.portNames).length === 0) delete d.portNames;
saveStore();
return true;
}
return false;
}
function portLabelWithTerm(term, port, sub){
// term must already be "Port" / "Interface" / "Jack" etc
return term + ' ' + port + (sub != null ? '/' + (sub + 1) : '');
}
function getLinkForEndpoint(deviceId, port, sub){
sub = (sub == null ? null : sub);
for (var i = 0; i < state.links.length; i++) {
var L = state.links[i];
var aSub = (L.a.sub == null ? null : L.a.sub);
var bSub = (L.b.sub == null ? null : L.b.sub);
if (L.a.deviceId === deviceId && L.a.port === port && aSub === sub) return L;
if (L.b.deviceId === deviceId && L.b.port === port && bSub === sub) return L;
}
return null;
}
function purgePortNamesThatMatchTerm(term){
if (!term) return false;
var changed = false;
state.devices.forEach(function(d){
if (!d.portNames) return;
Object.keys(d.portNames).forEach(function(k){
var v = (d.portNames[k] || '').trim();
if (!v) return;
var info = parsePortKey(k);
// only purge if the saved value is exactly the default label for THAT key
var def = portLabelWithTerm(term, info.port, info.sub);
if (v === def) {
delete d.portNames[k];
changed = true;
}
});
// optional clean-up if object becomes empty
if (d.portNames && Object.keys(d.portNames).length === 0) delete d.portNames;
});
return changed;
}
function getPortTerm(){
// Defaults
if (!store.settings) store.settings = {};
var mode = store.settings.portTermMode || 'port';
var custom = (store.settings.portTermCustom || '').trim();
if (mode === 'interface') return 'Interface';
if (mode === 'custom') return custom || 'Port'; // fallback if empty
return 'Port';
}
// "Port 5" / "Interface 5" / "Jack 5"
function portLabelDefault(port, sub){
var term = getPortTerm();
return term + ' ' + port + (sub != null ? '/' + (sub + 1) : '');
}
// Used in searches: "port5", "interface5", "jack5"
function portSearchTokens(port){
var term = getPortTerm().toLowerCase();
return [
term + port,
term + ' ' + port,
String(port)
];
}
/* ===================== LINK/RESERVED HELPERS (dual-aware) ===================== */
function keyFor(deviceId, port, sub){ return deviceId + ':' + port + ':' + (sub==null ? '' : sub); }
function aliasFor(deviceId, port, sub){ return state.portAliases[keyFor(deviceId,port,sub)] || ''; }
function reservedLabelFor(deviceId, port, sub){
return (state.reservedPorts && state.reservedPorts[keyFor(deviceId,port,sub)]) || null;
}
function isReservedPort(deviceId, port, sub){
return !!reservedLabelFor(deviceId, port, sub);
}
function linkForPort(deviceId, port, sub){
for(var i=0;i<state.links.length;i++){
var L = state.links[i];
if((L.a.deviceId===deviceId && L.a.port===port && (L.a.sub||null)===(sub||null)) ||
(L.b.deviceId===deviceId && L.b.port===port && (L.b.sub||null)===(sub||null))) return L;
}
return null;
}
function getPeer(deviceId, port, sub){
var L = linkForPort(deviceId, port, sub); if(!L) return null;
if (L.a.deviceId===deviceId && L.a.port===port && (L.a.sub||null)===(sub||null)) return L.b;
return L.a;
}
function speedToMbps(s){
if (!s) return Infinity;
const n = Number(String(s).replace(/[^0-9.]/g,'')) || 0;
return String(s).includes('Gbit') ? n * 1000 : n;
}
function connectPorts(a, b) {
if (linkForPort(a.deviceId,a.port,a.sub) || linkForPort(b.deviceId,b.port,b.sub)) return false;
if (isReservedPort(a.deviceId,a.port,a.sub) || isReservedPort(b.deviceId,b.port,b.sub)) return false;
// Create link
var id = uid();
state.links.push({ id:id, a:a, b:b });
// --- AUTO-NEGOTIATE SPEED ---
var devA = deviceById(a.deviceId);
var devB = deviceById(b.deviceId);
var maxA = devA && devA.maxSpeed ? devA.maxSpeed : null;
var maxB = devB && devB.maxSpeed ? devB.maxSpeed : null;
var spA = speedToMbps(maxA);
var spB = speedToMbps(maxB);
var lowest = Math.min(spA, spB);
if (lowest !== Infinity) {
var label = lowest >= 1000 ? (lowest/1000 + ' Gbit') : (lowest + ' Mbit');
setSpeedFor(a.deviceId, a.port, a.sub, label);
setSpeedFor(b.deviceId, b.port, b.sub, label);
}
saveStore();
render();
highlightLink(id);
return true;
}
function recalcLinkSpeedsForDevice(deviceId) {
const dev = deviceById(deviceId);
if (!dev) return;
state.links.forEach(function(L) {
let a = L.a;
let b = L.b;
// Only recalc links involving this device
if (a.deviceId !== deviceId && b.deviceId !== deviceId) return;
const devA = deviceById(a.deviceId);
const devB = deviceById(b.deviceId);
if (!devA || !devB) return;
const spA = speedToMbps(devA.maxSpeed);
const spB = speedToMbps(devB.maxSpeed);
const lowest = Math.min(spA, spB);
if (lowest !== Infinity) {
const label = lowest >= 1000
? (lowest / 1000 + ' Gbit')
: (lowest + ' Mbit');
setSpeedFor(a.deviceId, a.port, a.sub, label);
setSpeedFor(b.deviceId, b.port, b.sub, label);
}
});
}
function speedFor(deviceId, port, sub){
return (state.portSpeeds || {})[keyFor(deviceId,port,sub)] || '';
}
function setSpeedFor(deviceId, port, sub, val){
var k = keyFor(deviceId,port,sub);
state.portSpeeds = state.portSpeeds || {};
if (!val) delete state.portSpeeds[k]; else state.portSpeeds[k] = String(val);
saveStore();
}
function vlanFor(deviceId, port, sub){
var v = (state.portVlans || {})[keyFor(deviceId,port,sub)];
return (v==null || v==='') ? '' : Number(v);
}
function setVlanFor(deviceId, port, sub, val){
var k = keyFor(deviceId,port,sub);
state.portVlans = state.portVlans || {};
if (val==null || val==='') { delete state.portVlans[k]; }
else {
var n = Math.max(1, Math.min(4094, Number(val)||0)); // clamp 1–4094
state.portVlans[k] = n;
}
saveStore();
}
function linkedToOverrideFor(deviceId, port, sub){
return (state.portLinkedTo || {})[keyFor(deviceId, port, sub)] || '';
}
function setLinkedToOverrideFor(deviceId, port, sub, val){
var k = keyFor(deviceId, port, sub);
state.portLinkedTo = state.portLinkedTo || {};
if (!val) delete state.portLinkedTo[k];
else state.portLinkedTo[k] = String(val);
saveStore();
}
function fmtSpeed(val){
// normalize display
switch(String(val||'')){
case '100 Mbit': return '100 Mbit';
case '1 Gbit': return '1 Gbit';
case '2.5 Gbit': return '2.5 Gbit';
case '5 Gbit': return '5 Gbit';
case '10 Gbit': return '10 Gbit';
case '25 Gbit': return '25 Gbit';
case '40 Gbit': return '40 Gbit';
case '100 Gbit': return '100 Gbit';
default: return '';
}
}
/* ===================== COLOUR / SELECTION ===================== */
function hexToRgb(hex){ var h = String(hex||'').replace('#','').trim(); if (h.length===3) h = h.split('').map(function(c){return c+c}).join(''); var n = parseInt(h,16); if (isNaN(n)||h.length!==6) return {r:15,g:20,b:29}; return { r:(n>>16)&255, g:(n>>8)&255, b:n&255 }; }
function bestTextColorFor(bgHex){ var c = hexToRgb(bgHex); var L = 0.2126*(c.r/255) + 0.7152*(c.g/255) + 0.0722*(c.b/255); return (L > 0.6) ? '#000' : '#fff'; }
function paintPortBase(node, bgHex){
var bg = bgHex || '#0f141d';
node.style.background = bg;
node.style.borderRadius = '10px';
var txt = bestTextColorFor(bg);
node.style.color = txt;
var alias = node.querySelector('.alias'); if (alias) alias.style.color = txt;
var num = node.querySelector('.num'); if (num) num.style.color = txt;
var peer = node.querySelector('.peer'); if (peer) peer.style.color = txt;
}
/* CLEAR selection visuals */
function clearSelectionOutlines(){
$all('.port.selected').forEach(function(n){
n.classList.remove('selected');
n.style.boxShadow = 'none';
});
}
/* APPLY selection visuals: same on singles and dual halves */
function outlineForSelection(node){
node.classList.add('selected');
// Get actual background colour of the port
const bg = window.getComputedStyle(node).backgroundColor;
// Convert rgb(...) → hex
function rgbToHex(rgb){
const m = rgb.match(/\d+/g);
if (!m) return '#000';
return "#" + m.slice(0,3).map(x => {
const h = parseInt(x).toString(16);
return h.length === 1 ? "0" + h : h;
}).join('');
}
const hex = rgbToHex(bg);
// Use your EXISTING brightness logic
const edgeClr = bestTextColorFor(hex);
// Slight glow (match tone)
const glowClr = edgeClr === '#000'
? 'rgba(0,0,0,.35)'
: 'rgba(255,255,255,.35)';
var o = HI_OUTLINE, r = HI_RING, b = HI_BLUR;
node.style.boxShadow =
'0 0 0 ' + o + 'px ' + edgeClr + ',' +
'inset 0 0 0 ' + r + 'px ' + edgeClr + ',' +
'inset 0 0 ' + b + 'px ' + glowClr;
}
/* ---------- Hovercard (only shows while item is highlighted) ---------- */
var __hoverEl = null;
function hcEnsure(){
if (!__hoverEl){
__hoverEl = document.createElement('div');
__hoverEl.className = 'hovercard';
document.body.appendChild(__hoverEl);
}
return __hoverEl;
}
function hcHide(){ if(__hoverEl) __hoverEl.style.display = 'none'; }
function hcShowForTarget(target, html, evt){
var el = hcEnsure();
el.innerHTML = html;
el.style.display = 'block';
var x = 0, y = 0;
if (evt && typeof evt.clientX === 'number'){
x = evt.clientX + 14;
y = evt.clientY + 12;
} else {
var r = target.getBoundingClientRect();
x = r.right + 12;
y = r.top + 8;
}
// Keep in viewport
var vw = window.innerWidth, vh = window.innerHeight;
var ew = el.offsetWidth || 240, eh = el.offsetHeight || 100;
if (x + ew + 8 > vw) x = vw - ew - 8;
if (y + eh + 8 > vh) y = vh - eh - 8;
el.style.left = x + 'px';
el.style.top = y + 'px';
}
/* Hide the hovercard whenever selection is cleared */
const __orig_clearSel = clearSelectionOutlines;
clearSelectionOutlines = function(){
hcHide();
return __orig_clearSel.apply(this, arguments);
};
/* Also hide when we un-highlight a link */
const __orig_highlightLink = highlightLink;
highlightLink = function(id, opts){
if (!id) hcHide();
return __orig_highlightLink.apply(this, arguments);
};
/* ===================== UNIFORM PORT WIDTHS (two gaps) ===================== */
function updateUniformPortWidth(){
var host = document.getElementById('devRows'); if(!host) return;
var GAP_COL = 12;
var PAD_BRD = 26;
var gapFull = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--portGapFull')) || 9;
var gapHalf = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--portGapHalf')) || 8;
var Wrows = host.getBoundingClientRect().width || 800;
var WfullInner = Wrows - PAD_BRD;
var WhalfInner = ((Wrows - GAP_COL)/2) - PAD_BRD;
var portW12 = (WfullInner - (11*gapFull)) / 12;
var portW6 = (WhalfInner - (5*gapHalf)) / 6;
portW12 = Math.max(40, portW12);
portW6 = Math.max(40, portW6);
document.documentElement.style.setProperty('--portW12', portW12 + 'px');
document.documentElement.style.setProperty('--portW6', portW6 + 'px');
}
var __pw_timer=null;
window.addEventListener('resize', function(){ clearTimeout(__pw_timer); __pw_timer=setTimeout(updateUniformPortWidth, 60); });
/* ===================== LAYOUT RULES ===================== */
function isFullWidthDevice(d){
if (d.forceFullRow) return true;
if ((d.ports || 1) >= 13) return true;
return false;
}
function splitPortsIntoRows(n, dev){
if (n === 12 && dev.smallWrap) return [6, 6];
if (n >= 12){
if (n >= 13 && n <= 24 && dev.midWrapMode === 'balanced'){
var a = Math.ceil(n/2);
return [Math.min(12, a), Math.min(12, n - a)];
}
var rows = [], rem = n;
while (rem > 0){ rows.push(Math.min(12, rem)); rem -= 12; }
return rows;
}
if (n >= 7){
if (dev.smallWrap){ var a = Math.ceil(n/2); return [a, n - a]; }
return [n];
}
return [n];
}
/* ===================== CONNECT SELECTION ===================== */
var pendingPort = null;
var highlightedLinkId = null;
/* ===================== RENDER DEVICES ===================== */
function applyPeerScrolling() {
requestAnimationFrame(() => {
const peers = document.querySelectorAll('.peer');
peers.forEach(peer => {
const span = peer.querySelector('span');
if (!span) return;
const sw = span.getBoundingClientRect().width;
const cw = peer.clientWidth;
if (sw > cw) {
// calculate how far to bounce
const diff = sw - cw;