@@ -83,7 +83,6 @@ function setStateParts(state) {
8383
8484 // temp defaults
8585 state . parts [ 0 ] = 'do-you-know-which-license-you-need/yes/' ;
86- //state.parts[1] = 'which-license-do-you-need/cc-by/';
8786 state . parts [ 8 ] = 'attribution-details/' ;
8887}
8988// function to update state.parts
@@ -113,9 +112,6 @@ function updateStateParts(element, index, event, state) {
113112 state . parts [ index ] = element . id + '/' ;
114113
115114 }
116-
117- console . log ( "state.parts (after change)" ) ;
118- console . log ( state . parts ) ;
119115}
120116
121117// function to combine current tracked
@@ -142,7 +138,6 @@ function setStateProps(index, state) {
142138 Object . keys ( state . possibilities ) . forEach ( ( possibility ) => {
143139 if ( state . possibilities [ possibility ] . includes ( state . current ) ) {
144140 state . props . tool = possibility ;
145- console . log ( 'matched' ) ;
146141 }
147142 } ) ;
148143
@@ -174,16 +169,12 @@ function setStateProps(index, state) {
174169 }
175170
176171 state . props . cursor = index ;
177- console . log ( 'cursor at:' ) ;
178- console . log ( index ) ;
179172
180173 state . props . attribution = [ ] ;
181174 setStatePropsAttribution ( state ) ;
182-
183175}
184176
185-
186- // isolated function to just set the attribution
177+ // function to just set the attribution
187178// subset of state.props (for use other places)
188179function setStatePropsAttribution ( state ) {
189180
@@ -193,21 +184,18 @@ function setStatePropsAttribution(state) {
193184 state . props . attribution . title = document . querySelector ( '#attribution-details #title' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
194185 }
195186
196-
197187 if ( document . querySelector ( '#attribution-details #creator' ) . value == '' ) {
198188 state . props . attribution . creator = document . querySelector ( '#attribution-details #creator' ) . placeholder . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
199189 } else {
200190 state . props . attribution . creator = document . querySelector ( '#attribution-details #creator' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
201191 }
202192
203-
204193 if ( document . querySelector ( '#attribution-details #work-link' ) . value == '' ) {
205194 state . props . attribution . workLink = document . querySelector ( '#attribution-details #work-link' ) . placeholder . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
206195 } else {
207196 state . props . attribution . workLink = document . querySelector ( '#attribution-details #work-link' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
208197 }
209198
210-
211199 if ( document . querySelector ( '#attribution-details #creator-link' ) . value == '' ) {
212200 state . props . attribution . creatorLink = document . querySelector ( '#attribution-details #creator-link' ) . placeholder . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
213201 } else {
@@ -219,16 +207,10 @@ function setStatePropsAttribution(state) {
219207 } else {
220208 state . props . attribution . workCreationYear = document . querySelector ( '#attribution-details #work-creation-year' ) . value . replace ( / ( < ( [ ^ > ] + ) > ) / gi, "" ) ;
221209 }
222-
223- // state.props.attribution.title = document.querySelector('#attribution-details #title').value.replace(/(<([^>]+)>)/gi, "");
224- // state.props.attribution.creator = document.querySelector('#attribution-details #creator').value.replace(/(<([^>]+)>)/gi, "");
225- // state.props.attribution.workLink = document.querySelector('#attribution-details #work-link').value.replace(/(<([^>]+)>)/gi, "");
226- // state.props.attribution.creatorLink = document.querySelector('#attribution-details #creator-link').value.replace(/(<([^>]+)>)/gi, "");
227- // state.props.attribution.workCreationYear = document.querySelector('#attribution-details #work-creation-year').value.replace(/(<([^>]+)>)/gi, "");
228210}
229211
230212// function to reset values beyond current fieldset
231- // [T] this could potentially do with a refactor
213+ // [T]: this could potentially do with a refactor
232214// check for input type, and them perform
233215// contextual resets to universal defaults
234216// unchecked for radio/checkbox, noselect for
@@ -241,18 +223,11 @@ function clearStepsAfterCursor(fieldsets, state) {
241223 element . querySelector ( "#tool" ) . value = "noselect" ;
242224 }
243225
244- // if (index = 8) {
245-
246- // }
247-
248226 if ( index != 1 | index != 8 ) {
249- console . log ( 'clear at:' ) ;
250- console . log ( index ) ;
251227
252228 let inputs = element . querySelectorAll ( 'input' ) ;
253229 inputs . forEach ( ( input , i ) => {
254230 input . checked = false ;
255- console . log ( 'uncheck!' ) ;
256231 } ) ;
257232 }
258233 }
@@ -262,7 +237,6 @@ function clearStepsAfterCursor(fieldsets, state) {
262237// function to render "tool recommendation",
263238// if valid tool from state.parts and/or state.current
264239function renderToolRec ( state ) {
265- // document.querySelector('#tool-recommendation header h3').textContent = state.props.tool;
266240
267241 if ( state . props . tool != 'unknown' ) {
268242 document . querySelector ( '#tool-recommendation' ) . classList . remove ( 'disable' ) ;
@@ -272,12 +246,12 @@ function renderToolRec(state) {
272246 let templateContent = template . content . cloneNode ( true ) ;
273247 document . querySelector ( '#tool-recommendation .tool' ) . textContent = '' ;
274248 document . querySelector ( '#tool-recommendation .tool' ) . appendChild ( templateContent ) ;
275- console . log ( 'tool set to: ' + tool ) ;
276249 }
277250 else if ( state . props . tool == 'unknown' ) {
278251 document . querySelector ( '#tool-recommendation' ) . classList . add ( 'disable' ) ;
279252 document . querySelector ( '#tool-recommendation .tool' ) . textContent = '' ;
280253 }
254+
281255}
282256
283257// render specifically the mark formats subsections
@@ -287,11 +261,6 @@ function renderMarkingFormats(state) {
287261
288262 setStatePropsAttribution ( state ) ;
289263
290- //let title = state.props.attribution.title;
291- //let workCreationYear = state.props.attribution.workCreationYear;
292-
293- //let phrase = '(c) ' + workCreationYear + ' ' + title + ' is licensed under ';
294-
295264 let attribution = state . props . attribution ;
296265
297266 let type = "license" ;
@@ -301,12 +270,8 @@ function renderMarkingFormats(state) {
301270 typeAsVerb = "marked" ;
302271 }
303272
304- //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;
305- //document.querySelector('#mark-your-work .plain-text.mark').textContent = mark;
306-
307-
308273 // set contents of plain text mark
309- // TODO : reverse use of <template> since it has limits on tokenization capacity, even if
274+ // [T] : reverse use of <template> since it has limits on tokenization capacity, even if
310275 // it allows more dev readability.
311276 let template = document . getElementById ( 'plain-text' ) ;
312277 let templateContent = template . content . cloneNode ( true ) ;
@@ -326,7 +291,6 @@ function renderMarkingFormats(state) {
326291 markProps . toolLong = state . props . toolLong ;
327292 markProps . toolURL = state . props . toolURL ;
328293
329-
330294 // set contents of plain text mark
331295 plainTextFullName = document . querySelector ( '#plain-text-full-name' ) . checked ;
332296
@@ -337,19 +301,13 @@ function renderMarkingFormats(state) {
337301 markProps . toolName = state . props . toolShort ;
338302 }
339303
340- // could carve out separate sections for different mark formats here
304+ // [T]: could carve out separate sections for different mark formats here
341305 // only handles plain text at the moment
342306 for ( const [ key , value ] of Object . entries ( markProps ) ) {
343307 templateContent . textContent = parseTokens ( key , value , templateContent . textContent ) ;
344- console . log ( `${ key } : ${ value } ` ) ;
345- console . log ( templateContent ) ;
346308 }
347309 document . querySelector ( '#mark-your-work .plain-text.mark' ) . appendChild ( templateContent ) ;
348310
349-
350- //templateContent.textContent = parseTokens("year", attribution.workCreationYear, templateContent.textContent);
351- //document.querySelector('#mark-your-work .plain-text.mark').appendChild(templateContent);
352-
353311 // set contents of rich text mark
354312 let ccSVG = '<img src="https://mirrors.creativecommons.org/presskit/icons/cc.svg" style="max-width: 1em;max-height:1em;margin-left: .2em;">' ;
355313 let bySVG = '<img src="https://mirrors.creativecommons.org/presskit/icons/by.svg" style="max-width: 1em;max-height:1em;margin-left: .2em;">' ;
@@ -436,21 +394,19 @@ function renderMarkingFormats(state) {
436394// console.log(parsedMark);
437395
438396
397+
439398// function to render "empty area"
440399// if no valid tool from state.parts and/or state/current
441-
442400function renderEmptyPlaceholder ( state ) {
443401
444402 if ( state . props . tool == 'unknown' ) {
445403 document . querySelector ( '#empty' ) . classList . remove ( 'disable' ) ;
446- console . log ( 'show empty' ) ;
447404 }
448405
449406 else if ( state . props . tool != 'unknown' ) {
450407 document . querySelector ( '#empty' ) . classList . add ( 'disable' ) ;
451- console . log ( 'hide empty' ) ;
452408 }
453-
409+
454410}
455411
456412// function to render "mark your work",
@@ -461,14 +417,7 @@ function renderMarkYourWork(state) {
461417 // load attribution details template,
462418 // populate from attribution text values
463419 document . querySelector ( '#mark-your-work' ) . classList . remove ( 'disable' ) ;
464-
465- //state.props.attribution.title
466- // let title = state.props.attribution.title;
467- // let workCreationYear = state.props.attribution.workCreationYear;
468-
469- // let phrase = '(c) ' + workCreationYear + ' ' + title + ' is licensed under ';
470420
471- // document.querySelector('#mark-your-work .mark-holder').textContent = phrase + state.props.tool;
472421 renderMarkingFormats ( state ) ;
473422
474423 }
@@ -512,9 +461,7 @@ function renderSteps(applyDefaults, state) {
512461 } ) ;
513462 document . querySelector ( '#which-license-do-you-need' ) . classList . toggle ( 'disable' ) ;
514463 document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
515-
516- console . log ( "pass one" ) ;
517-
464+
518465 }
519466
520467 // if visitor doesn't need help
@@ -535,17 +482,13 @@ function renderSteps(applyDefaults, state) {
535482 document . querySelector ( element ) . classList . add ( 'disable' ) ;
536483 } ) ;
537484
538- //if (state.parts[0] == 'do-you-know-which-license-you-need/no/') {
539- //document.querySelector('#require-attribution').classList.remove('disable');
540- //}
541485 document . querySelector ( '#waive-your-copyright' ) . classList . remove ( 'disable' ) ;
542486
543487 } else {
544488 document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
545489 }
546490 if ( state . parts [ 2 ] == 'require-attribution/no/' ) {
547491 document . querySelector ( '#require-attribution' ) . classList . remove ( 'disable' ) ;
548- //document.querySelector('#confirmation').classList.remove('disable');
549492 }
550493
551494 // walk away from cc-0, reset attribution choice point
@@ -555,8 +498,6 @@ function renderSteps(applyDefaults, state) {
555498 } ) ;
556499 document . querySelector ( '#require-attribution' ) . classList . remove ( 'disable' ) ;
557500 document . querySelector ( '#waive-your-copyright' ) . classList . add ( 'disable' ) ;
558-
559- //document.querySelector('#confirmation').classList.remove('disable');
560501 }
561502
562503 // tie SA to ND choice
@@ -566,10 +507,7 @@ function renderSteps(applyDefaults, state) {
566507
567508}
568509
569- // function to render "mark your work", from attribution fields
570- // if valid tool from state.parts and/or state.current
571-
572- // function to handle error state
510+ // [T]: function to handle error state
573511
574512// function to watch for fieldset changes
575513function watchFieldsets ( fieldsets , state ) {
@@ -579,20 +517,13 @@ function watchFieldsets(fieldsets, state) {
579517
580518 element . addEventListener ( "change" , ( event ) => {
581519
582- console . log ( "something changed!" ) ;
583520 updateStateParts ( element , index , event , state ) ;
584521
585522 setStateCurrent ( element , index , state ) ;
586- console . log ( "state.current (after change)" ) ;
587- console . log ( state . current ) ;
588523
589524 setStateProps ( index , state ) ;
590- console . log ( "state.props (after change)" ) ;
591- console . log ( state . props ) ;
592525
593526 // [T]: also reset values beyond current changed fieldset to nothing each time
594- //element.checked = false;
595- //console.log('reset values beyond current fieldset to nothing');
596527 clearStepsAfterCursor ( fieldsets , state ) ;
597528
598529 renderSteps ( applyDefaults , state ) ;
@@ -603,8 +534,6 @@ function watchFieldsets(fieldsets, state) {
603534
604535 renderMarkYourWork ( state ) ;
605536
606- console . log ( state . props . toolShort ) ;
607-
608537 } ) ;
609538
610539 } ) ;
@@ -617,8 +546,6 @@ function watchAttributionDetails(fieldsets, state) {
617546 textFields . forEach ( ( element , index ) => {
618547
619548 element . addEventListener ( "keyup" , ( event ) => {
620- console . log ( 'typing is happening' ) ;
621-
622549 renderMarkingFormats ( state ) ;
623550 } ) ;
624551
@@ -630,8 +557,6 @@ function watchMarkToggles(toggles, state) {
630557 toggles . forEach ( ( element , index ) => {
631558
632559 element . addEventListener ( "click" , ( event ) => {
633- console . log ( 'toggling is happening' ) ;
634-
635560 renderMarkingFormats ( state ) ;
636561 } ) ;
637562
@@ -652,58 +577,42 @@ function watchMarkCopiers(copiers, state) {
652577 copiers . forEach ( ( element , index ) => {
653578
654579 element . addEventListener ( "click" , ( event ) => {
655- console . log ( 'copying is happening' ) ;
656580
657581 if ( element . parentNode . parentNode . querySelector ( '.mark' ) . value != null ) {
658582 copyToClipboard ( element . parentNode . parentNode . querySelector ( '.mark' ) . value ) ;
659- console . log ( 'copying value' ) ;
660583 } else {
661584 copyToClipboard ( element . parentNode . parentNode . querySelector ( '.mark' ) . innerHTML ) ;
662- console . log ( 'copying innerHTML' ) ;
663585 }
664586 } ) ;
665587
666588 } ) ;
667589}
668590
669-
670-
671-
672591document . addEventListener ( "DOMContentLoaded" , ( event ) => {
673592 // full flow logic
674593 setStateParts ( state ) ;
675- console . log ( "state.parts (at default)" ) ;
676- console . log ( state . parts ) ;
677594
678595 setStatePossibilities ( state ) ;
679- console . log ( "state.possibilities" ) ;
680- console . log ( state . possibilities ) ;
681596
682597 setDefaults ( applyDefaults ) ;
683- console . log ( "initial defaults applied" ) ;
684598
685599 setStateProps ( 0 , state ) ;
686- console . log ( "initial defaults applied" ) ;
687600
688601 watchFieldsets ( fieldsets , state ) ;
689602 watchAttributionDetails ( fieldsets , state ) ;
690603 watchMarkToggles ( toggles , state ) ;
691604 watchMarkCopiers ( copiers , state ) ;
692-
693- console . log ( "DOM fully loaded and parsed" ) ;
694605} ) ;
695606
696-
697607// rough panel expansion test
698- let expandButtons = document . querySelectorAll ( 'button.expandPanel' ) ;
608+ // let expandButtons = document.querySelectorAll('button.expandPanel');
699609
700- expandButtons . forEach ( ( element , index ) => {
701- element . addEventListener ( "click" , ( event ) => {
610+ // expandButtons.forEach((element, index) => {
611+ // element.addEventListener("click", (event) => {
702612
703- parent = event . target . parentNode . parentNode ;
704- parent . querySelector ( '.panel' ) . classList . toggle ( 'expand' ) ;
705- console . log ( 'expanded!' ) ;
613+ // parent = event.target.parentNode.parentNode;
614+ // parent.querySelector('.panel').classList.toggle('expand');
706615
707- } ) ;
708- } ) ;
616+ // });
617+ // });
709618
0 commit comments