diff --git a/index.html b/index.html index 6354310..88e3117 100644 --- a/index.html +++ b/index.html @@ -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! diff --git a/js/main.js b/js/main.js index a239dc7..f330d4a 100644 --- a/js/main.js +++ b/js/main.js @@ -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)