JSFiddle - React, Tailwind, and code Playground

by rickysullivan

JavaScript

window.someOtherCrapFunction = function () {
    console.log('YOU CALLED ME FROM JSON DATA');
};

function fetchJSONFile(path, callback) {
    var httpRequest = new XMLHttpRequest();
    httpRequest.onreadystatechange = function () {
        if (httpRequest.readyState === 4) {
            if (httpRequest.status === 200) {
                var data = JSON.parse(httpRequest.responseText);
                if (callback) callback(data);
            }
        }
    };
    httpRequest.open('GET', path);
    httpRequest.send();
}

fetchJSONFile('https://gist.githubusercontent.com/rickysullivan/377d74676bcc4d420945/raw/19605b6922cf47bded64e70bbad221cf93f5399e/functions.json', function (data) {
    window[data.myFunctions.b]();
});