xxxxxxxxxx
35
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
</head>
<body>
<main>
</main>
<input type="file" id="fileInput" accept=".json" />
<script>
(function(){ // this means it runs as soon as it is rendered
function onChange(event) {
var reader = new FileReader();
reader.onload = onReaderLoad;
reader.readAsText(event.target.files[0]);
}
function onReaderLoad(event){
var obj = JSON.parse(event.target.result);
console.log(obj);
}
document.getElementById('fileInput').addEventListener('change', onChange); // this is finding our input and attaching the onChange event to it
}());
</script>
</body>
</html>