Coefficients transit and display on UI
This commit is contained in:
parent
78ce24f3f7
commit
b42016c74a
7 changed files with 64 additions and 20 deletions
|
@ -89,16 +89,25 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
time.he = (new Date()).getTime();
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
});
|
||||
$http.get("/settings.json").success(function(settings) {
|
||||
$scope.settings = settings;
|
||||
});
|
||||
$http.get("/themes.json").success(function(themes) {
|
||||
$scope.themes = themes;
|
||||
$scope.max_gain = 0;
|
||||
$scope.max_solved = 0;
|
||||
angular.forEach(themes, function(theme, key) {
|
||||
this[key].exercice_count = Object.keys(theme.exercices).length;
|
||||
this[key].exercice_coeff_max = 0;
|
||||
this[key].gain = 0;
|
||||
this[key].solved = 0;
|
||||
angular.forEach(theme.exercices, function(ex, k) {
|
||||
this.gain += ex.gain;
|
||||
this.solved += ex.solved;
|
||||
this.exercice_coeff_max = Math.max(this.exercice_coeff_max, ex.curcoeff);
|
||||
}, theme);
|
||||
$scope.max_gain += theme.gain;
|
||||
$scope.max_solved = Math.max($scope.max_solved, theme.solved);
|
||||
}, themes);
|
||||
actMenu();
|
||||
});
|
||||
|
@ -116,6 +125,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$http.get("/my.json").success(function(my) {
|
||||
$scope.my = my;
|
||||
angular.forEach($scope.my.exercices, function(exercice, eid) {
|
||||
exercice.solved = exercice.solved_rank > 0;
|
||||
if (exercice.video_uri) {
|
||||
exercice.video_uri = $sce.trustAsResourceUrl(exercice.video_uri);
|
||||
}
|
||||
|
|
|
@ -69,3 +69,15 @@ angular.module("FICApp")
|
|||
return (Math.round(res * 100) / 100) + " " + units[unit];
|
||||
}
|
||||
})
|
||||
|
||||
.filter("coeff", function() {
|
||||
return function(input) {
|
||||
if (input > 1) {
|
||||
return "+" + Math.floor((input - 1) * 100) + " %"
|
||||
} else if (input < 1) {
|
||||
return "-" + Math.floor((1 - input) * 100) + " %"
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Reference in a new issue