diff --git a/admin/index.go b/admin/index.go index 43c7bdf3..197b9770 100644 --- a/admin/index.go +++ b/admin/index.go @@ -86,6 +86,7 @@ const indextpl = ` + ` diff --git a/admin/static/index.html b/admin/static/index.html index 6f9e4753..cffa020b 100644 --- a/admin/static/index.html +++ b/admin/static/index.html @@ -84,5 +84,6 @@ + diff --git a/admin/static/js/app.js b/admin/static/js/app.js index 5656ec6d..7dda9e7d 100644 --- a/admin/static/js/app.js +++ b/admin/static/js/app.js @@ -235,15 +235,6 @@ angular.module("FICApp") }) }); -String.prototype.capitalize = function() { - return this - .toLowerCase() - .replace( - /(^|\s)([a-z])/g, - function(m,p1,p2) { return p1+p2.toUpperCase(); } - ); -} - angular.module("FICApp") .filter("countHints", function() { return function(input) { @@ -252,12 +243,6 @@ angular.module("FICApp") return input.reduce(function(sum, n){ return sum + (n.content || n.file) ? 1 : 0; }, 0); } }) - .filter("capitalize", function() { - return function(input) { - if (input != undefined) - return input.capitalize(); - } - }) .filter("toColor", function() { return function(input) { num >>>= 0; @@ -268,28 +253,6 @@ angular.module("FICApp") return "#" + r.toString(16) + g.toString(16) + b.toString(16); } }) - .filter("size", function() { - var units = [ - "o", - "kio", - "Mio", - "Gio", - "Tio", - "Pio", - "Eio", - "Zio", - "Yio", - ] - return function(input) { - var res = input; - var unit = 0; - while (res > 1024) { - unit += 1; - res = res / 1024; - } - return (Math.round(res * 100) / 100) + " " + units[unit]; - } - }) .filter("cksum", function() { return function(input) { if (input == undefined) @@ -303,17 +266,6 @@ angular.module("FICApp") return hex } }) - .filter("time", function() { - return function(input) { - if (input == undefined) { - return "--"; - } else if (input >= 10) { - return input; - } else { - return "0" + input; - } - } - }) .directive('color', function() { return { @@ -362,6 +314,20 @@ angular.module("FICApp") }; }) + .run(function($rootScope, $http, $interval) { + function refresh() { + $http.get("/api/settings.json").then(function(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); + $rootScope.settings = response.data; + $rootScope.recvTime(response); + }) + } + refresh(); + $interval(refresh, 10000); + }) + .controller("VersionController", function($scope, Version) { $scope.v = Version.get(); }) @@ -1368,67 +1334,6 @@ angular.module("FICApp") $scope.presence.$promise.then(function(res) { presenceCal($scope, "#presenceCal", res); }); - }) - .controller("CountdownController", function(Settings, $scope, $rootScope, $http, $interval) { - $scope.time = {}; - - function updTime() { - if (sessionStorage.userService && $rootScope.settings) { - var time = angular.fromJson(sessionStorage.userService); - var settings = $rootScope.settings; - var srv_cur = new Date(Date.now() + (time.cu - time.he)); - - var remain = 0; - if (settings.start > 0 && settings.start > srv_cur) { - $scope.startIn = Math.floor((settings.start - srv_cur) / 1000); - remain = settings.end - settings.start; - } else if (settings.end > srv_cur) { - $scope.startIn = 0; - remain = settings.end - srv_cur; - } - - remain = remain / 1000; - - if (remain < 0) { - remain = 0; - $scope.time.end = true; - $scope.time.expired = true; - } else if (remain < 60) { - $scope.time.end = false; - $scope.time.expired = true; - } else { - $scope.time.end = false; - $scope.time.expired = false; - } - - $scope.time.remaining = remain; - $scope.time.hours = Math.floor(remain / 3600); - $scope.time.minutes = Math.floor((remain % 3600) / 60); - $scope.time.seconds = Math.floor(remain % 60); - $rootScope.time = $scope.time; - } - }; - $interval(updTime, 1000); - - $rootScope.updTime = function(response) { - sessionStorage.userService = angular.toJson({ - "cu": Math.floor(response.headers("x-fic-time") * 1000), - "he": (new Date()).getTime(), - }); - updTime(); - } - - function refresh() { - $http.get("/api/settings.json").then(function(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); - $rootScope.settings = response.data; - $rootScope.updTime(response); - }) - } - refresh(); - $interval(refresh, 10000); }); function solvedByLevelPie(location, data) { diff --git a/admin/static/js/common.js b/admin/static/js/common.js new file mode 120000 index 00000000..4e3fce35 --- /dev/null +++ b/admin/static/js/common.js @@ -0,0 +1 @@ +../../../frontend/static/js/common.js \ No newline at end of file diff --git a/admin/static/views/settings.html b/admin/static/views/settings.html index 3151d025..3a2d1f2c 100644 --- a/admin/static/views/settings.html +++ b/admin/static/views/settings.html @@ -32,9 +32,9 @@
- +
- +
@@ -50,7 +50,9 @@
- min +
+ min +