var bodyRegionData; var bodyLayerData; var bodyArtData; loadBodyViewData = function (currentBodyViewId) { //1. var bodyRegionjsonPath = '~/../content/data/json/da/da_dat_brview.json'; var req = new XMLHttpRequest(); req.open("GET", bodyRegionjsonPath, true); req.setRequestHeader("Content-type", "application/json"); req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { bodyRegionData = JSON.parse(req.responseText); console.log("bodyRegionData returned: " + bodyRegionData); loadLayerDataForCurrentBodyView(currentBodyViewId) } } req.send(); } loadLayerDataForCurrentBodyView = function (currentBodyViewId) { //1. var bgArtJsonPath = ''; var CommonViewId = 0; //2. var layerJsonPath = '~/../content/data/json/da/body-views/' + currentBodyViewId + '/da_dat_layer_' + currentBodyViewId + '.json'; var req = new XMLHttpRequest(); req.open("GET", layerJsonPath, true); req.setRequestHeader("Content-type", "application/json"); req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { bodyLayerData = JSON.parse(req.responseText); console.log("data returned: " + bodyLayerData); loadBodyArtData(); } } req.send(); } loadBodyArtData = function () { var bgArtJsonPath = ''; bgArtJsonPath = '~/../content/data/json/da/da_dat_bgart.json'; var req = new XMLHttpRequest(); req.open("GET", bgArtJsonPath, true); req.setRequestHeader("Content-type", "application/json"); req.onreadystatechange = function () { if (req.readyState == 4 && req.status == 200) { bodyArtData = JSON.parse(req.responseText); console.log("data returned: " + bodyArtData); self.postMessage({ 'bodyRegionData': bodyRegionData, 'bodyLayerData': bodyLayerData, 'bodyArtData': bodyArtData }); } } req.send(); }; self.onmessage = function (e) { loadBodyViewData(e.data.currentViewId); }