<commit_before>
/* count number of message qeues on the list view */
var $postListViewCount = 0;
var $MAX_ITEM = 0;
var $POST_VIEW_LIST = new Array();
var $COMMENTS_VIEW_LIST = new Array();
/* Choose Text by default*/
var $SELECTED_POST_TYPE = 'text';

/* struct.js runs from here. Placing the mid panel first*/
$.get("/author/"+$authorName, function(data){

	if(data){
		$("#struct-content").html(data);
		setPostOptClickListener();

	}
});

//set listener for each option button
function setPostOptClickListener(){
	$("#textOption").click(function(){
		$("#postSelectedType").html('Text');
		$SELECTED_POST_TYPE = 'Text';
	});

	$("#picOption").click(function(){
		$("#postSelectedType").html('Picture');
		$SELECTED_POST_TYPE = 'Picture';
	});

	$("#htmlOption").click(function(){
		$("#postSelectedType").html('HTML');
		$SELECTED_POST_TYPE = 'HTML';
	});

	$("#postSubmitBtn").click(function(){

		var $postObj = getJsonPostObj();
		if($postObj['permission'] != null && $postObj['message'] != '' && $postObj['title'] != ''){
			submitPostToServer($postObj);

		}else{
			alert("Please complete your form correctly before submit");
		}
	});

		getAllRawPostData();
		setRefreshTimer();
}

//Set a listener for each comment button
//The id for each li is #pid-expendBtn
function setCommentBtnClickLisener($pid){

	afterCommentsList($pid);
	appendReplyFormHtml($pid);

	$("#"+$pid+"-expandBtn").click(function(){
		$("#"+$pid+"-commentsList").show();
	});
}

//Generate the html code of the reply form
function appendReplyFormHtml($pid){
	var $li = "<textarea id=\""+$pid+"-replyForm\" class=\"form-control\" rows=\"3\"></textarea>" +
			"<button type=\"submit\" class=\"btn btn-default\">Reply</button>";

	$("#"+$pid+"-commentsList").append($li);

}

function createCommentHtml($cid,$content){
	var $li = "<div class=\"panel panel-default\">"+
			"<div class=\"panel-body\"><span>"+$content+"</span></div>"+
			"</div>";
}

function afterCommentsList($pid){
	$("#"+$pid).after("<li id=\""+$pid+"-commentsList\" style = \"display: none\"></li>");
}

//Send the Post object in json over http<commit_msg>Able to collapse the comments list<commit_after>
/* count number of message qeues on the list view */
var $postListViewCount = 0;
var $MAX_ITEM = 0;
var $POST_VIEW_LIST = new Array();
var $COMMENTS_VIEW_LIST = new Array();
/* Choose Text by default*/
var $SELECTED_POST_TYPE = 'text';

/* struct.js runs from here. Placing the mid panel first*/
$.get("/author/"+$authorName, function(data){

	if(data){
		$("#struct-content").html(data);
		setPostOptClickListener();

	}
});

//set listener for each option button
function setPostOptClickListener(){
	$("#textOption").click(function(){
		$("#postSelectedType").html('Text');
		$SELECTED_POST_TYPE = 'Text';
	});

	$("#picOption").click(function(){
		$("#postSelectedType").html('Picture');
		$SELECTED_POST_TYPE = 'Picture';
	});

	$("#htmlOption").click(function(){
		$("#postSelectedType").html('HTML');
		$SELECTED_POST_TYPE = 'HTML';
	});

	$("#postSubmitBtn").click(function(){

		var $postObj = getJsonPostObj();
		if($postObj['permission'] != null && $postObj['message'] != '' && $postObj['title'] != ''){
			submitPostToServer($postObj);

		}else{
			alert("Please complete your form correctly before submit");
		}
	});

		getAllRawPostData();
		setRefreshTimer();
}

//Set a listener for each comment button
//The id for each li is #pid-expendBtn
function setCommentBtnClickLisener($pid){

	afterCommentsList($pid);
	appendReplyFormHtml($pid);

	$("#"+$pid+"-expandBtn").click(function(){
		if($("#"+$pid+"-commentsList").is(":visible")){
			$("#"+$pid+"-commentsList").hide();
		}else{
			$("#"+$pid+"-commentsList").show();
		}
	});
}

//Generate the html code of the reply form
function appendReplyFormHtml($pid){
	var $li = "<textarea id=\""+$pid+"-replyForm\" class=\"form-control\" rows=\"3\"></textarea>" +
			"<button type=\"submit\" class=\"btn btn-default\">Reply</button>";

	$("#"+$pid+"-commentsList").append($li);

}

function createCommentHtml($cid,$content){
	var $li = "<div class=\"panel panel-default\">"+
			"<div class=\"panel-body\"><span>"+$content+"</span></div>"+
			"</div>";
}

function afterCommentsList($pid){
	$("#"+$pid).after("<li id=\""+$pid+"-commentsList\" style = \"display: none\"></li>");
}

//Send the Post object in json over http
{'fraction_non_alphanumeric': 0.222888786340563, 'fraction_numerical': 0.0013844023996308261, 'mean_word_length': 5.228448275862069, 'pattern_counts': {'":': 1, '<': 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': '2929150', 'n_tokens_mistral': 1475, 'n_tokens_neox': 1397, 'n_words': 307}