@@ -2,7 +2,6 @@ import { getOptions, getLayers } from '../utils';
22
33export async function onLoadOptions ( ) {
44
5- let defColors = [ "black" , "green" , "yellow" , "red" , "blue" , "brown" ] ;
65 let options = await getOptions ( ) ;
76 let layers = await getLayers ( ) ;
87
@@ -45,20 +44,18 @@ export async function onLoadOptions() {
4544 document . getElementById ( 'groupColorCheckbox' ) . addEventListener ( 'click' , checkColorBtn ) ;
4645 document . getElementById ( 'colorbarCheckbox' ) . addEventListener ( 'click' , checkColorBtn ) ;
4746
48- let colorsAdded = defColors . map ( e => {
49- if ( options . colors . includes ( e ) ) {
50- return document . getElementById ( `${ e } Checkbox` ) ;
51- }
47+ let colorsAdded = options . colors . map ( e => {
48+ return document . getElementById ( `${ e } Checkbox` ) ;
5249 } ) ;
53- colorsAdded . filter ( el => el != null ) . forEach ( e => { e . checked = true } ) ;
50+ colorsAdded . forEach ( e => { e . checked = true } ) ;
5451
5552 let form = document . getElementById ( "formoptions" ) ;
5653 if ( form ) {
57- [ ...form . elements ] . forEach ( e => e . addEventListener ( 'input' , ( ev ) => { onChange ( ev , options , defColors ) } ) )
54+ [ ...form . elements ] . forEach ( e => e . addEventListener ( 'input' , ( ev ) => { onChange ( ev , options ) } ) )
5855 }
5956}
6057
61- async function onChange ( ev , options , defColors ) {
58+ async function onChange ( ev , options ) {
6259
6360 ev . preventDefault ( ) ;
6461
@@ -86,16 +83,12 @@ async function onChange(ev, options, defColors) {
8683 break
8784 }
8885
89- if ( defColors ) {
90-
91- let colorCheckboxes = defColors . map ( e => document . getElementById ( `${ e } Checkbox` ) ) ;
92- let colorsNew = colorCheckboxes . map ( e => {
93- if ( e . checked ) { return e . value }
94- } )
95- options . colors = colorsNew . filter ( el => el != null ) ;
96- app . properties . color = options . colors [ 0 ] ;
97-
98- }
86+ let colorCheckboxes = document . getElementById ( 'colors-list' ) . querySelectorAll ( 'input[type="checkbox"]' ) ;
87+ let colorsNew = [ ...colorCheckboxes ] . map ( e => {
88+ if ( e . checked ) { return e . value }
89+ } )
90+ options . colors = colorsNew . filter ( el => el != null ) ;
91+ app . properties . color = options . colors [ 0 ] ;
9992
10093 if ( document . getElementById ( 'groupCheckbox' ) . checked ) {
10194 options . groupType = document . getElementById ( 'groupTypeCheckbox' ) . checked ;
0 commit comments