<commit_before>/* global angular,_,marked,hljs */
var corco = angular.module('corco', ['focusOn','ui.ace'] );

marked.setOptions({
	smartypants: true,
	breaks: true,
	highlight: function(code ) {
		hljs.highlightAuto(code).value;
	}
});

//corco.directive('startEdit', [function() {
	//return {
//
		//link: function( scope, element, attrs ) {
			//element.on('click', 
		//}
//
//}]);

/*
corco.directive('contenteditable', function() {

	return {
		require: 'ngModel',
		link: function(scope, elm, attrs, ctrl) {
			// view -> model
			elm.bind('blur', function() {
				scope.$apply(function() {
					ctrl.$setViewValue(elm.html());
				});
			});

			// model -> view
			ctrl.$render = function() {
				elm.html(ctrl.$viewValue);
			};

			// load init value from DOM
			ctrl.$setViewValue(elm.html());
		}
	};
});*/

/*
corco.directive('contenteditable', function() {
  return {
    require: 'ngModel',
    link: function(scope, element, attrs, ctrl) {
      // view -> model
      element.bind('blur', function() {
        scope.$apply(function() {
			console.log(element.html());
			ctrl.$setViewValue(element.text());
        });
      });

      // model -> view
      ctrl.$render = function() {
        element.html(ctrl.$viewValue);
      };

      // load init value from DOM
      ctrl.$render();
    }
  };
});
*/

corco.controller('CorcoController', ['$scope','$http','$sce','focus', function( $scope, $http, $sce, focus ) {

	$scope.title = 'Corco project';
	$scope.editingFullRaw = '';
	$scope.raw = '';
	$scope.sectionList = [];
	$scope.editingRaw = '';
	$scope.editingHtml = '';

	$scope.editMode = false;
	$scope.fullEditMode = false;

	$scope.editingDirection = false;
	$scope.editingIdx = false;

	$scope.cancelFullEdit = function() {
		$scope.fullEditMode = '';
		$scope.fullEditMode = false;
	};
	$scope.saveFullEdit = function() {
		var raw = $scope.editingFullRaw;
		var sectionList = $scope.parseToSectionList( raw );
		$scope.makeHtmlByMarkdown( sectionList );
		$scope.sectionList = sectionList;
		$scope.fullEditMode = false;
		$scope.raw = raw;

		var reqParams = { fileName: 'test.corco', raw: raw };
		$http.post('corcoFile', reqParams ).then( function( res ) {

			console.log( res );
<commit_msg>fix POST /corcoFile/:fileName<commit_after>/* global angular,_,marked,hljs */
var corco = angular.module('corco', ['focusOn','ui.ace'] );

marked.setOptions({
	smartypants: true,
	breaks: true,
	highlight: function(code ) {
		hljs.highlightAuto(code).value;
	}
});

//corco.directive('startEdit', [function() {
	//return {
//
		//link: function( scope, element, attrs ) {
			//element.on('click', 
		//}
//
//}]);

/*
corco.directive('contenteditable', function() {

	return {
		require: 'ngModel',
		link: function(scope, elm, attrs, ctrl) {
			// view -> model
			elm.bind('blur', function() {
				scope.$apply(function() {
					ctrl.$setViewValue(elm.html());
				});
			});

			// model -> view
			ctrl.$render = function() {
				elm.html(ctrl.$viewValue);
			};

			// load init value from DOM
			ctrl.$setViewValue(elm.html());
		}
	};
});*/

/*
corco.directive('contenteditable', function() {
  return {
    require: 'ngModel',
    link: function(scope, element, attrs, ctrl) {
      // view -> model
      element.bind('blur', function() {
        scope.$apply(function() {
			console.log(element.html());
			ctrl.$setViewValue(element.text());
        });
      });

      // model -> view
      ctrl.$render = function() {
        element.html(ctrl.$viewValue);
      };

      // load init value from DOM
      ctrl.$render();
    }
  };
});
*/

corco.controller('CorcoController', ['$scope','$http','$sce','focus', function( $scope, $http, $sce, focus ) {

	$scope.title = 'Corco project';
	$scope.editingFullRaw = '';
	$scope.raw = '';
	$scope.sectionList = [];
	$scope.editingRaw = '';
	$scope.editingHtml = '';

	$scope.editMode = false;
	$scope.fullEditMode = false;

	$scope.editingDirection = false;
	$scope.editingIdx = false;

	$scope.cancelFullEdit = function() {
		$scope.fullEditMode = '';
		$scope.fullEditMode = false;
	};
	$scope.saveFullEdit = function() {
		var raw = $scope.editingFullRaw;
		var sectionList = $scope.parseToSectionList( raw );
		$scope.makeHtmlByMarkdown( sectionList );
		$scope.sectionList = sectionList;
		$scope.fullEditMode = false;
		$scope.raw = raw;

		$http.post('corcoFile/test.corco', { raw: raw }).then( function( res ) {

			console.log( res );

{'fraction_non_alphanumeric': 0.1939120631341601, 'fraction_numerical': 0.0, 'mean_word_length': 3.19678334910123, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3903857', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1508, 'n_words': 271}