stub seed fetch

This commit is contained in:
Sorrel Bri 2020-05-25 17:46:24 -07:00
parent dbd671a964
commit 343e16c560
4 changed files with 41 additions and 2 deletions

View file

@ -1,5 +1,6 @@
const html = require("./controls.html"); const html = require("./controls.html");
const css = require("../styles/contols.css"); const css = require("../styles/controls.css");
const { getCalendar } = require("../utils/index");
const init = (gameField) => { const init = (gameField) => {
const controlsEl = document.getElementById("controls"); const controlsEl = document.getElementById("controls");
@ -10,6 +11,7 @@ const init = (gameField) => {
const resetEl = document.getElementById("reset"); const resetEl = document.getElementById("reset");
const clearEl = document.getElementById("clear"); const clearEl = document.getElementById("clear");
const canvasEl = document.getElementById("game-field"); const canvasEl = document.getElementById("game-field");
const calendarFormEl = document.getElementById("calendar-form");
const controls = { const controls = {
interval: null, interval: null,
play() { play() {
@ -78,6 +80,11 @@ const init = (gameField) => {
const { offsetX, offsetY } = e; const { offsetX, offsetY } = e;
controls.updateField(offsetX, offsetY); controls.updateField(offsetX, offsetY);
}); });
calendarFormEl.addEventListener("submit", (e) => {
e.preventDefault();
const user = e.target[0].value;
console.log(getCalendar(user));
});
return controls; return controls;
}; };

View file

@ -11,7 +11,7 @@
value="10" value="10"
/> />
</div> </div>
<form action="/"> <form action="/" id="calendar-form">
<input type="text" /> <input type="text" />
<input type="submit" value="seed" /> <input type="submit" value="seed" />
</form> </form>

View file

@ -1,3 +1,34 @@
const query = (user) => `query {
user (login: "${user}") {
contributionsCollection {
contributionCalendar {
weeks {
contributionDays {
contributionCount
}
}
}
}
}
}`;
const options = (user) => ({
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
query: query(user),
}),
});
const getCalendar = (user) => {
// return fetch(`https://api.github.com/graphql`, options(user)).then((res) =>
// res.json()
// );
};
class Stream { class Stream {
constructor(head, next) { constructor(head, next) {
this.head = head; this.head = head;
@ -30,4 +61,5 @@ const getNeighbors = (key) => {
module.exports = { module.exports = {
Stream, Stream,
getNeighbors, getNeighbors,
getCalendar,
}; };