Skip to content

Commit 4506bd4

Browse files
add ability to define state possibilities in addition to state paths, for later comparison tracking on choice pathway selection
1 parent daf4684 commit 4506bd4

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/scripts.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ let rawStatePathRoutes = [
1717
'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/attribution-details&license=cc-0'
1818
];
1919

20-
21-
let rawStatePath = rawStatePathRoutes[13];
22-
let statePath = rawStatePath.split("/");
23-
24-
let last = statePath[statePath.length - 1].split("&")
25-
let license = last[1].split("=");
26-
27-
2820
/////////////////////////////////////////////////////////////
2921

3022
let state = {};
@@ -34,11 +26,28 @@ state.parts[0] = 'do-you-know-which-license-you-need/yes/';
3426
state.parts[1] = 'which-license-do-you-need/cc-by';
3527
console.log(state.parts);
3628

29+
// create state possibilities from possible licenses with adjoining statePaths
30+
state.possibilities = [];
31+
rawStatePathRoutes.forEach((path, index) => {
32+
33+
statePath = path.split("&");
34+
statepath = statePath;
35+
license = statePath[statePath.length - 1].split("=");
36+
license = license[1];
37+
38+
if (state.possibilities[license] == undefined) {
39+
state.possibilities[license] = [];
40+
}
41+
42+
state.possibilities[license].push(statePath[0]);
43+
44+
});
45+
console.log(state.possibilities);
46+
3747
const fieldsets = document.querySelectorAll('fieldset');
3848
// [T]: filter this down to ones not currently set to disable?
3949

40-
// set default disabled pathways
41-
50+
// set default visibly disabled pathways
4251
let applyDefaults = {};
4352
applyDefaults.elements = [
4453
'#require-attribution',
@@ -52,13 +61,6 @@ applyDefaults.elements.forEach((element) => {
5261
document.querySelector(element).classList.toggle('disable');
5362
});
5463

55-
//document.querySelector('#require-attribution').classList.toggle('disable');
56-
//document.querySelector('#allow-commercial-use').classList.toggle('disable');
57-
//document.querySelector('#allow-derivatives').classList.toggle('disable');
58-
//document.querySelector('#share-alike').classList.toggle('disable');
59-
//document.querySelector('#waive-your-copyright').classList.toggle('disable');
60-
//document.querySelector('#confirmation').classList.toggle('disable');
61-
6264
fieldsets.forEach((element, index) => {
6365

6466
// [T]: set defaults here first in state.parts dynamically
@@ -71,6 +73,8 @@ fieldsets.forEach((element, index) => {
7173
//console.log(element.id + '/' + event.target.value + '/' );
7274

7375
state.parts[index] = element.id + '/' + event.target.value + '/';
76+
77+
// [T]: discern if checkboxes, change value
7478

7579
state.parts.forEach((element, i) => {
7680
if (i > index) {
@@ -80,16 +84,18 @@ fieldsets.forEach((element, index) => {
8084

8185
state.current = state.parts.join('');
8286

87+
state.props = {};
88+
state.props.license = 'unknown';
89+
8390
//console.log(state.parts);
8491
console.log(state.current);
92+
console.log(state.props.license);
8593

86-
8794
// if (state.current == 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/') {
8895
// let chosenLicense = 'cc-0';
8996
// console.log(chosenLicense);
9097
// }
9198

92-
9399
});
94100

95101
});

0 commit comments

Comments
 (0)