@@ -8,12 +8,12 @@ let rawStatePathRoutes = [
88 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/attribution-details&license=cc-by-nc-sa' ,
99 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/attribution-details&license=cc-by-nc-nd' ,
1010
11- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commerical -use/yes/allow-derivatives/yes/share-alike/yes /confirmation+ownership+read+revocation/attribution-details&license=cc-by' ,
12- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commerical -use/yes/allow-derivatives/yes/share-alike/no /confirmation+ownership+read+revocation/attribution-details&license=cc-by-sa' ,
13- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commerical -use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nd' ,
14- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commerical -use/no/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nc' ,
15- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commerical -use/no/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nc-sa' ,
16- 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commerical -use/no/allow-derivatives/no/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nc-nd' ,
11+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial -use/yes/allow-derivatives/yes/share-alike/no /confirmation+ownership+read+revocation/attribution-details&license=cc-by' ,
12+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial -use/yes/allow-derivatives/yes/share-alike/yes /confirmation+ownership+read+revocation/attribution-details&license=cc-by-sa' ,
13+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial -use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nd' ,
14+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial -use/no/allow-derivatives/yes/share-alike/yes/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nc' ,
15+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial -use/no/allow-derivatives/yes/share-alike/no/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nc-sa' ,
16+ 'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial -use/no/allow-derivatives/no/confirmation+ownership+read+revocation/attribution-details&license=cc-by-nc-nd' ,
1717 'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/attribution-details&license=cc-0'
1818] ;
1919
@@ -26,6 +26,8 @@ state.parts[0] = 'do-you-know-which-license-you-need/yes/';
2626state . parts [ 1 ] = 'which-license-do-you-need/cc-by' ;
2727console . log ( state . parts ) ;
2828
29+ //state.possibilities = [];
30+
2931state . current = state . parts . join ( '' ) ;
3032console . log ( state . current ) ;
3133
@@ -45,7 +47,7 @@ rawStatePathRoutes.forEach((path, index) => {
4547 state . possibilities [ license ] . push ( statePath [ 0 ] ) ;
4648
4749 } ) ;
48- console . log ( state . possibilities ) ;
50+ // console.log(state.possibilities);
4951
5052const fieldsets = document . querySelectorAll ( 'fieldset' ) ;
5153// [T]: filter this down to ones not currently set to disable?
@@ -81,8 +83,47 @@ fieldsets.forEach((element, index) => {
8183
8284 //console.log(element.id + '/' + event.target.value + '/' );
8385
84- state . parts [ index ] = element . id + '/' + event . target . value + '/' ;
86+ state . parts [ index ] = element . id + '/' + event . target . value ;
87+
88+
89+ // check if checkbox, with siblings
90+ if ( event . target . getAttribute ( 'type' ) == 'checkbox' ) {
91+ //state.parts[index] = element.id + '+' + event.target.value;
92+
93+ let checkboxElements = element . querySelectorAll ( 'input[type="checkbox"]' ) ;
94+ let checkboxes = [ ] ;
95+
96+ checkboxElements . forEach ( ( checkbox , index ) => {
97+ if ( checkbox . checked ) {
98+ checkboxes [ index ] = checkbox . value ;
99+ //console.log(checkbox.value);
100+ }
101+
102+ } ) ;
103+
104+ //console.log(checkboxes);
105+
106+ let joinedCheckboxes = checkboxes . filter ( Boolean ) . join ( '+' ) ;
107+
108+ state . parts [ index ] = element . id + '+' + joinedCheckboxes ;
109+ }
110+
111+ if ( event . target . getAttribute ( 'type' ) == 'text' ) {
85112
113+ state . parts [ index ] = element . id ;
114+
115+ }
116+
117+ // borked!
118+ if ( index + 1 != state . parts . length - 1 ) {
119+
120+ //state.parts[index] = state.parts[index] + '/';
121+ //console.log(index);
122+ //console.log(state.parts.length - 1);
123+
124+ }
125+
126+
86127
87128 // [T]: refactor three below as element.id instead?
88129
@@ -115,16 +156,23 @@ fieldsets.forEach((element, index) => {
115156 state . props . license = 'unknown' ;
116157
117158 // 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 ] ) ;
159+ Object . keys ( state . possibilities ) . forEach ( ( possibility , index ) => {
160+ if ( state . possibilities [ possibility ] . includes ( state . current ) ) {
161+ state . props . license = possibility ;
162+ console . log ( 'matched' ) ;
122163 }
164+ // console.log(possibility);
165+ // console.log(state.possibilities[possibility]);
166+ // console.log(state.current);
167+
168+ //console.log('possibility: ' + possibility);
169+ //console.log('possibilities');
123170 } ) ;
124171
125172 console . log ( state . parts ) ;
126173 console . log ( state . current ) ;
127174 console . log ( state . props . license ) ;
175+ //console.log(state.possibilities);
128176
129177 // if (state.current == 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/') {
130178 // let chosenLicense = 'cc-0';
0 commit comments