Created
October 9, 2016 16:38
-
-
Save edtoken/4e5459683171a28e2f7bb55d89cc6938 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function readTextFiles(file, callback, ctx) { | |
ctx = ctx || this; | |
if (typeof file === 'object') { | |
var index = file.length; | |
var response = []; | |
for (var i = 0; i < file.length; i++) { | |
(function (f, i) { | |
readTextFiles(f, function (resp) { | |
response.splice(i, 0, resp); | |
index--; | |
if (!index) { | |
callback.apply(ctx, response); | |
} | |
}) | |
})(file[i], i) | |
} | |
return; | |
} | |
var rawFile = new XMLHttpRequest(); | |
rawFile.overrideMimeType("application/json"); | |
rawFile.open("GET", file, true); | |
rawFile.onreadystatechange = function () { | |
if (rawFile.readyState === 4 && rawFile.status == "200") { | |
callback(rawFile.responseText); | |
} | |
}; | |
rawFile.send(null); | |
} | |
readTextFiles([configFile, dataFile], function (configSource, dataSource) { | |
var config = JSON.parse(configSource); | |
var data = JSON.parse(dataSource); | |
var Customizer = new ReactCustomizer(config, data); | |
Customizer.render(); | |
Customizer.onSubmit = function (data) { | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment