@@ -83,20 +83,46 @@ fieldsets.forEach((element, index) => {
8383
8484 state . parts [ index ] = element . id + '/' + event . target . value + '/' ;
8585
86+
87+ // [T]: refactor three below as element.id instead?
88+
89+ // [T]: discern if checkboxes, change value
90+ if ( element . id == 'waive-your-copyright' ) {
91+ //state.parts[index] = element.id + '+' + event.target.value;
92+ console . log ( 'waive-your-copyright' ) ;
93+ }
94+ // [T]: discern if checkboxes, change value
95+ if ( element . id == 'confirmation' ) {
96+ //state.parts[index] = element.id + '+' + event.target.value;
97+ console . log ( 'confirmation' ) ;
98+ }
8699 // [T]: discern if checkboxes, change value
100+ if ( element . id == 'attribution-details' ) {
101+ //state.parts[index] = element.id + '+' + event.target.value;
102+ console . log ( 'attribution-details' ) ;
103+ }
87104
88105 state . parts . forEach ( ( element , i ) => {
89106 if ( i > index ) {
90107 state . parts . splice ( i ) ;
91108 }
92109 } ) ;
110+ // [T]: also reset value to nothing each time
93111
94112 state . current = state . parts . join ( '' ) ;
95113
96114 state . props = { } ;
97115 state . props . license = 'unknown' ;
98116
99- //console.log(state.parts);
117+ // check and match possibilities
118+ state . possibilities . forEach ( ( possibility , index ) => {
119+ if ( possibility . includes ( state . current ) ) {
120+ //state.props.license = state.possibilities[index];
121+ console . log ( 'at:' + state . possibilities [ index ] ) ;
122+ }
123+ } ) ;
124+
125+ console . log ( state . parts ) ;
100126 console . log ( state . current ) ;
101127 console . log ( state . props . license ) ;
102128
@@ -108,26 +134,37 @@ fieldsets.forEach((element, index) => {
108134
109135/////////////////////////////////////////////////////////////
110136
111-
137+ // check if visitor needs help, start help pathways
112138 if ( state . current == 'do-you-know-which-license-you-need/no/' ) {
113139
114140 applyDefaults . elements . forEach ( ( element ) => {
115141 document . querySelector ( element ) . classList . toggle ( 'disable' ) ;
116142 } ) ;
117143 document . querySelector ( '#which-license-do-you-need' ) . classList . toggle ( 'disable' ) ;
144+ document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
118145
119146 }
120147
148+ // if visitor doesn't need help
121149 if ( state . current == 'do-you-know-which-license-you-need/yes/' ) {
122150
123151 applyDefaults . elements . forEach ( ( element ) => {
124152 document . querySelector ( element ) . classList . toggle ( 'disable' ) ;
125153 } ) ;
126154 document . querySelector ( '#which-license-do-you-need' ) . classList . toggle ( 'disable' ) ;
155+ document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
127156
128-
129157 }
130158
159+ // check if cc0
160+ if ( state . parts [ 2 ] == 'require-attribution/no/' || state . parts [ 1 ] == 'which-license-do-you-need/cc-0/' ) {
161+
162+ applyDefaults . elements . forEach ( ( element ) => {
163+ document . querySelector ( element ) . classList . add ( 'disable' ) ;
164+ } ) ;
165+ document . querySelector ( '#waive-your-copyright' ) . classList . remove ( 'disable' ) ;
166+
167+ }
131168
132169 } ) ;
133170
0 commit comments