Skip to content
Snippets Groups Projects
Commit b2b79a13 authored by Shabani, B. (Blert, Student B-TCS)'s avatar Shabani, B. (Blert, Student B-TCS)
Browse files

Work done on practical 2

parent 7d77e368
Branches update-trainer
No related tags found
No related merge requests found
Pipeline #98442 failed
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<meta charset="UTF-8">
<title>Trainers</title>
<link rel="icon" type="image/x-icon" href="/pokemon/favicon.ico">
</head>
<body>
<script src="js/requests.js"></script>
<script>
tableParentId = "tableDiv";
detailsParentId = "detailsDiv";
fetch('/pokemon/api/trainers')
.then(res => res.json())
.then(data => {
pokemonTrainers = data;
createPokemonTrainerTable();
})
.catch(err => {
console.error(`Unable to fetch Pokemon Trainers: ${err.status}`);
console.error(err);
});
</script>
<h1>Pokemon </h1>
<div class="container">
<div class="row">
<div id="tableDiv" class="col-8">No data</div>
<div id="detailsDiv" class="col-4">No data</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -60,4 +60,27 @@ function createPokemonTypesTable() {
</tbody>
</table>
`
}
function createPokemonTrainerTable() {
const tableParent = document.getElementById(tableParentId);
tableParent.innerHTML = `
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Pokedex Number</th>
<th scope="col">Primary Type</th>
<th scope="col">Secondary Type</th>
</tr>
</thead>
<tbody>
${
pokemonTypes.data.map(resource => `${pokemonTypeToRow(resource)}`).join("\n")
|| "no data"
}
</tbody>
</table>
`
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<title>Title</title>
<title>Types</title>
<link rel="icon" type="image/x-icon" href="/pokemon/favicon.ico">
</head>
<body>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment