<commit_before>// quest.js will want a base url for image resources
window.gridApi = window.gridApi || {};
window.gridApi.onLoad = function () {
	var file = $_GET['file'] || 'test.aslx';
	var ext = file.toLowerCase().substr(file.length - 4);
	if (ext === '.asl' || ext === '.cas') {
		var fileFetcher = function (filename, onSuccess, onFailure) {
			$.ajax({
				url: filename,
				success: onSuccess,
				error: onFailure
			});
		};
		
		var binaryFileFetcher = function (filename, onSuccess, onFailure) {
			var xhr = new XMLHttpRequest();
			xhr.open('GET', filename, true);
			xhr.responseType = 'arraybuffer';
			xhr.onload = function() {
				if (this.status == 200) {
					var result = new Uint8Array(this.response);
					onSuccess(result);
				}
				else {
					onFailure();
				}
			};
			xhr.send();
		};
		
		var game = new LegacyGame(file, file, null, fileFetcher, binaryFileFetcher);
		var onSuccess = function () {
			game.Begin();
		};
		var onFailure = function () {
			console.log("fail");
		};
		quest.sendCommand = game.SendCommand.bind(game);
		quest.endWait = game.EndWait.bind(game);
		quest.setQuestionResponse = game.SetQuestionResponse.bind(game);
		quest.setMenuResponse = game.SetMenuResponse.bind(game);
		quest.tick = game.Tick.bind(game);
		game.Initialise(onSuccess, onFailure);
	}
	else {
		$.get(file, function (data) {
			quest.load(data);
			quest.begin();
		});
	}
};<commit_msg>Get games using id via textadventures API<commit_after>(function () {
	var fileFetcher = function (filename, onSuccess, onFailure) {
		$.ajax({
			url: filename,
			success: onSuccess,
			error: onFailure
		});
	};
	
	var binaryFileFetcher = function (filename, onSuccess, onFailure) {
		var xhr = new XMLHttpRequest();
		xhr.open('GET', filename, true);
		xhr.responseType = 'arraybuffer';
		xhr.onload = function() {
			if (this.status == 200) {
				var result = new Uint8Array(this.response);
				onSuccess(result);
			}
			else {
				onFailure();
			}
		};
		xhr.send();
	};
	
	// quest.js will want a base url for image resources
	window.gridApi = window.gridApi || {};
	window.gridApi.onLoad = function () {
		var id = $_GET['id'];
		if (!id) return;
		
		$.get('http://textadventures.co.uk/api/game/' + id, function (result) {
			if (result.ASLVersion >= 500) {
				$.get(result.PlayUrl, function (data) {
					quest.load(data);
					quest.begin();
				});
			}
			else {
				var file = result.PlayUrl;
				var game = new LegacyGame(file, file, null, fileFetcher, binaryFileFetcher);
				var onSuccess = function () {
					game.Begin();
				};
				var onFailure = function () {
					console.log("fail");
				};
				quest.sendCommand = game.SendCommand.bind(game);
				quest.endWait = game.EndWait.bind(game);
				quest.setQuestionResponse = game.SetQuestionResponse.bind(game);
				quest.setMenuResponse = game.SetMenuResponse.bind(game);
				quest.tick = game.Tick.bind(game);
				game.Initialise(onSuccess, onFailure);
			}
		});
	};
})();
{'fraction_non_alphanumeric': 0.15794802564967939, 'fraction_numerical': 0.004049949375632805, 'mean_word_length': 3.2832369942196533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '6485040', 'n_tokens_mistral': 1182, 'n_tokens_neox': 990, 'n_words': 213}