]> git.sesse.net Git - ultimatescore/blobdiff - carousel.js
Add a FIXME.
[ultimatescore] / carousel.js
index 98724729d5e050bb00f2f8e4d262b3802b88a58e..f8f2f8c69728e54f9a820f3c29d84be01fd5e3d6 100644 (file)
@@ -1,5 +1,16 @@
 'use strict';
 
+// Log with deep clone, so that the browser will show the object at time of log,
+// instead of what it looks like at time of view.
+function dlog()
+{
+       let args = [];
+       for (const arg of arguments) {
+               args.push(JSON.parse(JSON.stringify(arg)));
+       }
+       console.log(args);
+}
+
 function addheading(carousel, colspan, content)
 {
        let thead = document.createElement("thead");
@@ -10,19 +21,21 @@ function addheading(carousel, colspan, content)
        tr.appendChild(th);
        thead.appendChild(tr);
        carousel.appendChild(thead);
-};
+}
+
 function addtd(tr, className, content) {
        let td = document.createElement("td");
        td.appendChild(document.createTextNode(content));
        td.className = className;
        tr.appendChild(td);
-};
+}
+
 function addth(tr, className, content) {
        let th = document.createElement("th");
        th.appendChild(document.createTextNode(content));
        th.className = className;
        tr.appendChild(th);
-};
+}
 
 function subrank_partitions(games, parts, start_rank, tiebreakers, func) {
        let result = [];
@@ -428,7 +441,7 @@ function filter_teams(teams, response)
                let idx1 = teams_to_idx[games[i].name1];
                let idx2 = teams_to_idx[games[i].name2];
                if (idx1 !== undefined) {
-                       ++teams[idx1].ngames;
+                       ++teams[idx1].ngames;  // FIXME: shouldn't nplayed be just as good?
                }
                if (idx2 !== undefined) {
                        ++teams[idx2].ngames;
@@ -711,6 +724,7 @@ function showcarousel()
        let cb = function(response, group_name) {
                let teams = parse_teams_from_spreadsheet(response);
                let games = parse_games_from_spreadsheet(response, group_name, true);
+               teams = filter_teams(teams, response);
                teams_per_group[group_name] = teams;
                games_per_group[group_name] = games;
 
@@ -723,7 +737,7 @@ function showcarousel()
                                [ 13000, function() { display_group_parsed(teams_per_group['Group B'], games_per_group['Group B'], 'Group B'); } ],
                                [ 2000, function() { hidetable(); } ],
                                [ 13000, function() { display_group_parsed(teams_per_group['Group C'], games_per_group['Group C'], 'Group C'); } ],
-                               [ 2000, function() { hidetable(); } ]
+                               [ 2000, function() { hidetable(); } ],
                                [ 13000, function() { display_group_parsed(teams_per_group['Playoffs 9th-13th'], games_per_group['Playoffs 9th-13th'], 'Playoffs 9th–13th'); } ],
                                [ 2000, function() { hidetable(); } ]
                        ];