You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
889 B
32 lines
889 B
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 = {
|
|
generateDiagram: (eventKey) => {
|
|
const metaMatrix = Matrices.buildMetaMatrix(main.json, eventKey);
|
|
const chordMatrix = Matrices.buildChordMatrix(main.json, eventKey);
|
|
Diagram.clear();
|
|
Diagram.build(main.json, eventKey, metaMatrix, chordMatrix);
|
|
},
|
|
|
|
generateUI: () => {
|
|
UI.buildEventsPane();
|
|
},
|
|
|
|
initJSON: (strData) => {
|
|
main.json = JSON.parse(strData);
|
|
},
|
|
}
|
|
|
|
fetch('worldcup.json')
|
|
.then(main.initJSON)
|
|
.then(main.generateUI)
|
|
.then(main.generateDiagram.bind(null, 1930));
|
|
|