diff --git a/frontend/static/css/fic.css b/frontend/static/css/fic.css index 0a073478..783f5dde 100644 --- a/frontend/static/css/fic.css +++ b/frontend/static/css/fic.css @@ -1,3 +1,7 @@ +body { + overflow-y: scroll; +} + .navbar { margin-bottom: 0; } @@ -46,3 +50,13 @@ text-shadow: 0 0 20px #0055ff; }; } + +.teamname { + padding: 2px 7px; + border-radius: 2px; + box-shadow: #444 0 0 3px; +} +.teamname span { + -webkit-filter: invert(100%); + filter: invert(100%); +} diff --git a/frontend/static/index.html b/frontend/static/index.html index 92e1eef1..853c162f 100644 --- a/frontend/static/index.html +++ b/frontend/static/index.html @@ -19,6 +19,7 @@ + @@ -46,7 +47,7 @@ -
+
@@ -63,14 +64,17 @@
- {{ teams[my.team_id].name }}edit

- {{ teams[my.team_id].score }} points
- {{ teams[my.team_id].rank }}e sur {{ teams_count }} + {{ teams[my.team_id].name }} + edit

+ + {{ teams[my.team_id].rank }}e sur {{ teams_count }} – + {{ teams[my.team_id].score }} points + classement
@@ -86,7 +90,6 @@ - diff --git a/frontend/static/js/app.js b/frontend/static/js/app.js index 6c42ad7c..e5232bef 100644 --- a/frontend/static/js/app.js +++ b/frontend/static/js/app.js @@ -10,58 +10,151 @@ angular.module("FICApp", ["ngRoute"]) templateUrl: "views/team-list.html" }) .when("/:theme", { - controller: "ThemeController", + controller: "ExerciceController", templateUrl: "views/theme.html" }) .when("/:theme/:exercice", { controller: "ExerciceController", templateUrl: "views/theme.html" }) - .otherwise({ + .when("/", { controller: "HomeController", templateUrl: "views/home.html" + }) + .otherwise({ + redirectTo: "/" }); $locationProvider.html5Mode(true); }) - .run(function($rootScope, $http) { - $http.get("/themes.json").success(function(themes) { - $rootScope.themes = themes; - angular.forEach(themes, function(value, key) { - this[key].exercice_count = Object.keys(value.exercices).length; - }, themes); - }); - $http.get("/teams.json").success(function(teams) { - $rootScope.teams_count = Object.keys(teams).length - $rootScope.teams = teams; - }); - $http.get("/my.json").success(function(my) { - $rootScope.my = my; - }); + .run(function($rootScope) { + $rootScope.current_theme = 0; + $rootScope.current_exercice = 0; }); angular.module("FICApp") - .controller("ExerciceController", function($scope, $routeParams, $rootScope) { + .controller("DataController", function($scope, $http, $rootScope) { + var actMenu = function() { + if ($scope.my && $scope.themes) { + angular.forEach($scope.themes, function(theme, key) { + $scope.themes[key].exercice_solved = 0; + angular.forEach(theme.exercices, function(exercice, k) { + if ($scope.my.exercices[k] && $scope.my.exercices[k].solved) { + $scope.themes[key].exercice_solved++; + } + }); + }); + } + } + var repeat = function() { + $http.get("/themes.json").success(function(themes) { + $scope.themes = themes; + angular.forEach(themes, function(theme, key) { + this[key].exercice_count = Object.keys(theme.exercices).length; + }, themes); + actMenu(); + }); + $http.get("/teams.json").success(function(teams) { + $scope.teams_count = Object.keys(teams).length + $scope.teams = teams; + + $scope.rank = []; + angular.forEach($scope.teams, function(team, tid) { + team.id = tid; + this.push(team); + }, $scope.rank); + }); + $http.get("/my.json").success(function(my) { + $scope.my = my; + actMenu(); + }); + console.log("refresh!"); + } + repeat(); + setInterval(repeat, 60000); + }) + .controller("ExerciceController", function($scope, $routeParams, $http, $rootScope) { $rootScope.current_theme = $routeParams.theme; - $rootScope.current_exercice = $routeParams.exercice; + + if ($routeParams.exercice) { + $rootScope.current_exercice = $routeParams.exercice; + } else { + if ($scope.themes && $scope.my && $scope.themes[$scope.current_theme]) { + var exos = Object.keys($scope.themes[$scope.current_theme].exercices); + var i = 0; + for (; i < exos.length - 1; i++) { + if (!$scope.my.exercices[exos[i]] || !$scope.my.exercices[exos[i]].solved) + break; + } + $rootScope.current_exercice = exos[i]; + } else { + $rootScope.current_exercice = 0; + } + } + + $scope.ssubmit = function() { + if (!$("#solution").val().length) { + return false + } + $http({ + url: "/submit/" + $rootScope.current_exercice, + method: "POST", + data: $("#solution").val() + }).success(function(data, status, header, config) { + $scope.messageClass = {"alert-success": true}; + $scope.message = data.errmsg; + + $scope.refresh = function() { + $http.get("/my.json").success(function(my) { + if ($scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) { + $scope.my = my; + } else { + setTimeout($scope.refresh, 750); + } + }); + }; + $scope.refresh() + }).error(function(data, status, header, config) { + if (status >= 500) { + $scope.my.exercices[$rootScope.current_exercice].submitted = false; + } + $scope.messageClass = {"alert-danger": true}; + $scope.message = data.errmsg; + }); + $scope.my.exercices[$rootScope.current_exercice].submitted = true; + }; }) .controller("MyTeamController", function($scope, $rootScope) { $rootScope.current_theme = 0; $rootScope.current_exercice = 0; $rootScope.title = "Edit team"; }) + .controller("RankController", function($scope, $rootScope) { + $rootScope.current_theme = 0; + $rootScope.current_exercice = 0; + $rootScope.title = "Classement général"; + + $scope.fields = ["rank", "name", "score"]; + $scope.rankOrder = "rank"; + $scope.reverse = false; + $scope.order = function(fld) { + if ($scope.rankOrder == fld) { + $scope.reverse = !$scope.reverse; + } else { + $scope.rankOrder = fld; + $scope.reverse = false; + } + }; + }) .controller("HomeController", function($scope, $rootScope) { $rootScope.current_theme = 0; $rootScope.current_exercice = 0; $rootScope.title = ""; - }) - .controller("ThemeController", function($scope, $routeParams, $rootScope) { - $rootScope.current_theme = $routeParams.theme; - - var exos = Object.keys($rootScope.themes[$rootScope.current_theme].exercices); - var i = 0; - for (; i < exos.length - 1; i++) { - if (!$rootScope.my.exercices[exos[i]] || !$rootScope.my.exercices[exos[i]].solved) - break; - } - $rootScope.current_exercice = exos[i]; }); + +function sready() { + if ($("#solution").val().length) { + $("#sbmt").removeClass("disabled"); + } else { + $("#sbmt").addClass("disabled"); + } +}; diff --git a/frontend/static/views/home.html b/frontend/static/views/home.html new file mode 100644 index 00000000..824519a6 --- /dev/null +++ b/frontend/static/views/home.html @@ -0,0 +1,56 @@ +
+

Bienvenue !

+

+ Compromissions, défauts de configuration, utilisations malveillantes, + contournements des règles de sécurité, … tous les jours nous mettons + en danger nos données. +

+

+ Saurez-vous identifier les différents vecteurs de fuites de données avec + lesquels nos systèmes d'informations et nos utilisateurs font faces ? +

+

+ Bon courage ! +

+
+ +
+
+

Progressions

+
+
+ + Vous +
+
+ 18% Complete +
+
+ 18% Complete +
+
+ + Le temps +
+
+ 90 minutes restantes +
+
+ + La meilleure équipe +
+
+ 18% Complete +
+
+ 18% Complete +
+
+ +
+
diff --git a/frontend/static/views/theme.html b/frontend/static/views/theme.html index 69562c21..3474f315 100644 --- a/frontend/static/views/theme.html +++ b/frontend/static/views/theme.html @@ -2,6 +2,9 @@
  • {{ exercice.title }}{{ exercice.title }} {{ exercice.gain }}
  • +
    + Vous n'avez pas encore accès à cet exercice. +

    {{ my.exercices[current_exercice].statement }}

    {{ my.exercices[current_exercice].hint }}

    @@ -35,16 +38,21 @@
    -
    +
    + Your solution has been submitted. {{ message }} +
    + +
    Soumettre une solution
    -
    +

    Dernière solution envoyée à {{ my.exercices[current_exercice].solved_time }}.

    +
    - +
    - +