js: compatible with angular 1.6
This commit is contained in:
parent
d965aab14a
commit
6047dcd6a9
|
@ -362,10 +362,10 @@ angular.module("FICApp")
|
|||
}
|
||||
$scope.reset = function(type) {
|
||||
if (confirm("Êtes-vous sûr ?")) {
|
||||
$http.post("/api/reset", {"type": type}).success(function(time) {
|
||||
$http.post("/api/reset", {"type": type}).then(function(time) {
|
||||
$rootScope.newBox('success', type + 'reseted');
|
||||
$location.url("/");
|
||||
}).error(function(repsonse) {
|
||||
}, function(response) {
|
||||
$rootScope.newBox('danger', 'An error occurs when reseting ' + type + ':', response.data);
|
||||
});
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ angular.module("FICApp")
|
|||
}
|
||||
}
|
||||
|
||||
$http.get("/time.json").success(function(time) {
|
||||
$http.get("/time.json").then(function(time) {
|
||||
time.he = (new Date()).getTime();
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
updTime();
|
||||
|
|
|
@ -39,6 +39,8 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
$rootScope.current_exercice = 0;
|
||||
$rootScope.time = {};
|
||||
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
function updTime() {
|
||||
if (sessionStorage.userService) {
|
||||
var time = angular.fromJson(sessionStorage.userService);
|
||||
|
@ -78,7 +80,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
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) {
|
||||
if ($scope.my.exercices && $scope.my.exercices[k] && $scope.my.exercices[k].solved) {
|
||||
$scope.themes[key].exercice_solved++;
|
||||
}
|
||||
});
|
||||
|
@ -89,18 +91,19 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
if (!justMy) {
|
||||
$timeout.cancel($scope.cbr);
|
||||
$scope.cbr = $timeout($rootScope.refresh, 42000);
|
||||
$http.get("/time.json").success(function(time) {
|
||||
$http.get("/time.json").then(function(response) {
|
||||
var time = response.data;
|
||||
time.he = (new Date()).getTime();
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
});
|
||||
$http.get("/settings.json").success(function(settings) {
|
||||
$scope.settings = settings;
|
||||
$http.get("/settings.json").then(function(response) {
|
||||
$scope.settings = response.data;
|
||||
});
|
||||
$http.get("/themes.json").success(function(themes) {
|
||||
$scope.themes = themes;
|
||||
$http.get("/themes.json").then(function(response) {
|
||||
$scope.themes = response.data;
|
||||
$scope.max_gain = 0;
|
||||
$scope.max_solved = 0;
|
||||
angular.forEach(themes, function(theme, key) {
|
||||
angular.forEach(response.data, function(theme, key) {
|
||||
this[key].exercice_count = Object.keys(theme.exercices).length;
|
||||
this[key].exercice_coeff_max = 0;
|
||||
this[key].gain = 0;
|
||||
|
@ -112,10 +115,11 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
}, theme);
|
||||
$scope.max_gain += theme.gain;
|
||||
$scope.max_solved = Math.max($scope.max_solved, theme.solved);
|
||||
}, themes);
|
||||
}, response.data);
|
||||
actMenu();
|
||||
});
|
||||
$http.get("/teams.json").success(function(teams) {
|
||||
$http.get("/teams.json").then(function(response) {
|
||||
var teams = response.data;
|
||||
$scope.teams_count = Object.keys(teams).length
|
||||
$scope.teams = teams;
|
||||
|
||||
|
@ -126,8 +130,8 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
}, $scope.rank);
|
||||
});
|
||||
}
|
||||
$http.get("/my.json").success(function(my) {
|
||||
$scope.my = my;
|
||||
$http.get("/my.json").then(function(response) {
|
||||
$scope.my = response.data;
|
||||
angular.forEach($scope.my.exercices, function(exercice, eid) {
|
||||
exercice.solved = exercice.solved_rank > 0;
|
||||
if (exercice.video_uri) {
|
||||
|
@ -135,7 +139,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
}
|
||||
});
|
||||
actMenu();
|
||||
if (my.team_id == 0) {
|
||||
if ($scope.my.team_id == 0) {
|
||||
angular.forEach($scope.my.exercices, function(exercice, eid) {
|
||||
angular.forEach(exercice.hints, function(hint, hid) {
|
||||
$scope.my.exercices[eid].hints[hid].hidden = true;
|
||||
|
@ -157,7 +161,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
var exos = Object.keys($scope.themes[$scope.current_theme].exercices);
|
||||
var i = 0;
|
||||
for (; i < exos.length; i++) {
|
||||
if (!$scope.my.exercices[exos[i]] || !$scope.my.exercices[exos[i]].solved)
|
||||
if (!$scope.my.exercices || !$scope.my.exercices[exos[i]] || !$scope.my.exercices[exos[i]].solved)
|
||||
break;
|
||||
}
|
||||
if (i < exos.length) {
|
||||
|
@ -172,9 +176,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
|
||||
$scope.hsubmit = function(hint) {
|
||||
hint.submitted = true;
|
||||
$http({ url: "/openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).success(function(data, status, header, config) {
|
||||
$http({ url: "/openhint/" + $rootScope.current_exercice, method: "POST", data: { id: hint.id } }).then(function(response, status, header, config) {
|
||||
var checkDiffHint = function() {
|
||||
$http.get("/my.json").success(function(my) {
|
||||
$http.get("/my.json").then(function(response) {
|
||||
var my = response.data;
|
||||
angular.forEach(my.exercices[$rootScope.current_exercice].hints, function(h,hid){
|
||||
if (hint.id == h.id) {
|
||||
if (hint.content != h.content) {
|
||||
|
@ -188,9 +193,9 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
};
|
||||
checkDiffHint();
|
||||
}).error(function(data, status, header, config) {
|
||||
}, function(response, status, header, config) {
|
||||
hint.submitted = false;
|
||||
console.error(data.errmsg);
|
||||
console.error(response.data.errmsg);
|
||||
});
|
||||
};
|
||||
})
|
||||
|
@ -225,9 +230,9 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
flgs[flag.name] = flag.value;
|
||||
});
|
||||
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: flgs }).success(function(data, status, header, config) {
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: flgs }).then(function(response, status, header, config) {
|
||||
$rootScope.messageClass = {"text-success": true};
|
||||
$rootScope.message = data.errmsg;
|
||||
$rootScope.message = response.data.errmsg;
|
||||
$rootScope.sberr = "";
|
||||
|
||||
angular.forEach($scope.flags, function(flag,kid) {
|
||||
|
@ -235,7 +240,8 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
|
||||
var checkDiff = function() {
|
||||
$http.get("/my.json").success(function(my) {
|
||||
$http.get("/my.json").then(function(response) {
|
||||
var my = response.data;
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) {
|
||||
$rootScope.refresh();
|
||||
$scope.my = my;
|
||||
|
@ -247,12 +253,12 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
};
|
||||
checkDiff();
|
||||
}).error(function(data, status, header, config) {
|
||||
}, function(response, status, header, config) {
|
||||
if (status >= 500) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
||||
}
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.message = data.errmsg;
|
||||
$rootScope.message = response.data.errmsg;
|
||||
if (status != 402) {
|
||||
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
||||
}
|
||||
|
@ -295,14 +301,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
url: "/submit/name",
|
||||
method: "POST",
|
||||
data: {newName: $scope.newName}
|
||||
}).success(function(data, status, header, config) {
|
||||
}).success(function(response, status, header, config) {
|
||||
$rootScope.messageClass = {"text-success": true};
|
||||
$rootScope.message = data.errmsg;
|
||||
$rootScope.message = response.data.errmsg;
|
||||
|
||||
var checkDiff = function() {
|
||||
$http.get("/my.json").success(function(my) {
|
||||
console.log(my.name);
|
||||
if ($scope.my.name != my.name) {
|
||||
$http.get("/my.json").then(function(response) {
|
||||
if ($scope.my.name != response.data.name) {
|
||||
$scope.newName = "";
|
||||
$rootScope.message = "";
|
||||
$rootScope.refresh();
|
||||
|
@ -313,9 +318,9 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||
});
|
||||
};
|
||||
checkDiff();
|
||||
}).error(function(data, status, header, config) {
|
||||
}, function(response, status, header, config) {
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.message = data.errmsg;
|
||||
$rootScope.message = response.data.errmsg;
|
||||
if (status != 402) {
|
||||
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ angular.module("FICApp")
|
|||
var initTime = function() {
|
||||
$timeout.cancel($scope.cbi);
|
||||
$scope.cbi = $timeout(initTime, 10000);
|
||||
$http.get("/time.json").success(function(time) {
|
||||
$http.get("/time.json").then(function(response) {
|
||||
var time = response.data;
|
||||
console.log("upd time");
|
||||
time.he = (new Date()).getTime();
|
||||
sessionStorage.userService = angular.toJson(time);
|
||||
|
@ -126,11 +127,11 @@ angular.module("FICApp")
|
|||
|
||||
$scope.my = response.data;
|
||||
});
|
||||
$http.get("/stats.json").success(function(stats) {
|
||||
$scope.stats = stats;
|
||||
$http.get("/stats.json").then(function(response) {
|
||||
$scope.stats = response.data;
|
||||
});
|
||||
$http.get("/settings.json").success(function(settings) {
|
||||
$scope.settings = settings;
|
||||
$http.get("/settings.json").then(function(response) {
|
||||
$scope.settings = response.data;
|
||||
});
|
||||
$http.get("/themes.json").then(function(response) {
|
||||
if ($scope.lastthemeetag == response.headers().etag)
|
||||
|
@ -175,7 +176,7 @@ angular.module("FICApp")
|
|||
})
|
||||
.controller("TeamController", function($scope, $http, $interval) {
|
||||
$scope.mystats = null;
|
||||
$http.get("/api/teams/" + $scope.team.id + "/stats.json").success(function(mstats) {
|
||||
$scope.mystats = mstats;
|
||||
$http.get("/api/teams/" + $scope.team.id + "/stats.json").then(function(response) {
|
||||
$scope.mystats = response.data;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user