Moving fetch method into main.

master
Ben Burlingham 9 years ago
parent a67bdcbf87
commit c3dddfd7df
  1. 5
      index.html
  2. 23
      js/main.js

@ -75,15 +75,10 @@ body {
1974 two germanies? 1974 two germanies?
embiggen current event flag embiggen current event flag
move styling out of index.html move styling out of index.html
move fetch into main
add sort metric below team name add sort metric below team name
hide rounds
round persistence
better layout better layout
better colors better colors
webpack 2 / css modules? webpack 2 / css modules?
add three.js sketchup clone to a list somewhere
separate three.js swell map below post or something
tweet it! tweet it!
</div> </div>
</body> </body>

@ -1,13 +1,3 @@
const fetch = (url) => new Promise((resolve, reject) => {
const listener = ({ srcElement: req }) => {
req.status === 200 ? resolve(req.responseText) : reject("busted");
};
const req = new XMLHttpRequest();
req.addEventListener('load', listener);
req.open('GET', url);
req.send();
});
const main = { const main = {
changeEvent: (e) => { changeEvent: (e) => {
@ -73,6 +63,17 @@ const main = {
UI.updateRoundsPane(state.rounds.split(','), main.json.rounds); UI.updateRoundsPane(state.rounds.split(','), main.json.rounds);
}, },
fetch: (url) => new Promise((resolve, reject) => {
const listener = ({ srcElement: req }) => {
req.status === 200 ? resolve(req.responseText) : reject("busted");
};
const req = new XMLHttpRequest();
req.addEventListener('load', listener);
req.open('GET', url);
req.send();
}),
initJSON: (strData) => { initJSON: (strData) => {
main.json = JSON.parse(strData); main.json = JSON.parse(strData);
}, },
@ -121,7 +122,7 @@ const main = {
}, },
} }
fetch('worldcup.json') main.fetch('worldcup.json')
.then(main.initJSON) .then(main.initJSON)
.then(main.initState) .then(main.initState)
.then(main.generateUI) .then(main.generateUI)

Loading…
Cancel
Save