2
2
3
3
var bomsplit ;
4
4
var canvassplit ;
5
- var canvaslayout = "default" ;
6
- var bomlayout = "default" ;
7
5
var initDone = false ;
8
6
var bomSortFunction = null ;
9
7
var currentSortColumn = null ;
@@ -13,9 +11,6 @@ var highlightHandlers = [];
13
11
var moduleIndexToHandler = { } ;
14
12
var highlightedModules = [ ] ;
15
13
var highlightedNet = null ;
16
- var checkboxes = [ ] ;
17
- var bomCheckboxes = "" ;
18
- var highlightpin1 = false ;
19
14
var lastClicked ;
20
15
21
16
function dbg ( html ) {
@@ -31,37 +26,37 @@ function redrawIfInitDone() {
31
26
32
27
function padsVisible ( value ) {
33
28
writeStorage ( "padsVisible" , value ) ;
34
- renderPads = value ;
29
+ settings . renderPads = value ;
35
30
redrawIfInitDone ( ) ;
36
31
}
37
32
38
33
function referencesVisible ( value ) {
39
34
writeStorage ( "referencesVisible" , value ) ;
40
- renderReferences = value ;
35
+ settings . renderReferences = value ;
41
36
redrawIfInitDone ( ) ;
42
37
}
43
38
44
39
function valuesVisible ( value ) {
45
40
writeStorage ( "valuesVisible" , value ) ;
46
- renderValues = value ;
41
+ settings . renderValues = value ;
47
42
redrawIfInitDone ( ) ;
48
43
}
49
44
50
45
function tracksVisible ( value ) {
51
46
writeStorage ( "tracksVisible" , value ) ;
52
- renderTracks = value ;
47
+ settings . renderTracks = value ;
53
48
redrawIfInitDone ( ) ;
54
49
}
55
50
56
51
function zonesVisible ( value ) {
57
52
writeStorage ( "zonesVisible" , value ) ;
58
- renderZones = value ;
53
+ settings . renderZones = value ;
59
54
redrawIfInitDone ( ) ;
60
55
}
61
56
62
57
function dnpOutline ( value ) {
63
58
writeStorage ( "dnpOutline" , value ) ;
64
- renderDnpOutline = value ;
59
+ settings . renderDnpOutline = value ;
65
60
redrawIfInitDone ( ) ;
66
61
}
67
62
@@ -72,24 +67,25 @@ function setDarkMode(value) {
72
67
topmostdiv . classList . remove ( "dark" ) ;
73
68
}
74
69
writeStorage ( "darkmode" , value ) ;
70
+ settings . darkMode = value ;
75
71
redrawIfInitDone ( ) ;
76
72
}
77
73
78
74
function fabricationVisible ( value ) {
79
- renderFabrication = value ;
80
75
writeStorage ( "fabricationVisible" , value ) ;
76
+ settings . renderFabrication = value ;
81
77
redrawIfInitDone ( ) ;
82
78
}
83
79
84
80
function silkscreenVisible ( value ) {
85
- renderSilkscreen = value ;
86
81
writeStorage ( "silkscreenVisible" , value ) ;
82
+ settings . renderSilkscreen = value ;
87
83
redrawIfInitDone ( ) ;
88
84
}
89
85
90
86
function setHighlightPin1 ( value ) {
91
87
writeStorage ( "highlightpin1" , value ) ;
92
- highlightpin1 = value ;
88
+ settings . highlightpin1 = value ;
93
89
redrawIfInitDone ( ) ;
94
90
}
95
91
@@ -107,11 +103,13 @@ function getStoredCheckboxRefs(checkbox) {
107
103
return intref ;
108
104
}
109
105
}
110
- var existingRefs = readStorage ( "checkbox_" + checkbox ) ;
111
- if ( ! existingRefs ) {
106
+ if ( ! ( checkbox in settings . checkboxStoredRefs ) ) {
107
+ settings . checkboxStoredRefs [ checkbox ] = readStorage ( "checkbox_" + checkbox ) ;
108
+ }
109
+ if ( ! settings . checkboxStoredRefs [ checkbox ] ) {
112
110
return new Set ( ) ;
113
111
} else {
114
- return new Set ( existingRefs . split ( "," ) . map ( r => convert ( r ) ) ) ;
112
+ return new Set ( settings . checkboxStoredRefs [ checkbox ] . split ( "," ) . map ( r => convert ( r ) ) ) ;
115
113
}
116
114
}
117
115
@@ -155,7 +153,8 @@ function createCheckboxChangeHandler(checkbox, references) {
155
153
refsSet . delete ( ref [ 1 ] ) ;
156
154
}
157
155
}
158
- writeStorage ( "checkbox_" + checkbox , [ ...refsSet ] . join ( "," ) ) ;
156
+ settings . checkboxStoredRefs [ checkbox ] = [ ...refsSet ] . join ( "," ) ;
157
+ writeStorage ( "checkbox_" + checkbox , settings . checkboxStoredRefs [ checkbox ] ) ;
159
158
updateCheckboxStats ( checkbox ) ;
160
159
}
161
160
}
@@ -237,11 +236,11 @@ function highlightFilter(s) {
237
236
function checkboxSetUnsetAllHandler ( checkboxname ) {
238
237
return function ( ) {
239
238
var checkboxnum = 0 ;
240
- while ( checkboxnum < checkboxes . length &&
241
- checkboxes [ checkboxnum ] . toLowerCase ( ) != checkboxname . toLowerCase ( ) ) {
239
+ while ( checkboxnum < settings . checkboxes . length &&
240
+ settings . checkboxes [ checkboxnum ] . toLowerCase ( ) != checkboxname . toLowerCase ( ) ) {
242
241
checkboxnum ++ ;
243
242
}
244
- if ( checkboxnum >= checkboxes . length ) {
243
+ if ( checkboxnum >= settings . checkboxes . length ) {
245
244
return ;
246
245
}
247
246
var allset = true ;
@@ -328,7 +327,7 @@ function populateBomHeader() {
328
327
return 0 ;
329
328
}
330
329
}
331
- for ( var checkbox of checkboxes ) {
330
+ for ( var checkbox of settings . checkboxes ) {
332
331
th = createColumnHeader (
333
332
checkbox , "bom-checkbox" , checkboxCompareClosure ( checkbox ) ) ;
334
333
th . onclick = fancyDblClickHandler (
@@ -379,7 +378,7 @@ function populateBomBody() {
379
378
moduleIndexToHandler = { } ;
380
379
currentHighlightedRowId = null ;
381
380
var first = true ;
382
- switch ( canvaslayout ) {
381
+ switch ( settings . canvaslayout ) {
383
382
case 'F' :
384
383
bomtable = pcbdata . bom . F ;
385
384
break ;
@@ -412,7 +411,7 @@ function populateBomBody() {
412
411
td . textContent = rownum ;
413
412
tr . appendChild ( td ) ;
414
413
// Checkboxes
415
- for ( var checkbox of checkboxes ) {
414
+ for ( var checkbox of settings . checkboxes ) {
416
415
if ( checkbox ) {
417
416
td = document . createElement ( "TD" ) ;
418
417
var input = document . createElement ( "input" ) ;
@@ -536,23 +535,23 @@ function changeCanvasLayout(layout) {
536
535
switch ( layout ) {
537
536
case 'F' :
538
537
document . getElementById ( "fl-btn" ) . classList . add ( "depressed" ) ;
539
- if ( bomlayout != "bom-only" ) {
538
+ if ( settings . bomlayout != "bom-only" ) {
540
539
canvassplit . collapse ( 1 ) ;
541
540
}
542
541
break ;
543
542
case 'B' :
544
543
document . getElementById ( "bl-btn" ) . classList . add ( "depressed" ) ;
545
- if ( bomlayout != "bom-only" ) {
544
+ if ( settings . bomlayout != "bom-only" ) {
546
545
canvassplit . collapse ( 0 ) ;
547
546
}
548
547
break ;
549
548
default :
550
549
document . getElementById ( "fb-btn" ) . classList . add ( "depressed" ) ;
551
- if ( bomlayout != "bom-only" ) {
550
+ if ( settings . bomlayout != "bom-only" ) {
552
551
canvassplit . setSizes ( [ 50 , 50 ] ) ;
553
552
}
554
553
}
555
- canvaslayout = layout ;
554
+ settings . canvaslayout = layout ;
556
555
writeStorage ( "canvaslayout" , layout ) ;
557
556
resizeAll ( ) ;
558
557
populateBomTable ( ) ;
@@ -671,9 +670,9 @@ function changeBomLayout(layout) {
671
670
onDragEnd : resizeAll
672
671
} ) ;
673
672
}
674
- bomlayout = layout ;
673
+ settings . bomlayout = layout ;
675
674
writeStorage ( "bomlayout" , layout ) ;
676
- changeCanvasLayout ( canvaslayout ) ;
675
+ changeCanvasLayout ( settings . canvaslayout ) ;
677
676
}
678
677
679
678
function focusFilterField ( ) {
@@ -685,7 +684,7 @@ function focusRefLookupField() {
685
684
}
686
685
687
686
function toggleBomCheckbox ( bomrowid , checkboxnum ) {
688
- if ( ! bomrowid || checkboxnum > checkboxes . length ) {
687
+ if ( ! bomrowid || checkboxnum > settings . checkboxes . length ) {
689
688
return ;
690
689
}
691
690
var bomrow = document . getElementById ( bomrowid ) ;
@@ -697,11 +696,11 @@ function toggleBomCheckbox(bomrowid, checkboxnum) {
697
696
698
697
function checkBomCheckbox ( bomrowid , checkboxname ) {
699
698
var checkboxnum = 0 ;
700
- while ( checkboxnum < checkboxes . length &&
701
- checkboxes [ checkboxnum ] . toLowerCase ( ) != checkboxname . toLowerCase ( ) ) {
699
+ while ( checkboxnum < settings . checkboxes . length &&
700
+ settings . checkboxes [ checkboxnum ] . toLowerCase ( ) != checkboxname . toLowerCase ( ) ) {
702
701
checkboxnum ++ ;
703
702
}
704
- if ( ! bomrowid || checkboxnum >= checkboxes . length ) {
703
+ if ( ! bomrowid || checkboxnum >= settings . checkboxes . length ) {
705
704
return ;
706
705
}
707
706
var bomrow = document . getElementById ( bomrowid ) ;
@@ -712,24 +711,23 @@ function checkBomCheckbox(bomrowid, checkboxname) {
712
711
}
713
712
714
713
function setBomCheckboxes ( value ) {
715
- bomCheckboxes = value ;
716
714
writeStorage ( "bomCheckboxes" , value ) ;
715
+ settings . checkboxes = value . split ( "," ) . filter ( ( e ) => e ) ;
717
716
prepCheckboxes ( ) ;
718
717
populateBomTable ( ) ;
719
718
}
720
719
721
720
function prepCheckboxes ( ) {
722
- checkboxes = bomCheckboxes . split ( "," ) . filter ( ( e ) => e ) ;
723
721
var table = document . getElementById ( "checkbox-stats" ) ;
724
722
while ( table . childElementCount > 1 ) {
725
723
table . removeChild ( table . lastChild ) ;
726
724
}
727
- if ( checkboxes . length ) {
725
+ if ( settings . checkboxes . length ) {
728
726
table . style . display = "" ;
729
727
} else {
730
728
table . style . display = "none" ;
731
729
}
732
- for ( var checkbox of checkboxes ) {
730
+ for ( var checkbox of settings . checkboxes ) {
733
731
var tr = document . createElement ( "TR" ) ;
734
732
var td = document . createElement ( "TD" ) ;
735
733
td . innerHTML = checkbox ;
@@ -823,94 +821,6 @@ document.onkeydown = function(e) {
823
821
}
824
822
}
825
823
826
- function getStorageBooleanOrDefault ( storageString , def ) {
827
- var b = readStorage ( storageString ) ;
828
- if ( b === null ) {
829
- b = def ;
830
- } else {
831
- b = ( b == "true" ) ;
832
- }
833
- return b ;
834
- }
835
-
836
- function initDefaults ( ) {
837
- bomlayout = readStorage ( "bomlayout" ) ;
838
- if ( bomlayout === null ) {
839
- bomlayout = config . bom_view ;
840
- }
841
- if ( ! [ 'bom-only' , 'left-right' , 'top-bottom' ] . includes ( bomlayout ) ) {
842
- bomlayout = config . bom_view ;
843
- }
844
- canvaslayout = readStorage ( "canvaslayout" ) ;
845
- if ( canvaslayout === null ) {
846
- canvaslayout = config . layer_view ;
847
- }
848
- bomCheckboxes = readStorage ( "bomCheckboxes" ) ;
849
- if ( bomCheckboxes === null ) {
850
- bomCheckboxes = config . checkboxes ;
851
- }
852
- document . getElementById ( "bomCheckboxes" ) . value = bomCheckboxes ;
853
-
854
- var b = getStorageBooleanOrDefault ( "padsVisible" , config . show_pads ) ;
855
- document . getElementById ( "padsCheckbox" ) . checked = b ;
856
- padsVisible ( b ) ;
857
-
858
- b = getStorageBooleanOrDefault ( "fabricationVisible" , config . show_fabrication ) ;
859
- document . getElementById ( "fabricationCheckbox" ) . checked = b ;
860
- fabricationVisible ( b ) ;
861
-
862
- b = getStorageBooleanOrDefault ( "silkscreenVisible" , config . show_silkscreen ) ;
863
- document . getElementById ( "silkscreenCheckbox" ) . checked = b ;
864
- silkscreenVisible ( b ) ;
865
-
866
- b = getStorageBooleanOrDefault ( "referencesVisible" , true ) ;
867
- document . getElementById ( "referencesCheckbox" ) . checked = b ;
868
- referencesVisible ( b ) ;
869
-
870
- b = getStorageBooleanOrDefault ( "valuesVisible" , true ) ;
871
- document . getElementById ( "valuesCheckbox" ) . checked = b ;
872
- valuesVisible ( b ) ;
873
-
874
- if ( "tracks" in pcbdata ) {
875
- b = getStorageBooleanOrDefault ( "tracksVisible" , true ) ;
876
- document . getElementById ( "tracksCheckbox" ) . checked = b ;
877
- tracksVisible ( b ) ;
878
-
879
- b = getStorageBooleanOrDefault ( "zonesVisible" , true ) ;
880
- document . getElementById ( "zonesCheckbox" ) . checked = b ;
881
- zonesVisible ( b ) ;
882
- } else {
883
- document . getElementById ( "tracksAndZonesCheckboxes" ) . style . display = "none" ;
884
- tracksVisible ( false ) ;
885
- zonesVisible ( false ) ;
886
- }
887
-
888
- b = getStorageBooleanOrDefault ( "dnpOutline" , false ) ;
889
- document . getElementById ( "dnpOutlineCheckbox" ) . checked = b ;
890
- dnpOutline ( b ) ;
891
-
892
- b = getStorageBooleanOrDefault ( "redrawOnDrag" , config . redraw_on_drag ) ;
893
- document . getElementById ( "dragCheckbox" ) . checked = b ;
894
- setRedrawOnDrag ( b ) ;
895
-
896
- b = getStorageBooleanOrDefault ( "darkmode" , config . dark_mode ) ;
897
- document . getElementById ( "darkmodeCheckbox" ) . checked = b ;
898
- setDarkMode ( b ) ;
899
-
900
- b = getStorageBooleanOrDefault ( "highlightpin1" , config . highlight_pin1 ) ;
901
- document . getElementById ( "highlightpin1Checkbox" ) . checked = b ;
902
- setHighlightPin1 ( b ) ;
903
-
904
- boardRotation = readStorage ( "boardRotation" ) ;
905
- if ( boardRotation === null ) {
906
- boardRotation = config . board_rotation * 5 ;
907
- } else {
908
- boardRotation = parseInt ( boardRotation ) ;
909
- }
910
- document . getElementById ( "boardRotation" ) . value = boardRotation / 5 ;
911
- document . getElementById ( "rotationDegree" ) . textContent = boardRotation ;
912
- }
913
-
914
824
window . onload = function ( e ) {
915
825
initUtils ( ) ;
916
826
initRender ( ) ;
@@ -926,7 +836,7 @@ window.onload = function(e) {
926
836
initDone = true ;
927
837
prepCheckboxes ( ) ;
928
838
// Triggers render
929
- changeBomLayout ( bomlayout ) ;
839
+ changeBomLayout ( settings . bomlayout ) ;
930
840
}
931
841
932
842
window . onresize = resizeAll ;
0 commit comments