Skip to content

Commit

Permalink
racerName
Browse files Browse the repository at this point in the history
  • Loading branch information
nalbam committed Aug 30, 2019
1 parent dc52863 commit 6bff632
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 51 deletions.
86 changes: 41 additions & 45 deletions static/leaderboard.json
Original file line number Diff line number Diff line change
@@ -1,45 +1,41 @@
{
"title": "Pusan",
"items": [
{
"name": "Racer",
"time": "00:12.345"
},
{
"name": "Racer",
"time": "00:13.654"
},
{
"name": "Racer",
"time": "00:10.357"
},
{
"name": "Racer",
"time": "00:10.742"
},
{
"name": "Racer",
"time": "00:09.367"
},
{
"name": "Racer",
"time": "00:10.135"
},
{
"name": "Racer",
"time": "00:10.456"
},
{
"name": "Racer",
"time": "00:11.726"
},
{
"name": "Racer",
"time": "00:12.538"
},
{
"name": "Racer",
"time": "00:10.922"
}
]
}
[{
"racerName": "Racer",
"lapTime": "00:12.345"
},
{
"racerName": "Racer",
"lapTime": "00:13.654"
},
{
"racerName": "Racer",
"lapTime": "00:10.357"
},
{
"racerName": "Racer",
"lapTime": "00:10.742"
},
{
"racerName": "Racer",
"lapTime": "00:09.367"
},
{
"racerName": "Racer",
"lapTime": "00:10.135"
},
{
"racerName": "Racer",
"lapTime": "00:10.456"
},
{
"racerName": "Racer",
"lapTime": "00:11.726"
},
{
"racerName": "Racer",
"lapTime": "00:12.538"
},
{
"racerName": "Racer",
"lapTime": "00:10.922"
}
]
12 changes: 6 additions & 6 deletions static/league.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ function print(res) {
let pos = 0;
items.forEach(function (item) {
pos++;
addRow('lb-row', pos, item.name, item.time);
addRow('lb-row', pos, item.racerName, item.lapTime);
});
}

function compare(a, b) {
a2 = sec(a.time);
b2 = sec(b.time);
a2 = sec(a.lapTime);
b2 = sec(b.lapTime);
if (a2 < b2) {
return -1;
} else if (a2 > b2) {
Expand All @@ -59,12 +59,12 @@ function sec(t) {
return ((+a[0]) * 60) + (+a[1]);
}

function addRow(className, position, name, time) {
function addRow(className, position, racerName, lapTime) {
let row = document.createElement('div');
row.classList.add(className);
addText(row, position);
addText(row, name);
addText(row, time);
addText(row, racerName);
addText(row, lapTime);
lb_items.appendChild(row);
}

Expand Down

0 comments on commit 6bff632

Please sign in to comment.