Commit 33d7540d authored by Antek Grzanka's avatar Antek Grzanka

Points from API.

parent b25409d3
......@@ -3,12 +3,14 @@
var calculatePerTeam = function(data) {
var teams = {};
console.log("data", data);
for (var team in data) {
if (data.hasOwnProperty(team)) {
teams[team] = 0;
for (var level in data[team]){
if (data[team].hasOwnProperty(level)){
teams[team] += data[team][level].length;
var score = data[team][level].map(function(o){return o.points;}).reduce(function(a,b){return a+b;});
teams[team] += score;
}
}
}
......@@ -16,12 +18,12 @@
return teams;
};
function viewGraph(){
function viewGraph(maxValue){
$('.column').css('height','0');
// console.log($scope.teamsScores);
setTimeout(function(){
$('.column').each(function(){
$(this).animate({width: 150*$(this).attr('data-score')}, 1500);
$(this).animate({width: (100 * (parseFloat($(this).attr('data-score'))/maxValue)).toString() + '%'}, 1500);
});
}
);
......@@ -32,7 +34,8 @@
// console.log('Data from server', data);
$scope.teamsScores = calculatePerTeam(data);
// console.log('Teams scores', $scope.teamsScores);
viewGraph();
var maxValue = Math.max.apply(null, $.map($scope.teamsScores, function(v,k){return v;}));
viewGraph(maxValue);
});
......
......@@ -16,7 +16,7 @@
if (!$scope.task.completedFlags){
$scope.task.completedFlags = [];
}
$scope.task.completedFlags.push(data.description);
$scope.task.completedFlags.push(data);
$scope.submitUnknown = false;
$flag.val('');
}).error(function(){
......
......@@ -40,7 +40,7 @@
app.factory('AppSettings', ['$http', function($http) {
// fallback into defaults, if everything fails, world collapses, hell freezes and /startup will not resolve
var domainName = '52.25.28.64', port = "http", schema = 8080;
var domainName = '52.25.28.64', port = 8080, schema = "http";
return {
......
......@@ -88,7 +88,7 @@
if (!task.completedFlags){
task.completedFlags = [];
}
task.completedFlags.push(data.description);
task.completedFlags.push(data);
}
});
}.bind(this));
......
......@@ -39,7 +39,7 @@
<p ng-if="task.completedFlags && task.completedFlags.length !== 0">
<div ng-repeat="flag in task.completedFlags">
{{ flag }}
{{ flag.description }} ({{ flag.points }} pkt)
</div>
</p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment