45 lines
977 B
HTML
45 lines
977 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Go Again</title>
|
|
</head>
|
|
<body>
|
|
<h1>Hello, World!</h1>
|
|
<form class="js-schedules-list">
|
|
<label
|
|
>Token:
|
|
<input class="js-auth-token" type="text" />
|
|
</label>
|
|
<button>See Schedules</button>
|
|
</form>
|
|
<pre><code class="js-schedules"> </code></pre>
|
|
<script>
|
|
'use strict';
|
|
|
|
document.body.addEventListener('submit', function(ev) {
|
|
if (ev.target.matches('.js-schedules-list')) {
|
|
ev.preventDefault();
|
|
ev.stopPropagation();
|
|
getSchedules();
|
|
}
|
|
});
|
|
|
|
function getSchedules() {
|
|
var token = document.querySelector('.js-auth-token').value;
|
|
window
|
|
.fetch('/api/schedules', {
|
|
headers: { Authorization: token }
|
|
})
|
|
.then(function(resp) {
|
|
return resp.json().then(function(schedules) {
|
|
document.querySelector(
|
|
'.js-schedules'
|
|
).innerText = JSON.stringify(schedules, null, 2);
|
|
});
|
|
});
|
|
return;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|