Skip to content

Commit a6b0fe0

Browse files
corect naming in markup, add logic for all three mark toggles
1 parent ac9cffe commit a6b0fe0

File tree

2 files changed

+37
-14
lines changed

2 files changed

+37
-14
lines changed

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ <h4>Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International</
819819
<p>{{title}} {{copyright}} by {{creator}} is {{typeAsVerb}} {{toolName}}. To view a copy of this {{type}}, visit {{toolURL}}</p>
820820
</template>
821821

822-
<template id="plain-text-generic-mark" class="mark">
822+
<template id="plain-text-generic" class="mark">
823823
<p>This work is {{typeAsVerb}} {{toolName}}. To view a copy of this {{type}}, visit {{toolURL}}</p>
824824
</template>
825825

src/scripts.js

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,19 @@ function renderMarkingFormats(state) {
275275
// set contents of plain text mark
276276
// [T]: reverse use of <template> since it has limits on tokenization capacity, even if
277277
// it allows more dev readability.
278-
let template = document.getElementById('plain-text');
279-
let templateContent = template.content.cloneNode(true);
278+
279+
// determine if generic mark is toggled.
280+
plainTextGenericMark = document.querySelector('#plain-text-generic-mark').checked;
281+
282+
if (plainTextGenericMark == true) {
283+
template = document.getElementById('plain-text-generic');
284+
console.log('plain text generic mark true');
285+
} else {
286+
template = document.getElementById('plain-text');
287+
console.log('plain text generic mark false');
288+
}
289+
290+
templateContent = template.content.cloneNode(true);
280291
document.querySelector('#mark-your-work .plain-text.mark').textContent = '';
281292

282293
function parseTokens(name, value, str){
@@ -302,15 +313,6 @@ function renderMarkingFormats(state) {
302313
} else {
303314
markProps.toolName = state.props.toolShort;
304315
}
305-
306-
// determine if generic mark is toggled.
307-
plainTextGenericMark = document.querySelector('#plain-text-generic-mark').checked;
308-
309-
if (plainTextGenericMark == true) {
310-
console.log('plain text generic mark true');
311-
} else {
312-
console.log('plain text generic mark false');
313-
}
314316

315317
// [T]: could carve out separate sections for different mark formats here
316318
// only handles plain text at the moment
@@ -363,7 +365,17 @@ function renderMarkingFormats(state) {
363365
markProps.toolName = state.props.toolShort;
364366
}
365367

366-
let richTextMark = '<a href="' + attribution.workLink + '">' + attribution.title + '</a>' + copyright + ' by ' + '<a href="' + attribution.creatorLink + '">' + attribution.creator + '</a>' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
368+
// determine if generic mark is toggled.
369+
richTextGenericMark = document.querySelector('#rich-text-generic-mark').checked;
370+
371+
if (richTextGenericMark == true) {
372+
richTextMark = 'This work' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
373+
console.log('plain text generic mark true');
374+
} else {
375+
richTextMark = '<a href="' + attribution.workLink + '">' + attribution.title + '</a>' + copyright + ' by ' + '<a href="' + attribution.creatorLink + '">' + attribution.creator + '</a>' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
376+
console.log('plain text generic mark false');
377+
}
378+
367379
document.querySelector('#mark-your-work .rich-text.mark').innerHTML = richTextMark;
368380

369381

@@ -376,8 +388,19 @@ function renderMarkingFormats(state) {
376388
} else {
377389
markProps.toolName = state.props.toolShort;
378390
}
391+
392+
// determine if generic mark is toggled.
393+
htmlGenericMark = document.querySelector('#html-generic-mark').checked;
394+
395+
if (htmlGenericMark == true) {
396+
htmlMark = 'This work' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
397+
console.log('plain text generic mark true');
398+
} else {
399+
htmlMark = '<a href="' + attribution.workLink + '">' + attribution.title + '</a>' + copyright + ' by ' + '<a href="' + attribution.creatorLink + '">' + attribution.creator + '</a>' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
400+
console.log('plain text generic mark false');
401+
}
402+
379403
//defaultHTML = '<p xmlns:cc="http://creativecommons.org/ns#">This work is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0<img src="https://mirrors.creativecommons.org/presskit/icons/cc.svg" alt=""><img src="https://mirrors.creativecommons.org/presskit/icons/by.svg" alt=""><img src="https://mirrors.creativecommons.org/presskit/icons/sa.svg" alt=""></a></p>';
380-
let htmlMark = '<a href="' + attribution.workLink + '">' + attribution.title + '</a>' + copyright + ' by ' + '<a href="' + attribution.creatorLink + '">' + attribution.creator + '</a>' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
381404
document.querySelector('#mark-your-work .html.mark').innerHTML = htmlMark;
382405
}
383406

0 commit comments

Comments
 (0)