-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
1371 lines (1228 loc) · 68.7 KB
/
index.html
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>
<head>
<title>CliqueVM</title>
<meta charset="utf-8">
<meta content="width=device-width, height=device-height, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0, user-scalable=no" name="viewport">
<link rel="icon" type="image/png" href="favicon.png">
<meta name="twitter:title" content="CliqueVM">
<meta name="twitter:description" content="CliqueVM is a framework for building computational models, both classical and quantum mechanical, and tracing their multithreaded evolution as 2D/3D graphs.">
<meta name="twitter:image" content="https://met4citizen.github.io/CliqueVM/screenshot.jpg">
<meta name="twitter:card" content="summary_large_image">
<style>
html{ width:100%; height:100%; height: -webkit-fill-available; font-size: 1vw; font-family: Verdana, Geneva, sans-serif; }
body{ width: 100%; height: 100%; min-height: 100vh; min-height: -webkit-fill-available; margin: 0; padding: 0; background-color: white; color: #505050; line-height:1vw; overflow: hidden; text-align: left; touch-action: manipulation; }
h1{ color: slategray; padding: 3px 20px; font-family: "Courier",monospace; font-weight: bold; margin: 2px 0 0 0; vertical-align: middle; font-size: 14px; cursor: pointer; pointer-events: auto; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: rgba(119, 136, 153, 0.5); border: transparent; }
#outer{ display: flex; position: absolute; top: 5.1vw; line-height: 1vw; left:0; right:0; bottom:0; margin:0; padding:0; }
#graph { flex: 1; position: relative; margin: 0; padding:0; border-top: 1px solid lightgray; }
#graph-dot{ position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0; padding:0; overflow:scroll; vertical-align:top; text-align: center; scrollbar-color: rgba(155, 155, 155, 0.5) transparent; scrollbar-width: thin; }
#graph-dot > svg { margin: 50px 50px 120px 50px; }
#graph-force { position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0; padding:0; overflow: hidden; }
#legend { position: absolute; z-index: 3; opacity: 0.8; bottom:1.5vw; right: 0; margin: 0 15px 0 0; padding: 0; color: slategray; cursor: default; pointer-events: none; font-family: Verdana, Geneva, sans-serif; vertical-align: middle; text-align: left; font-size:1.2vw; line-height: 1.5vw; }
.legend { display:block; clear:both; width: 100%; height:100%;}
.legend svg { display: inline-block; margin: 0 5px; padding: 0; height: 1.2vw; }
#resizer{ flex: 0 0 4px; background-color: white; border-left: 1px solid lightgray; border-right: 1px solid lightgray; margin:0; padding:0; display: none; }
#resizer:hover{cursor: ew-resize;}
#panel { flex: 1; display: flex; margin: 0; padding:1vw 0; vertical-align:top; text-align: center; overflow:scroll; display:none; border-top: 1px solid lightgray; border-right: 1px solid lightgray;}
#text { margin:0; padding: 0; flex: 1; resize: none; font-family: "Courier",monospace; font-size:14px; line-height: 14px; color:#404040; background-color: white; text-align: left; }
.collapse { display: inline-block; margin-right: 5px; font-size: 16px; color: #a0a0a0; }
.code { resize: none; min-height: 20px; margin:5px 5px 5px 15px; padding: 0px; border: 1px solid lightgrey; overflow: hidden !important; font-size:13px; opacity: 1; }
.js { margin:5px 0 5px 15px; padding: 4px; white-space: nowrap; opacity: 0.7; }
.js-key { color: purple; }
.js-type { color: steelblue; font-weight: bold; }
.js-param { font-weight: bold; }
.js-test { display: inline-block; line-height: 11px; font-size: 12px; padding: 1px 4px; margin-left: 10px; color: white; border-radius: 2px; opacity: 0.7; }
.js-debug { color: darkred; font-weight: bold; white-space: wrap;}
#log { display: flex; margin: 0 0 5px 30px; width: Calc(100% - 30px); height: Calc(100% - 5px); }
#logtext { flex: 1; font-family: "Lucida","Courier",monospace; font-size: 18px; border: 0; resize: none; }
#logbar { display: flex; flex-basis: 3vw; }
#toolbar { display: flex; flex-basis: 3vw; vertical-align: bottom; }
#toolbar-panel { position: relative; width: 5vw; display: none; flex-direction: column; margin: 1vw 0 1.5vw 0; padding: 0; z-index: 3; font-size: 1vw; text-align: middle; line-height: 3vw; cursor: default; pointer-events: none;}
.group { display: flex; gap: 2px; height: 3.3vw; padding: 0.2vw 1vw; margin: 1.5vw 0 0 0; }
#toolbar > .group { border-left: 1px solid lightgray; }
#toolbar > .group:first-child { border: 0; }
.flex-filler { flex: 1; align-items: center; justify-content: center; }
.unit { display: block; position: relative; margin:0; padding: 0; line-height: 3vw; border: 0; vertical-align:middle; text-align: center; }
.unit-action { height: 3vw; width: 3vw; border-radius: 50%; font-size: 1.2vw; font-weight: 600; cursor: pointer; pointer-events: auto; }
.unit-text { font-size: 1.2vw; font-weight: 600; pointer-events: none; }
.unit-zero { flex-basis: 0; }
.unit svg { margin: 0; padding: 0; width: 3vw; height: 3vw; }
.unit-action:active, .selected { background-color: #305070; color: white; }
.set-force { flex-basis: 4.5vw; width: 4.5vw; }
#play.selected, #yalp.selected { background: darkred; color: white; }
.subtitle { position: absolute; display:block; font-size: 1.2vw; font-weight: 500; vertical-align:middle; text-align: center; margin-left: 50%; height: 3vw; color: #a0a0a0; transform: translate(-50%,-2.4vw) scaleX(0.7); white-space: nowrap; }
input[type="range"] { width: 100%; height: 100%; margin: 0.2vw 0 0 0; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; pointer-events: auto; }
input[type="range"]::-webkit-slider-runnable-track { background: #a0a0a0; height: 0.4vw; }
input[type="range"]::-moz-range-track { background: #a0a0a0; height: 0.4vw; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; margin-top: -0.6vw; background: #505050; height: 1.6vw; width: 0.7vw; }
input[type="range"]::-moz-range-thumb { border: none; border-radius: 0; background-color: #505050; height: 1.6vw; width: 0.7vw; }
input[type="range"]:focus { outline: none; }
input[type="range"]:focus::-webkit-slider-thumb { border: 1px solid #002040; outline: 2px solid #002040; outline-offset: 1px; }
input[type="range"]:focus::-moz-range-thumb { border: 1px solid #002040; outline: 2px solid #002040; outline-offset: 1px; }
input[type="checkbox"] { width: 1.5vw; height: 1.5vw; margin-top: 0.9vw; background: transparent; cursor: pointer; pointer-events: auto; }
.box-left { display: flex; position: absolute; right: 0.9vw; z-index: 5; background: white; border: 1px solid lightgray; padding: 0.5vw; line-height: 1vw; cursor: pointer; pointer-events: auto; }
.box-bottom { display: flex; flex-direction: column; position: absolute; top: 3.4vw; padding: 1vw 0 0.5vw 0; z-index: 5; background: white; border: 1px solid lightgray; cursor: pointer; pointer-events: auto; }
#observer-box { width: 4.8vw; margin-left: -1vw; }
#filter-box { width: 16vw; margin-left: -1vw; right: -4.3vw; }
#server-box { width: 24vw; margin-left: -1vw; right: -4.3vw; }
#serverd-url { width: 19vw; pointer-events: auto; resize: none; font-size: 0.8vw; font-family: Verdana, Geneva, sans-serif; }
#export-box { top: -1.5vw; width: 25vw; height: 3.5vw; }
#import-box { top: -1.5vw; width: 25vw; height: 3.5vw; }
#export-json, #import-json {
display:block; resize: none; width: 100%; height: 2.5vw;
overflow-x:hidden; overflow-y:scroll;
margin:3px 0 0 0; padding: 2px; border: 1px solid lightgrey;
font-family: "Courier",monospace; font-size:9px;
line-height: 11px; color:#404040; background-color: white;
text-align: left; -webkit-touch-callout: text; -webkit-user-select: text;
-khtml-user-select: text; -moz-user-select: text; -ms-user-select: text;
user-select: text;
}
#progress-bar { width: 100%; height: 1.3vw; margin-top: 0.6vw; display: flex; gap: 0.2vw; flex-wrap: nowrap; padding: 2px; border: 1px solid #a0a0a0; }
#progress-bar span { position: relative; width: 100%; height: 100%; background-color: #a0a0a0; }
#progress-mask { position: absolute; background-color: white; top: 0; right: 0; bottom: 0; width: 100%; z-index: 2; }
#progress-ui { flex: 0 0 1.5vw; width: 1.5vw; height: 100%; background-color: #a0a0a0; opacity: 1; }
.lcd { font-family: LCD; color: #a0a0a0; font-size: 1.2vw; line-height: 1.7vw; font-weight: 600; vertical-align:middle; text-align: center; white-space: nowrap; }
.fg-label { color: black;}
a { cursor: pointer; pointer-events: auto; }
.bar { fill: slategray; }
.xaxis { font-size: 12px; }
.yaxis { font-size: 16px; }
#logo { margin: 3px; padding: 3px; position: fixed; z-index: 3; opacity: 0.6; bottom: 0; left: 2px; }
#logo img { float:left; margin: 0; padding: 0; width: 3vw; height: 3vw; }
.noselect { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; }
.hidden { display: none !important; }
.highlight { background: darkred; color: white; }
.highlight span { color: darkred; }
.disabled { opacity: 0.2; pointer-events: none; }
.pass { content: "PASS"; background: green; }
.pass:after { content: "PASS"; }
.fail { content: "FAIL"; background: darkred; }
.fail:after { content: "FAIL"; }
.smooth { transition: width 0.1s linear; }
.blink { animation: blink 1s step-start 0s infinite; }
@keyframes blink { 50% { opacity: 0.0; } }
@font-face { font-family:"LCD"; src: url("./fonts/lcd.woff") format('woff'); }
</style>
<script nomodule>alert("You browser doesn't seem to support modules. Use a modern browser to run CliqueVM.");</script>
<script src="https://d3js.org/d3.v6.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-X/XCfMm41VSsqRNQgDerQczD69XqmjOOOwYQvr/uuC+j4OPoNhVgjdGFwhvN02Ja" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-+XBljXPPiv+OzfbB3cVmLHf4hdUFHlWNZN5spNQ7rmHTXpd7WvJum6fIACpNNfIR" crossorigin="anonymous"></script>
<script type="module">
import { CliqueVM } from './modules/CliqueVM.mjs';
import { ModelManager } from './modules/ModelManager.mjs';
// Global variables
let mm; // Model Manager
let vm; // Virtual Machine
const codenames = ['init','oper','coord','probs','show','detectors']; // Code segments
let prevcode = null; // Code when focusin
let scale = 0.5; // Zoom level
let graphw = 40; // Graph window width in percentage
let timerPress = null; // Repeat command when user holds down a button
const timeoutPress = 200; // Repeat command timeout, in milliseconds
// Shorten LCD display for large numbers
function lcd(n) {
if (n > 1000000) return Math.round(n/1000000) + 'M';
if (n > 10000) return Math.round(n/1000) + 'K';
return ''+n;
}
// CliqueVM event handler
function vmEventHandler(type,x=null) {
// console.log(type,x);
switch(type) {
case 'step-progress': // Notify step processing progress [0-100]
d3.select("#progress-mask")
.classed('smooth', x>0 )
.style('width', (100-x)+'%');
break;
case 'step-ready': // Notify step processing progress [0-100]
d3.select("#progress-mask")
.classed('smooth', true )
.style('width', '0');
break;
case 'view-progress': // Notify view processing progress [0-100]
d3.select("#progress-ui").classed('blink', x!==100 );
zoom();
break;
case 'view-ready': // Notify view processing progress [0-100]
d3.select("#progress-ui").classed('blink', false );
if ( d3.select('#play').classed('selected') ) {
setTimeout( function() {
if ( !d3.select('#play').classed('disabled') ) d3.select('#next').dispatch('click');
}, 500 );
} else if ( d3.select('#yalp').classed('selected') ) {
setTimeout( function() {
if ( !d3.select('#yalp').classed('disabled') ) d3.select('#prev').dispatch('click');
}, 500 );
}
zoom();
break;
case 'abort': // Notify that some (all) jobs were aborted/cancelled
d3.select("#progress-mask")
.classed('smooth', false )
.style('width', '100%');
d3.select("#progress-ui")
.classed('blink', false )
break;
case 'info': // Information about the data
if ( x.step ) {
d3.select("#step").text(x.step);
d3.selectAll('#prev,#yalp').classed('disabled', (x.step <= 1) );
if ( x.step === 1 ) d3.select('#yalp').classed('selected',false);
}
if ( x.ids ) {
d3.select("#ops").text(lcd(x.ids[1]-x.ids[0]));
d3.select("#states").text(lcd(x.ids[2]-x.ids[1]));
d3.select("#cliques").text(lcd(x.ids[3]-x.ids[2]));
d3.select("#size").text(lcd(x.ids[3]));
d3.selectAll('#next,#play').classed('disabled', x.ids[3]===x.ids[2] );
if ( x.ids[3]===x.ids[2] ) d3.select('#play').classed('selected',false);
}
break;
case 'step-error': // Error handling
case 'view-error':
case 'dot-error':
console.log(x)
alert('Error in the model:\n' + x.message);
break;
default: // Unknown message
console.log(type,x);
}
}
// Get URL parameters
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.href);
return results === null ? false : decodeURIComponent(results[1].replace(/\+/g, ' '));
}
// The DOT renderer has finished all actions
function zoom(r=1) {
// Change zoom
scale = Math.max(0.05,Math.min(3,scale*r));
d3.select('#zoom-in').classed('disabled',scale===3);
d3.select('#zoom-out').classed('disabled',scale===0.05);
// Scale SVG based on current zoom level
let svg = d3.select('#graph-dot > svg');
if ( !svg.empty() ) {
let s = scale;
if ( d3.select('#snap').classed('selected') ||
d3.select('#hits').classed('selected') ) {
s = 1.2 * s;
}
const viewBox = svg.node().attributes.viewBox.value.split(' ').map(Number);
svg.node().attributes.width.value = (4 * s * viewBox[2] / 3) + 'px';
svg.node().attributes.height.value = (4 * s * viewBox[3] / 3) + 'px';
}
}
// Set legend
function setLegend(legend=null) {
d3.selectAll('.legend').classed('hidden',true);
if ( legend ) {
d3.selectAll(legend).classed('hidden',false);
}
}
// Initialize the app
async function init() {
// Load server
const serverType = parseInt(localStorage.getItem('serverType')) || 0;
d3.select('#serverd-enable').property( 'checked', (serverType===2) ? true : null );
d3.select('#server').classed('selected', serverType !== 0 );
const serverdUrl = localStorage.getItem('serverdUrl') || "wss://localhost:8881/\nwss://localhost:8882/";
d3.select('#serverd-url').property('value', serverdUrl );
// Check URL parameter 'model'
// If set, import it to the model manager, otherwise use local storage.
let modelurl = getUrlParameter('model');
if ( modelurl ) {
let promises = [ d3.text(modelurl) ];
const data = await Promise.allSettled( promises );
if ( data[0].status === 'rejected' ) {
alert('Loading JSON model failed:\n\n'+data[0].reason );
mm.load();
} else {
mm.import(data[0].value);
}
} else {
mm.load();
}
// Setup the model
let model = mm.get();
let server = null;
if ( serverType === 2 ){
server = serverdUrl.split('\n');
}
vm.reset(model, server );
d3.select('#trace').dispatch('click');
// Check URL parameter 'view'
// If set, change the view by clicking the given ids.
let view = getUrlParameter('view');
if ( view ) {
view.split(',').forEach( id => {
let e = d3.select('#'+id);
if ( !e.empty() ) e.dispatch('click');
});
}
// Check URL parameter 'step'
// If set, pre-run the given number of steps
let step = getUrlParameter('step');
if ( step ) {
let n = parseInt(step);
if ( n && n > 0 ) {
while (--n>0) vm.runNext();
}
}
}
// Page ready
document.addEventListener('DOMContentLoaded', function(e) {
// Resize panel window width
d3.select('#resizer').on('mousedown touchstart', function(e) {
d3.select(document).on('mousemove touchmove', function(e) {
let p = 100 * e.pageX / window.innerWidth;
if ( p >= 20 && p < 80 ) {
d3.select('#graph').style('flex-basis',p+'%');
d3.select('#legend').style('right',(100-p)+'%');
vm.resize();
}
});
d3.select(document).on('mouseup mouseleave touchend touchcancel', function(e) {
d3.select(document).on('mouseup mouseleave touchend mousemove touchmove touchcancel', null);
}, {passive: false});
}, {passive: false});
// Window resize event, resume and update graph dimensions
d3.select(window).on('resize', function(){
vm.resize();
});
// Coding UI (CodeMirror)
d3.selectAll('.code').on('focusin',function(e) {
d3.selectAll(".js-test").classed('hidden',true);
if ( d3.select("#deploy").classed('highlight') ) {
prevcode = null;
} else {
d3.select("#deploy").classed('highlight',true);
let id = d3.select(this).property('id');
let ndx = codenames.indexOf(id);
prevcode = mm.cm6view[ndx].state.doc.toString();
}
}).on('focusout',function(e) {
let id = d3.select(this).property('id');
let ndx = codenames.indexOf(id);
let currcode = mm.cm6view[ndx].state.doc.toString();
if ( prevcode === currcode ) {
d3.select("#deploy").classed('highlight',false);
}
});
// Zoom in/out
d3.select('#zoom-in').on('mousedown', function(e) {
timerPress = setInterval(zoom, timeoutPress, 1.2);
zoom(1.2);
}).on('mouseup mouseleave', function(e) {
if ( timerPress ) timerPress = clearInterval(timerPress);
});
d3.select('#zoom-out').on('mousedown', function(e) {
timerPress = setInterval(zoom, timeoutPress, 0.8);
zoom(0.8);
}).on('mouseup mouseleave', function(e) {
if ( timerPress ) timerPress = clearInterval(timerPress);
});
// Reset
d3.select('#reset').on('click', function(e) {
d3.selectAll('#play,#yalp').classed('selected',false);
let server = null;
if ( d3.select("#serverd-enable").property("checked") ){
server = d3.select("#serverd-url").property("value").split('\n');
}
vm.reset( null, server );
});
// Cancel
d3.select('#cancel').on('click', function(e) {
d3.selectAll('#play,#yalp').classed('selected',false);
vm.abort();
});
// Next step
d3.select('#next').on('click', function(e) {
let options = {};
if ( d3.select('#observer-quantum').classed('selected') ) {
options.observer = 1;
} else if ( d3.select('#observer-classical').classed('selected') ) {
options.observer = 2;
}
if ( d3.select('#filter').classed('selected') ) {
if ( d3.select('#filter-1').property('checked') ) {
let val = parseInt( d3.select("#filter-1-range").property('value'), 10 );
options.maxcliquesperloc = val;
}
if ( d3.select('#filter-2').property('checked') ) {
let val = parseInt( d3.select("#filter-2-range").property('value'), 10 );
options.maxstatesperclique = val;
}
}
vm.runNext(options);
});
// Play
d3.select('#play').on('click', function(e) {
if ( d3.select(this).classed('selected') ) {
d3.select(this).classed('selected', false);
} else {
d3.select(this).classed('selected', true);
d3.select('#yalp').classed('selected',false);
d3.select('#next').dispatch('click');
}
});
// Play in reverse
d3.select('#yalp').on('click', function(e) {
if ( d3.select(this).classed('selected') ) {
d3.select(this).classed('selected', false);
} else {
d3.select(this).classed('selected', true);
d3.select('#play').classed('selected',false);
d3.select('#prev').dispatch('click');
}
});
// Previous step
d3.select('#prev').on('click', function(e) {
vm.runPrev();
});
// Toggle model panel
d3.selectAll('#model').on('click', function(e) {
if ( !d3.select(this).classed('selected') ) {
d3.select(this).classed('selected', true);
d3.selectAll('#panel,#toolbar-panel').style('display','flex');
d3.select('#resizer').style('display','block');
d3.select('#graph').style('flex','0 0 ' + graphw + '%');
d3.select('#legend').style('right',(100-graphw)+'%');
} else {
d3.select(this).classed('selected', false);
graphw = parseInt( d3.select('#graph').style('flex-basis') );
d3.selectAll('#panel,#toolbar-panel').style('display','none');
d3.select('#resizer').style('display','none');
d3.select('#graph').style('flex','1');
d3.select('#legend').style('right','0');
}
vm.resize();
});
// Pick a graph
d3.selectAll('.set-graph').on('click', function(e) {
d3.selectAll(".set-graph").classed('selected',false);
d3.select(this).classed('selected', true);
let graph = d3.select(this).property('id');
d3.selectAll(".set-space,.set-trace,.set-snap,.set-hits").classed('hidden',true);
d3.selectAll(".set-"+graph).classed('hidden',false);
let isSpace = (graph === 'space');
d3.selectAll('.set-force').classed('hidden',!isSpace);
d3.selectAll('.set-zoom').classed('hidden',isSpace);
d3.select("#graph-dot").classed('hidden', isSpace);
d3.select("#graph-force").classed('hidden', !isSpace);
d3.select('.set-'+graph+'.selected').dispatch('click');
});
// Trace full
d3.select('#trace-full').on('click', function(e) {
d3.selectAll(".set-trace").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-operation,#legend-state,#legend-clique,#legend-location');
vm.run('trace', { mode: 1 });
});
// Trace cliques
d3.select('#trace-clique').on('click', function(e) {
d3.selectAll(".set-trace").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-clique,#legend-location');
vm.run('trace', { mode: 2 });
});
// Trace locations
d3.select('#trace-location').on('click', function(e) {
d3.selectAll(".set-trace").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-location');
vm.run('trace', { mode: 3 });
});
// Snap view with states
d3.select('#snap-state').on('click', function(e) {
d3.selectAll(".set-snap").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-state,#legend-location');
vm.run('snap', { mode: 1 });
});
// Snap view with cliques
d3.select('#snap-clique').on('click', function(e) {
d3.selectAll(".set-snap").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-clique,#legend-location');
vm.run('snap', { mode: 2 });
});
// Snap view with locations
d3.select('#snap-location').on('click', function(e) {
d3.selectAll(".set-snap").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-location');
vm.run('snap', { mode: 3 });
});
// Space now
d3.select('#space-paths').on('click', function(e) {
d3.selectAll(".set-space").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-density,#legend-ends');
vm.run('space', { mode: 1 });
});
// Space, full history
d3.select('#space-action').on('click', function(e) {
d3.selectAll(".set-space").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend('#legend-density,#legend-paths');
vm.run('space', { mode: 2 });
});
// Hits at this current step
d3.select('#hits-step').on('click', function(e) {
d3.selectAll(".set-hits").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend();
vm.run('hits',{ mode: 1});
});
// Hits, cumulative sum
d3.select('#hits-sum').on('click', function(e) {
d3.selectAll(".set-hits").classed('selected',false);
d3.select(this).classed('selected', true);
setLegend();
vm.run('hits',{ mode: 2});
});
// Observers
d3.select('#observer').on('click', function(e) {
if ( d3.select('#observer-box').classed('hidden') ) {
d3.selectAll('.box-bottom').classed('hidden',true);
d3.select('#observer-box').classed('hidden', false);
} else {
d3.select('#observer-box').classed('hidden', true);
}
if ( d3.selectAll('.set-observer.selected').empty() ) {
d3.select(this).classed('selected', false );
} else {
d3.select(this).classed('selected', true );
}
});
d3.selectAll('.set-observer').on('click', function(e) {
if ( d3.select(this).classed('selected') ) {
d3.select(this).classed('selected', false );
d3.select('#observer').classed('selected', false);
} else {
d3.selectAll('.set-observer').classed('selected', false);
d3.select(this).classed('selected', true );
d3.select('#observer').classed('selected', true);
}
});
// Filters
d3.select('#filter').on('click', function(e) {
if ( d3.select('#filter-box').classed('hidden') ) {
d3.selectAll('.box-bottom').classed('hidden',true);
d3.select('#filter-box').classed('hidden', false);
} else {
d3.select('#filter-box').classed('hidden', true);
}
});
d3.selectAll('.set-filter').on('change', function(e) {
let checked = false;
d3.selectAll(".set-filter").each(function(d){
checked |= d3.select(this).property('checked');
});
d3.select('#filter').classed('selected', checked );
});
d3.selectAll('#filter-1-range').on('input change keyup', function() {
let val = d3.select(this).property('value');
d3.select('#filter-1-value').text(val);
});
d3.selectAll('#filter-2-range').on('input change keyup', function() {
let val = d3.select(this).property('value');
d3.select('#filter-2-value').text(val);
});
// Server
d3.select('#server').on('click', function(e) {
if ( d3.select('#server-box').classed('hidden') ) {
d3.selectAll('.box-bottom').classed('hidden',true);
d3.select('#server-box').classed('hidden', false);
} else {
d3.select('#server-box').classed('hidden', true);
}
});
d3.select('#serverd-enable').on('change',function(e) {
d3.selectAll('#play,#yalp').classed('selected',false);
if ( e.currentTarget.checked ) {
localStorage.setItem('serverType', '2' );
d3.select('#server').classed('selected', true );
vm.reset( null, d3.select("#serverd-url").property("value").split('\n') );
} else {
localStorage.setItem('serverType', '0' );
d3.select('#server').classed('selected', false );
vm.reset( null, null );
}
});
d3.select('#serverd-url').on('change keyup paste input',function(e) {
localStorage.setItem('serverdUrl', d3.select('#serverd-url').property('value') );
});
// Changed force
d3.selectAll('#force-range,#friction-range').on('input change keyup', function() {
let force = parseInt( d3.select("#force-range").property('value'), 10 );
let friction = parseInt( d3.select("#friction-range").property('value'), 10 );
vm.force(force,friction);
});
// Title
d3.selectAll('.title').on('click', function() {
if ( d3.select(this).select('.collapse').html()==='▶' ) {
d3.select(this).select('.collapse').html('▼');
d3.select(this.nextElementSibling).style('display','block');
} else {
d3.select(this).select('.collapse').html('▶');
d3.select(this.nextElementSibling).style('display','none');
}
});
// Deploy the current model and run it
d3.select('#deploy').on('click', function(e) {
mm.save();
d3.selectAll(".js-test").classed('hidden',true);
d3.selectAll(".js-debug").text('');
d3.select(this).classed('highlight',false);
const model = mm.get();
const server = d3.select("#serverd-enable").property("checked") ? d3.select("#serverd-url").property("value").split('\n') : null;
d3.select("#logtext").property("value","");
vm.reset(model,server);
});
// Test/debug
d3.select('#test').on('click', function(e) {
mm.test( function(r) {
codenames.forEach( x => {
d3.select("#" + x + "-test")
.classed('hidden',false)
.classed('pass', r[x].pass)
.classed('fail', !r[x].pass);
d3.select("#" + x + "-debug")
.text(r[x].error ? r[x].error : '');
});
if ( !r.model.pass ) {
alert(r.model.error);
}
});
});
// Show/hide log
d3.select('#showlog').on('click', function(e) {
let s = !d3.select(this).classed('selected');
d3.select(this).classed('selected',s);
d3.select("#text").classed('hidden',s);
d3.select("#log").classed('hidden',!s);
});
// Clear log
d3.select('#clearlog').on('click', function(e) {
d3.select("#logtext").property("value","");
});
// Export (copy)
d3.select('#export').on('click', function(e) {
let s = !d3.select(this).classed('selected');
d3.select(this).classed('selected',s);
if ( s ) {
let json = mm.export();
d3.select("#export-box").classed('hidden',false);
d3.select("#export-json").property('value',json);
let n = d3.select("#export-json").node();
n.focus();
n.select();
} else {
d3.select("#export-box").classed('hidden',true);
d3.select("#export-json").property('value','');
}
});
// Import (paste)
d3.select('#import').on('click', function(e) {
let s = !d3.select(this).classed('selected');
d3.select(this).classed('selected',s);
if ( s ) {
d3.select("#import-box").classed('hidden',false);
d3.select("#import-json").property('value','');
let n = d3.select("#import-json").node();
n.focus();
n.select();
} else {
d3.select("#import-box").classed('hidden',true);
let json = d3.select("#import-json").property('value');
if ( json.length ) {
mm.import( json );
}
}
});
// Open project's GitHub page
d3.select('#github').on('click', function(e) {
window.open('https://github.com/met4citizen/CliqueVM','_blank');
});
// Setup model manager
mm = new ModelManager(codenames);
// Setup virtual machine
let edot = document.getElementById("graph-dot");
let eforce = document.getElementById("graph-force");
let elog = document.getElementById("logtext");
vm = new CliqueVM(vmEventHandler,edot,eforce,elog);
// window.vm = vm;
// Initialize
init();
});
</script>
</head>
<body>
<div id="outer">
<div id="graph" class="noselect">
<div id="graph-dot"></div>
<div id="graph-force"></div>
</div>
<div id="resizer" class="noselect"></div>
<div id="panel">
<div id="text" spellcheck="false">
<h1 class="title noselect"><span class="collapse">▶</span>INITIAL STATE<span id="init-test" class="js-test hidden"></span></h1>
<div style="display:none">
<p class="js noselect">
<span class="js-key">@return</span> {<span class="js-type">any[]</span>} Array of initial states.
</p>
<div id="init" class="code"></div>
<p id="init-debug" class="js js-debug noselect">
</p>
</div>
<h1 class="title noselect"><span class="collapse">▼</span>OPERATOR<span id="oper-test" class="js-test hidden"></span></h1>
<div>
<p class="js noselect">
<span class="js-key">@param</span> {<span class="js-type">any[]</span>} <span class="js-param">c</span> Clique; array of input states<br>
<span class="js-key">@return</span> {<span class="js-type">any[][]</span>} Operations; arrays with output states.
</p>
<div id="oper" class="code"></div>
<p id="oper-debug" class="js js-debug noselect">
</p>
</div>
<h1 class="title noselect"><span class="collapse">▶</span>COORDINATE / EQUIVALENCE<span id="coord-test" class="js-test hidden"></span></h1>
<div style="display:none">
<p class="js noselect">
<span class="js-key">@param</span> {<span class="js-type">any</span>} <span class="js-param">s</span> State<br>
<span class="js-key">@return</span> {<span class="js-type">string</span>} Spatial coordinate.
</p>
<div id="coord" class="code"></div>
<p id="coord-debug" class="js js-debug noselect">
</p>
</div>
<h1 class="title noselect"><span class="collapse">▶</span>PROBABILITIES<span id="probs-test" class="js-test hidden"></span></h1>
<div style="display:none">
<p class="js noselect">
<span class="js-key">@param</span> {<span class="js-type">string</span>} <span class="js-param">coord</span> Coordinate<br>
<span class="js-key">@param</span> {<span class="js-type">any[][]</span>} <span class="js-param">cs</span> Cliques; array of array of states.<br>
<span class="js-key">@return</span> {<span class="js-type">number[]</span>} Clique probabilities or null/undefined.
</p>
<div id="probs" class="code"></div>
<p id="probs-debug" class="js js-debug noselect">
</p>
</div>
<h1 class="title noselect"><span class="collapse">▶</span>VISIBILITY<span id="show-test" class="js-test hidden"></span></h1>
<div style="display:none">
<p class="js">
<span class="js-key">@param</span> {<span class="js-type">any</span>} <span class="js-param">s</span> State<br>
<span class="js-key">@return</span> {<span class="js-type">boolean</span>} true, if the state is to be shown/visible.
</p>
<div id="show" class="code"></div>
<p id="show-debug" class="js js-debug">
</p>
</div>
<h1 class="title noselect"><span class="collapse">▶</span>DETECTORS<span id="detectors-test" class="js-test hidden"></span></h1>
<div style="display:none">
<p class="js noselect">
<span class="js-key">@return</span> {<span class="js-type">string[]</span>} Array of detector coordinates.
</p>
<div id="detectors" class="code"></div>
<p id="detectors-debug" class="js js-debug noselect">
</p>
</div>
</div>
<div id="log" class="hidden">
<textarea id="logtext" readonly></textarea>
<div id="logbar" class="noselect">
<div class="group">
<span id="clearlog" class="unit unit-action" title="Clear the log">
<span class="subtitle">Clear</span>
<svg viewBox="-3 -3 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M17 5V4C17 2.89543 16.1046 2 15 2H9C7.89543 2 7 2.89543 7 4V5H4C3.44772 5 3 5.44772 3 6C3 6.55228 3.44772 7 4 7H5V18C5 19.6569 6.34315 21 8 21H16C17.6569 21 19 19.6569 19 18V7H20C20.5523 7 21 6.55228 21 6C21 5.44772 20.5523 5 20 5H17ZM15 4H9V5H15V4ZM17 7H7V18C7 18.5523 7.44772 19 8 19H16C16.5523 19 17 18.5523 17 18V7Z" fill="currentColor" />
<path d="M9 9H11V17H9V9Z" fill="currentColor" />
<path d="M13 9H15V17H13V9Z" fill="currentColor" />
</svg>
</span>
</div>
</div>
</div>
</div>
<div id="toolbar-panel" class="noselect">
<div class="group">
<span id="deploy" class="unit unit-action" title="Deploy the model">
<span class="subtitle">Deploy</span>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="12" cy="12" r="7" fill="none" stroke="currentColor" stroke-width="2" />
<path d="M16 12L10 16.3301V7.66987L16 12Z" fill="currentColor" />
</svg>
</span>
</div>
<div class="group">
<span id="test" class="unit unit-action" title="Test the model">
<span class="subtitle">Test</span>
<svg viewBox="-2 -2 28 28" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 11C10 10.4477 10.4477 10 11 10H13C13.5523 10 14 10.4477 14 11C14 11.5523 13.5523 12 13 12H11C10.4477 12 10 11.5523 10 11Z" fill="currentColor" />
<path d="M11 14C10.4477 14 10 14.4477 10 15C10 15.5523 10.4477 16 11 16H13C13.5523 16 14 15.5523 14 15C14 14.4477 13.5523 14 13 14H11Z" fill="currentColor" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.09447 4.74918C8.41606 4.03243 8 3.0648 8 2H10C10 3.10457 10.8954 4 12 4C13.1046 4 14 3.10457 14 2H16C16 3.0648 15.5839 4.03243 14.9055 4.74918C16.1782 5.45491 17.1673 6.6099 17.6586 8H19C19.5523 8 20 8.44772 20 9C20 9.55229 19.5523 10 19 10H18V12H19C19.5523 12 20 12.4477 20 13C20 13.5523 19.5523 14 19 14H18V16H19C19.5523 16 20 16.4477 20 17C20 17.5523 19.5523 18 19 18H17.6586C16.8349 20.3304 14.6124 22 12 22C9.38756 22 7.16508 20.3304 6.34141 18H5C4.44772 18 4 17.5523 4 17C4 16.4477 4.44772 16 5 16H6V14H5C4.44772 14 4 13.5523 4 13C4 12.4477 4.44772 12 5 12H6V10H5C4.44772 10 4 9.55229 4 9C4 8.44772 4.44772 8 5 8H6.34141C6.83274 6.6099 7.82181 5.45491 9.09447 4.74918ZM8 16V10C8 7.79086 9.79086 6 12 6C14.2091 6 16 7.79086 16 10V16C16 18.2091 14.2091 20 12 20C9.79086 20 8 18.2091 8 16Z" fill="currentColor" />
</svg>
</span>
</div>
<div class="group">
<span id="showlog" class="unit unit-action" title="Log">
<span class="subtitle">Log</span>
<svg viewBox="-5 -5 34 34" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.0333 14.8284L6.44751 16.2426L10.6902 12L6.44751 7.75733L5.0333 9.17155L7.86172 12L5.0333 14.8284Z" fill="currentColor" />
<path d="M15 14H11V16H15V14Z" fill="currentColor" />
<path fill-rule="evenodd" clip-rule="evenodd" d="M2 2C0.895431 2 0 2.89543 0 4V20C0 21.1046 0.89543 22 2 22H22C23.1046 22 24 21.1046 24 20V4C24 2.89543 23.1046 2 22 2H2ZM22 4H2L2 20H22V4Z" fill="currentColor" />
</svg>
</span>
</div>
<div class="flex-filler"></div>
<div class="group">
<span class="unit unit-zero">
<div id="export-box" class="box-left hidden">
<textarea id="export-json" spellcheck="false" wrap="on">
</textarea>
</div>
</span>
<span id="export" class="unit unit-action" title="Export JSON">
<span class="subtitle">Export</span>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="none" stroke="currentColor" stroke-width="1.6" d="M9 10 9 6 18 6 18 18 9 18 9 14" />
<path fill="none" stroke="currentColor" stroke-width="1.4" d="M3 12 14.5 12M11.5 9 14.5 12 11.5 15" />
</svg>
</span>
</div>
<div class="group">
<span class="unit unit-zero">
<div id="import-box" class="box-left hidden">
<textarea id="import-json" spellcheck="false" wrap="on">
</textarea>
</div>
</span>
<span id="import" class="unit unit-action" title="Import JSON">
<span class="subtitle">Import</span>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="none" stroke="currentColor" stroke-width="1.6" d="M9 10 9 6 18 6 18 18 9 18 9 14" />
<path fill="none" stroke="currentColor" stroke-width="1.4" d="M14 12 4 12M6 9 3 12 6 15" />
</svg>
</span>
</div>
<div class="group">
<span id="github" class="unit unit-action" title="GitHub project">
<span class="subtitle">GitHub</span>
<svg viewBox="-1 -1 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" fill="currentColor"/>
</svg>
</span>
</div>
</div>
</div>
<div id="toolbar" class="noselect">
<div class="group">
<span id="trace" class="unit unit-action set-graph selected" title="Multithread trace">
<span class="subtitle">Trace</span>
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="triangle" viewBox="0 0 10 10" refX="1" refY="5" markerUnits="strokeWidth" markerWidth="3" markerHeight="3" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="currentColor" fill-opacity="0.5" />
</marker>
</defs>
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" marker-end="url(#triangle)" x1="10" y1="6" x2="7" y2="10" />
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" marker-end="url(#triangle)" x1="10" y1="6" x2="10" y2="10" />
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" marker-end="url(#triangle)" x1="10" y1="6" x2="13" y2="10" />
<ellipse fill="currentColor" stroke="currentColor" stroke-width="1" cx="10" cy="6" rx="1.8" ry="1.8" />
<ellipse fill="none" stroke="currentColor" stroke-width="0.9" cx="5" cy="14" rx="1.8" ry="1.8" />
<ellipse fill="none" stroke="currentColor" stroke-width="0.9" cx="10" cy="14" rx="1.8" ry="1.8" />
<ellipse fill="none" stroke="currentColor" stroke-width="0.9" cx="15" cy="14" rx="1.8" ry="1.8" />
</svg>
</span>
<span id="snap" class="unit unit-action set-graph" title="Snapshot trace">
<span class="subtitle">Snap</span>
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" x1="9.5" y1="8" x2="6.5" y2="12" />
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" x1="10.5" y1="8" x2="12.5" y2="12" />
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" x1="8" y1="13" x2="12" y2="13" />
<ellipse fill="none" stroke="currentColor" stroke-width="1" cx="10" cy="7" rx="1.8" ry="1.8" />
<ellipse fill="none" stroke="currentColor" stroke-width="1" cx="6" cy="13" rx="1.8" ry="1.8" />
<ellipse fill="none" stroke="currentColor" stroke-width="1" cx="14" cy="13" rx="1.8" ry="1.8" />
</svg>
</span>
<span id="space" class="unit unit-action set-graph" title="Spatial projection">
<span class="subtitle">Space</span>
<svg viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg">
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" x1="5" y1="7" x2="5" y2="14" />
<line stroke="currentColor" stroke-width="0.9" stroke-opacity="0.5" x1="5" y1="7" x2="10" y2="5" />
<line stroke="currentColor" stroke-width="1.1" stroke-opacity="0.5" x1="5" y1="7" x2="10" y2="9" />
<line stroke="currentColor" stroke-width="1" stroke-opacity="0.5" x1="15" y1="7" x2="15" y2="14" />
<line stroke="currentColor" stroke-width="0.9" stroke-opacity="0.5" x1="15" y1="7" x2="10" y2="5" />
<line stroke="currentColor" stroke-width="1.1" stroke-opacity="0.5" x1="15" y1="7" x2="10" y2="9" />
<line stroke="currentColor" stroke-width="1.1" stroke-opacity="0.5" x1="10" y1="16" x2="5" y2="14" />
<line stroke="currentColor" stroke-width="1.2" stroke-opacity="0.5" x1="10" y1="16" x2="10" y2="9" />
<line stroke="currentColor" stroke-width="1.1" stroke-opacity="0.5" x1="10" y1="16" x2="15" y2="14" />
<ellipse fill="currentColor" stroke="none" cx="5" cy="7" rx="1.4" ry="1.4" />
<ellipse fill="currentColor" stroke="none" cx="5" cy="14" rx="1.4" ry="1.4" />
<ellipse fill="currentColor" stroke="none" cx="10" cy="5" rx="1.35" ry="1.35" />
<ellipse fill="currentColor" stroke="none" cx="10" cy="9" rx="1.55" ry="1.55" />
<ellipse fill="currentColor" stroke="none" cx="10" cy="16" rx="1.55" ry="1.55" />
<ellipse fill="currentColor" stroke="none" cx="15" cy="7" rx="1.4" ry="1.4" />
<ellipse fill="currentColor" stroke="none" cx="15" cy="14" rx="1.4" ry="1.4" />
</svg>
</span>
<span id="hits" class="unit unit-action set-graph" title="Detector counters">
<span class="subtitle">Hits</span>
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path stroke="currentColor" stroke-width="2" d="M7 10V14M10 5V14M13 7V14"/>
<path stroke="currentColor" stroke-width="1" stroke-opacity="0.5" d="M4 4V15H16"/>
</svg>
</span>
<span class="unit unit-text" style="flex: 0 0 1.5vw; width:1.5vw;">
<span class="subtitle">></span>
</span>