<commit_before>'use strict';

angular.module('CST.stock', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/stock', {
    templateUrl: 'views/stock/stock.html',
    controller: 'stockCtrl'
  });
}])

.controller('stockCtrl', ['$scope', '$filter', 'Notification', '$rootScope', '$q', '$sce', 'FileLoader', function($scope, $filter, Notification, $rootScope, $q, $sce, FileLoader) {
	var ctrl = $scope;

	ctrl.system = {
		stock: null,
		view: {
			_: {
				wantBuy: false
			},
			headers: {},
			data: {},
			modal: {
				getPrice: getPrice,
				getHeaders: getHeaders,
				getData: getData,
				displayField: displayField,
				buy: buy
			},
			info: {
				title: 'titi'
			}
		},
		_: {
			categoryList: ['processor', 'memory', 'disk', 'motherboard', 'alim', 'boxe', 'lecteur', 'graphic'],
			uglifyHeader: uglifyHeader,
			translateCategoryByNo: translateCategoryByNo,
			categoryTranslate: [],
			showInfo: showInfo,
			showByCat: showByCat,
			showInfoButton: showInfoButton,
			receiveStock: null,
			commandeType: 0,
			routines: {
				trustHTML: trustHTML,
				changeTabTo: changeTabTo
			},
			tabs: {
				fournisseur: true,
				amazon: false
			}
		}
	};

	start();

	function showInfo(cat, header) {
		console.log('Cat = ' + cat + ' header = ' + header);
		ctrl.system.view.info.title = translateCategoryByNo(cat);
		$("#infoModal").modal();
	}

	function translateCategoryByNo(no) {
		return translateCategory(ctrl.system._.categoryList[no - 1]);
	}

	function translateCategory(word) {
		var replaceBy = "";

		for (var i = 0; i < ctrl.system._.categoryTranslate.length; i++) {
			if (ctrl.system._.categoryTranslate[i].category === word) {
				replaceBy = ctrl.system._.categoryTranslate[i].translate;
				break;
			}
		}
		return replaceBy;
	}

	function start() {
		ctrl.system._.receiveStock = $rootScope.$on('stock', function(event, data) {
			console.log(data);
			ctrl.system.stock = data;
		});
		ctrl.$on("$destroy", ctrl.system._.receiveStock);
		$rootScope.$emit("getStock", {});

		/* Get components data to populate Shop */
		$.each(ctrl.system._.categoryList, function(i, elem) {
			FileLoader.getFile('./res/json/' + ctrl.system._.categoryList[i] + '.json', i).success(function(data) {
				ctrl.system.view.data = Object.defineProperty(ctrl.system.view.data, ctrl.system._.categoryList[i], {value: data, writable: true});
			});
			FileLoader.getFile('./res/json/' + ctrl.system._.categoryList[i] + '_header.json').success(function(data) {
				ctrl.system.view.headers = Object.defineProperty(ctrl.system.view.headers, ctrl.system._.categoryList[i], {value: data, writable: true});
			});
		});
	}<commit_msg>Add title to stock panel<commit_after>'use strict';

angular.module('CST.stock', ['ngRoute'])

.config(['$routeProvider', function($routeProvider) {
  $routeProvider.when('/stock', {
    templateUrl: 'views/stock/stock.html',
    controller: 'stockCtrl'
  });
}])

.controller('stockCtrl', ['$scope', '$filter', 'Notification', '$rootScope', '$q', '$sce', 'FileLoader', function($scope, $filter, Notification, $rootScope, $q, $sce, FileLoader) {
	var ctrl = $scope;

	ctrl.system = {
		stock: null,
		view: {
			_: {
				wantBuy: false
			},
			headers: {},
			data: {},
			modal: {
				getPrice: getPrice,
				getHeaders: getHeaders,
				getData: getData,
				displayField: displayField,
				buy: buy
			},
			info: {
				title: 'titi'
			}
		},
		_: {
			categoryList: ['processor', 'memory', 'disk', 'motherboard', 'alim', 'boxe', 'lecteur', 'graphic'],
			uglifyHeader: uglifyHeader,
			translateCategoryByNo: translateCategoryByNo,
			categoryTranslate: [],
			showInfo: showInfo,
			showByCat: showByCat,
			showInfoButton: showInfoButton,
			receiveStock: null,
			commandeType: 0,
			routines: {
				trustHTML: trustHTML,
				changeTabTo: changeTabTo
			},
			tabs: {
				fournisseur: true,
				amazon: false
			}
		}
	};

	start();

	function showInfo(cat, header) {
		console.log('Cat = ' + cat + ' header = ' + header);
		ctrl.system.view.info.title = translateCategoryByNo(cat-1);
		$("#infoModal").modal();
	}

	function translateCategoryByNo(no) {
		console.log(no);
		return translateCategory(ctrl.system._.categoryList[no-1]);
	}

	function translateCategory(word) {
		var replaceBy = "";

		for (var i = 0; i < ctrl.system._.categoryTranslate.length; i++) {
			if (ctrl.system._.categoryTranslate[i].category === word) {
				replaceBy = ctrl.system._.categoryTranslate[i].translate;
				break;
			}
		}
		return replaceBy;
	}

	function start() {
		ctrl.system._.receiveStock = $rootScope.$on('stock', function(event, data) {
			console.log(data);
			ctrl.system.stock = data;
		});
		ctrl.$on("$destroy", ctrl.system._.receiveStock);
		$rootScope.$emit("getStock", {});
		FileLoader.getFile('./res/json/category_translate.json').success(function(data) {
			ctrl.system._.categoryTranslate = data;
		});

		/* Get components data to populate Shop */
		$.each(ctrl.system._.categoryList, function(i, elem) {
			FileLoader.getFile('./res/json/' + ctrl.system._.categoryList[i] + '.json', i).success(function(data) {
				ctrl.system.view.data = Object.defineProperty(ctrl.system.view.data, ctrl.system._.categoryList[i], {value: data, writable: true});
			});
			FileLoader.getFile('./res/json/' + ctrl.system._.categoryList[i] + '_header.json').success(function(data) {
				ctrl.system.view.headers = Object.defineProperty(ctrl.system.view.headers, ctrl.system._.categoryList[i], {value: data, writable: true});
			});
		});

	}
{'fraction_non_alphanumeric': 0.17674755523361102, 'fraction_numerical': 0.0012676566461427019, 'mean_word_length': 3.896276595744681, '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': '2938498', 'n_tokens_mistral': 2141, 'n_tokens_neox': 1840, 'n_words': 331}