-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathscripts.js
95 lines (70 loc) · 4.42 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
let rawStatePathRoutes = [
'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',
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/attribution-details&license=cc-by',
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/attribution-details&license=cc-by-sa',
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/attribution-details&license=cc-by-nd',
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/attribution-details&license=cc-by-nc',
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/attribution-details&license=cc-by-nc-sa',
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/attribution-details&license=cc-by-nc-nd',
'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',
'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',
'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',
'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',
'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',
'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',
'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/attribution-details&license=cc-0'
];
let rawStatePath = rawStatePathRoutes[13];
let statePath = rawStatePath.split("/");
let last = statePath[statePath.length - 1].split("&")
let license = last[1].split("=");
/////////////////////////////////////////////////////////////
let state = {};
state.parts = [];
// temp defaults
state.parts[0] = 'do-you-know-which-license-you-need/yes/';
state.parts[1] = 'which-license-do-you-need/cc-by';
console.log(state.parts);
const fieldsets = document.querySelectorAll('fieldset');
// [T]: filter this down to ones not currently set to disable?
// set default disabled pathways
let applyDefaults = {};
applyDefaults.elements = [
'#require-attribution',
'#allow-commercial-use',
'#allow-derivatives',
'#share-alike',
'#waive-your-copyright',
'#confirmation'
];
applyDefaults.elements.forEach((element) => {
document.querySelector(element).classList.toggle('disable');
});
//document.querySelector('#require-attribution').classList.toggle('disable');
//document.querySelector('#allow-commercial-use').classList.toggle('disable');
//document.querySelector('#allow-derivatives').classList.toggle('disable');
//document.querySelector('#share-alike').classList.toggle('disable');
//document.querySelector('#waive-your-copyright').classList.toggle('disable');
//document.querySelector('#confirmation').classList.toggle('disable');
fieldsets.forEach((element, index) => {
// [T]: set defaults here first in state.parts dynamically
element.addEventListener("change", (event) => {
//console.log(index);
//console.log(element.id);
//console.log(event.target.value);
//console.log(element.id + '/' + event.target.value + '/' );
state.parts[index] = element.id + '/' + event.target.value + '/';
state.parts.forEach((element, i) => {
if (i > index) {
state.parts.splice(i);
}
});
state.current = state.parts.join('');
//console.log(state.parts);
console.log(state.current);
// if (state.current == 'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/') {
// let chosenLicense = 'cc-0';
// console.log(chosenLicense);
// }
});
});