<commit_before>/**
 * 
 */
tasks = [];
$(function(){
	$('.mainNav').buttonset();
	$( document ).tooltip();

	//Scroll effect
	$( '.viewGroup' ).on( 'scroll', function( event ) {
		var $viewGroup=$( '.viewGroup');
		var scrollLeft=$(this).scrollLeft();
		$viewGroup.find('.taskName').css('left', scrollLeft);
		$viewGroup.find('.add').css('left', scrollLeft);
	});
});

function id2path(val){
	return JSON.parse('[' + val.replace('.', ',') + ']');
}


function getTask(path) {
	var index = path[0]-1;
	if(index >= tasks.length)
		return null;
	var container = tasks[path[0]-1];
	for (var i = 1; i < path.length; i++) {
		index = path[i]-1;
		if(index >= container.subTaskslength)
			return null;
		container = container.subTasks[index];
	}
	return container;
}

function makeTaskName(path) {
	var str = 'task';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makePlayTaskName(path) {
	var str = 'playTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makeEditTaskName(path) {
	var str = 'editTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makeDeleteTaskName(path) {
	var str = 'deleteTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makeAddTaskName(path) {
	var str = 'addTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

var startPos = 0;
var scale = 2;
//
//function generateTaskView() {
//	
//}

function addTaskChrono(viewGroup, task){
	var viewItem = '<div class="task" '+ 'id="' + makeTaskName(task.id) +'" >';
	viewItem += generateTaskView(task);
	viewItem += '</div>';
	viewGroup.append(viewItem);
}

function editTaskChrono(viewGroup, task){
	var $element = viewGroup.find('#' + makeTaskName(task.id));
	var viewItem = generateTaskView(task);
	$element.html(viewItem);
}

function generateOptions(task){
	var path = task.id;
	var optionItem = '<span class="play ui-icon ui-icon-play" id="'+ makePlayTaskName(path) + '"></span>';
	optionItem 	  += '<span class="edit ui-icon ui-icon-pencil" id="'+ makeEditTaskName(path) + '"></span>';
	optionItem 	  += '<span class="add ui-icon ui-icon-plus" id="'+ makeAddTaskName(path) + '"></span>';
	optionItem 	  += '<span class="delete ui-icon ui-icon-trash" id="'+ makeDeleteTaskName(path) + '"></span>';
	return optionItem;
}

function generateTaskView(task) {
	var path = task.id;
	var viewItem = '<span class="taskName">'+generateOptions(task)+path.join('.')+ ". "+task.name + '</span>';
	viewItem += '<span class="meter start" style = "width:'+(task.start()*scale)+'em"></span>';
	viewItem += '<span class="meter spentReg" style = "width:'+(task.spentReg()*scale)+'em"></span>';
	viewItem += '<span class="meter remaining" style = "width:'+(task.remaining()*scale)+'em"></span>';
	viewItem += '<span class="meter leftover" style = "width:'+(task.leftover()*scale)+'em"></span>';
	viewItem += '<span class="meter overdue" style = "width:'+(task.overdue()*scale)+'em"></span>';
	adjustRuler(task.end());
	return viewItem;
}

currentEnd = 15;
function adjustRuler(end){
	if(end > currentEnd){
		var incr = Math.ceil((end - currentEnd)/5);
		var $timeLabel = $('.timeLabel');
		for(var i = 1; i <= incr; ++i){
			$timeLabel.append('<span>' + (currentEnd + i*5) + 'h</span>');
		}
		currentEnd += (incr*5);
	}
}

function Task(id, name, description, duration, spent, status, dependencies){
	this.id = id;
	this.name = name;
	this.description = description;
	this.duration = duration;
	this.spent = spent;
	if(!status)
		this.status = 'proposed';
	else
		this.status = status;
	if(!dependencies)
		this.dependencies = [];
	else <commit_msg>Some documentation did.<commit_after>/**
 * 
 */
tasks = [];
$(function(){
	$('.mainNav').buttonset();
	$( document ).tooltip();

	//Scroll effect
	$( '.viewGroup' ).on( 'scroll', function( event ) {
		var $viewGroup=$( '.viewGroup');
		var scrollLeft=$(this).scrollLeft();
		$viewGroup.find('.taskName').css('left', scrollLeft);
		$viewGroup.find('.add').css('left', scrollLeft);
	});
});

/**
 * Converts an id expression in a path.
 * @param val
 * @returns [Number] 
 */
function id2path(val){
	return JSON.parse('[' + val.replace('.', ',') + ']');
}


function getTask(path) {
	var index = path[0]-1;
	if(index >= tasks.length)
		return null;
	var container = tasks[path[0]-1];
	for (var i = 1; i < path.length; i++) {
		index = path[i]-1;
		if(index >= container.subTaskslength)
			return null;
		container = container.subTasks[index];
	}
	return container;
}

/**
 * Converts a path in a task name.
 * @param path
 * @returns String
 */
function makeTaskName(path) {
	var str = 'task';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makePlayTaskName(path) {
	var str = 'playTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makeEditTaskName(path) {
	var str = 'editTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makeDeleteTaskName(path) {
	var str = 'deleteTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

function makeAddTaskName(path) {
	var str = 'addTask';
	path.forEach(function(element) {
		str += '_' + element;
	});
	return str;
}

/**
 * The offset of representation 
 */
var offset = 0;
/**
 * The scale of representation
 */
var scale = 2;

/**
 * Show a new task on schedule;
 * @param viewGroup
 * @param task
 */
function addTaskChrono(viewGroup, task){
	var viewItem = '<div class="task" '+ 'id="' + makeTaskName(task.id) +'" >';
	viewItem += generateTaskView(task);
	viewItem += '</div>';
	viewGroup.append(viewItem);
}

/**
 * Refresh the tas on schedule
 * @param viewGroup
 * @param task
 */
function editTaskChrono(viewGroup, task){
	var $element = viewGroup.find('#' + makeTaskName(task.id));
	var viewItem = generateTaskView(task);
	$element.html(viewItem);
}

/**
 * Private
 * @param task
 * @returns {String}
 */
function generateOptions(task){
	var path = task.id;
	var optionItem = '<span class="play ui-icon ui-icon-play" id="'+ makePlayTaskName(path) + '"></span>';
	optionItem 	  += '<span class="edit ui-icon ui-icon-pencil" id="'+ makeEditTaskName(path) + '"></span>';
	optionItem 	  += '<span class="add ui-icon ui-icon-plus" id="'+ makeAddTaskName(path) + '"></span>';
	optionItem 	  += '<span class="delete ui-icon ui-icon-trash" id="'+ makeDeleteTaskName(path) + '"></span>';
	return optionItem;
}

/**
 * Private
 * @param task
 * @returns {String}
 */
function generateTaskView(task) {
	var path = task.id;
	var viewItem = '<span class="taskName">'+generateOptions(task)+path.join('.')+ ". "+task.name + '</span>';
	viewItem += '<span class="meter start" style = "width:'+(task.start()*scale)+'em"></span>';
	viewItem += '<span class="meter spentReg" style = "width:'+(task.spentReg()*scale)+'em"></span>';
	viewItem += '<span class="meter remaining" style = "width:'+(task.remaining()*scale)+'em"></span>';
	viewItem += '<span class="meter leftover" style = "width:'+(task.leftover()*scale)+'em"></span>';
	viewItem += '<span class="meter overdue" style = "width:'+(task.overdue()*scale)+'em"></span>';
	adjustRuler(task.end());
	return viewItem;
}

/**
 * The current position of the ruler.
 * Should be private, please do not change.
 */
currentEnd = 15;

/**
 * Adjust the ruler.
 * @param end
 */
function adjustRuler(end){
	if(end > currentEnd){
		var incr = Math.ceil((end - currentEnd)/5);
		var $timeLabel = $('.timeLabel');
		for(var i = 1; i <= incr; ++i){
			$timeLabel.append('<span>' + (currentEnd + i*5) + 'h</span>');
		}
		currentEnd += (incr*5);
	}
}

/**
 * The Task class. Its our main thing here.
 */
function Task(id, name, description, duration, spent, status, dependencies){
	this.id = id;
	this.name = name;
	this.description = description;
	this.duration = duration;
	this.spent = spent;
	if(!status)
		this.status = 'proposed';
	else
		this.status = status;
	if(!dependencies)
		this.dependencies = [];
	else 
{'fraction_non_alphanumeric': 0.20476840928846393, 'fraction_numerical': 0.0037253197566124428, 'mean_word_length': 4.445571331981069, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 57, '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': '7002997', 'n_tokens_mistral': 2904, 'n_tokens_neox': 2790, 'n_words': 635}