';if(this.showFeaturedImage){html_to_add+=this.getFeaturedImageHtml(post);} if(this.showExcerpt){html_to_add+='
' +this.maybeStripShortcodes(post.excerpt.rendered) +'
';} if(this.showContent){var content_html='';if(this.include_inline_js){content_html=post.content.rendered;}else{var parsed_nodes=jQuery.parseHTML(post.content.rendered);if(parsed_nodes!==null){for(var i=0;i';} if(this.showComments){html_to_add+=this.renderCommentsOf(post);} if(this.showDivider){html_to_add+='
';} this.posts_div.append(html_to_add);};this.getPostTitle=function(post){return post.title.rendered.replace(this.translations.protected,'').replace(this.translations.private,'')};this.maybeStripShortcodes=function(content){if(!this.shortcodes){return content.replace(/\[[^\]]+\]/g,'');} return content;};this.addTaxonomies=function(post){var html=' ';if('_embedded'in post&&'wp:term'in post._embedded){for(taxonomy in post._embedded['wp:term']){var term_names=[];var taxonomy_slug='';jQuery.each(post._embedded['wp:term'][taxonomy],(key,term)=>{term_names.push(term.name);taxonomy_slug=term.taxonomy;});if(term_names.length>0){html+=' ';}}} return html;};this.getPublishedDate=function(post) {return this.getPrettyDate(post.date);};this.getPrettyDate=function(iso_date) {var dateParser=/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/;var match=iso_date.match(dateParser);var date=new Date(match[1],match[2]-1,match[3],match[4],match[5],match[6]);var months=['January','February','March','April','May','June','July','August','September','October','November','December'];return months[date.getMonth()]+' '+date.getDate()+', '+date.getFullYear();};this.getFeaturedImageHtml=function(post) {if('_embedded'in post&&'wp:featuredmedia'in post._embedded&&typeof post._embedded['wp:featuredmedia']=="object"&&typeof post._embedded['wp:featuredmedia'][0]=="object"&&typeof post._embedded['wp:featuredmedia'][0].media_details=="object"){var featured_media_url=null;if(typeof post._embedded['wp:featuredmedia'][0].media_details.sizes=="object"&&typeof post._embedded['wp:featuredmedia'][0].media_details.sizes.full=="object"){featured_media_url=post._embedded['wp:featuredmedia'][0].media_details.sizes.full.source_url;}else if(typeof post._embedded['wp:featuredmedia'][0].source_url=="string"){featured_media_url=post._embedded['wp:featuredmedia'][0].source_url;} if(featured_media_url!==null){return'';}} return'';};this.renderCommentsOf=function(post) {let html='';let has_comments=typeof post.comments!=='undefined'&&post.comments!==null&&post.comments.length>0;var comments_header_text=this.translations.comments;html+='
';html+='
';html+='

'+comments_header_text+'

';html+='
';html+='
    ';if(has_comments){let htmlAndEven=this.renderComments(post.comments,1,true,true);html+=htmlAndEven.html;} html+='
';return html;};this.renderComments=function(comments,depth,evenThread,even){let html='';for(let i=0;i\n'+'\t\t\t
\n'+'\t\t\t\t
\n'+'\t\t\t\t\t
\n'+'\t\t\t\t\t\t\t\t\t\t\t\t'+comment.author_name+' '+this.translations.says+'\t\t\t\t\t
\n'+'\n'+'\t\t\t\t\t\n'+'\n'+'\t\t\t\t\t\t\t\t\t
\n'+'\n'+'\t\t\t\t
\n'+'\t\t\t\t\t'+comment.content.rendered+'\t\t\t\t
\n'+'\n';if(typeof comment.children!=='undefined'&&comment.children!==null&&comment.children.length>0){html+='
    ';let htmlAndEven=this.renderComments(comment.children,depth++,evenThread,!even);even=!htmlAndEven.even;html+=htmlAndEven.html;html+='
';} html+='';evenThread=!evenThread;even=!even;} return{html:html,even:even};};this.copyPosts=function(){try{copyToClip(this.posts_div.html());alert(this.translations.copied);}catch(err){alert(this.translations.copy_error);}} this.stopAndShowError=function(errorText){this.header.html(this.translations.error);this.status_span.html(this.translations.error_fetching_posts+errorText+'
'+this.translations.troubleshooting);}} function pmb_print_preview() {jQuery('.pmb-waiting-message-fullpage').toggle();} function pmb_help_show(id){jQuery('.'+id).show();jQuery('.pmb-help-ask').hide();} function pmb_copy(){pmb_print.copyPosts();} var pmb_print=null;var original_backbone_sync;jQuery(document).ready(function(){pmb_print=new PmbPrintPage(pmb_print_data.data,pmb_print_data.i18n);setTimeout(function(){if(!pmb_print.working){alert(pmb_print_data.i18n.init_error);}},30000);wp.api.loadPromise.done(function(){setTimeout(function(){pmb_print.initialize();},1000);});original_backbone_sync=Backbone.sync;Backbone.sync=function(method,model,options){options.converters={'text json':function(result){let new_result=result;do{var start_of_json=Math.min(new_result.indexOf('{'),new_result.indexOf('['),new_result.indexOf('true'),new_result.indexOf('false'),new_result.indexOf('"'));new_result=new_result.substring(start_of_json);try{let i=jQuery.parseJSON(new_result);return i;}catch(error){new_result=new_result.substring(1);}}while(start_of_json!==false);throw"No JSON found in AJAX response using custom JSON parser.";}};return original_backbone_sync(method,model,options);};});function copyToClip(text){if(!navigator.clipboard||typeof ClipboardItem==='undefined'){copyToClipOld(text);return;} var item=new ClipboardItem({"text/html":new Blob([text],{type:"text/html"})});navigator.clipboard.write([item]).then(function(){console.log('Async: Copying to clipboard was successful!');},function(err){console.log('Async: Could not copy text: '+err);copyToClipOld(text);});} function copyToClipOld(str){function listener(e){e.clipboardData.setData("text/html",str);e.clipboardData.setData("text/plain",str);e.preventDefault();} document.addEventListener("copy",listener);document.execCommand("copy");document.removeEventListener("copy",listener);console.log('Fallback: Copying to clipboard was attempted');};