<commit_before>// Controller for the poll list
function PollListCtrl($scope, Poll) {
	$scope.polls = Poll.query();
}

// Controller for the form list
function FormListCtrl($scope, TechlabForm) {
	$scope.forms = TechlabForm.query();
}

// Controller for an individual poll
function PollItemCtrl($scope, $routeParams, socket, Poll) {	
	$scope.poll = Poll.get({pollId: $routeParams.pollId});
	
	socket.on('myvote', function(data) {
		console.dir(data);
		if(data._id === $routeParams.pollId) {
			$scope.poll = data;
		}
	});
	
	socket.on('vote', function(data) {
		console.dir(data);
		if(data._id === $routeParams.pollId) {
			$scope.poll.choices = data.choices;
			$scope.poll.totalVotes = data.totalVotes;
		}		
	});
	
	$scope.vote = function() {
		var pollId = $scope.poll._id,
			choiceId = $scope.poll.userVote;
		
		if(choiceId) {
			var voteObj = { poll_id: pollId, choice: choiceId };
			socket.emit('send:vote', voteObj);
		} else {
			alert('You must select an option to vote for');
		}
	};
}

// Controller for an individual form
function FormItemCtrl($scope, $routeParams, $timeout, socket, TechlabForm, TechlabFormResults) {	
	TechlabForm.get({formId: $routeParams.formId}, function(form) {
		$scope.message = {type: "info", text: ""};
		$scope.showAlert = false;
		
		var hideAlert = function() {
			$scope.showAlert = false;
		}

		$scope.init = function(form) {
			$scope.form = form;
			$scope.results = TechlabFormResults.init.get({formId: $routeParams.formId});
		} 

		$scope.init(form);

		socket.on('mysubmit', function(data) {
			$scope.init(form);
		});
		
		socket.on('submit', function(data) {
			$scope.init(form);		
		});
		
		$scope.submit = function() {
			var	results = $scope.results;
			console.log("RESULT");
			console.log(results);
			
			for(i=0; i<results.results.length; i++) {
				results.results[i].values = results.results[i].values.filter(function(n){return n; });
			}
			
			var result = jQuery.parseJSON(angular.toJson(results));
			socket.emit('send:submit', result);<commit_msg>Changed init() call to only be called on mysubmit<commit_after>// Controller for the poll list
function PollListCtrl($scope, Poll) {
	$scope.polls = Poll.query();
}

// Controller for the form list
function FormListCtrl($scope, TechlabForm) {
	$scope.forms = TechlabForm.query();
}

// Controller for an individual poll
function PollItemCtrl($scope, $routeParams, socket, Poll) {	
	$scope.poll = Poll.get({pollId: $routeParams.pollId});
	
	socket.on('myvote', function(data) {
		console.dir(data);
		if(data._id === $routeParams.pollId) {
			$scope.poll = data;
		}
	});
	
	socket.on('vote', function(data) {
		console.dir(data);
		if(data._id === $routeParams.pollId) {
			$scope.poll.choices = data.choices;
			$scope.poll.totalVotes = data.totalVotes;
		}		
	});
	
	$scope.vote = function() {
		var pollId = $scope.poll._id,
			choiceId = $scope.poll.userVote;
		
		if(choiceId) {
			var voteObj = { poll_id: pollId, choice: choiceId };
			socket.emit('send:vote', voteObj);
		} else {
			alert('You must select an option to vote for');
		}
	};
}

// Controller for an individual form
function FormItemCtrl($scope, $routeParams, $timeout, socket, TechlabForm, TechlabFormResults) {	
	TechlabForm.get({formId: $routeParams.formId}, function(form) {
		$scope.message = {type: "info", text: ""};
		$scope.showAlert = false;
		
		var hideAlert = function() {
			$scope.showAlert = false;
		}

		$scope.init = function(form) {
			$scope.form = form;
			$scope.results = TechlabFormResults.init.get({formId: $routeParams.formId});
		} 

		$scope.init(form);

		socket.on('mysubmit', function(data) {
			$scope.init(form);
		});
		
		socket.on('submit', function(data) {
			//$scope.init(form);		
		});
		
		$scope.submit = function() {
			var	results = $scope.results;
			console.log("RESULT");
			console.log(results);
			
			for(i=0; i<results.results.length; i++) {
				results.results[i].values = results.results[i].values.filter(function(n){return n; });
			}
			
			var result = jQuery.parseJSON(angular.toJson(results));
			socket.emit('send:submit', result);
{'fraction_non_alphanumeric': 0.1687866927592955, 'fraction_numerical': 0.0004892367906066536, 'mean_word_length': 3.8620689655172415, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5810971', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1397, 'n_words': 273}