2019-06-22 07:10:21 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Go Again</title>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>Hello, World!</h1>
|
2019-06-22 07:28:02 +00:00
|
|
|
<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>
|
2019-06-22 07:10:21 +00:00
|
|
|
</body>
|
|
|
|
</html>
|