// Retrieve JSON data from file function getJSONData(filename, eIndex) { var xmlhttp = new XMLHttpRequest(); xmlhttp.open('GET', filename, true); xmlhttp.setRequestHeader("Content-type", "application/json", true); xmlhttp.onreadystatechange = function () { if (this.readyState == 4 && this.status == "200") { var mksData = JSON.parse(this.responseText); setJSONData(eIndex, mksData); } }; xmlhttp.send(null); } // Show JSON data from file function setJSONData(eIndex, data) { // Initialize values var count = 7; // Show chemical name var value = data["Entities"][eIndex]["Identifier"]; content = document.getElementById("chemName"); content.innerHTML = value; // Show chemical's property data for (pIndex = 0; pIndex < count; pIndex++) { setPropValue(eIndex, data, pIndex); } } // Property value function function setPropValue(eIndex, data, pIndex) { // Property name content = document.getElementById("prop" + pIndex); props = data["Entities"][eIndex]["Properties"]; name = props[pIndex]["Property"]; content.innerHTML = name; // Property value content = document.getElementById("value" + pIndex); value = props[pIndex]["Data"][0]["Value"]; content.innerHTML = value; // Property units content = document.getElementById("units" + pIndex); units = props[pIndex]["Data"][0]["ValueUnits"]; if (units == null) units = "- - -"; content.innerHTML = units; }