<commit_before>function Timeline(target)
{
	this.element = this.appendTemplate(target);
	InteractiveObject.call(this, this.element);
	this.graph = undefined;

	this.iType = "Timeline";

	this.interval = 0;

	TimeUtils.setDateMinusDays(new Date(), 5, this);
	this.updateInterval();

	this.init();

	this.windowList = [];
}

Timeline.prototype = tEngine.clone(InteractiveObject.prototype);
Timeline.prototype.parent = InteractiveObject.prototype;

Timeline.prototype.constructor = InteractiveObject;


Timeline.prototype.initDays = function()
{
	this.weekday = new Array(7);
	this.weekday[0]="Sunday";
	this.weekday[1]="Monday";
	this.weekday[2]="Tuesday";
	this.weekday[3]="Wednesday";
	this.weekday[4]="Thursday";
	this.weekday[5]="Friday";
	this.weekday[6]="Saturday";

	var firstMoment = this.begin;
	var lastMoment  = this.end;

	// console.log(firstMoment, lastMoment);

	var toMidnight = TimeUtils.toMidnight(firstMoment);
	var day = TimeUtils.days(1);

	var moment = Number(firstMoment)+Number(toMidnight);

	this.days = [];
	while(moment < Number(lastMoment))
	{
		this.days.push(new Date(moment));
		moment += day;
	}
	console.log(this.days)
}

Timeline.prototype.renderDays = function()
{
	var lastInstant  = this.end;
	var firstInstant = this.begin;

	var group = this.graph.selectAll(".days");
	var n = 0;
	group.each(function() { ++n; });

	var x = d3.time.scale().domain([firstInstant, lastInstant]).range([0, this.size[0]]);

	if(n == 0)
	{
		group = this.graph.append("g").attr("class", "grid days");
	}

	group = group.selectAll("line").data(this.days);

	group.enter()
		.append("line")
		.attr("x1", x)
		.attr("y1", 0)
		.attr("x2", x)
		.attr("y2", 90)
		.attr("class", "timelineDay");

	group
		.attr("x1", x)
		.attr("x2", x);

	group.exit().remove();
}


Timeline.prototype.addGraph = function(graph)
{
	var window = new TimelineWindow(this.graph, graph, this);
	tEngine.interactiveObjectList["timelineWindow"+graph.element.id] = window;
	this.windowList.push(window);
}

Timeline.prototype.init = function()
{
	this.initDays();
	this.graph = d3.select("#timeline .timelineGraph").append("svg:svg").attr("width", "100%").attr("height", "100%");
	this.renderGrid();
	this.renderLabels(this.graph);
}

Timeline.prototype.appendTemplate = function(target)
{
	target = d3.select(target);
	var graphDiv = target.append("div").attr("class", "timelineGraph");
	return graphDiv[0][0];
}

Timeline.prototype.updateInterval = function()
{
	this.interval = (this.end.valueOf()-this.begin.valueOf())/1000;
}

Timeline.prototype.renderLabels = function(target)
{
	var lastInstant  = this.end;
	var firstInstant = this.begin;

	var x = d3.time.scale().domain([firstInstant, lastInstant]).range([0, this.size[0]]);
	var labelGroup = target.selectAll(".label");

	n = 0;
	labelGroup.each(function() { ++n; });

	if(n == 0)
	{
		labelGroup = target.append("g").attr("class", "grid label").attr("transform", "translate(0,15)");
	}

	var labelList = [];

	// var beginStr = TimeUtils.dateFormatter(this.begin);
	// var endStr = TimeUtils.dateFormatter(this.end);

	// labelList.push(new GraphText(beginStr, "timelineTimestamp", 0, 0));
	// labelList.push(new GraphText(endStr, "timelineTimestamp", 700, 0, "end"));

	for(var i in this.days)
	{
		labelList.push(new GraphText(this.weekday[this.days[i].getDay()], "graphDay", x(this.days[i])+2, 0));
		var timeStr = TimeUtils.dateFormatter(this.days[i], false);
		labelList.push(new GraphText(timeStr, "graphDay", x(this.days[i])+2, 70));
	}


	labelGroup = labelGroup.selectAll("text").data(labelList);
	
	labelGroup.enter()
		.append("text")
		.style("text-anchor", function(d) { return d.anchor; })
		.attr("class", function(d) { return d.style; })
		.attr("dx", function(d) { return d.x; } )
		.attr("dy", function(d) { return d.y; });
		// .attr("class", "tick");

	labelGroup.transition()
		.duration(0)
		.style("text-anchor", function(d) { return d.anchor; })
		.attr("class", function(d) { return d.style; })
		.text(function(d) { return d.text; } )
		.attr("dx", function(d) { return d.x; } )
		.attr("dy", function(d) { return d.y; });

	labelGroup.exit().remove();
}

Timeline.prototype.render = function()
{
	this.graph.selectAll(".window").remove();
	<commit_msg>Now days on the timeline are updating properly.<commit_after>function Timeline(target)
{
	this.element = this.appendTemplate(target);
	InteractiveObject.call(this, this.element);
	this.graph = undefined;

	this.iType = "Timeline";

	this.interval = 0;

	TimeUtils.setDateMinusDays(new Date(), 5, this);
	this.updateInterval();

	this.init();

	this.windowList = [];
}

Timeline.prototype = tEngine.clone(InteractiveObject.prototype);
Timeline.prototype.parent = InteractiveObject.prototype;

Timeline.prototype.constructor = InteractiveObject;


Timeline.prototype.initDays = function()
{
	this.weekday = new Array(7);
	this.weekday[0]="Sunday";
	this.weekday[1]="Monday";
	this.weekday[2]="Tuesday";
	this.weekday[3]="Wednesday";
	this.weekday[4]="Thursday";
	this.weekday[5]="Friday";
	this.weekday[6]="Saturday";

	var firstMoment = this.begin;
	var lastMoment  = this.end;

	// console.log(firstMoment, lastMoment);

	var toMidnight = TimeUtils.toMidnight(firstMoment);
	var day = TimeUtils.days(1);

	var moment = Number(firstMoment)+Number(toMidnight);

	this.days = [];
	while(moment < Number(lastMoment))
	{
		this.days.push(new Date(moment));
		moment += day;
	}
}

Timeline.prototype.updateDays = function()
{
	var firstMoment = this.begin;
	var lastMoment  = this.end;

	var toMidnight = TimeUtils.toMidnight(firstMoment);
	var day = TimeUtils.days(1);

	var moment = Number(firstMoment)+Number(toMidnight);

	this.days = [];
	while(moment < Number(lastMoment))
	{
		this.days.push(new Date(moment));
		moment += day;
	}
}


Timeline.prototype.renderDays = function()
{
	var lastInstant  = this.end;
	var firstInstant = this.begin;

	var group = this.graph.selectAll(".days");
	var n = 0;
	group.each(function() { ++n; });

	var x = d3.time.scale().domain([firstInstant, lastInstant]).range([0, this.size[0]]);

	if(n == 0)
	{
		group = this.graph.append("g").attr("class", "grid days");
	}

	group = group.selectAll("line").data(this.days);

	group.enter()
		.append("line")
		.attr("x1", x)
		.attr("y1", 0)
		.attr("x2", x)
		.attr("y2", 90)
		.attr("class", "timelineDay");

	group
		.attr("x1", x)
		.attr("x2", x);

	group.exit().remove();
}


Timeline.prototype.addGraph = function(graph)
{
	var window = new TimelineWindow(this.graph, graph, this);
	tEngine.interactiveObjectList["timelineWindow"+graph.element.id] = window;
	this.windowList.push(window);
}

Timeline.prototype.init = function()
{
	this.initDays();
	this.graph = d3.select("#timeline .timelineGraph").append("svg:svg").attr("width", "100%").attr("height", "100%");
	this.renderGrid();
	this.renderLabels(this.graph);
}

Timeline.prototype.appendTemplate = function(target)
{
	target = d3.select(target);
	var graphDiv = target.append("div").attr("class", "timelineGraph");
	return graphDiv[0][0];
}

Timeline.prototype.updateInterval = function()
{
	this.interval = (this.end.valueOf()-this.begin.valueOf())/1000;
	this.updateDays();
}

Timeline.prototype.renderLabels = function(target)
{
	var lastInstant  = this.end;
	var firstInstant = this.begin;

	var x = d3.time.scale().domain([firstInstant, lastInstant]).range([0, this.size[0]]);
	var labelGroup = target.selectAll(".label");

	n = 0;
	labelGroup.each(function() { ++n; });

	if(n == 0)
	{
		labelGroup = target.append("g").attr("class", "grid label").attr("transform", "translate(0,15)");
	}

	var labelList = [];

	// var beginStr = TimeUtils.dateFormatter(this.begin);
	// var endStr = TimeUtils.dateFormatter(this.end);

	// labelList.push(new GraphText(beginStr, "timelineTimestamp", 0, 0));
	// labelList.push(new GraphText(endStr, "timelineTimestamp", 700, 0, "end"));

	for(var i in this.days)
	{
		labelList.push(new GraphText(this.weekday[this.days[i].getDay()], "graphDay", x(this.days[i])+2, 0));
		var timeStr = TimeUtils.dateFormatter(this.days[i], false);
		labelList.push(new GraphText(timeStr, "graphDay", x(this.days[i])+2, 70));
	}

	labelGroup = labelGroup.selectAll("text").data(labelList);
	
	labelGroup.enter()
		.append("text")
		.style("text-anchor", function(d) { return d.anchor; })
		.attr("class", function(d) { return d.style; })
		.attr("dx", function(d) { return d.x; } )
		.attr("dy", function(d) { return d.y; });
		// .attr("class", "tick");

	labelGroup.transition()
		.duration(0)
		.style("text-anchor", function(d) { return d.anchor; })
		.attr("class", function(d) { return d.style; })
		.text(function(d) { return d.text; } )
		.attr("dx", function(d) { return d.x; } )
		.attr("dy", function(d) { return d.y; });

	labelGroup.exit().remove();
}

Timeline.prototype.render = function()
{
	this.graph.selectAll(".window").remove();
	
{'fraction_non_alphanumeric': 0.19405515370705245, 'fraction_numerical': 0.013449367088607595, 'mean_word_length': 4.848645076007931, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, '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': '964072', 'n_tokens_mistral': 3398, 'n_tokens_neox': 3179, 'n_words': 541}