<commit_before>'use strict';

function restify(url) {

	return {
		list : function(callback) {
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					var objects = JSON.parse(event.target.responseText);
					callback(objects);
				}
			);
			xhr.open('GET', url, true);
			xhr.send();
		},

		add : function(object, callback) {
			var form_data = new FormData();
			form_data.append('object', JSON.stringify(object));
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					if(event.target.status === 200) {
						if(callback) {
							callback();
						}
					}
					else if(event.target.status === 400) {
						UI.Notify(JSON.parse(event.target.responseText).message);
					}
					//unauthorized
					else if(event.target.status === 401) {
						UI.Notify(JSON.parse(event.target.responseText).message);
						//TODO show login window
					}
				}
			);
			xhr.open('PUT', url, true);
			xhr.send(form_data);
		},

		remove : function(key, callback) {
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					if(event.target.status === 400) {
						UI.Notify(JSON.parse(event.responseText).message);
					}
					else {
						if(callback) {
							callback();
						}
					}
				}
			);
			xhr.open('DELETE', url + '/' + key, true);
			xhr.send();
		}
	};
}

window.addEventListener(
	'load',
	function() {
		//helpers
		function render_date(value) {
			return value ? value.toFullDisplay() : 'NA';
		}

		//manage configuration
		var configuration = document.getElementById('configuration');

		function update_configuration() {
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					var settings = JSON.parse(event.target.responseText);
					configuration['sender_email'].value = settings.sender_email || '';
					configuration['website_timeout'].value = settings.website_timeout || '';
					configuration['avoid_cache'].checked = settings.avoid_cache === 'True';
				}
			);
			xhr.open('GET', '/api/configuration', true);
			xhr.send(null);
		}

		configuration.addEventListener(
			'submit',
			function(event) {
				Event.stop(event);
				var xhr = new XMLHttpRequest();
				xhr.addEventListener(
					'load',
					function(event) {
						UI.Notify('Modifications save successfully');
					}
				);
				var form_data = new FormData();
				form_data.append('configuration', JSON.stringify({
					sender_email : this['sender_email'].value,
					website_timeout : this['website_timeout'].value,
					avoid_cache : this['avoid_cache'].checked
				}));
				xhr.open('POST', '/api/configuration', true);
				xhr.send(form_data);
			}
		);

		//manage subscribers list
		var Subscribers = restify('/api/subscriber');

		var subscribers_ui = document.getElementById('subscribers');

		function delete_subscriber_listener(event) {
			Event.stop(event);
			var subscriber_ui = this.parentNode.parentNode;
			Subscribers.remove(subscriber_ui.dataset.key, function() {
				subscriber_ui.parentNode.removeChild(subscriber_ui);
				UI.Notify('Subscriber deleted successfully');
			});
		}
<commit_msg>Fix typo<commit_after>'use strict';

function restify(url) {

	return {
		list : function(callback) {
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					var objects = JSON.parse(event.target.responseText);
					callback(objects);
				}
			);
			xhr.open('GET', url, true);
			xhr.send();
		},

		add : function(object, callback) {
			var form_data = new FormData();
			form_data.append('object', JSON.stringify(object));
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					if(event.target.status === 200) {
						if(callback) {
							callback();
						}
					}
					else if(event.target.status === 400) {
						UI.Notify(JSON.parse(event.target.responseText).message);
					}
					//unauthorized
					else if(event.target.status === 401) {
						UI.Notify(JSON.parse(event.target.responseText).message);
						//TODO show login window
					}
				}
			);
			xhr.open('PUT', url, true);
			xhr.send(form_data);
		},

		remove : function(key, callback) {
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					if(event.target.status === 400) {
						UI.Notify(JSON.parse(event.responseText).message);
					}
					else {
						if(callback) {
							callback();
						}
					}
				}
			);
			xhr.open('DELETE', url + '/' + key, true);
			xhr.send();
		}
	};
}

window.addEventListener(
	'load',
	function() {
		//helpers
		function render_date(value) {
			return value ? value.toFullDisplay() : 'NA';
		}

		//manage configuration
		var configuration = document.getElementById('configuration');

		function update_configuration() {
			var xhr = new XMLHttpRequest();
			xhr.addEventListener(
				'load',
				function(event) {
					var settings = JSON.parse(event.target.responseText);
					configuration['sender_email'].value = settings.sender_email || '';
					configuration['website_timeout'].value = settings.website_timeout || '';
					configuration['avoid_cache'].checked = settings.avoid_cache === 'True';
				}
			);
			xhr.open('GET', '/api/configuration', true);
			xhr.send(null);
		}

		configuration.addEventListener(
			'submit',
			function(event) {
				Event.stop(event);
				var xhr = new XMLHttpRequest();
				xhr.addEventListener(
					'load',
					function(event) {
						UI.Notify('Modifications saved successfully');
					}
				);
				var form_data = new FormData();
				form_data.append('configuration', JSON.stringify({
					sender_email : this['sender_email'].value,
					website_timeout : this['website_timeout'].value,
					avoid_cache : this['avoid_cache'].checked
				}));
				xhr.open('POST', '/api/configuration', true);
				xhr.send(form_data);
			}
		);

		//manage subscribers list
		var Subscribers = restify('/api/subscriber');

		var subscribers_ui = document.getElementById('subscribers');

		function delete_subscriber_listener(event) {
			Event.stop(event);
			var subscriber_ui = this.parentNode.parentNode;
			Subscribers.remove(subscriber_ui.dataset.key, function() {
				subscriber_ui.parentNode.removeChild(subscriber_ui);
				UI.Notify('Subscriber deleted successfully');
			});
		}

{'fraction_non_alphanumeric': 0.15039494470774092, 'fraction_numerical': 0.0037914691943127963, 'mean_word_length': 3.1271186440677967, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1956432', 'n_tokens_mistral': 2611, 'n_tokens_neox': 1952, 'n_words': 339}