<commit_before><meta charset="utf-8" />
<style>

	.tes__container {
		font-family: Arial, Helvetica;
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0,0,0,.75);
		z-index: 99998;
	}
	.tes__title {
		font-weight: bold;
		font-size: 14px;
		color: #589800;
		position: absolute;
		top: 10px;
		left: 20px;
		padding: 0;
		margin: 0;
	}
    .tes__title:after {
		  content: '';
		  height: 1px;
		  background: #589800;
		  top: 24px;
		  left: -20px;
		  width: 540px;
		  position: absolute;
	}
	.tes__form {
		position: absolute;
		width: 500px;
		padding: 40px 20px 10px;
		left: 50%;
		margin: 0 0 0 -270px;
		top: 10%;
		z-index: 99999;
		background: #fff;
		border: 1px solid #589800;
	}
	.tes__selected-text {
		font-style: italic;
		padding: 0;
		margin: 0;
	}
	.tes__close {
		position: absolute;
		top: -5px;
		right: 16px;
		cursor: pointer;
		transform: rotate(45deg);
		font-size: 40px;
		color: #589800;
	}
	.tes__close:hover {
		color: #007F16;
	}
	.tes__submit {
		float: right;
		cursor: pointer;
		border: none;
		background: #589800;
		color: #fff;
		padding: 5px 10px;
	}
	.tes__submit:hover {
		background: #007F16;
	}
</style>

<script>
;(function()
	{
		var selectedText = '',
			comment = '',
			isForm = false;

		function getSelection()
		{
			var selection = '';

            if (window.getSelection)
                selection = window.getSelection().toString();
            else if (document.selection && document.selection.type != 'Control')
                selection = document.selection.createRange().text;

            if( !selection )
                throw new Error('no_selection');

            return selection;
		}

		function createForm()
		{
			if( isForm ) return false;

			var container = document.createElement('div'),
				title = document.createElement('p'),
				form = document.createElement('form'),
				text = document.createElement('p'),
				submit = document.createElement('input'),
				close = document.createElement('span');

			container.classList.add('tes__container');
			container.id = 'tes-container';

			title.classList.add('tes__title');
			title.innerText = 'Отправить текст с ошибкой';

			form.classList.add('tes__form');
			form.action = '';
			form.method = 'POST';
			form.appendChild(title);
			form.appendChild(text);
			form.appendChild(submit);
			form.appendChild(close);
			form.addEventListener('submit', function(e)
                {
					e.preventDefault();
					var json = {
                        url : encodeURIComponent(window.location.href),
                        text : encodeURIComponent(selectedText),
                        comment : encodeURIComponent(comment)
                    },
                    xhr = new XMLHttpRequest();


					xhr.open('POST', '/backend/heagemon/frontendspelling/spellingrequests/ajaxcreate;', true);
					xhr.setRequestHeader('Content-Type', 'application/json');

					xhr.send(JSON.stringify({textError : json}));

					xhr.onreadystatechange = function()
                    {
						if (xhr.readyState != 4) return;

						if (xhr.status != 200)
						{
							console.log(xhr.status + ': ' + xhr.statusText);
						} else
						{
                            console.log(xhr.responseText);
						}

					}
				}
			);

			text.classList.add('tes__selected-text');
			text.innerText = selectedText;

			submit.type = 'submit';
			submit.classList.add('tes__submit');

			close.classList.add('tes__close');
			close.innerText = '+';
			close.addEventListener('click', function()
				{
					container.parentNode.removeChild(container);
					isForm = false;
				}
			);

			container.appendChild(form);
			document.body.appendChild(container);
			isForm = true;
		}

		document.addEventListener('keypress', function()
			{
				if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD)))
				{
					selectedText = getSelection();
					try {
                        createForm();
                    } catch(e) {}

				}
			}
		);
	}
)();
</script><commit_msg>Move code, which get selection in try block<commit_after><meta charset="utf-8" />
<style>

	.tes__container {
		font-family: Arial, Helvetica;
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0,0,0,.75);
		z-index: 99998;
	}
	.tes__title {
		font-weight: bold;
		font-size: 14px;
		color: #589800;
		position: absolute;
		top: 10px;
		left: 20px;
		padding: 0;
		margin: 0;
	}
    .tes__title:after {
		  content: '';
		  height: 1px;
		  background: #589800;
		  top: 24px;
		  left: -20px;
		  width: 540px;
		  position: absolute;
	}
	.tes__form {
		position: absolute;
		width: 500px;
		padding: 40px 20px 10px;
		left: 50%;
		margin: 0 0 0 -270px;
		top: 10%;
		z-index: 99999;
		background: #fff;
		border: 1px solid #589800;
	}
	.tes__selected-text {
		font-style: italic;
		padding: 0;
		margin: 0;
	}
	.tes__close {
		position: absolute;
		top: -5px;
		right: 16px;
		cursor: pointer;
		transform: rotate(45deg);
		font-size: 40px;
		color: #589800;
	}
	.tes__close:hover {
		color: #007F16;
	}
	.tes__submit {
		float: right;
		cursor: pointer;
		border: none;
		background: #589800;
		color: #fff;
		padding: 5px 10px;
	}
	.tes__submit:hover {
		background: #007F16;
	}
</style>

<script>
;(function()
	{
		var selectedText = '',
			comment = '',
			isForm = false;

		function getSelection()
		{
			var selection = '';

            if (window.getSelection)
                selection = window.getSelection().toString();
            else if (document.selection && document.selection.type != 'Control')
                selection = document.selection.createRange().text;

            if( !selection )
                throw new Error('no_selection');

            return selection;
		}

		function createForm()
		{
			if( isForm ) return false;

			var container = document.createElement('div'),
				title = document.createElement('p'),
				form = document.createElement('form'),
				text = document.createElement('p'),
				submit = document.createElement('input'),
				close = document.createElement('span');

			container.classList.add('tes__container');
			container.id = 'tes-container';

			title.classList.add('tes__title');
			title.innerText = 'Отправить текст с ошибкой';

			form.classList.add('tes__form');
			form.action = '';
			form.method = 'POST';
			form.appendChild(title);
			form.appendChild(text);
			form.appendChild(submit);
			form.appendChild(close);
			form.addEventListener('submit', function(e)
                {
					e.preventDefault();
					var json = {
                        url : encodeURIComponent(window.location.href),
                        text : encodeURIComponent(selectedText),
                        comment : encodeURIComponent(comment)
                    },
                    xhr = new XMLHttpRequest();


					xhr.open('POST', '/backend/heagemon/frontendspelling/spellingrequests/ajaxcreate;', true);
					xhr.setRequestHeader('Content-Type', 'application/json');

					xhr.send(JSON.stringify({textError : json}));

					xhr.onreadystatechange = function()
                    {
						if (xhr.readyState != 4) return;

						if (xhr.status != 200)
						{
							console.log(xhr.status + ': ' + xhr.statusText);
						} else
						{
                            console.log(xhr.responseText);
						}

					}
				}
			);

			text.classList.add('tes__selected-text');
			text.innerText = selectedText;

			submit.type = 'submit';
			submit.classList.add('tes__submit');

			close.classList.add('tes__close');
			close.innerText = '+';
			close.addEventListener('click', function()
				{
					container.parentNode.removeChild(container);
					isForm = false;
				}
			);

			container.appendChild(form);
			document.body.appendChild(container);
			isForm = true;
		}

		document.addEventListener('keypress', function()
			{
				if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD)))
				{
					try {
                        selectedText = getSelection();
                        createForm();
                    } catch(e) {}

				}
			}
		);
	}
)();
</script>
{'fraction_non_alphanumeric': 0.1434179855232487, 'fraction_numerical': 0.02944423997055576, 'mean_word_length': 2.418029350104822, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3855275', 'n_tokens_mistral': 3341, 'n_tokens_neox': 2619, 'n_words': 512}