<commit_before>var submit = function (formData, cb) {

	var xhr = new XMLHttpRequest();
	xhr.open('POST', '/v2/view/results/filtered', true);
	xhr.onload = function(e) {
		if (this.status == 200) {
			cb(this.response);
		}
	};
	xhr.send(formData);
};

var removeFilter = function (e) {

	e.preventDefault();

	this.parentNode.parentNode.removeChild(this.parentNode);

	var formData = new FormData();
	var filters = document.querySelectorAll('#filters li');

	if (!filters.length)
		window.location.href = window.location.pathname;

	[].forEach.call(filters, function (li, idx) {
		formData.append(li.dataset.filter, li.dataset.value);
	});

	submit(formData, function (data) {
		document.querySelector('tbody').innerHTML = data;
		addEventListeners();
	});

	createFilterURL();
	return false;

};

var createFilterURL = function () {
	var stringURL = 'http://localhost:3000/v2/view/results?';
	[].forEach.call(document.querySelectorAll('#filters li'), function (li, idx) {
		stringURL += li.dataset.filter + '=' + li.dataset.value + '&';
	});
	var select = document.querySelector('select');
	stringURL += 'date=' + select.options[select.selectedIndex].dataset.value + '&';

	history.pushState('', '', stringURL);
	console.log('updated URL', window.location.href);

};

window.addEventListener('popstate', function () {

	var filters = location.href.split('?');
	if(filters.length > 1)
		refreshFilters(filters[1].replace('#', ''));

}, false);

var refreshFilters = function (filters) {


	if(filters) {
		
		filters = filters.trim().replace('#', '').replace(/%20/g, " ");;
		var docFrag = document.createDocumentFragment()
		,	formData = new FormData()<commit_msg>changed path in script;this is hardcoded and needs fix<commit_after>var submit = function (formData, cb) {

	var xhr = new XMLHttpRequest();
	xhr.open('POST', '/v2/view/results/filtered', true);
	xhr.onload = function(e) {
		if (this.status == 200) {
			cb(this.response);
		}
	};
	xhr.send(formData);
};

var removeFilter = function (e) {

	e.preventDefault();

	this.parentNode.parentNode.removeChild(this.parentNode);

	var formData = new FormData();
	var filters = document.querySelectorAll('#filters li');

	if (!filters.length)
		window.location.href = window.location.pathname;

	[].forEach.call(filters, function (li, idx) {
		formData.append(li.dataset.filter, li.dataset.value);
	});

	submit(formData, function (data) {
		document.querySelector('tbody').innerHTML = data;
		addEventListeners();
	});

	createFilterURL();
	return false;

};

var createFilterURL = function () {
	var stringURL = 'http://topcoat.herokuapp.com/v2/view/?';
	[].forEach.call(document.querySelectorAll('#filters li'), function (li, idx) {
		stringURL += li.dataset.filter + '=' + li.dataset.value + '&';
	});
	var select = document.querySelector('select');
	stringURL += 'date=' + select.options[select.selectedIndex].dataset.value + '&';

	history.pushState('', '', stringURL);
	console.log('updated URL', window.location.href);

};

window.addEventListener('popstate', function () {

	var filters = location.href.split('?');
	if(filters.length > 1)
		refreshFilters(filters[1].replace('#', ''));

}, false);

var refreshFilters = function (filters) {


	if(filters) {
		
		filters = filters.trim().replace('#', '').replace(/%20/g, " ");;
		var docFrag = document.createDocumentFragment()
		,	formData = new FormData()
{'fraction_non_alphanumeric': 0.1832196857396976, 'fraction_numerical': 0.006522383634746516, 'mean_word_length': 4.747870528109029, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6523158', 'n_tokens_mistral': 1149, 'n_tokens_neox': 1095, 'n_words': 207}