<commit_before>function getParameterByName(name) {
	name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
	var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
	var results = regex.exec(location.search);
	return results == null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}

var rootPath = '/forkability';

if (/localhost/i.test(window.location.href)) {
	rootPath = '/';
}

var loadPage = function() {
	var currentUser;
	var repoOptions = {};
	var repos = [];

	$(document).on('click', '.sign-in', function(e) {
		e.preventDefault();
		authClient.login({
			rememberMe: true,
			scope: undefined
		});
	});

	repoOptions.username = getParameterByName('u');
	repoOptions.repository = getParameterByName('r');
	repoOptions.languages = (getParameterByName('l') || '').trim();
	repoOptions.languages = repoOptions.languages.length > 0 ? repoOptions.languages.split(',') : [];

	var authClient = new GetAPI.GitHubClient({
		clientId: '9dddfb154feb2d02d35c'
	}, function(error, user) {
		if (error) {
			// an error occurred while attempting login
			console.log(error);
			$('.sign-out').hide();
			$('nav .sign-in').show();
		} else if (user && user.accessToken) {
			$('.sign-out').show();
			$('nav .sign-in').hide();
			currentUser = user;
			renderByID('#logging-in-template');
			$.ajax(
				'https://api.github.com/user', {
					dataType: 'json',
					method: 'GET',
					headers: {
						Authorization: 'Token ' + currentUser.accessToken
					},
					success: function(data, textStatus, jqXHR) {
						var o = {
							user: repoOptions.username,
							repository: repoOptions.repository,
							languages: repoOptions.languages
						};
						if (currentUser && currentUser.accessToken) {
							o.auth = {
								token: currentUser.accessToken
							};
						}
						currentUser = $.extend(currentUser, data);
						// user authenticated with GetAPI
						console.log('User ID: ' + user.uid + ', Provider: ' + user.provider);
						if (repoOptions.username && repoOptions.repository) {
							checkRepo(o);
						} else {
							showRepoPicker({
								defaultUsername: (currentUser && currentUser.login) ? currentUser.login : undefined
							}, repoOptions);
						}
					}
				});
		} else {
			showRepoPicker();
		}
	});

	$('.sign-out').click(function() {
		authClient.logout();
		history.pushState({}, 'Forkability', rootPath);
		showSignIn();
		$(this).hide();
		$('nav .sign-in').show();
	});

	function renderByID(id, o) {
		var source = $(id).html();
		var template = Handlebars.compile(source);
		return $('.main-body').html(template(o));
	}

	function showSignIn(showAlert) {
		var hero = renderByID('#sign-in-template', {
			repoOptions: repoOptions,
			showAlert: showAlert || repoOptions.username || repoOptions.repository
		});

		hero.find('.skip-for-now').click(function(e) {
			e.preventDefault();
			showRepoPicker();
		});

		$('.sign-out').hide();
		$('nav .sign-in').show();
	}

	function showRepoPicker(model, o) {
		var hero = renderByID('#choose-repo-template', model);<commit_msg>Fixed merge...?<commit_after>function getParameterByName(name) {
	name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
	var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
	var results = regex.exec(location.search);
	return results == null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
}

var rootPath = '/forkability';

if (/localhost/i.test(window.location.href)) {
	rootPath = '/';
}

var loadPage = function() {
	var currentUser;
	var repoOptions = {};
	var repos = [];

	$(document).on('click', '.sign-in', function(e) {
		e.preventDefault();
		authClient.login({
			rememberMe: true,
			scope: undefined
		});
	});

	repoOptions.username = getParameterByName('u');
	repoOptions.repository = getParameterByName('r');
	repoOptions.languages = (getParameterByName('l') || '').trim();
	repoOptions.languages = repoOptions.languages.length > 0 ? repoOptions.languages.split(',') : [];

	var authClient = new GetAPI.GitHubClient({
		clientId: '9dddfb154feb2d02d35c'
	}, function(error, user) {
		if (error) {
			// an error occurred while attempting login
			console.log(error);
			$('.sign-out').hide();
			$('nav .sign-in').show();
		} else if (user && user.accessToken) {
			$('.sign-out').show();
			$('nav .sign-in').hide();
			currentUser = user;
			renderByID('#logging-in-template');
			$.ajax(
				'https://api.github.com/user', {
					dataType: 'json',
					method: 'GET',
					headers: {
						Authorization: 'Token ' + currentUser.accessToken
					},
					success: function(data, textStatus, jqXHR) {
						var o = {
							user: repoOptions.username,
							repository: repoOptions.repository,
							languages: repoOptions.languages
						};
						if (currentUser && currentUser.accessToken) {
							o.auth = {
								token: currentUser.accessToken
							};
						}
						currentUser = $.extend(currentUser, data);
						// user authenticated with GetAPI
						console.log('User ID: ' + user.uid + ', Provider: ' + user.provider);
						if (repoOptions.username && repoOptions.repository) {
							checkRepo(o);
						} else {
							showRepoPicker({
								defaultUsername: (currentUser && currentUser.login) ? currentUser.login : undefined
							}, repoOptions);
						}
					}
				});
		} else {
			showRepoPicker();
		}
	});

	$('.sign-out').click(function() {
		authClient.logout();
		history.pushState({}, 'Forkability', rootPath);
		showSignIn();
		$(this).hide();
		$('nav .sign-in').show();
	});

	function renderByID(id, o) {
		var source = $(id).html();
		var template = Handlebars.compile(source);
		return $('.main-body').html(template(o));
	}

	function showSignIn(showAlert) {
		var hero = renderByID('#sign-in-template', {
			repoOptions: repoOptions,
			showAlert: showAlert || repoOptions.username || repoOptions.repository
		});

		hero.find('.skip-for-now').click(function(e) {
			e.preventDefault();
			showRepoPicker();
		});
		$('.sign-out').hide();
		$('nav .sign-in').show();
	}

	function showRepoPicker(model, o) {
		var hero = renderByID('#choose-repo-template', model);
{'fraction_non_alphanumeric': 0.19154187921671878, 'fraction_numerical': 0.0036202073391476057, 'mean_word_length': 3.3167613636363638, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '5124648', 'n_tokens_mistral': 2411, 'n_tokens_neox': 1981, 'n_words': 360}