This repository has been archived on 2023-11-10. You can view files and clone it, but cannot push or open issues or pull requests.
freecodecamp-projects/6-backend-dev/4-exercise-tracker/views/index.html

47 lines
1.8 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<title>Exercise Tracker | freeCodeCamp</title>
<link rel="shortcut icon" href="https://cdn.freecodecamp.org/universal/favicons/favicon.ico" type="image/x-icon" />
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<h1>Exercise tracker</h1>
<form action="/api/users" method="post">
<h3>Create a New User</h3>
<p><code>POST /api/users</code></p>
<input id="uname" type="text" name="username" placeholder="username" />
<input type="submit" value="Submit" />
</form>
<form id="exercise-form" method="post">
<h3>Add exercises</h3>
<p><code>POST /api/users/:_id/exercises</code></p>
<input id="uid" type="text" name=":_id" placeholder=":_id" />
<input id="desc" type="text" name="description" placeholder="description*" />
<input id="dur" type="text" name="duration" placeholder="duration* (mins.)" />
<input id="date" type="text" name="date" placeholder="date (yyyy-mm-dd)" />
<input type="submit" value="Submit" />
</form>
<p>
<strong>GET user's exercise log: </strong>
<code>GET /api/users/:_id/logs?[from][&amp;to][&amp;limit]</code>
</p>
<p><strong>[ ]</strong> = optional</p>
<p><strong>from, to</strong> = dates (yyyy-mm-dd); <strong>limit</strong> = number</p>
</div>
<script>
const exerciseForm = document.getElementById("exercise-form");
exerciseForm.addEventListener("submit", () => {
const userId = document.getElementById("uid").value;
exerciseForm.action = `/api/users/${userId}/exercises`;
exerciseForm.submit();
});
</script>
</body>
</html>