Skip to content

Commit daf4684

Browse files
add pathstate finding skeleton base
1 parent 93746cd commit daf4684

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ <h1>Choose a License for Your Work</h1>
163163
<legend>Attribution?</legend>
164164

165165
<div>
166-
<input type="radio" id="yes-attribution" name="attribution" value="yes" checked />
166+
<input type="radio" id="yes-attribution" name="attribution" value="yes" />
167167
<label for="yes-attribution">Yes</label>
168168
</div>
169169

src/scripts.js

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,70 @@ let last = statePath[statePath.length - 1].split("&")
2525
let license = last[1].split("=");
2626

2727

28+
/////////////////////////////////////////////////////////////
2829

30+
let state = {};
31+
state.parts = [];
32+
// temp defaults
33+
state.parts[0] = 'do-you-know-which-license-you-need/yes/';
34+
state.parts[1] = 'which-license-do-you-need/cc-by';
35+
console.log(state.parts);
2936

30-
const fieldsets = document.querySelectorAll('fieldset');
37+
const fieldsets = document.querySelectorAll('fieldset');
38+
// [T]: filter this down to ones not currently set to disable?
39+
40+
// set default disabled pathways
41+
42+
let applyDefaults = {};
43+
applyDefaults.elements = [
44+
'#require-attribution',
45+
'#allow-commercial-use',
46+
'#allow-derivatives',
47+
'#share-alike',
48+
'#waive-your-copyright',
49+
'#confirmation'
50+
];
51+
applyDefaults.elements.forEach((element) => {
52+
document.querySelector(element).classList.toggle('disable');
53+
});
54+
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');
3161

3262
fieldsets.forEach((element, index) => {
3363

64+
// [T]: set defaults here first in state.parts dynamically
65+
3466
element.addEventListener("change", (event) => {
35-
console.log(index);
67+
//console.log(index);
3668
//console.log(element.id);
3769
//console.log(event.target.value);
3870

39-
console.log(element.id + '/' + event.target.value + '/' );
71+
//console.log(element.id + '/' + event.target.value + '/' );
72+
73+
state.parts[index] = element.id + '/' + event.target.value + '/';
74+
75+
state.parts.forEach((element, i) => {
76+
if (i > index) {
77+
state.parts.splice(i);
78+
}
79+
});
80+
81+
state.current = state.parts.join('');
82+
83+
//console.log(state.parts);
84+
console.log(state.current);
85+
86+
87+
// if (state.current == 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/') {
88+
// let chosenLicense = 'cc-0';
89+
// console.log(chosenLicense);
90+
// }
91+
4092

4193
});
4294

0 commit comments

Comments
 (0)