<commit_before>'use strict';
/*global json2html*/
/*global UI*/
/*global App*/
/*global getID*/
/*global getClass*/

UI.PostPage = function(elem) {
	var element = elem;
	document.addEventListener('postExpanded', function(e){
		displayContentItems(e.detail);
	});

	var displayContentItems = function(data) {
			//element.className = 'hidden';
			element.innerHTML = json2html.transform(data, mainTemplate);
			commentHandler();
			var postMode = new CustomEvent('postMode', {});
			document.dispatchEvent(postMode);
		};

	var commentHandler = function(){
		function switchButtonClasses(id){
			var tempComments = getID('singlePostComments-' + id);
			if(tempComments.className === 'comments line'){
				tempComments.className = 'comments line active';
			} else {
				tempComments.className = 'comments line';
			}
		}
		element.addEventListener('click', function(e){
			switchButtonClasses(e.target.dataset.id);
		});
	};

	var mainTemplate = {
		'tag':'article',
		'class':'missedConnection line post',
		'html':'<div class="line post-meta"><span class="tempname">from: ${tempname}</span></div>',
		'children' : [
			{
				'tag':'h2',
				'html':'${title}',
				'class':'title line'
			},
			{
				'tag':'section',
				'id':'singlePost-${_id}',
				'children': [
					{
						'tag':'p',
						'html':'${body}'
					}
				],
			},
			{
				'tag' : 'div',
				id: 'singlePostComments-${_id}',
				'class' :'comments line',
				'html' :
					'<form class="comment-box" method="post" action="api/v1/comments/${_id}">'+
						'<label>Submit a comment</label>'+
						'<textarea class="comment-out" name="body"></textarea>'+
						'<button data-id=${_id} class="submit-comment" type="submit" value="send-comment">Submit A Comment</button>' + '</form>',
				'children' : [
					{
						'tag' : 'ul',
						'children' : [
							{
								'tag' : 'li',
								'children' : function(){
									return(json2html.transform(this.comments, commentMicroTemplate));
								}
							}
						]
					}
				]
			},
			{
				'tag':'footer',
				'class':'gesturebar line',
				'children': [
					{
						'tag':'div',
						'class':'vote',
						'children': [
							{
								'tag':'button',
								'class':'upVote',
								'title':'up vote',
								'html':''
							},
							{
								'tag':'button',
								'class': 'downvote',
								'title':'down vote',
								'html':''
							}
						]
					},
					{
						'tag':'button',
						'class':'viewComment',
						'data-id': '${_id}',
						'title':'comment',
						'html':''
					}
				]
			}
		]
	};

	var commentMicroTemplate = {
		'tag':'div',
		'data-id':'${_id}',
		'children': [
			{
				'tag':'h5',
				'html':'${tempname}'
			},
			{
				'tag':'p',
				'html':'${body}'
			}
		]
	};
};<commit_msg>shows comments by default in single post view<commit_after>'use strict';
/*global json2html*/
/*global UI*/
/*global App*/
/*global getID*/
/*global getClass*/

UI.PostPage = function(elem) {
	var element = elem;
	document.addEventListener('postExpanded', function(e){
		displayContentItems(e.detail);
	});

	var displayContentItems = function(data) {
			//element.className = 'hidden';
			element.innerHTML = json2html.transform(data, mainTemplate);
			var postMode = new CustomEvent('postMode', {});
			document.dispatchEvent(postMode);
		};

	var mainTemplate = {
		'tag':'article',
		'class':'missedConnection line post',
		'html':'<div class="line post-meta"><span class="tempname">from: ${tempname}</span></div>',
		'children' : [
			{
				'tag':'h2',
				'html':'${title}',
				'class':'title line'
			},
			{
				'tag':'section',
				'id':'singlePost-${_id}',
				'children': [
					{
						'tag':'p',
						'html':'${body}'
					}
				],
			},
			{
				'tag' : 'div',
				id: 'singlePostComments-${_id}',
				'class' :'comments line active',
				'html' :
					'<form class="comment-box" method="post" action="api/v1/comments/${_id}">'+
						'<label>Submit a comment</label>'+
						'<textarea class="comment-out" name="body"></textarea>'+
						'<button data-id=${_id} class="submit-comment" type="submit" value="send-comment">Submit A Comment</button>' + '</form>',
				'children' : [
					{
						'tag' : 'ul',
						'children' : [
							{
								'tag' : 'li',
								'children' : function(){
									return(json2html.transform(this.comments, commentMicroTemplate));
								}
							}
						]
					}
				]
			},
			{
				'tag':'footer',
				'class':'gesturebar line',
				'children': [
					{
						'tag':'div',
						'class':'vote',
						'children': [
							{
								'tag':'button',
								'class':'upVote',
								'title':'up vote',
								'html':''
							},
							{
								'tag':'button',
								'class': 'downvote',
								'title':'down vote',
								'html':''
							}
						]
					}
				]
			}
		]
	};

	var commentMicroTemplate = {
		'tag':'div',
		'data-id':'${_id}',
		'children': [
			{
				'tag':'h5',
				'html':'${tempname}'
			},
			{
				'tag':'p',
				'html':'${body}'
			}
		]
	};
};
{'fraction_non_alphanumeric': 0.21338155515370705, 'fraction_numerical': 0.0024110910186859553, 'mean_word_length': 2.5430604982206404, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1746551', 'n_tokens_mistral': 2423, 'n_tokens_neox': 1676, 'n_words': 272}