frontend: beautiful URLs
This commit is contained in:
parent
bd75157a79
commit
0c540a39eb
13 changed files with 54 additions and 31 deletions
|
@ -107,12 +107,16 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$scope.themes = response.data;
|
||||
$scope.max_gain = 0;
|
||||
$scope.max_solved = 0;
|
||||
$scope.themesUrl = {};
|
||||
$scope.exercicesUrl = {};
|
||||
angular.forEach(response.data, function(theme, key) {
|
||||
$scope.themesUrl[theme.urlid] = 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) {
|
||||
$scope.exercicesUrl[ex.urlid] = k;
|
||||
this.gain += ex.gain;
|
||||
this.solved += ex.solved;
|
||||
this.exercice_coeff_max = Math.max(this.exercice_coeff_max, ex.curcoeff);
|
||||
|
@ -160,10 +164,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$rootScope.refresh();
|
||||
})
|
||||
.controller("ExerciceController", function($scope, $routeParams, $http, $rootScope, $timeout) {
|
||||
$rootScope.current_theme = $routeParams.theme;
|
||||
$rootScope.current_theme = $scope.themesUrl[$routeParams.theme];
|
||||
|
||||
if ($routeParams.exercice) {
|
||||
$rootScope.current_exercice = $routeParams.exercice;
|
||||
$rootScope.current_exercice = $scope.exercicesUrl[$routeParams.exercice];
|
||||
} else {
|
||||
if ($scope.themes && $scope.my && $scope.themes[$scope.current_theme]) {
|
||||
var exos = Object.keys($scope.themes[$scope.current_theme].exercices);
|
||||
|
|
Reference in a new issue