frontend: use a common JS file to contain common features between challenger and public interface
This commit is contained in:
parent
8bef64ad6b
commit
76effdd1fd
@ -126,6 +126,7 @@
|
|||||||
<script src="/js/angular-route.min.js"></script>
|
<script src="/js/angular-route.min.js"></script>
|
||||||
<script src="/js/angular-sanitize.min.js"></script>
|
<script src="/js/angular-sanitize.min.js"></script>
|
||||||
<script src="/js/i18n/angular-locale_fr-fr.js"></script>
|
<script src="/js/i18n/angular-locale_fr-fr.js"></script>
|
||||||
<script src="/js/app.js"></script>
|
<script src="/js/challenge.js"></script>
|
||||||
|
<script src="/js/common.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -68,55 +68,6 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
updTime();
|
updTime();
|
||||||
});
|
|
||||||
|
|
||||||
String.prototype.capitalize = function() {
|
|
||||||
return this
|
|
||||||
.toLowerCase()
|
|
||||||
.replace(
|
|
||||||
/(^|\s)([a-z])/g,
|
|
||||||
function(m,p1,p2) { return p1+p2.toUpperCase(); }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
angular.module("FICApp")
|
|
||||||
.filter("capitalize", function() {
|
|
||||||
return function(input) {
|
|
||||||
return input.capitalize();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter("time", function() {
|
|
||||||
return function(input) {
|
|
||||||
if (input == undefined) {
|
|
||||||
return "--";
|
|
||||||
} else if (input >= 10) {
|
|
||||||
return input;
|
|
||||||
} else {
|
|
||||||
return "0" + input;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.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];
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.controller("DataController", function($sce, $scope, $http, $rootScope, $timeout) {
|
.controller("DataController", function($sce, $scope, $http, $rootScope, $timeout) {
|
||||||
var actMenu = function() {
|
var actMenu = function() {
|
71
frontend/static/js/common.js
Normal file
71
frontend/static/js/common.js
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
String.prototype.capitalize = function() {
|
||||||
|
return this
|
||||||
|
.toLowerCase()
|
||||||
|
.replace(
|
||||||
|
/(^|\s)([a-z])/g,
|
||||||
|
function(m,p1,p2) { return p1+p2.toUpperCase(); }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
angular.module("FICApp")
|
||||||
|
.filter("capitalize", function() {
|
||||||
|
return function(input) {
|
||||||
|
return input.capitalize();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter("rankTitle", function() {
|
||||||
|
var itms = {
|
||||||
|
"rank": "Rang",
|
||||||
|
"name": "Équipe",
|
||||||
|
"score": "Score",
|
||||||
|
};
|
||||||
|
return function(input) {
|
||||||
|
if (itms[input] != undefined) {
|
||||||
|
return itms[input];
|
||||||
|
} else {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter("time", function() {
|
||||||
|
return function(input) {
|
||||||
|
if (input == undefined) {
|
||||||
|
return "--";
|
||||||
|
} else if (input >= 10) {
|
||||||
|
return input;
|
||||||
|
} else {
|
||||||
|
return "0" + input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter("since", function() {
|
||||||
|
return function(passed) {
|
||||||
|
if (passed < 120000) {
|
||||||
|
return "Il y a " + Math.floor(passed/1000) + " secondes";
|
||||||
|
} else {
|
||||||
|
return "Il y a " + Math.floor(passed/60000) + " minutes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.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];
|
||||||
|
}
|
||||||
|
})
|
@ -10,31 +10,6 @@ String.prototype.capitalize = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
angular.module("FICApp")
|
angular.module("FICApp")
|
||||||
.filter("capitalize", function() {
|
|
||||||
return function(input) {
|
|
||||||
return input.capitalize();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter("since", function() {
|
|
||||||
return function(passed) {
|
|
||||||
if (passed < 120000) {
|
|
||||||
return "Il y a " + Math.floor(passed/1000) + " secondes";
|
|
||||||
} else {
|
|
||||||
return "Il y a " + Math.floor(passed/60000) + " minutes";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter("time", function() {
|
|
||||||
return function(input) {
|
|
||||||
if (input == undefined) {
|
|
||||||
return "--";
|
|
||||||
} else if (input >= 10) {
|
|
||||||
return input;
|
|
||||||
} else {
|
|
||||||
return "0" + input;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.controller("TimeController", function($scope, $rootScope, $http, $timeout) {
|
.controller("TimeController", function($scope, $rootScope, $http, $timeout) {
|
||||||
$scope.time = {};
|
$scope.time = {};
|
||||||
var initTime = function() {
|
var initTime = function() {
|
||||||
|
@ -200,5 +200,6 @@
|
|||||||
<script src="/js/angular-sanitize.min.js"></script>
|
<script src="/js/angular-sanitize.min.js"></script>
|
||||||
<script src="/js/i18n/angular-locale_fr-fr.js"></script>
|
<script src="/js/i18n/angular-locale_fr-fr.js"></script>
|
||||||
<script src="/js/public.js"></script>
|
<script src="/js/public.js"></script>
|
||||||
|
<script src="/js/common.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user