<commit_before>'use strict';

angular.module('notes.controllers', []).
	controller('MainCtrl', function ($scope, $location, $http) {

		$scope.noteList = [];
		$scope.isThereUnsavedData = false;
		$scope.isSaving = false;
		$scope.isUsingNoteArea = false;

		var path = $scope.path = $location.path();
		$scope.base = (path === '/') ? '' : path + '/';

		var getNoteDataLocation = function() {
			return '/data' + $location.path();
		};

		var getNoteListLocation = function() {
			return '/notes-at' + $location.path();
		};

		var saveNoteData = function () {
			if ($scope.isThereUnsavedData) {
				$scope.isThereUnsavedData = false;
				$scope.isSaving = true;

				var data = {};
				data.note = $scope.noteData;

				$http.put(getNoteDataLocation(), data)<commit_msg>Fix: Ensure save requests are valid<commit_after>'use strict';

angular.module('notes.controllers', []).
	controller('MainCtrl', function ($scope, $location, $http) {

		$scope.noteList = [];
		$scope.isThereUnsavedData = false;
		$scope.isSaving = false;
		$scope.isUsingNoteArea = false;

		var path = $scope.path = $location.path();
		$scope.base = (path === '/') ? '' : path + '/';

		var getNoteDataLocation = function() {
			return '/data' + $location.path();
		};

		var getNoteListLocation = function() {
			return '/notes-at' + $location.path();
		};

		var saveNoteData = function () {

			if ($scope.isThereUnsavedData) {
				if (path !== $location.path()) {
					// Stop invalid requests that can happen
					// when we're navigating quickly.
					$scope.isThereUnsavedData = false;
					return;
				}

				$scope.isThereUnsavedData = false;
				$scope.isSaving = true;

				var data = {};
				data.note = $scope.noteData;

				$http.put(getNoteDataLocation(), data)
{'fraction_non_alphanumeric': 0.17190177041690463, 'fraction_numerical': 0.0, 'mean_word_length': 3.4354430379746836, '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': '5968956', 'n_tokens_mistral': 669, 'n_tokens_neox': 564, 'n_words': 118}