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?
embiggen current event flag
move styling out of index.html
move fetch into main
add sort metric below team name
hide rounds
round persistence
better layout
better colors
webpack 2 / css modules?
add three.js sketchup clone to a list somewhere
separate three.js swell map below post or something
tweet it!
</div>
</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 = {
changeEvent: (e) => {
@ -73,6 +63,17 @@ const main = {
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) => {
main.json = JSON.parse(strData);
},
@ -121,7 +122,7 @@ const main = {
},
}
fetch('worldcup.json')
main.fetch('worldcup.json')
.then(main.initJSON)
.then(main.initState)
.then(main.generateUI)

Loading…
Cancel
Save