2022-06-20 04:17:48 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" href="style.css">
|
|
|
|
<style>
|
|
|
|
table tbody tr:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<h1>Pick a runner</h1>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr class="heading">
|
|
|
|
<th>ID</th>
|
|
|
|
<th>Description</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody></tbody>
|
|
|
|
</table>
|
|
|
|
<a href="runner.html">Show all runners</a>
|
|
|
|
|
2022-06-20 12:46:39 +00:00
|
|
|
<div class="template">
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td class="id"></td>
|
|
|
|
<td class="desc"></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
2022-06-20 04:17:48 +00:00
|
|
|
|
|
|
|
<script src="common.js"></script>
|
|
|
|
<script>
|
2022-06-20 12:46:39 +00:00
|
|
|
const template = $('.template')
|
2022-06-20 04:17:48 +00:00
|
|
|
const table = $('tbody')
|
|
|
|
|
|
|
|
listRunners()
|
|
|
|
.then(runners => {
|
|
|
|
runners.forEach(runner => {
|
|
|
|
const fragment = initTemplate(template, {
|
|
|
|
id: runner.id,
|
|
|
|
desc: runner.description
|
|
|
|
})
|
2022-06-20 12:46:39 +00:00
|
|
|
const row = $(fragment, 'tr')
|
|
|
|
row.addEventListener('click', ev => {
|
2022-06-20 04:17:48 +00:00
|
|
|
document.location.href = 'runner.html?id=' + runner.id
|
|
|
|
})
|
2022-06-20 12:46:39 +00:00
|
|
|
table.appendChild(row)
|
2022-06-20 04:17:48 +00:00
|
|
|
})
|
|
|
|
})
|
2022-06-20 12:45:59 +00:00
|
|
|
.catch(err => {
|
|
|
|
console.error(err)
|
|
|
|
alert(err.toString())
|
|
|
|
})
|
2022-06-20 04:17:48 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|