Improve team interface
This commit is contained in:
parent
7f9581f578
commit
6863891ba2
6 changed files with 76 additions and 23 deletions
|
@ -63,7 +63,21 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
updTime();
|
||||
});
|
||||
|
||||
String.prototype.capitalize = function() {
|
||||
return this
|
||||
.toLowerCase()
|
||||
.replace(
|
||||
/(^|\s)([a-z])/g,
|
||||
function(m,p1,p2) { return p1+p2.toUpperCase(); }
|
||||
);
|
||||
}
|
||||
|
||||
angular.module("FICApp")
|
||||
.filter("capitalize", function() {
|
||||
return function(input) {
|
||||
return input.capitalize();
|
||||
}
|
||||
})
|
||||
.filter("time", function() {
|
||||
return function(input) {
|
||||
if (input == undefined) {
|
||||
|
@ -75,6 +89,11 @@ angular.module("FICApp")
|
|||
}
|
||||
}
|
||||
})
|
||||
.filter("date", function() {
|
||||
return function(input) {
|
||||
return (new Date(Date.parse(input))).toLocaleTimeString();
|
||||
}
|
||||
})
|
||||
.controller("DataController", function($scope, $http, $rootScope, $timeout) {
|
||||
var actMenu = function() {
|
||||
if ($scope.my && $scope.themes) {
|
||||
|
@ -90,7 +109,7 @@ angular.module("FICApp")
|
|||
}
|
||||
$rootScope.refresh = function(justMy) {
|
||||
if (!justMy) {
|
||||
$timeout($rootScope.refresh, 60000);
|
||||
$timeout($rootScope.refresh, 42000);
|
||||
$http.get("/time.json").success(function(time) {
|
||||
time.he = (new Date()).getTime();
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
|
@ -130,11 +149,15 @@ angular.module("FICApp")
|
|||
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++) {
|
||||
for (; i < exos.length; i++) {
|
||||
if (!$scope.my.exercices[exos[i]] || !$scope.my.exercices[exos[i]].solved)
|
||||
break;
|
||||
}
|
||||
$rootScope.current_exercice = exos[i];
|
||||
if (i < exos.length) {
|
||||
$rootScope.current_exercice = exos[i];
|
||||
} else {
|
||||
$rootScope.current_exercice = exos[0];
|
||||
}
|
||||
} else {
|
||||
$rootScope.current_exercice = 0;
|
||||
}
|
||||
|
@ -143,6 +166,7 @@ angular.module("FICApp")
|
|||
})
|
||||
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
|
||||
$scope.flags = []
|
||||
$rootScope.sberr = "";
|
||||
|
||||
var waitMy = function() {
|
||||
if (!$scope.my || !$scope.my.exercices || !$scope.my.exercices[$rootScope.current_exercice]) {
|
||||
|
@ -162,18 +186,35 @@ angular.module("FICApp")
|
|||
$scope.ssubmit = function() {
|
||||
var flgs = {}
|
||||
|
||||
var filled = true;
|
||||
angular.forEach($scope.flags, function(flag,kid) {
|
||||
flgs[flag.name] = flag.value;
|
||||
flag.value = "";
|
||||
filled = filled && flag.value.length > 0;
|
||||
});
|
||||
|
||||
if (!filled) {
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.sberr = "Tous les champs sont obligatoires.";
|
||||
$timeout(function() {
|
||||
if ($rootScope.sberr == "Tous les champs sont obligatoires.") {
|
||||
$rootScope.sberr = "";
|
||||
}
|
||||
}, 2345);
|
||||
return;
|
||||
}
|
||||
|
||||
$http({
|
||||
url: "/submit/" + $rootScope.current_exercice,
|
||||
method: "POST",
|
||||
data: flgs
|
||||
}).success(function(data, status, header, config) {
|
||||
$rootScope.messageClass = {"alert-success": true};
|
||||
$rootScope.messageClass = {"text-success": true};
|
||||
$rootScope.message = data.errmsg;
|
||||
$rootScope.sberr = "";
|
||||
|
||||
angular.forEach($scope.flags, function(flag,kid) {
|
||||
flag.value = "";
|
||||
});
|
||||
|
||||
var checkDiff = function() {
|
||||
$http.get("/my.json").success(function(my) {
|
||||
|
@ -189,8 +230,11 @@ angular.module("FICApp")
|
|||
if (status >= 500) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
||||
}
|
||||
$rootScope.messageClass = {"alert-danger": true};
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.message = data.errmsg;
|
||||
if (status != 402) {
|
||||
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
||||
}
|
||||
});
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = true;
|
||||
};
|
||||
|
@ -260,6 +304,7 @@ angular.module("FICApp")
|
|||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.title = "Classement général";
|
||||
$rootScope.authors = "";
|
||||
|
||||
$scope.fields = ["rank", "name", "score"];
|
||||
$scope.rankOrder = "rank";
|
||||
|
@ -277,6 +322,7 @@ angular.module("FICApp")
|
|||
$rootScope.current_theme = 0;
|
||||
$rootScope.current_exercice = 0;
|
||||
$rootScope.title = "";
|
||||
$rootScope.authors = "";
|
||||
});
|
||||
|
||||
function sready() {
|
||||
|
|
Reference in a new issue