Skip to content
Snippets Groups Projects

Saddlegallmidge form idec 372

Compare and
2 files
+ 82
10
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -154,7 +154,17 @@ async function getStationWeatherData(endpoint, weatherStationId, parameters, int
+ "&weatherStationId=" + weatherStationId
+ "&parameters=" + parameters.join(",")
);
return await response.json();
if(response.status == 200)
{
return await response.json();
}
else
{
let errorMessage = "No weather data was returned. Message from the data source was: \n\n" + await response.text();
alert(errorMessage);
return null;
}
}
/**
@@ -177,7 +187,18 @@ async function getLocationWeatherData(endpoint, longitude, latitude, parameters,
+ "&latitude=" + latitude
+ "&parameters=" + parameters.join(",")
);
return (response.status == 200) ? await response.json() : null;
if(response.status == 200)
{
return await response.json();
}
else
{
let errorMessage = "No weather data was returned. Message from the data source was: \n\n" + await response.text();
alert(errorMessage);
return null;
}
}
/**
@@ -500,13 +521,13 @@ function getUnix(aDate)
}
/**
* Saves a bit of typing. Currently checks if the val is either undefined or null
* Saves a bit of typing. Currently checks if the val is either undefined or null, and if a string == ""
* @param {Object} val
* @returns {Boolean} true if the value is considered empty
*/
function isEmpty(val)
{
return val === undefined || val === null;
return val === undefined || val === null || (typeof val === "string" && val.trim() == "");
}
// Keeping track of maps
Loading