<commit_before>'use strict';

angular.module('pie')
.controller('EditController', function ($scope, $resource, $routeParams, discussionService) {
	var Document = $resource('/mockAPI/document/:id', {id: '@id'});
	$scope.document = Document.get({id: $routeParams.documentId});

	$scope.isMyContentEditable = false;

	$scope.edit = function(section) {
		if (! section.isMyContentEditable) {
			section.isMyContentEditable = true;
		}
		else {
			section.isMyContentEditable = false;
			$scope.document.$save({id: $scope.document.id});
		}
	};

	$scope.showDiscussion = function(discussion) {
		discussionService.get(discussion.id);
	};

	$scope.createDiscussion = function(section) {
	};

	$scope.editButtonImage = function(section) {
		return section.isMyContentEditable ? "icon-ok" : "icon-edit";
	};
});<commit_msg>edit.js now pulls data from the API<commit_after>'use strict';

angular.module('pie')
.controller('EditController', function ($scope, $resource, $routeParams, authService, discussionService) {
	var token = authService.ensureLoginAndReturnToken();

	var Document = $resource(
		'http://localhost\\:8080/documents/:id',
		{
			id: '@id',
			token: token
		}
	);
	$scope.document = Document.get({id: $routeParams.documentId});

	$scope.edit = function(section) {
		if (! section.isMyContentEditable) {
			section.isMyContentEditable = true;
		}
		else {
			section.isMyContentEditable = false;
			//$scope.document.$update({id: $scope.document.id});
		}
	};

	$scope.showDiscussion = function(discussion) {
		discussionService.get(discussion.id);
	};

	$scope.createDiscussion = function(section) {
	};

	$scope.editButtonImage = function(section) {
		return section.isMyContentEditable ? "icon-ok" : "icon-edit";
	};
});
{'fraction_non_alphanumeric': 0.16387766878245816, 'fraction_numerical': 0.002308136180034622, 'mean_word_length': 4.938356164383562, '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': '400619', 'n_tokens_mistral': 610, 'n_tokens_neox': 556, 'n_words': 93}