Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ <h3>Mark Your Work</h3>
<input type="checkbox" id="rich-text-full-name" name="rich-text-full-name" value="rich-text-full-name" />
<label for="rich-text-full-name">full tool name</label>
</div>
<div>
<input type="checkbox" id="rich-text-generic-mark" name="rich-text-generic-mark" value="rich-text-generic-mark" />
<label for="rich-text-generic-mark">generic mark</label>
</div>
<button id="copy-rich-text-mark">Copy</button>
</footer>
</details>
Expand All @@ -377,6 +381,10 @@ <h3>Mark Your Work</h3>
<input type="checkbox" id="html-full-name" name="html-full-name" value="html-full-name" />
<label for="html-full-name">full tool name</label>
</div>
<div>
<input type="checkbox" id="html-generic-mark" name="html-generic-mark" value="html-generic-mark" />
<label for="html-generic-mark">generic mark</label>
</div>
<button id="copy-html-mark">Copy</button>
</footer>
</details>
Expand All @@ -400,6 +408,10 @@ <h3>Mark Your Work</h3>
<input type="checkbox" id="plain-text-full-name" name="plain-text-full-name" value="plain-text-full-name" />
<label for="plain-text-full-name">full tool name</label>
</div>
<div>
<input type="checkbox" id="plain-text-generic-mark" name="plain-text-generic-mark" value="plain-text-generic-mark" />
<label for="plain-text-generic-mark">generic mark</label>
</div>
<button id="copy-plain-text-mark">Copy</button>
</footer>
</details>
Expand Down Expand Up @@ -807,5 +819,9 @@ <h4>Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International</
<p>{{title}} {{copyright}} by {{creator}} is {{typeAsVerb}} {{toolName}}. To view a copy of this {{type}}, visit {{toolURL}}</p>
</template>

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

</body>
</html>
41 changes: 36 additions & 5 deletions src/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,19 @@ function renderMarkingFormats(state) {
// set contents of plain text mark
// [T]: reverse use of <template> since it has limits on tokenization capacity, even if
// it allows more dev readability.
let template = document.getElementById('plain-text');
let templateContent = template.content.cloneNode(true);

// determine if generic mark is toggled.
plainTextGenericMark = document.querySelector('#plain-text-generic-mark').checked;

if (plainTextGenericMark == true) {
template = document.getElementById('plain-text-generic');
console.log('plain text generic mark true');
} else {
template = document.getElementById('plain-text');
console.log('plain text generic mark false');
}

templateContent = template.content.cloneNode(true);
document.querySelector('#mark-your-work .plain-text.mark').textContent = '';

function parseTokens(name, value, str){
Expand All @@ -299,7 +310,6 @@ function renderMarkingFormats(state) {

if (plainTextFullName == true) {
markProps.toolName = state.props.toolLong;

} else {
markProps.toolName = state.props.toolShort;
}
Expand Down Expand Up @@ -355,7 +365,17 @@ function renderMarkingFormats(state) {
markProps.toolName = state.props.toolShort;
}

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;
// determine if generic mark is toggled.
richTextGenericMark = document.querySelector('#rich-text-generic-mark').checked;

if (richTextGenericMark == true) {
richTextMark = 'This work' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
console.log('plain text generic mark true');
} else {
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;
console.log('plain text generic mark false');
}

document.querySelector('#mark-your-work .rich-text.mark').innerHTML = richTextMark;


Expand All @@ -368,8 +388,19 @@ function renderMarkingFormats(state) {
} else {
markProps.toolName = state.props.toolShort;
}

// determine if generic mark is toggled.
htmlGenericMark = document.querySelector('#html-generic-mark').checked;

if (htmlGenericMark == true) {
htmlMark = 'This work' + ' is ' + typeAsVerb + ' ' + '<a href="' + state.props.toolURL + '">' + markProps.toolName + '</a>' + ccIconSet;
console.log('plain text generic mark true');
} else {
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;
console.log('plain text generic mark false');
}

//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>';
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;
document.querySelector('#mark-your-work .html.mark').innerHTML = htmlMark;
}

Expand Down