stub seed fetch
This commit is contained in:
parent
dbd671a964
commit
343e16c560
4 changed files with 41 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
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 controlsEl = document.getElementById("controls");
|
||||
|
@ -10,6 +11,7 @@ const init = (gameField) => {
|
|||
const resetEl = document.getElementById("reset");
|
||||
const clearEl = document.getElementById("clear");
|
||||
const canvasEl = document.getElementById("game-field");
|
||||
const calendarFormEl = document.getElementById("calendar-form");
|
||||
const controls = {
|
||||
interval: null,
|
||||
play() {
|
||||
|
@ -78,6 +80,11 @@ const init = (gameField) => {
|
|||
const { offsetX, offsetY } = e;
|
||||
controls.updateField(offsetX, offsetY);
|
||||
});
|
||||
calendarFormEl.addEventListener("submit", (e) => {
|
||||
e.preventDefault();
|
||||
const user = e.target[0].value;
|
||||
console.log(getCalendar(user));
|
||||
});
|
||||
return controls;
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
value="10"
|
||||
/>
|
||||
</div>
|
||||
<form action="/">
|
||||
<form action="/" id="calendar-form">
|
||||
<input type="text" />
|
||||
<input type="submit" value="seed" />
|
||||
</form>
|
||||
|
|
|
@ -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 {
|
||||
constructor(head, next) {
|
||||
this.head = head;
|
||||
|
@ -30,4 +61,5 @@ const getNeighbors = (key) => {
|
|||
module.exports = {
|
||||
Stream,
|
||||
getNeighbors,
|
||||
getCalendar,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue