/* * By: Arjun Patel * Date: 7/30/18 * */ /* * jQuery function call on DOM loading */ $(function() { // Event Handlers $("#inputFile").change(function(e) { onChangeInput(e); $('#inputFile').css("background-color", "#0d7aa5"); }); // Helper Function to read/load specific file function onChangeInput(event) { var reader = new FileReader(); reader.onload = onReaderLoad; reader.readAsText(event.target.files[0]); } // General function to parse JSON function onReaderLoad(event) { var obj = JSON.parse(event.target.result); console.log(obj.orders); obj.orders.map((order) => { console.log(order); $('#table').append("

" + order.customer_id + "

" + order.order_no + "

" + order.part_id + "

" + order.parent_part + "

" + order.price + "

" + order.qty + "

" + order.paid + "

").fadeIn(); }); } });