diff --git a/index.html b/index.html
index c4ae037..3760462 100644
--- a/index.html
+++ b/index.html
@@ -7,6 +7,8 @@
{{ 'TITLE' | translate }}
+
+
diff --git a/package.json b/package.json
index 1cd861f..c0a02d7 100644
--- a/package.json
+++ b/package.json
@@ -21,11 +21,12 @@
"karma": "~0.12.28",
"karma-jasmine": "~0.3.2",
"karma-phantomjs-launcher": "~0.1.4",
- "protractor": "~1.5.0",
"http-server": "~0.7.4",
"jasmine-core": "~2.1.3",
"angular": "~1.2.28",
"angular-mocks": "~1.2.28",
- "angular-translate": "~2.5.2"
+ "angular-translate": "~2.5.2",
+ "angular-cookies": "~1.2.28",
+ "lodash": "~2.4.1"
}
}
diff --git a/salaryController.js b/salaryController.js
index cd68fc4..d7bbdd9 100644
--- a/salaryController.js
+++ b/salaryController.js
@@ -1,6 +1,11 @@
'use strict';
-var app = angular.module('calculator', ['pascalprecht.translate']);
+var lodash = angular.module('lodash', []);
+lodash.factory('_', function() {
+ return window._;
+})
+
+var app = angular.module('calculator', ['pascalprecht.translate', 'ngCookies', 'lodash']);
app.config(function($translateProvider) {
$translateProvider
@@ -71,7 +76,9 @@ function getGNFactor(rate) {
return 1-rate/100;
}
-function salaryController($translate, $scope) {
+function salaryController($translate, $cookies, $scope, _) {
+ $scope.favCountry = $cookies.favCountry;
+
// Default values
$scope.mg = 2500; // Gross Monthly Salary
$scope.hw = 35; // Number of hours worked by week
@@ -82,8 +89,10 @@ function salaryController($translate, $scope) {
{ label: 'USA', value: 'en-US'},
{ label: 'France', value: 'fr-FR'}
];
+ var defCountry = _.find($scope.countries, {value: $cookies.favCountry});
- $scope.country = $scope.countries[0];
+ $scope.country = defCountry ? defCountry : $scope.countries[0];
+ $translate.use($scope.country.value);
$scope.withExplain = false;
@@ -146,6 +155,7 @@ function salaryController($translate, $scope) {
};
$scope.setLang = function() {
+ $cookies.favCountry = $scope.country.value;
$translate.use($scope.country.value);
};
}
\ No newline at end of file
diff --git a/test/karma-conf.js b/test/karma-conf.js
index ea715cc..d92f47a 100644
--- a/test/karma-conf.js
+++ b/test/karma-conf.js
@@ -6,6 +6,8 @@ module.exports = function(config) {
'node_modules/angular/angular.js',
'node_modules/angular-mocks/angular-mocks.js',
'node_modules/angular-translate/dist/angular-translate.js',
+ 'node_modules/angular-cookies/angular-cookies.js',
+ 'node_modules/lodash/dist/lodash.js',
'salaryController.js',
'test/spec.js'
],