<commit_before>/*

	Timer.splits[] is the split list. Each split is an object composed like this:
	
	- name: The name of the split
	- pb_duration: The duration of the PB time
	- pb_split: The elapsed time since the beginning of the run
	- split_best: The Golden time.
	
 */

function Timer()
{
	this.timer_name = "";
	this.run_name = "";
	this.run_count = 0;
	this.splits = [];
	this.timer_type = Timer.Type.RTA;
}

Timer.Type = { RTA: 0, MANUAL: 1 };

Timer.prototype.save = function()
{
	if(typeof localStorage != 'undefined')
	{
		localStorage[this.timer_name] = JSON.stringify(this);
		
		var names = JSON.parse(localStorage.timer_names);
		if(typeof names.pop == "undefined")
			names = [];
		
		if(names.indexOf(this.timer_name) == -1)
		{
			names.push(this.timer_name);
			localStorage.timer_names = JSON.stringify(names);
		}
	}
}

Timer.prototype.delete = function()
{
	
	if(typeof localStorage != 'undefined')
	{
		delete localStorage[this.timer_name];
		var names = JSON.parse(localStorage.timer_names);
		if(typeof names.pop == "undefined")
			names = [];
		
		var i = names.indexOf(this.timer_name);
		if(i != -1)
		{
			delete names[i];
			names.length--;
			localStorage.timer_names = JSON.stringify(names);
		}
	}
}

Timer.prototype.to_string = function()
{
	return JSON.stringify(this);
}

Timer.prototype.save_splits = function(run)
{
	for(var k in this.splits)
		this.splits[k].pb_split = run.split_times[k];
	
	this.save();
}

Timer.prototype.compute_split_lengths = function()
{
	var previous_elapsed = 0;
	for(var i in this.splits)
	{
		if(this.splits[i].pb_split != null && this.splits[i].pb_duration == null)
		{
			this.splits[i].pb_duration = this.splits[i].pb_split - previous_elapsed;
			previous_elapsed = this.splits[i].pb_split;
		}
		else if(this.splits[i].pb_split == null)
			this.splits[i].pb_duration = null;
	}
	 
	// this.save();
}
<commit_msg>Fix PB splits.<commit_after>/*

	Timer.splits[] is the split list. Each split is an object composed like this:
	
	- name: The name of the split
	- pb_duration: The duration of the PB time
	- pb_split: The elapsed time since the beginning of the run
	- split_best: The Golden time.
	
 */

function Timer()
{
	this.timer_name = "";
	this.run_name = "";
	this.run_count = 0;
	this.splits = [];
	this.timer_type = Timer.Type.RTA;
}

Timer.Type = { RTA: 0, MANUAL: 1 };

Timer.prototype.save = function()
{
	if(typeof localStorage != 'undefined')
	{
		localStorage[this.timer_name] = JSON.stringify(this);
		
		var names = JSON.parse(localStorage.timer_names);
		if(typeof names.pop == "undefined")
			names = [];
		
		if(names.indexOf(this.timer_name) == -1)
		{
			names.push(this.timer_name);
			localStorage.timer_names = JSON.stringify(names);
		}
	}
}

Timer.prototype.delete = function()
{
	
	if(typeof localStorage != 'undefined')
	{
		delete localStorage[this.timer_name];
		var names = JSON.parse(localStorage.timer_names);
		if(typeof names.pop == "undefined")
			names = [];
		
		var i = names.indexOf(this.timer_name);
		if(i != -1)
		{
			delete names[i];
			names.length--;
			localStorage.timer_names = JSON.stringify(names);
		}
	}
}

Timer.prototype.to_string = function()
{
	return JSON.stringify(this);
}

Timer.prototype.save_splits = function(run)
{
	for(var k in this.splits)
	{
		this.splits[k].pb_split = run.split_times[k];
		
		this.splits[k].pb_duration = run.split_times[k];
		if(k > 0)
			this.splits[k].pb_duration -= run.split_times[k - 1];
	}
	
	this.save();
}

Timer.prototype.compute_split_lengths = function()
{
	var previous_elapsed = 0;
	for(var i in this.splits)
	{
		// Fixing PB splits
		if(this.splits[i].pb_split != null)
		{
			this.splits[i].pb_duration = this.splits[i].pb_split - previous_elapsed;
			previous_elapsed = this.splits[i].pb_split;
		}
		else if(this.splits[i].pb_split == null)
			this.splits[i].pb_duration = null;
	}
	 
	// this.save();
}

{'fraction_non_alphanumeric': 0.15103092783505154, 'fraction_numerical': 0.0036082474226804126, 'mean_word_length': 3.603795966785291, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3890421', 'n_tokens_mistral': 1565, 'n_tokens_neox': 1420, 'n_words': 280}