11
22let rawStatePathRoutes = [
3- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/attribution-details&license=cc-0' ,
4- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/attribution-details&license=cc-by' ,
5- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/attribution-details&license=cc-by-sa' ,
6- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/attribution-details&license=cc-by-nd' ,
7- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/attribution-details&license=cc-by-nc' ,
8- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/attribution-details&license=cc-by-nc-sa' ,
9- 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/attribution-details&license=cc-by-nc-nd' ,
3+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/( attribution-details) &license=cc-0' ,
4+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/( attribution-details) &license=cc-by' ,
5+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/( attribution-details) &license=cc-by-sa' ,
6+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/( attribution-details) &license=cc-by-nd' ,
7+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/( attribution-details) &license=cc-by-nc' ,
8+ 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/( attribution-details) &license=cc-by-nc-sa' ,
9+ '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-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/share-alike/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/no/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/yes/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' ,
17- 'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/attribution-details&license=cc-0'
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/share-alike/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/no/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/yes/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' ,
17+ 'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/( attribution-details) &license=cc-0'
1818] ;
1919
2020/////////////////////////////////////////////////////////////
@@ -40,12 +40,30 @@ rawStatePathRoutes.forEach((path, index) => {
4040 statepath = statePath ;
4141 license = statePath [ statePath . length - 1 ] . split ( "=" ) ;
4242 license = license [ 1 ] ;
43-
43+
44+ regEx = / \( ( [ ^ ) ] + ) \) / g;
45+ optionals = statePath [ 0 ] . match ( regEx ) ;
46+
47+ optionals . forEach ( ( optional ) => {
48+
49+ //console.log(optional);
50+ noOptionalsPath = statePath [ 0 ] . replace ( optional , '' ) ;
51+
52+ } ) ;
53+
54+ fullPath = statePath [ 0 ] . replace ( / [ { ( ) } ] / g, '' ) + '/' ;
55+
56+ //console.log(fullPath);
57+ //console.log(noOptionalsPath);
58+
4459 if ( state . possibilities [ license ] == undefined ) {
4560 state . possibilities [ license ] = [ ] ;
4661 }
4762
48- state . possibilities [ license ] . push ( statePath [ 0 ] + '/' ) ;
63+ //state.possibilities[license].push(statePath[0]+ '/');
64+
65+ state . possibilities [ license ] . push ( fullPath ) ;
66+ state . possibilities [ license ] . push ( noOptionalsPath ) ;
4967
5068 } ) ;
5169 //console.log(state.possibilities);
@@ -179,7 +197,7 @@ fieldsets.forEach((element, index) => {
179197 console . log ( state . parts ) ;
180198 console . log ( state . current ) ;
181199 console . log ( state . props . license ) ;
182- // console.log(state.possibilities);
200+ console . log ( state . possibilities ) ;
183201
184202 // if (state.current == 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/') {
185203 // let chosenLicense = 'cc-0';
@@ -193,7 +211,7 @@ fieldsets.forEach((element, index) => {
193211 if ( state . current == 'do-you-know-which-license-you-need/no/' ) {
194212
195213 applyDefaults . elements . forEach ( ( element ) => {
196- document . querySelector ( element ) . classList . toggle ( 'disable' ) ;
214+ document . querySelector ( element ) . classList . remove ( 'disable' ) ;
197215 } ) ;
198216 document . querySelector ( '#which-license-do-you-need' ) . classList . toggle ( 'disable' ) ;
199217 document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
@@ -204,7 +222,7 @@ fieldsets.forEach((element, index) => {
204222 if ( state . current == 'do-you-know-which-license-you-need/yes/' ) {
205223
206224 applyDefaults . elements . forEach ( ( element ) => {
207- document . querySelector ( element ) . classList . toggle ( 'disable' ) ;
225+ document . querySelector ( element ) . classList . add ( 'disable' ) ;
208226 } ) ;
209227 document . querySelector ( '#which-license-do-you-need' ) . classList . toggle ( 'disable' ) ;
210228 document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
@@ -217,8 +235,17 @@ fieldsets.forEach((element, index) => {
217235 applyDefaults . elements . forEach ( ( element ) => {
218236 document . querySelector ( element ) . classList . add ( 'disable' ) ;
219237 } ) ;
238+
239+ //if (state.parts[0] == 'do-you-know-which-license-you-need/no/') {
240+ //document.querySelector('#require-attribution').classList.remove('disable');
241+ //}
220242 document . querySelector ( '#waive-your-copyright' ) . classList . remove ( 'disable' ) ;
221243
244+ } else {
245+ document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
246+ }
247+ if ( state . parts [ 2 ] == 'require-attribution/no/' ) {
248+ document . querySelector ( '#require-attribution' ) . classList . remove ( 'disable' ) ;
222249 }
223250
224251 } ) ;
0 commit comments