<commit_before>zr.controller('IdeController', ['$scope', '$modal', '$http', '$timeout', '$location', 'config', 'realtime', 'drive', 'resources', 'zrdb', 
		function($scope, $modal, $http, $timeout, $location, config, realtime, drive, resources, zrdb) {
	var realtimeDocument = resources[0];
	$scope.model = realtimeDocument.getModel();
	var graphical = $scope.model.getRoot().get('graphical');
	$scope.graphical = graphical;
	$scope.editorMode = graphical ? 'graphical' : 'text';
	$scope.pages = $scope.model.getRoot().get('pages');
	$scope.currentPageName = '';
	$scope.currentPage = {
		text: ''
	};
	$scope.simRunning = false;
	if(graphical && resources[1].data.hllBlockSet) {
		$scope.blocklyTreeUrl = '/blockly/games/' + resources[1].data.hllBlockSet + 'tree.xml';
	}
	else {
		$scope.blocklyTreeUrl = null;
	}
	
	var collabLog = $scope.model.getRoot().get('log');
	$scope.log = null;
	var updateLog = function() {
		$scope.log = collabLog.items().sort(function(a,b) {
			return parseInt(b[0]) - parseInt(a[0]);
		});
	};
	updateLog();
	
	$scope.logOpen = false;
	$scope.chat = {
		message: ''
	};
	
	$scope.projectName = '';
	var setProjectName = function() {
		drive.getFileMetadata(realtime.id, function(data) {
			$timeout(function() {
				$scope.projectName = data.title;
			});
		});
	}
	setProjectName();
	
	$scope.blocklyText='';
	$scope.aceEditor = null;
	$scope.aceOptions = {
		theme:'chrome',
		mode: 'c_cpp',
		showPrintMargin: false,
		onLoad: function(ace) {
			$scope.aceEditor = ace;
		}
	};

	$scope.newProject = function() {
		drive.newProject();
	}
	
	$scope.openProject = function() {
		drive.openProject();
	}
	
	$scope.focusLog = function(item) {
		if(item.content) {
			var template = '<div class="modal-header"><button type="button" class="close" aria-hidden="true" ng-click="$dismiss()">&times;</button><h4 class="modal-title">'
				+ item.title + '</h4></div><div class="modal-body log-body">'
				+ item.content + '</div>';
			$modal.open({
				template: template
			});
		}
	};
	
	var logRemoteChange = function(e) {
		if(!e.isLocal) {
			$scope.$apply(updateLog);
		}
	};
	collabLog.addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED, logRemoteChange);
	
	var getMyName = function() {
		var collaborators = realtimeDocument.getCollaborators();
		var len = collaborators.length;
		for(var i = 0; i < len; i++) {
			if(collaborators[i].isMe) {
				return collaborators[i].displayName;
			}
		}
		return 'Anonymous';
	}
	
	//Opens the new page dialog
	$scope.newPage = function() {
		$modal.open({
			templateUrl: '/partials/new-page-modal.html',
			controller: 'NewPageController',
			resolve: {
				isGraphical: function(){ return graphical; }
			}
		}).result.then(function(result) {
			if(result.title==='') {
				alert('Enter a page name.');
				return;
			}
			if($scope.pages.has(result.title)) {
				alert('Page "' + result.title + '" already exists.');
				return;
			}
			if(!graphical) {
				$scope.pages.set(result.title, $scope.model.createString(''));
			}
			else {
				if(!Blockly.Blocks.CNameValidator(result.title)) {
					alert('Not a valid C function name.');
					return;
				}
				var pageRoot = $scope.model.createMap();
				$scope.pages.set(result.title, pageRoot);
				//This code copied from blockly/core/realtime.js
				var blocksMap = $scope.model.createMap();
				pageRoot.set('blocks', blocksMap);
				var topBlocks = $scope.model.createList();
				pageRoot.set('topBlocks', topBlocks);
				pageRoot.set('type',result.returnValue ? 'return' : 'noreturn');
			}
			$scope.setActivePage(result.title);
		});
	};

	$scope.go = function (path) {
		$location.path( path );
	};
	
	//Opens the simulation dialog
	$scope.openSimDialog = function() {
		$modal.open({
			templateUrl: '/partials/simulation-modal.html',
			controller: 'SimulationController',
			resolve: {
				gameResource: function() {
					return resources[1];
				}
			}
		}).result.then(function(data) {
			simulate(data);
		});
	};

	//Opens the submission dialog
	$scope.openSubmitDialog = function() {
		$modal.open({
			templateUrl: '/partials/submit-modal.html',
			controller: 'SubmitModalController',
			resolve: {
				projectText: function() { return realtime.getDocAsString($scope.model.getRoot()); }
			},
			windowClass: {
				'width': '9999px'
			}
		}).result.then(function(data) {
		});
	};
	
	//Opens the project rename dialog
	$scope.renameProject = function() {
		$modal.open({
			templateUrl: '/partials/rename-project-modal.html',
			controller: 'RenameProjectController', 
			resolve: {
				callback: function() { return setProjectName; }
			}
		});
	};
	
	$scope.deletePage = function(title) {<commit_msg>Mockup submission modal<commit_after>zr.controller('IdeController', ['$scope', '$modal', '$http', '$timeout', '$location', 'config', 'realtime', 'drive', 'resources', 'zrdb', 
		function($scope, $modal, $http, $timeout, $location, config, realtime, drive, resources, zrdb) {
	var realtimeDocument = resources[0];
	$scope.model = realtimeDocument.getModel();
	var graphical = $scope.model.getRoot().get('graphical');
	$scope.graphical = graphical;
	$scope.editorMode = graphical ? 'graphical' : 'text';
	$scope.pages = $scope.model.getRoot().get('pages');
	$scope.currentPageName = '';
	$scope.currentPage = {
		text: ''
	};
	$scope.simRunning = false;
	if(graphical && resources[1].data.hllBlockSet) {
		$scope.blocklyTreeUrl = '/blockly/games/' + resources[1].data.hllBlockSet + 'tree.xml';
	}
	else {
		$scope.blocklyTreeUrl = null;
	}
	
	var collabLog = $scope.model.getRoot().get('log');
	$scope.log = null;
	var updateLog = function() {
		$scope.log = collabLog.items().sort(function(a,b) {
			return parseInt(b[0]) - parseInt(a[0]);
		});
	};
	updateLog();
	
	$scope.logOpen = false;
	$scope.chat = {
		message: ''
	};
	
	$scope.projectName = '';
	var setProjectName = function() {
		drive.getFileMetadata(realtime.id, function(data) {
			$timeout(function() {
				$scope.projectName = data.title;
			});
		});
	}
	setProjectName();
	
	$scope.blocklyText='';
	$scope.aceEditor = null;
	$scope.aceOptions = {
		theme:'chrome',
		mode: 'c_cpp',
		showPrintMargin: false,
		onLoad: function(ace) {
			$scope.aceEditor = ace;
		}
	};

	$scope.newProject = function() {
		drive.newProject();
	}
	
	$scope.openProject = function() {
		drive.openProject();
	}
	
	$scope.focusLog = function(item) {
		if(item.content) {
			var template = '<div class="modal-header"><button type="button" class="close" aria-hidden="true" ng-click="$dismiss()">&times;</button><h4 class="modal-title">'
				+ item.title + '</h4></div><div class="modal-body log-body">'
				+ item.content + '</div>';
			$modal.open({
				template: template
			});
		}
	};
	
	var logRemoteChange = function(e) {
		if(!e.isLocal) {
			$scope.$apply(updateLog);
		}
	};
	collabLog.addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED, logRemoteChange);
	
	var getMyName = function() {
		var collaborators = realtimeDocument.getCollaborators();
		var len = collaborators.length;
		for(var i = 0; i < len; i++) {
			if(collaborators[i].isMe) {
				return collaborators[i].displayName;
			}
		}
		return 'Anonymous';
	}
	
	//Opens the new page dialog
	$scope.newPage = function() {
		$modal.open({
			templateUrl: '/partials/new-page-modal.html',
			controller: 'NewPageController',
			resolve: {
				isGraphical: function(){ return graphical; }
			}
		}).result.then(function(result) {
			if(result.title==='') {
				alert('Enter a page name.');
				return;
			}
			if($scope.pages.has(result.title)) {
				alert('Page "' + result.title + '" already exists.');
				return;
			}
			if(!graphical) {
				$scope.pages.set(result.title, $scope.model.createString(''));
			}
			else {
				if(!Blockly.Blocks.CNameValidator(result.title)) {
					alert('Not a valid C function name.');
					return;
				}
				var pageRoot = $scope.model.createMap();
				$scope.pages.set(result.title, pageRoot);
				//This code copied from blockly/core/realtime.js
				var blocksMap = $scope.model.createMap();
				pageRoot.set('blocks', blocksMap);
				var topBlocks = $scope.model.createList();
				pageRoot.set('topBlocks', topBlocks);
				pageRoot.set('type',result.returnValue ? 'return' : 'noreturn');
			}
			$scope.setActivePage(result.title);
		});
	};

	$scope.go = function (path) {
		$location.path( path );
	};
	
	//Opens the simulation dialog
	$scope.openSimDialog = function() {
		$modal.open({
			templateUrl: '/partials/simulation-modal.html',
			controller: 'SimulationController',
			resolve: {
				gameResource: function() {
					return resources[1];
				}
			}
		}).result.then(function(data) {
			simulate(data);
		});
	};

	//Opens the submission dialog
	$scope.openSubmitDialog = function() {
		$modal.open({
			templateUrl: '/partials/submit-modal.html',
			controller: 'SubmitModalController',
			resolve: {
				projectText: function() { return realtime.getDocAsString($scope.model.getRoot()); }
			}
		}).result.then(function(data) {
		});
	};
	
	//Opens the project rename dialog
	$scope.renameProject = function() {
		$modal.open({
			templateUrl: '/partials/rename-project-modal.html',
			controller: 'RenameProjectController', 
			resolve: {
				callback: function() { return setProjectName; }
			}
		});
	};
	
	$scope.deletePage = function(title) {
{'fraction_non_alphanumeric': 0.1800646551724138, 'fraction_numerical': 0.0023706896551724138, 'mean_word_length': 3.8088082901554405, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '196700', 'n_tokens_mistral': 3620, 'n_tokens_neox': 3147, 'n_words': 547}