Skip to content

Commit b1a0e9b

Browse files
authored
Create index.html
1 parent 10fa9f4 commit b1a0e9b

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

index.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Google Sheets Leaderboard</title>
7+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tabletop.js/1.5.1/tabletop.min.js"></script>
8+
</head>
9+
<body>
10+
<table id="leaderboard">
11+
<thead>
12+
<tr>
13+
<th>Rank</th>
14+
<th>Name</th>
15+
<th>Score</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
<!-- Data will be inserted here -->
20+
</tbody>
21+
</table>
22+
23+
<script>
24+
const SPREADSHEET_ID = '2PACX-1vSL6qw9cokBYoe_GbE21KeeXoo38EKnM-TI5fHaj1xJjxZEpUJR0UqMFsGHcwGnVJdeHGucle4vLaj9'; // Replace with your actual spreadsheet ID
25+
26+
function showInfo(data) {
27+
const tbody = document.getElementById('leaderboard').getElementsByTagName('tbody')[0];
28+
tbody.innerHTML = ''; // Clear existing data
29+
30+
data.forEach((row, index) => {
31+
const tr = document.createElement('tr');
32+
tr.innerHTML = `
33+
<td>${index + 1}</td>
34+
<td>${row.Name}</td>
35+
<td>${row.Score}</td>
36+
`;
37+
tbody.appendChild(tr);
38+
});
39+
}
40+
41+
window.addEventListener('DOMContentLoaded', () => {
42+
Tabletop.init({
43+
key: SPREADSHEET_ID,
44+
callback: showInfo,
45+
simpleSheet: true
46+
});
47+
});
48+
</script>
49+
</body>
50+
</html>

0 commit comments

Comments
 (0)