Mahaffey - Random Forecaster App Code
Mahaffey - Random Forecaster App Code
hideElement("forecastDropdown");
// list of all values
var cityList = getColumn("Daily Weather", "City");
var highTemp = getColumn("Daily Weather", "High Temperature");
var lowTemp = getColumn("Daily Weather", "Low Temperature");
var conditionList = getColumn("Daily Weather", "Condition Description");
var forecastNumberList = getColumn("Daily Weather", "Forecast Number");
var imageList = getColumn("Daily Weather", "Icon");
// These are the var's for the new chosen City, Condition, Image, High Temp, Low Temp.
var lteredCityList = [];
var lteredConditionList = [];
var lteredImageList = [];
var lteredHighTemp = [];
var lteredLowTemp = [];
function lter() {
lteredCityList = [];
lteredConditionList = [];
lteredImageList = [];
lteredHighTemp = [];
lteredLowTemp = [];
// This is to pick a random City, Condition, Image, High Temp, Low Temp.
for (var i = 0; i < cityList.length; i++) {
if (forecastNumberList[i] < 2) {
// adding the new conditions to the var states
appendItem( lteredCityList, cityList[i]);
appendItem( lteredConditionList, conditionList[i]);
appendItem( lteredLowTemp, lowTemp[i]);
appendItem( lteredImageList, imageList[i]);
appendItem( lteredHighTemp, highTemp[i]);
}
}
}
// If there is data for the selected city, update the screen with today's forecast
if ( lteredCityList.length > 0) {
setText("cityOutput", lteredCityList[0]);
setText("highTempOutput", lteredHighTemp[0]);
setText("lowTempOutput", lteredLowTemp[0]);
setText("conditionOutput", lteredConditionList[0]);
setImageURL("iconOutput", lteredImageList[0]);
// If there is data for the selected city and forecast, update the screen
if ( lteredCityList.length > 0) {
setText("cityOutput", lteredCityList[0]);
setText("highTempOutput", lteredHighTemp[0]);
setText("lowTempOutput", lteredLowTemp[0]);
setText("conditionOutput", lteredConditionList[0]);
setImageURL("iconOutput", lteredImageList[0]);