-
Notifications
You must be signed in to change notification settings - Fork 0
/
rank.html
111 lines (89 loc) · 8 KB
/
rank.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css">
</head>
<body class="bg-dark">
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<img src="logo.png" style="width: 160px; margin-bottom: 30px;" />
<table id="main-table" class="table table-dark table-striped"
style="max-width: 800px; margin: 0px auto;">
<thead>
<tr>
<th>Rank</th>
<th>Name</th>
<th>Honour</th>
<th>Dart (Rank)</th>
<th>Dart (Score)</th>
</tr>
</thead>
<tbody id="main-tbody">
</tbody>
</table>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
// https://www.codewars.com/api/v1/users/denyocrworld
var users = [
{ 'name': 'Saiful Bahri', 'username': 'bahrie127' }, { 'name': 'Deny', 'username': 'denyocrworld' }, { 'name': 'Fadillah Nur Faqih', 'username': 'fadillahfaqih' }, { 'name': 'Farizal Setya A I', 'username': 'farizalfrizzy12' }, { 'name': 'Abdillah Faiz', 'username': 'abdillahfaiz' }, { 'name': 'Fernosha', 'username': 'fernosa12' }, { 'name': 'Agung Saputro', 'username': 'BisaAgung' }, { 'name': 'Aldi', 'username': 'mostsinz' }, { 'name': 'Aswin A', 'username': 'aswinadi' }, { 'name': 'Taukhid', 'username': 'taukhidajin' }, { 'name': 'M. Zulkarnaen', 'username': 'magerngulik' }, { 'name': 'aditiya Sardi', 'username': 'aditiyasardi' }, { 'name': 'syamsul maarif', 'username': 'msyamsul725' }, { 'name': 'rayhan febriansyah', 'username': 'cyberDev890' }, { 'name': 'Robert P', 'username': 'bertDev-rpn' }, { 'name': 'Fikri', 'username': 'fikrichairulazmi' }, { 'name': 'Alvin', 'username': 'alvinwatner' }, { 'name': 'Adit Prasetia', 'username': 'adit3455' }, { 'name': 'Yonattan', 'username': 'lie16' }, { 'name': 'Fajar ', 'username': 'hafizhfattah' }, { 'name': 'Fahmi Feb :', 'username': 'Fahmi1599' }, { 'name': 'Rezza :', 'username': 'septiansyah04' }, { 'name': 'Fatih :', 'username': 'Fatihr257' }, { 'name': 'Zelda Ababil :', 'username': 'zeldaababil19' }, { 'name': 'Ridwan hanif', 'username': 'nickridwan' }, { 'name': 'Muhammad Rayyaan :', 'username': 'RayyanFv' }, { 'name': 'Ferry S :', 'username': 'ownersikom' }, { 'name': 'Novian', 'username': 'fleetimee' }, { 'name': 'Muhammad Rizky -', 'username': 'rizkyraihan44' }, { 'name': 'M. Syamsul arifin', 'username': 'msarifin' }, { 'name': 'Farid Kharisudin', 'username': 'Faridkharisudin' }, { 'name': 'Randho Bagaskara', 'username': 'RandhoB' }, { 'name': 'Hilman Ramdhani', 'username': 'hilman117' }, { 'name': 'Ari', 'username': 'arieLampar' }, { 'name': 'Eka Widiatno', 'username': 'eawidiatno' }, { 'name': 'Thimoty Daud K', 'username': 'tdaku' }, { 'name': 'L Wahyu Hardininggrat', 'username': 'ningrat' }, { 'name': 'Yosua Elwistio Malau', 'username': 'cuatiawww' }, { 'name': 'Maorid Manarul H', 'username': 'maodaaa' }, { 'name': 'Dedi', 'username': 'dedizainal11' }, { 'name': 'Haeruddin', 'username': 'haeruddinteknologi' }, { 'name': 'Taufiq D. Cahyono', 'username': 'taufiqjack' }, { 'name': 'Yusuf', 'username': 'Kuuhaku7' }, { 'name': 'Edi mr', 'username': 'Edi Mulyadi Rosdiman' }, { 'name': 'Ripki Hamdi', 'username': 'ripkihamdi' }, { 'name': 'Tri Agung', 'username': 'chisez06' }, { 'name': 'Lucky Maulana', 'username': 'LuckyMaulana24' }, { 'name': 'Achriyatul Setyorini', 'username': 'AchriyatulS' }, { 'name': 'Muhamad Fhebry', 'username': 'fhebry23' }, { 'name': 'Tsaqib Arsalan', 'username': 'tsaqib73' }, { 'name': 'Miftahul Khoir', 'username': 'FathHaq' }, { 'name': 'Andri', 'username': 'andrisilaban' }, { 'name': 'Egit', 'username': 'egitheri' }, { 'name': 'Ahmad Faqih', 'username': 'danthz2' }, { 'name': 'Kresna Bimantara', 'username': 'bimbimzzz' }, { 'name': 'Teguh Susanto', 'username': 'teguhsusanto2304' }, { 'name': 'Surya', 'username': 'HarunSH' }, { 'name': 'Ahmad Hidayat', 'username': 'AhmadHidayat120402' }, { 'name': 'Naufal Marzuk Mulyo Saputra', 'username': 'naufalmms' }, { 'name': 'Rangga Wardhana Prasetyo', 'username': 'RanggaWP25' }, { 'name': 'Windy S', 'username': 'azkajihan09' }, { 'name': 'Gema Yoeda', 'username': 'gmayoeda' }, { 'name': 'Khoirul fahmi', 'username': 'kfahmi77' }, { 'name': 'Mutia', 'username': 'mutiakk' }, { 'name': 'Dimas Farid', 'username': 'Manculix' }, { 'name': 'Adam', 'username': 'adamshaq' }, { 'name': 'Ringga Syihabbudin', 'username': 'Ringgasyihabb39' }, { 'name': 'Asrafil', 'username': 'asrafilll' }, { 'name': 'Yordan Baniara', 'username': 'yordanb' }, { 'name': 'Udin', 'username': 'udindn' }, { 'name': 'Eka', 'username': '0xaN0n' }, { 'name': 'Arrachmad Nur Fauzie', 'username': 'fauzieit' }, { 'name': 'Suri Suryanto', 'username': 'surisuryanto' }, { 'name': 'Adnan Zain', 'username': 'gbadnanzain' }, { 'name': 'Fauzi Nur Irfan', 'username': 'fauzinurirfan23' }, { 'name': 'Hangga', 'username': 'hanggakristanto' }, { 'name': 'Yusman', 'username': 'yusmnn' }, { 'name': 'Rio Ferdian', 'username': 'riofrdn16' }, { 'name': 'Azkia', 'username': 'AzkiaFikrilM' }, { 'name': 'Gunadi Pratama Sulistiawan', 'username': 'gndsulistiawan' }, { 'name': 'Yuko', 'username': 'yukofland' }, { 'name': 'I Made setiawan', 'username': 'made-setiawan' }, { 'name': 'Agus Sarjuni', 'username': 'agus.sarjuni' },
];
async function loadData(username) {
var response = await fetch(`https://www.codewars.com/api/v1/users/${username}`);
var obj = await response.json();
return obj;
}
var fetchedCount = 0;
async function fillUsers() {
var sortedUsers = users.sort((a, b) => b.dart_score - a.dart_score);
console.log(sortedUsers);
for (var i = 0; i < sortedUsers.length; i++) {
var item = sortedUsers[i];
document.getElementById("main-tbody").innerHTML +=
`
<tr>
<td>${i + 1}</td>
<td style='text-align: left;'>${item["name"]}</td>
<td>${item.honor}</td>
<td>${item.dart_kyu}</td>
<td>${item.dart_score}</td>
</tr>
`;
}
}
async function main() {
for (var i = 0; i < users.length; i++) {
var item = users[i];
loadData(item["username"]).then(function (response) {
var username = response.username;
var index = users.findIndex(i => i["username"] == username);
console.log(index + " : " + username);
var rowItem = users[index];
rowItem["honor"] = response.honor ?? 0;
if (response?.ranks?.languages?.dart != null) {
rowItem["dart_kyu"] = response.ranks.languages.dart.rank;
rowItem["dart_score"] = response.ranks.languages.dart.score;
}
rowItem["honor"] = rowItem["honor"] ?? 0;
rowItem["dart_kyu"] = rowItem["dart_kyu"] ?? 0;
rowItem["dart_score"] = rowItem["dart_score"] ?? 0;
fetchedCount++;
console.log(`fetchedCount: ${fetchedCount}`);
if (fetchedCount == users.length) {
fillUsers();
}
});
}
}
main();
</script>
</body>
</html>