diff --git a/WebView/app/src/main/assets/main.js b/WebView/app/src/main/assets/main.js index 7498f8af..74363ec6 100644 --- a/WebView/app/src/main/assets/main.js +++ b/WebView/app/src/main/assets/main.js @@ -18,11 +18,13 @@ function sendAndroidMessage() { * in the WebViewCompat reference doc, the second parameter, MessagePorts, is optional. * Also note that onmessage, addEventListener and removeEventListener are not supported. */ + // TODO: Change message to account for changes in data jsObject.postMessage("The weather in " + `${document.getElementById("title").innerText}` + " today is " + `${document.getElementById("shortDescription").innerText} `); } function getData() { + // TODO: Change the path to grab data from new location; Change longDescription and currentTemp to work with changes in data fetch("https://gcoleman799.github.io/Asset-Loader/weather.json").then(function(resp) { return resp.json(); }).then(function(data) { @@ -36,4 +38,6 @@ function getData() { + `${data[currentLocation].humidity}.`; document.getElementById("icon").src = data[currentLocation].icon; }) -} \ No newline at end of file +} + +// TODO: Create getIcon() function to decide which icon to render. \ No newline at end of file diff --git a/WebView/sampleData/weather.json b/WebView/sampleData/weather.json new file mode 100644 index 00000000..d9c19e80 --- /dev/null +++ b/WebView/sampleData/weather.json @@ -0,0 +1,26 @@ +{ + "newYork":{ + "currentTemp":75, + "highTemp":83, + "lowTemp":64, + "chancePrecip":90, + "humidity":23, + "description":"Rainy", + }, + "sanFrancisco":{ + "currentTemp":70, + "highTemp":75, + "lowTemp":61, + "chancePrecip":0, + "humidity":2, + "description":"Clear Sky", + }, + "london":{ + "currentTemp":88, + "highTemp":89, + "lowTemp":67, + "chancePrecip":15, + "humidity":36, + "description":"Partly Cloudy", + } +} \ No newline at end of file