$(document).ready(function(){
	window.addEventListener('message', function(event) {
		var node = document.createElement('textarea');
		var selection = document.getSelection();

		var coords = event.data.coords
		var tableau = coords.split(" ")

		var x = tableau[0].indexOf(".")
		var y = tableau[1].indexOf(".")
		var z = tableau[2].indexOf(".")

		var first = tableau[0].substr(0, x + 3)
		var second = tableau[1].substr(0, y + 3)
		var trois = tableau[2].substr(0, z + 3)

		var final = first + ', ' + second + ', ' + trois

		node.textContent = final;
		document.body.appendChild(node);

		selection.removeAllRanges();
		node.select();
		document.execCommand('copy');

		selection.removeAllRanges();
		document.body.removeChild(node);
	});
});
