<commit_before>/* File: apercu.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), <NAME>, 86360 CHASSENEUIL-DU-POITOU, France
 * (<EMAIL>)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*jshint loopfunc:true*/

'use strict';

angular.module('cnedApp').controller('ApercuCtrl', function($scope, $http, $rootScope, _, $location) {

	$scope.data = [];
	$scope.blocks = [];
	$scope.blocksAlternative = [];
	$scope.plans = [];
	$scope.showApercu = 'hidden';
	$scope.showPlan = 'visible';
	$scope.counterElements = 0;
	$scope.stylePlan = '';

	$scope.init = function(idDocuments) {

		// initialiser le nombre d'appel du service
		var callsFinish = 0;
		// console.log("the documents length ==> ");
		// console.log(idDocuments);

		//$rootScope.profilId = '52fb65eb8856dce835c2ca86';
		if ($location.search().profil) {
			$rootScope.profilId = $location.search().profil;
		}

		if ($rootScope.profilId) {
			$http.post('/chercherTagsParProfil', {
				idProfil: $rootScope.profilId
			})
				.success(function(data) {
					if (data === 'err') {
						console.log('Désolé un problème est survenu lors de l\'enregistrement');
					} else {
						$scope.profiltags = data;
						// console.log('proflies selected ==> ');
						// console.log(data);
					}
				});
		}


		if (idDocuments) {
			$scope.loader = true;
			for (var i = 0; i < idDocuments.length; i++) {

				// console.log(idDocuments[i]);

				$http.post('/getDocument', {
					idDoc: idDocuments[i]
				}).success(function(data) {
					// incrémenter le nombre d'appel du service de 1
					callsFinish += 1;
					$scope.blocks.push(data);

					if (idDocuments.length === callsFinish) {
						$scope.position = 0;
						// implement show des blocks
						traverse($scope.blocks);
					}
				}).error(function() {
					$scope.msg = 'ko';
				});

			}
			$scope.loader = false;
		}
	};


	// init slider
	//$rootScope.idDocument = ['52fb66e38856dce835c2ca91'];
	console.log('the document ==> ');
	console.log(typeof($location.search().document));
	if ($location.search().document) {
		$rootScope.idDocument = [];
		if (typeof($location.search().document) === 'string') {
			$rootScope.idDocument.push($location.search().document);
		} else {
			$rootScope.idDocument = $location.search().document;
		}
	}
	$scope.init($rootScope.idDocument);


	function traverse(obj) {
		//for (var key in obj) {
		for (var key in obj) {
			if (typeof(obj[key]) === 'object') {
				var alreadyExist = _.findWhere($scope.blocksAlternative, {
					_id: obj[key]._id
				});

				if (!alreadyExist) {
					if (obj[key].text !== '') {
						$scope.counterElements += 1;
						var debutStyle = '<p id="' + $scope.counterElements + '">';<commit_msg>Integrer un loader dans le plan.<commit_after>/* File: apercu.js
 *
 * Copyright (c) 2014
 * Centre National d’Enseignement à Distance (Cned), <NAME>, 86360 CHASSENEUIL-DU-POITOU, France
 * (<EMAIL>)
 *
 * GNU Affero General Public License (AGPL) version 3.0 or later version
 *
 * This file is part of a program which is free software: you can
 * redistribute it and/or modify it under the terms of the
 * GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public
 * License along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*jshint loopfunc:true*/

'use strict';

angular.module('cnedApp').controller('ApercuCtrl', function($scope, $http, $rootScope, _, $location) {

	$scope.data = [];
	$scope.blocks = [];
	$scope.blocksAlternative = [];
	$scope.plans = [];
	$scope.showApercu = 'hidden';
	$scope.showPlan = 'visible';
	$scope.counterElements = 0;
	$scope.stylePlan = '';

	$scope.init = function(idDocuments) {

		// initialiser le nombre d'appel du service
		var callsFinish = 0;
		// console.log("the documents length ==> ");
		// console.log(idDocuments);
		$scope.loader = true;
		//$rootScope.profilId = '52fb65eb8856dce835c2ca86';
		if ($location.search().profil) {
			$rootScope.profilId = $location.search().profil;
		}

		if ($rootScope.profilId) {
			$http.post('/chercherTagsParProfil', {
				idProfil: $rootScope.profilId
			})
				.success(function(data) {
					if (data === 'err') {
						console.log('Désolé un problème est survenu lors de l\'enregistrement');
					} else {
						$scope.profiltags = data;
						// console.log('proflies selected ==> ');
						// console.log(data);
					}
				});
		}

		if (idDocuments) {
			for (var i = 0; i < idDocuments.length; i++) {

				// console.log(idDocuments[i]);

				$http.post('/getDocument', {
					idDoc: idDocuments[i]
				}).success(function(data) {
					// incrémenter le nombre d'appel du service de 1
					callsFinish += 1;
					$scope.blocks.push(data);

					if (idDocuments.length === callsFinish) {
						$scope.position = 0;
						// implement show des blocks
						traverse($scope.blocks);
						$scope.loader = false;
					}
				}).error(function() {
					$scope.msg = 'ko';
				});

			}
		}
	};


	// init slider
	//$rootScope.idDocument = ['52fb66e38856dce835c2ca91'];
	console.log('the document ==> ');
	console.log(typeof($location.search().document));
	if ($location.search().document) {
		$rootScope.idDocument = [];
		if (typeof($location.search().document) === 'string') {
			$rootScope.idDocument.push($location.search().document);
		} else {
			$rootScope.idDocument = $location.search().document;
		}
	}
	$scope.init($rootScope.idDocument);


	function traverse(obj) {
		//for (var key in obj) {
		for (var key in obj) {
			if (typeof(obj[key]) === 'object') {
				var alreadyExist = _.findWhere($scope.blocksAlternative, {
					_id: obj[key]._id
				});

				if (!alreadyExist) {
					if (obj[key].text !== '') {
						$scope.counterElements += 1;
						var debutStyle = '<p id="' + $scope.counterElements + '">';
{'fraction_non_alphanumeric': 0.1537237888647867, 'fraction_numerical': 0.01388286334056399, 'mean_word_length': 3.287662740235586, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3095710', 'n_tokens_mistral': 2687, 'n_tokens_neox': 2234, 'n_words': 587}