@@ -172,14 +172,15 @@ function setStateProps(index, state) {
172172 setStatePropsAttribution ( state ) ;
173173}
174174
175+
175176// isolated function to just set the attribution
176177// subset of state.props (for use other places)
177178function setStatePropsAttribution ( state ) {
178- state . props . attribution . title = document . querySelector ( '#attribution-details #title' ) . value ;
179- state . props . attribution . creator = document . querySelector ( '#attribution-details #creator' ) . value ;
180- state . props . attribution . workLink = document . querySelector ( '#attribution-details #work-link' ) . value ;
181- state . props . attribution . creatorLink = document . querySelector ( '#attribution-details #creator-link' ) . value ;
182- state . props . attribution . workCreationYear = document . querySelector ( '#attribution-details #work-creation-year' ) . value ;
179+ state . props . attribution . title = document . querySelector ( '#attribution-details #title' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi , "" ) ;
180+ state . props . attribution . creator = document . querySelector ( '#attribution-details #creator' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi , "" ) ;
181+ state . props . attribution . workLink = document . querySelector ( '#attribution-details #work-link' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi , "" ) ;
182+ state . props . attribution . creatorLink = document . querySelector ( '#attribution-details #creator-link' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi , "" ) ;
183+ state . props . attribution . workCreationYear = document . querySelector ( '#attribution-details #work-creation-year' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi , "" ) ;
183184}
184185
185186// function to reset values beyond current fieldset
@@ -294,9 +295,42 @@ function renderMarkingFormats(state) {
294295 //templateContent.textContent = parseTokens("year", attribution.workCreationYear, templateContent.textContent);
295296 //document.querySelector('#mark-your-work .plain-text.mark').appendChild(templateContent);
296297
297-
298298 // set contents of rich text mark
299- let richTextMark = attribution . title + ' © ' + attribution . workCreationYear + ' by ' + attribution . creator + ' is ' + typeAsVerb + ' ' + '<a href="#">' + state . props . toolShort + '</a> <svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-logo"></use></svg> <svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-by"></use></svg> <svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-sa"></use></svg> ' ;
299+ let ccSVG = '<svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-logo"></use></svg>' ;
300+ let bySVG = '<svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-by"></use></svg>' ;
301+ let saSVG = '<svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-sa"></use></svg>' ;
302+ let ncSVG = '<svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-nc"></use></svg>' ;
303+ let ndSVG = '<svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-nd"></use></svg>' ;
304+ let zeroSVG = '<svg><use href="vocabulary/svg/cc/icons/cc-icons.svg#cc-zero"></use></svg>' ;
305+
306+ const currentTool = state . props . tool ;
307+ switch ( currentTool ) {
308+ case 'cc-0' :
309+ ccIconSet = ccSVG + zeroSVG ;
310+ break ;
311+ case 'cc-by' :
312+ ccIconSet = ccSVG + bySVG ;
313+ break ;
314+ case 'cc-by-sa' :
315+ ccIconSet = ccSVG + bySVG + saSVG ;
316+ break ;
317+ case 'cc-by-nd' :
318+ ccIconSet = ccSVG + bySVG + ndSVG ;
319+ break ;
320+ case 'cc-by-nc' :
321+ ccIconSet = ccSVG + bySVG + ncSVG ;
322+ break ;
323+ case 'cc-by-nc-sa' :
324+ ccIconSet = ccSVG + bySVG + ncSVG + saSVG ;
325+ break ;
326+ case 'cc-by-nc-nd' :
327+ ccIconSet = ccSVG + bySVG + ncSVG + ndSVG ;
328+ break ;
329+ default :
330+ currentTool = '' ;
331+ }
332+
333+ let richTextMark = attribution . title + ' © ' + attribution . workCreationYear + ' by ' + attribution . creator + ' is ' + typeAsVerb + ' ' + '<a href="#">' + state . props . toolShort + '</a>' + ccIconSet ;
300334 document . querySelector ( '#mark-your-work .rich-text.mark' ) . innerHTML = richTextMark ;
301335
302336
0 commit comments