admin: Base challenge start on server time

This commit is contained in:
nemunaire 2024-02-09 13:46:36 +01:00
parent 7798420d56
commit 81cd6fe3a1

View File

@ -669,7 +669,7 @@ angular.module("FICApp")
}); });
} }
$scope.launchChallenge = function() { $scope.launchChallenge = function() {
var ts = Date.now() - Date.now() % 60000; var ts = $rootScope.getSrvTime().getTime() - $rootScope.getSrvTime().getTime() % 60000;
var d = new Date(ts + 120000); var d = new Date(ts + 120000);
this.config.start = d.toISOString(); this.config.start = d.toISOString();
var f = new Date(ts + 120000 + this.duration * 60000); var f = new Date(ts + 120000 + this.duration * 60000);
@ -684,7 +684,7 @@ angular.module("FICApp")
$rootScope.settings.activateTime = this.activateTime; $rootScope.settings.activateTime = this.activateTime;
} }
$scope.updActivateTime = function(modulo) { $scope.updActivateTime = function(modulo) {
var ts = Math.floor((new Date(this.config.end) - Date.now() - (60000 * modulo / 2)) / (60000 * modulo)) * (60000 * modulo); var ts = Math.floor((new Date(this.config.end) - $rootScope.getSrvTime().getTime() - (60000 * modulo / 2)) / (60000 * modulo)) * (60000 * modulo);
var d = new Date(this.config.end) - ts; var d = new Date(this.config.end) - ts;
this.activateTime = new Date(d).toISOString(); this.activateTime = new Date(d).toISOString();
this.updateActivateTime(); this.updateActivateTime();
@ -1184,7 +1184,7 @@ angular.module("FICApp")
$scope.display.customCountdown = { $scope.display.customCountdown = {
show: true, show: true,
shadow: "#E8CF5C", shadow: "#E8CF5C",
end: new Date(Date.now() + 1802000).toISOString(), end: new Date($rootScope.getSrvTime().getTime() + 1802000).toISOString(),
before: "Heure joyeuse : chaque résolution compte double !", before: "Heure joyeuse : chaque résolution compte double !",
after: "Heure joyeuse terminée !", after: "Heure joyeuse terminée !",
} }
@ -1193,7 +1193,7 @@ angular.module("FICApp")
$scope.display.customCountdown = { $scope.display.customCountdown = {
show: true, show: true,
shadow: "#3DD28F", shadow: "#3DD28F",
end: new Date(Date.now() + 902000).toISOString(), end: new Date($rootScope.getSrvTime().getTime() + 902000).toISOString(),
before: "Quart d'heure facile : indices dévoilés !", before: "Quart d'heure facile : indices dévoilés !",
after: "Quart d'heure facile terminée !", after: "Quart d'heure facile terminée !",
} }
@ -1201,13 +1201,13 @@ angular.module("FICApp")
}; };
$scope.genSceneCountdownDate = function(scene, duration) { $scope.genSceneCountdownDate = function(scene, duration) {
scene.params.end = (new Date(Date.now() + duration)).toISOString(); scene.params.end = (new Date($rootScope.getSrvTime().getTime() + duration)).toISOString();
} }
$scope.genCustomCountdownDate = function(duration) { $scope.genCustomCountdownDate = function(duration) {
if (duration == null) { if (duration == null) {
$scope.display.customCountdown.end = $rootScope.settings.activateTime; $scope.display.customCountdown.end = $rootScope.settings.activateTime;
} else { } else {
$scope.display.customCountdown.end = (new Date(Date.now() + duration)).toISOString(); $scope.display.customCountdown.end = (new Date($rootScope.getSrvTime().getTime() + duration)).toISOString();
} }
} }