diff --git a/dashboard/static/js/dashboard.js b/dashboard/static/js/dashboard.js index 2aa2d242..61f25684 100644 --- a/dashboard/static/js/dashboard.js +++ b/dashboard/static/js/dashboard.js @@ -40,7 +40,7 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"]) refreshEvents() $interval(refreshEvents, 2100); }) - .controller("TimerController", function($scope, $rootScope, $interval) { + .controller("TimerController", function($scope, $rootScope, $interval, $timeout) { $scope.duration = 0; $scope.init = function(end) { @@ -53,9 +53,12 @@ angular.module("FICApp", ["ngSanitize", "ngAnimate"]) }) } $scope.initT = function(end) { - var time = angular.fromJson(sessionStorage.userService); - var srv_cur = new Date(Date.now() + (time.cu - time.he)); - $scope.duration = Math.floor((end - srv_cur)/1000); + var time = angular.fromJson(sessionStorage.time); + if (time) { + var srv_cur = new Date(Date.now() + (time.cu - time.he)); + $scope.duration = Math.floor((end - srv_cur)/1000); + } else + $timeout(function() { $scope.initT(end); }, 1000); } var stop = $interval(function() { diff --git a/frontend/static/js/challenge.js b/frontend/static/js/challenge.js index 9a89be9b..81bf9c41 100644 --- a/frontend/static/js/challenge.js +++ b/frontend/static/js/challenge.js @@ -77,12 +77,17 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) $rootScope.current_tag = undefined; $rootScope.notify_field = 0; - Notification.requestPermission().then(function(result) { - if (result == "granted") - $rootScope.notify_field = 7; - else - $rootScope.notify_field = 0; - }); + if ('Notification' in window) + Notification.requestPermission(function(result) { + if (result == "granted") { + if (localStorage && localStorage.notification) + $rootScope.notify_field = localStorage.notification; + else + $rootScope.notify_field = 63; + } + else + $rootScope.notify_field = 0; + }); }) .component('flagKey', { bindings: { @@ -259,7 +264,30 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) else if (event.time > maxTimeSeen) maxTimeSeen = event.time; - if ($rootScope.notify_field != 0) { + // Determine the kind of event + var kind = 1; + + if (event.txt.match(/<\/strong> qui vient de nous rejoindre/)) { + kind = 64; + } else { + var res = event.txt.match(/(\w+) le \d+e<\/sup><\/strong> défi [^&]+/) + if (res) { + if (res[1] == "résolu") + kind = 8; + else if (res[1] == "pour") + kind = 16; + else if (res[1] == "tente") + kind = 32; + } + } + if (kind != 1) { + if ($scope.my && $scope.my.name && event.txt.indexOf($scope.my.name) >= 0) + kind |= 2; + else + kind |= 4; + } + + if ((kind & $rootScope.notify_field) == kind) { var notification = new Notification("Challenge forensic", {body: event.txt.replace(/&#(\d+);/g, function(match, dec) {return String.fromCharCode(dec);}).replace(/(<([^>]+)>)/ig,""), badge: "/img/icon-" + event.kind + ".ico", icon: "/img/icon-" + event.kind + ".ico"}); notification.onclick = function(ev) { $location.url("/edit"); @@ -542,7 +570,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) }); } }) - .controller("MyTeamController", function($scope, $http, $rootScope, $timeout) { + .controller("MyTeamController", function($scope, $http, $rootScope, $timeout, $location) { $rootScope.current_theme = 0; $rootScope.current_exercice = 0; $rootScope.current_tag = undefined; @@ -555,6 +583,32 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"]) $rootScope.message = ""; $rootScope.sberr = ""; + $scope.notify = { + info: ($rootScope.notify_field & 1) != 1, + team: ($rootScope.notify_field & 2) != 2, + others: ($rootScope.notify_field & 4) != 4, + solve: ($rootScope.notify_field & 8) != 8, + hint: ($rootScope.notify_field & 16) != 16, + tries: ($rootScope.notify_field & 32) != 32, + rename: ($rootScope.notify_field & 64) != 64, + } + + $scope.alternotify = function() { + $rootScope.notify_field = + ($scope.notify.info?0:1) | + ($scope.notify.team?0:2) | + ($scope.notify.others?0:4) | + ($scope.notify.solve?0:8) | + ($scope.notify.hint?0:16) | + ($scope.notify.tries?0:32) | + ($scope.notify.rename?0:64); + if ($rootScope.notify_field != 0) + localStorage.notification = $rootScope.notify_field; + else + delete localStorage.notification; + $location.url("/"); + } + var cbt; $scope.tsubmit = function() { diff --git a/frontend/static/js/common.js b/frontend/static/js/common.js index 2509069d..95d08cae 100644 --- a/frontend/static/js/common.js +++ b/frontend/static/js/common.js @@ -133,8 +133,8 @@ angular.module("FICApp") angular.module("FICApp") .controller("CountdownController", function($scope, $rootScope, $interval) { var time; - if (sessionStorage.userService) - time = angular.fromJson(sessionStorage.userService); + if (sessionStorage.time) + time = angular.fromJson(sessionStorage.time); $scope.time = {}; @@ -149,7 +149,7 @@ angular.module("FICApp") "cu": Math.floor(response.headers("x-fic-time") * 1000), "he": (new Date()).getTime(), }; - sessionStorage.userService = angular.toJson(time); + sessionStorage.time = angular.toJson(time); return time; } diff --git a/frontend/static/views/team-edit.html b/frontend/static/views/team-edit.html index 447da358..9cbc44d9 100644 --- a/frontend/static/views/team-edit.html +++ b/frontend/static/views/team-edit.html @@ -1,3 +1,6 @@ +
+
+
Votre équipe est composée de :
@@ -32,3 +35,69 @@
+ +
+
+ +
+
Gestion des notifications
+
+

+ Ces paramètres ne seront valable que pour votre navigateur. +

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+
+ +
+