<commit_before>//Patch to prevent dropdowns closing on right-click in Firefox
//Courtesy of http://stackoverflow.com/questions/15931962/
document.onclick = function(e) {
	e.button === 2 && e.stopImmediatePropagation();
};

//Initial module setup and URL routing

var zr = angular.module('zr', ['ui.bootstrap', 'ui.ace', 'ui.keypress', 'ngRoute', 'ngSanitize', 'uiSlider'])
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
	//Use HTML5 URL rewriting instead of hash string
	$locationProvider.html5Mode(true);

	//Auth check for views that require it
	var checkAuth = function() {
		var token = gapi.auth.getToken();
		if(token && token.status.signed_in) {
			return $q.when();
		}
		else {
			window.authDeferred = $q.deferred();
			gapi.auth.signIn();
			return window.authDeferred.promise;
		}
	};
	
	//Function to inject the Realtime doc and game into the editor controller
	var loadFile = function ($route, realtime, zrdb) {
		var id = $route.current.params['fileId'];
		return checkAuth().then(function() {
			return realtime.getDocument(id)
			.then(function(doc) {
				var id = doc.getModel().getRoot().get('gameId');
				return zrdb.getSingleResource('game', id)
				.then(function(game) {
					return [doc, game];
				});
			});
		});
	};
	loadFile.$inject = ['$route', 'realtime', 'zrdb'];

	var visualizationResources = function(zrdb) {
		//Chained dependent resources: first load the sim, then get the game based on the ID in the sim
		return checkAuth().then(function() {
			return zrdb.getSingleResource('simulation')
			.then(function(sim) {
				return zrdb.getSingleResource('game', sim.data.gameId)
				.then(function(game) {
					return [sim, game];
				});
			});
		});
	};
	visualizationResources.$inject = ['zrdb'];
<commit_msg>Added view-by-view auth check<commit_after>//Patch to prevent dropdowns closing on right-click in Firefox
//Courtesy of http://stackoverflow.com/questions/15931962/
document.onclick = function(e) {
	e.button === 2 && e.stopImmediatePropagation();
};

//Initial module setup and URL routing

var zr = angular.module('zr', ['ui.bootstrap', 'ui.ace', 'ui.keypress', 'ngRoute', 'ngSanitize', 'uiSlider'])
.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
	//Use HTML5 URL rewriting instead of hash string
	$locationProvider.html5Mode(true);

	//Auth check for views that require it
	var checkAuth = function($q) {
		var token = gapi.auth.getToken();
		if(token && token.status.signed_in) {
			return $q.when();
		}
		else {
			window.authDeferred = $q.deferred();
			gapi.auth.signIn();
			return window.authDeferred.promise;
		}
	};
	checkAuth.$inject = ['$q'];
	
	//Function to inject the Realtime doc and game into the editor controller
	var loadFile = function ($route, realtime, zrdb) {
		var id = $route.current.params['fileId'];
		return checkAuth().then(function() {
			return realtime.getDocument(id)
			.then(function(doc) {
				var id = doc.getModel().getRoot().get('gameId');
				return zrdb.getSingleResource('game', id)
				.then(function(game) {
					return [doc, game];
				});
			});
		});
	};
	loadFile.$inject = ['$route', 'realtime', 'zrdb'];

	var visualizationResources = function(zrdb) {
		//Chained dependent resources: first load the sim, then get the game based on the ID in the sim
		return checkAuth().then(function() {
			return zrdb.getSingleResource('simulation')
			.then(function(sim) {
				return zrdb.getSingleResource('game', sim.data.gameId)
				.then(function(game) {
					return [sim, game];
				});
			});
		});
	};
	visualizationResources.$inject = ['zrdb'];

{'fraction_non_alphanumeric': 0.1568951279933939, 'fraction_numerical': 0.006055601431323975, 'mean_word_length': 4.096774193548387, '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': '1136352', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1158, 'n_words': 291}