Skip to content

Commit f346d47

Browse files
change stored, and non user-facing terminology to tool instead of license
1 parent ad05c02 commit f346d47

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

src/scripts.js

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11

22
// all possible State Path Routes
33
let rawStatePathRoutes = [
4-
'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',
5-
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/(attribution-details)&license=cc-by',
6-
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/(attribution-details)&license=cc-by-sa',
7-
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/(attribution-details)&license=cc-by-nd',
8-
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/(attribution-details)&license=cc-by-nc',
9-
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/(attribution-details)&license=cc-by-nc-sa',
10-
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/(attribution-details)&license=cc-by-nc-nd',
4+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-0/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0',
5+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by/(attribution-details)&tool=cc-by',
6+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-sa/(attribution-details)&tool=cc-by-sa',
7+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nd/(attribution-details)&tool=cc-by-nd',
8+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc/(attribution-details)&tool=cc-by-nc',
9+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-sa/(attribution-details)&tool=cc-by-nc-sa',
10+
'do-you-know-which-license-you-need/yes/which-license-do-you-need/cc-by-nc-nd/(attribution-details)&tool=cc-by-nc-nd',
1111

12-
'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',
13-
'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',
14-
'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',
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',
16-
'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',
17-
'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',
18-
'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/(attribution-details)&license=cc-0'
12+
'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)&tool=cc-by',
13+
'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)&tool=cc-by-sa',
14+
'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/yes/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nd',
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)&tool=cc-by-nc',
16+
'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)&tool=cc-by-nc-sa',
17+
'do-you-know-which-license-you-need/no/require-attribution/yes/allow-commercial-use/no/allow-derivatives/no/confirmation+ownership+read+revocation/(attribution-details)&tool=cc-by-nc-nd',
18+
'do-you-know-which-license-you-need/no/require-attribution/no/waive-your-copyright+waive+read/(attribution-details)&tool=cc-0'
1919
];
2020

2121
// empty state obj
@@ -42,14 +42,14 @@ applyDefaults.elements = [
4242
// from rawStatePathRoutes
4343
function setStatePossibilities(state) {
4444

45-
// create state possibilities from possible licenses with adjoining statePaths
45+
// create state possibilities from possible tools with adjoining statePaths
4646
state.possibilities = [];
4747
rawStatePathRoutes.forEach((path, index) => {
4848

4949
statePath = path.split("&");
5050
statepath = statePath;
51-
license = statePath[statePath.length - 1].split("=");
52-
license = license[1];
51+
tool = statePath[statePath.length - 1].split("=");
52+
tool = tool[1];
5353

5454
regEx = /\(([^)]+)\)/g;
5555
optionals = statePath[0].match(regEx);
@@ -62,11 +62,11 @@ function setStatePossibilities(state) {
6262

6363
fullPath = statePath[0].replace(/[{()}]/g, '') + '/';
6464

65-
if (state.possibilities[license] == undefined) {
66-
state.possibilities[license] = [];
65+
if (state.possibilities[tool] == undefined) {
66+
state.possibilities[tool] = [];
6767
}
68-
state.possibilities[license].push(fullPath);
69-
state.possibilities[license].push(noOptionalsPath);
68+
state.possibilities[tool].push(fullPath);
69+
state.possibilities[tool].push(noOptionalsPath);
7070

7171
});
7272
}
@@ -125,40 +125,40 @@ function setStateCurrent(element, index, state) {
125125
}
126126

127127
// function to set state.props
128-
// including setting state.props.license (if valid)
128+
// including setting state.props.tool (if valid)
129129
// or error
130130
function setStateProps(index, state) {
131131

132132
state.props = {};
133-
state.props.license = 'unknown';
133+
state.props.tool = 'unknown';
134134

135135
// check and match possibilities
136136
Object.keys(state.possibilities).forEach((possibility) => {
137137
if(state.possibilities[possibility].includes(state.current)) {
138-
state.props.license = possibility;
138+
state.props.tool = possibility;
139139
console.log('matched');
140140
}
141141
});
142142

143-
// set licenseFull, licenseShort, licenseURL
144-
if (state.props.license != 'unknown' | state.props.license != 'cc-0' ) {
143+
// set toolFull, toolShort, toolURL
144+
if (state.props.tool != 'unknown' | state.props.tool != 'cc-0' ) {
145145

146-
formattedLicense = state.props.license.replace(/-/, ' ').toUpperCase();
147-
state.props.licenseShort = formattedLicense + ' 4.0';
146+
formattedTool = state.props.tool.replace(/-/, ' ').toUpperCase();
147+
state.props.toolShort = formattedTool + ' 4.0';
148148

149-
// set licenseFhort
149+
// set toolFhort
150150

151-
shortName = state.props.license.replace(/cc-/, '');
152-
state.props.licenseURL = 'https://creativecommons.org/licenses/'+ shortName +'/4.0/';
151+
shortName = state.props.tool.replace(/cc-/, '');
152+
state.props.toolURL = 'https://creativecommons.org/licenses/'+ shortName +'/4.0/';
153153
}
154154

155-
if (state.props.license == 'cc-0') {
155+
if (state.props.tool == 'cc-0') {
156156

157-
state.props.licenseShort = 'CC0 1.0';
157+
state.props.toolShort = 'CC0 1.0';
158158

159-
// set licenseFull
159+
// set toolFull
160160

161-
state.props.licenseURL = 'https://creativecommons.org/publicdomain/zero/1.0/';
161+
state.props.toolURL = 'https://creativecommons.org/publicdomain/zero/1.0/';
162162
}
163163

164164

@@ -219,17 +219,17 @@ function clearStepsAfterCursor(fieldsets, state) {
219219
function renderLicenseRec(state) {
220220
// document.querySelector('#license-recommendation header h3').textContent = state.props.license;
221221

222-
if (state.props.license != 'unknown' ) {
222+
if (state.props.tool != 'unknown' ) {
223223
document.querySelector('#license-recommendation').classList.remove('disable');
224224

225-
let license = state.props.license;
225+
let tool = state.props.tool;
226226
let template = document.getElementById(license);
227227
let templateContent = template.content.cloneNode(true);
228228
document.querySelector('#license-recommendation .license').textContent = '';
229229
document.querySelector('#license-recommendation .license').appendChild(templateContent);
230-
console.log('license set to: ' + license);
230+
console.log('license set to: ' + tool);
231231
}
232-
else if (state.props.license == 'unknown') {
232+
else if (state.props.tool == 'unknown') {
233233
document.querySelector('#license-recommendation').classList.add('disable');
234234
document.querySelector('#license-recommendation .license').textContent = '';
235235
}
@@ -239,7 +239,7 @@ function renderLicenseRec(state) {
239239
function renderMarkingFormats(state) {
240240

241241

242-
if (state.props.license != 'unknown' ) {}
242+
if (state.props.tool != 'unknown' ) {}
243243

244244
setStatePropsAttribution(state);
245245

@@ -251,22 +251,22 @@ function renderMarkingFormats(state) {
251251
let attribution = state.props.attribution;
252252

253253
let type = "licensed under";
254-
if (state.props.license == 'cc-0') {
254+
if (state.props.tool == 'cc-0') {
255255
type = "marked";
256256
}
257257

258-
let mark = attribution.title + ' © ' + attribution.workCreationYear + ' by ' + attribution.creator + ' is ' + type + ' ' + state.props.licenseShort + '. To view a copy of this license, visit ' + state.props.licenseURL;
258+
let mark = attribution.title + ' © ' + attribution.workCreationYear + ' by ' + attribution.creator + ' is ' + type + ' ' + state.props.toolShort + '. To view a copy of this license, visit ' + state.props.toolURL;
259259

260260
document.querySelector('#mark-your-work .plain-text.mark').textContent = mark;
261261
}
262262

263263

264264

265265
// function to render "mark your work",
266-
// if valid license from state.parts and/or state.current
266+
// if valid tool from state.parts and/or state.current
267267
// if attribution details input(s) filled out
268268
function renderMarkYourWork(state) {
269-
if (state.props.license != 'unknown' ) {
269+
if (state.props.tool != 'unknown' ) {
270270
// load attribution details template,
271271
// populate from attribution text values
272272
document.querySelector('#mark-your-work').classList.remove('disable');
@@ -282,7 +282,7 @@ function renderMarkYourWork(state) {
282282

283283
}
284284

285-
else if (state.props.license == 'unknown') {
285+
else if (state.props.tool == 'unknown') {
286286
document.querySelector('#mark-your-work').classList.add('disable');
287287
}
288288

@@ -375,7 +375,7 @@ function renderSteps(applyDefaults, state) {
375375
}
376376

377377
// function to render "mark your work", from attribution fields
378-
// if valid license from state.parts and/or state.current
378+
// if valid tool from state.parts and/or state.current
379379

380380
// function to handle error state
381381

@@ -409,7 +409,7 @@ function watchFieldsets(fieldsets, state) {
409409

410410
renderMarkYourWork(state);
411411

412-
console.log(state.props.licenseShort);
412+
console.log(state.props.toolShort);
413413

414414
});
415415

0 commit comments

Comments
 (0)