<commit_before>require([
	'/socket.io/socket.io.js',
	'js/Joystick'
], function (
	io,
	Joystick
) {
	window.requestAnimationFrame =
		window.requestAnimationFrame ||
		window.mozRequestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.msRequestAnimationFrame;

	var gameData = {
		gameId: null,
		key: null
	};

	var socket = null;
	var host = window.location.host;
	var $window = $(window);
	var joystick;

	var GYRO_FREQUENCY = 20;
	var CMD_ROTATE = 'rotate';
	var CMD_KEY_DOWN = 'keydown';
	var CMD_KEY_UP = 'keyup';
	var CMD_MOUSE_MOVE = 'mousemove';
	var CMD_MOUSE_DOWN = 'mousedown';
	var CMD_MOUSE_UP = 'mouseup';
	var CMD_ANALOG_POSITION = 'analogpos';
	var CMD_SHOOT = 'shoot';

	$(document).ready(function () {
		socket = io.connect('http://' + host);

		register();
		addListeners();

		joystick = new Joystick($('.joystick'));

		window.requestAnimationFrame(update);
	});

	//--------------------------------------------------------------------------

	function update(elapsedTime) {
		joystick.update(elapsedTime);
		sendCommand(CMD_ANALOG_POSITION, joystick.position);

		window.requestAnimationFrame(update);
	};


	/**
	 * Registers the player with the game.
	 */
	function register() {
		var params = getQueryParams(document.location.search);

		gameData.gameId = params.gameId;
		gameData.key = params.key;

		socket.emit('registerPlayer', gameData, function (response) {
			if (response === 'OK') {
				console.log('Player registered successfully.');
			} else {
				console.log('Error registering player: ' + response.error);
			}
		});
	}


	/**
	 * Adds the event listeners that will collect data and send it to the game.
	 */
	function addListeners() {
		//$window.on('mousemove', onMouseMove);
		//$window.on('touchmove', onTouchMove);
		$window.on('keydown', onKeyDown);
		$window.on('keyup', onKeyUp);

		var eventName = 'mousedown';
		if ('ontouchend' in document.documentElement) {
			eventName = 'touchend';
		}

		$('.shoot-button').on(eventName, function () {
			document.body.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
			sendCommand(CMD_SHOOT);
		});

		//document.mozRequestFullScreen();
		//document.msRequestFullscreen();
		//document.body.requestFullscreen();

		//$window.on('mousedown', onMouseDown);
		//$window.on('mousemove', onMouseMove);
<commit_msg>Trying to fix touch events on iOS.<commit_after>require([
	'/socket.io/socket.io.js',
	'js/Joystick'
], function (
	io,
	Joystick
) {
	window.requestAnimationFrame =
		window.requestAnimationFrame ||
		window.mozRequestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.msRequestAnimationFrame;

	var gameData = {
		gameId: null,
		key: null
	};

	var socket = null;
	var host = window.location.host;
	var $window = $(window);
	var joystick;

	var GYRO_FREQUENCY = 20;
	var CMD_ROTATE = 'rotate';
	var CMD_KEY_DOWN = 'keydown';
	var CMD_KEY_UP = 'keyup';
	var CMD_MOUSE_MOVE = 'mousemove';
	var CMD_MOUSE_DOWN = 'mousedown';
	var CMD_MOUSE_UP = 'mouseup';
	var CMD_ANALOG_POSITION = 'analogpos';
	var CMD_SHOOT = 'shoot';

	$(document).ready(function () {
		socket = io.connect('http://' + host);

		register();
		addListeners();

		joystick = new Joystick($('.joystick'));

		window.requestAnimationFrame(update);
	});

	//--------------------------------------------------------------------------

	function update(elapsedTime) {
		joystick.update(elapsedTime);
		sendCommand(CMD_ANALOG_POSITION, joystick.position);

		window.requestAnimationFrame(update);
	};


	/**
	 * Registers the player with the game.
	 */
	function register() {
		var params = getQueryParams(document.location.search);

		gameData.gameId = params.gameId;
		gameData.key = params.key;

		socket.emit('registerPlayer', gameData, function (response) {
			if (response === 'OK') {
				console.log('Player registered successfully.');
			} else {
				console.log('Error registering player: ' + response.error);
			}
		});
	}


	/**
	 * Adds the event listeners that will collect data and send it to the game.
	 */
	function addListeners() {
		//$window.on('mousemove', onMouseMove);
		//$window.on('touchmove', onTouchMove);
		$window.on('keydown', onKeyDown);
		$window.on('keyup', onKeyUp);

		var eventName = 'mousedown';
		if ('ontouchstart' in document.documentElement) {
			eventName = 'touchstart';
		}

		$('.shoot-button').on(eventName, function (event) {
			event.preventDefault();

			if (document.body.webkitRequestFullscreen) {
				document.body.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
			}
			sendCommand(CMD_SHOOT);
		});

		//document.mozRequestFullScreen();
		//document.msRequestFullscreen();
		//document.body.requestFullscreen();

		//$window.on('mousedown', onMouseDown);
		//$window.on('mousemove', onMouseMove);

{'fraction_non_alphanumeric': 0.17530296698704556, 'fraction_numerical': 0.0008357709987463436, 'mean_word_length': 3.5460588793922128, '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': '3714812', 'n_tokens_mistral': 1751, 'n_tokens_neox': 1552, 'n_words': 300}