2018-12-04 03:13:01 +00:00
|
|
|
angular.module("FICApp", ["ngSanitize", "ngAnimate"])
|
2017-03-31 17:47:48 +00:00
|
|
|
.controller("EventsController", function($scope, $http, $interval) {
|
|
|
|
$scope.events = [];
|
|
|
|
var refreshEvents = function() {
|
2018-01-23 01:26:55 +00:00
|
|
|
// Update times
|
|
|
|
var now = new Date().getTime();
|
|
|
|
$scope.events.forEach(function(ev) {
|
|
|
|
ev.since = now - ev.time;
|
|
|
|
});
|
|
|
|
|
2017-03-31 17:47:48 +00:00
|
|
|
$http.get("/events.json").then(function(response) {
|
2018-01-23 01:26:55 +00:00
|
|
|
// Don't make anything if the page hasn't changed
|
2018-12-04 03:13:25 +00:00
|
|
|
if ($scope.lasteventsetag != undefined && $scope.lasteventsetag == response.headers()["last-modified"])
|
2017-03-31 17:47:48 +00:00
|
|
|
return;
|
2018-12-04 03:13:25 +00:00
|
|
|
$scope.lasteventsetag = response.headers()["last-modified"];
|
2017-03-31 17:47:48 +00:00
|
|
|
|
2018-12-06 02:48:23 +00:00
|
|
|
$scope.events = response.data;
|
|
|
|
$scope.events.forEach(function(event) {
|
2018-01-23 01:26:55 +00:00
|
|
|
event.time = Date.parse(event.time);
|
|
|
|
event.since = now - event.time;
|
2018-12-09 17:35:28 +00:00
|
|
|
event.kind = ["border-" + event.kind, "alert-" + event.kind];
|
2017-03-31 17:47:48 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
refreshEvents()
|
|
|
|
$interval(refreshEvents, 2100);
|
|
|
|
})
|
2018-12-04 04:31:56 +00:00
|
|
|
.controller("TimerController", function($scope, $rootScope, $interval) {
|
2017-12-17 19:44:23 +00:00
|
|
|
$scope.duration = 0;
|
|
|
|
|
|
|
|
$scope.init = function(end) {
|
2018-12-04 04:31:56 +00:00
|
|
|
$scope.initT(Date.parse(end));
|
|
|
|
}
|
|
|
|
$scope.initStart = function() {
|
|
|
|
$scope.$watch("settings", function(settings){
|
|
|
|
if (settings)
|
|
|
|
$scope.initT(settings.start);
|
|
|
|
})
|
2017-12-17 19:44:23 +00:00
|
|
|
}
|
|
|
|
$scope.initT = function(end) {
|
|
|
|
var time = angular.fromJson(sessionStorage.userService);
|
2018-12-04 04:31:56 +00:00
|
|
|
var srv_cur = new Date(Date.now() + (time.cu - time.he));
|
|
|
|
$scope.duration = Math.floor((end - srv_cur)/1000);
|
2017-12-17 19:44:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var stop = $interval(function() {
|
|
|
|
$scope.duration -= 1;
|
|
|
|
if ($scope.duration < -10)
|
|
|
|
$interval.cancel(stop);
|
|
|
|
}, 1000);
|
|
|
|
})
|
2017-03-31 17:47:48 +00:00
|
|
|
.controller("DataController", function($scope, $http, $rootScope, $interval) {
|
2018-04-13 18:02:47 +00:00
|
|
|
var pathname = window.location.pathname;
|
|
|
|
if (pathname == "/")
|
2018-12-04 04:34:34 +00:00
|
|
|
pathname = "/public0.html";
|
|
|
|
pathname = pathname.replace(".html", ".json");
|
|
|
|
|
2017-03-31 17:47:48 +00:00
|
|
|
var refreshScene = function() {
|
2018-12-04 04:34:34 +00:00
|
|
|
$http.get(pathname).then(function(response) {
|
2018-12-04 03:13:25 +00:00
|
|
|
if ($scope.lastpublicetag != undefined && $scope.lastpublicetag == response.headers()["last-modified"])
|
2017-03-31 17:47:48 +00:00
|
|
|
return;
|
2018-12-04 03:13:25 +00:00
|
|
|
$scope.lastpublicetag = response.headers()["last-modified"];
|
2017-03-31 17:47:48 +00:00
|
|
|
|
|
|
|
$scope.scene = response.data;
|
2016-01-25 02:09:22 +00:00
|
|
|
});
|
2017-03-31 17:47:48 +00:00
|
|
|
}
|
2018-12-04 04:34:34 +00:00
|
|
|
refreshScene();
|
|
|
|
var refreshSceneInterval = $interval(refreshScene, 900);
|
|
|
|
|
|
|
|
var refreshSettings = function() {
|
|
|
|
$http.get("/settings.json").then(function(response) {
|
|
|
|
$rootScope.recvTime(response);
|
|
|
|
response.data.start = new Date(response.data.start);
|
|
|
|
response.data.end = new Date(response.data.end);
|
|
|
|
response.data.generation = new Date(response.data.generation);
|
|
|
|
response.data.awards = new Date("2019-01-23T15:00:00Z");
|
|
|
|
$rootScope.settings = response.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
refreshSettings();
|
|
|
|
var refreshSettingsInterval = $interval(refreshSettings, 4200);
|
|
|
|
|
|
|
|
|
|
|
|
$rootScope.refresh = function() {
|
2017-03-31 17:47:48 +00:00
|
|
|
$http.get("/my.json").then(function(response) {
|
2018-12-04 03:13:25 +00:00
|
|
|
if ($scope.lastmyetag != undefined && $scope.lastmyetag == response.headers()["last-modified"])
|
2017-03-31 17:47:48 +00:00
|
|
|
return;
|
2018-12-04 03:13:25 +00:00
|
|
|
$scope.lastmyetag = response.headers()["last-modified"];
|
2017-03-31 17:47:48 +00:00
|
|
|
|
|
|
|
$scope.my = response.data;
|
2016-01-25 02:09:22 +00:00
|
|
|
});
|
2017-12-14 02:20:38 +00:00
|
|
|
$http.get("/stats.json").then(function(response) {
|
|
|
|
$scope.stats = response.data;
|
2016-01-25 02:09:22 +00:00
|
|
|
});
|
2017-12-14 02:20:38 +00:00
|
|
|
$http.get("/settings.json").then(function(response) {
|
2018-11-21 04:19:57 +00:00
|
|
|
$rootScope.recvTime(response);
|
|
|
|
response.data.start = new Date(response.data.start);
|
|
|
|
response.data.end = new Date(response.data.end);
|
|
|
|
response.data.generation = new Date(response.data.generation);
|
2018-12-04 04:30:25 +00:00
|
|
|
response.data.awards = new Date("2019-01-23T15:00:00Z");
|
2018-11-21 04:19:57 +00:00
|
|
|
$rootScope.settings = response.data;
|
2017-04-02 09:40:23 +00:00
|
|
|
});
|
2017-03-31 17:47:48 +00:00
|
|
|
$http.get("/themes.json").then(function(response) {
|
2018-12-04 03:13:25 +00:00
|
|
|
if ($scope.lastthemeetag != undefined && $scope.lastthemeetag == response.headers()["last-modified"])
|
2017-03-31 17:47:48 +00:00
|
|
|
return;
|
2018-12-04 03:13:25 +00:00
|
|
|
$scope.lastthemeetag = response.headers()["last-modified"];
|
2017-03-31 17:47:48 +00:00
|
|
|
|
|
|
|
var themes = response.data;
|
2016-01-25 02:09:22 +00:00
|
|
|
$scope.themes = themes;
|
|
|
|
$scope.max_gain = 0;
|
|
|
|
angular.forEach(themes, function(theme, key) {
|
2018-01-26 11:01:05 +00:00
|
|
|
if (theme.exercices)
|
|
|
|
this[key].exercice_count = Object.keys(theme.exercices).length;
|
|
|
|
else
|
|
|
|
this[key].exercice_count = 0;
|
2016-01-25 02:09:22 +00:00
|
|
|
this[key].gain = 0;
|
|
|
|
angular.forEach(theme.exercices, function(ex, k) {
|
|
|
|
this.gain += ex.gain;
|
|
|
|
}, theme);
|
|
|
|
$scope.max_gain += theme.gain;
|
|
|
|
}, themes);
|
|
|
|
});
|
2017-03-31 17:47:48 +00:00
|
|
|
$http.get("/teams.json").then(function(response) {
|
2018-12-04 03:13:25 +00:00
|
|
|
if ($scope.lastteametag != undefined && $scope.lastteametag == response.headers()["last-modified"])
|
2017-03-31 17:47:48 +00:00
|
|
|
return;
|
2018-12-04 03:13:25 +00:00
|
|
|
$scope.lastteametag = response.headers()["last-modified"];
|
2017-03-31 17:47:48 +00:00
|
|
|
|
|
|
|
var teams = response.data;
|
|
|
|
|
2016-01-25 02:09:22 +00:00
|
|
|
$scope.teams_count = Object.keys(teams).length
|
|
|
|
$scope.teams = teams;
|
|
|
|
|
|
|
|
$scope.rank = [];
|
|
|
|
angular.forEach($scope.teams, function(team, tid) {
|
|
|
|
team.id = tid;
|
|
|
|
if (team.rank) {
|
|
|
|
this.push(team);
|
|
|
|
}
|
|
|
|
}, $scope.rank);
|
2018-02-04 20:24:40 +00:00
|
|
|
$scope.pagesrank = Array(Math.ceil($scope.rank.length / 7)).fill(0).map(function(v, i){ return i; });
|
2016-01-25 02:09:22 +00:00
|
|
|
});
|
|
|
|
}
|
2018-12-04 04:34:34 +00:00
|
|
|
$rootScope.refresh();
|
|
|
|
$interval($rootScope.refresh, 4200);
|
2017-03-31 17:47:48 +00:00
|
|
|
})
|
|
|
|
.controller("TeamController", function($scope, $http, $interval) {
|
|
|
|
$scope.mystats = null;
|
2017-12-14 02:20:38 +00:00
|
|
|
$http.get("/api/teams/" + $scope.team.id + "/stats.json").then(function(response) {
|
|
|
|
$scope.mystats = response.data;
|
2017-03-31 17:47:48 +00:00
|
|
|
});
|
2016-01-25 02:09:22 +00:00
|
|
|
});
|