Commit 2b31ac65 authored by Weiser's avatar Weiser
Browse files

mehr

parent e4e98431
......@@ -124,37 +124,121 @@ const HistoricalWeatherData = (props) => {
</div>
);
function getData() {
const city = document.getElementById("city").value;
const region = document.getElementById("region").value;
const country = document.getElementById("country").value;
const latitude = document.getElementById("latitude").value;
const longitude = document.getElementById("longitude").value;
const temperature = document.getElementById("temperature").checked;
const isDay = document.getElementById("isDay").checked;
const condition = document.getElementById("condition").checked;
const pressure = document.getElementById("pressure").checked;
const precipitation = document.getElementById("precipitation").checked;
const humidity = document.getElementById("humidity").checked;
const cloud = document.getElementById("cloud").checked;
const feelslikeTemp = document.getElementById("feelslikeTemp").checked;
const visibility = document.getElementById("visibility").checked;
const uv = document.getElementById("uv").checked;
const gust = document.getElementById("gust").checked;
const airquality = boolToWord(
document.getElementById("airquality").checked
);
const unitTemperature = document.getElementById("unitTemperature").value;
const unitWindSpeed = document.getElementById("unitWindSpeed").value;
const unitPressure = document.getElementById("unitPressure").value;
const unitPrecipitation =
document.getElementById("unitPrecipitation").value;
const output = document.getElementById("output").value;
const format = document.getElementById("format").value;
const apiKey = "1244099aeaee4b179e6111803241304";
const apiUrl = `https://api.weatherapi.com/v1/current.${format}?key=${apiKey}&q=${city}&aqi=${airquality}`;
function getData() {
const city_text = document.getElementById("city_text").value;
const region_text = document.getElementById("region_text").value;
const country_text = document.getElementById("country_text").value;
const latitude_text = document.getElementById("latitude_text").value;
const longitude_text = document.getElementById("longitude_text").value;
const timezone_text = document.getElementById("timezone_text").value;
//Checkboxes
const latitude = document.getElementById("latitude").checked;
const longitude = document.getElementById("longitude").checked;
const generationtime_ms = document.getElementById("generationtime_ms").checked;
const utc_offset_seconds = document.getElementById("utc_offset_seconds").checked;
const timezone = document.getElementById("timezone").checked;
const timezone_abbreviation = document.getElementById("timezone_abbreviation").checked;
const elevation = document.getElementById("elevation").checked;
const hourly_time = document.getElementById("hourly_time").checked;
const temperature_2m = document.getElementById("temperature_2m").checked;
const relative_humidity_2m = document.getElementById("relative_humidity_2m").checked;
const precipitation = document.getElementById("precipitation").checked;
const surface_pressure = document.getElementById("surface_pressure").checked;
const wind_speed_10m = document.getElementById("wind_speed_10m").checked;
const wind_direction_10m = document.getElementById("wind_direction_10m").checked;
const wind_gusts_10m = document.getElementById("wind_gusts_10m").checked;
const daily_time = document.getElementById("daily_time").checked;
const temperature_2m_max = document.getElementById("temperature_2m_max").checked;
const temperature_2m_min = document.getElementById("temperature_2m_min").checked;
const temperature_2m_mean = document.getElementById("temperature_2m_mean").checked;
const precipitation_sum = document.getElementById("precipitation_sum").checked;
const precipitation_hours = document.getElementById("precipitation_hours").checked;
const wind_speed_10m_max = document.getElementById("wind_speed_10m_max").checked;
const wind_gusts_10m_max = document.getElementById("wind_gusts_10m_max").checked;
const wind_direction_10m_dominant = document.getElementById("wind_direction_10m_dominant").checked;
let filterArray = [];
if (latitude) {
filterArray.push("latitude");
}
if (longitude) {
filterArray.push("longitude");
}
if (generationtime_ms) {
filterArray.push("generationtime_ms");
}
if (utc_offset_seconds) {
filterArray.push("utc_offset_seconds");
}
if (timezone) {
filterArray.push("timezone");
}
if (timezone_abbreviation) {
filterArray.push("timezone_abbreviation");
}
if (elevation) {
filterArray.push("elevation");
}
if (hourly_time) {
filterArray.push("hourly.time");
}
if (temperature_2m) {
filterArray.push("hourly.temperature_2m");
}
if (relative_humidity_2m) {
filterArray.push("hourly.relative_humidity_2m");
}
if (precipitation) {
filterArray.push("hourly.precipitation");
}
if (surface_pressure) {
filterArray.push("hourly.surface_pressure");
}
if (wind_speed_10m) {
filterArray.push("hourly.wind_speed_10m");
}
if (wind_direction_10m) {
filterArray.push("hourly.wind_direction_10m");
}
if (wind_gusts_10m) {
filterArray.push("hourly.wind_gusts_10m");
}
if (daily_time) {
filterArray.push("daily.time");
}
if (temperature_2m_max) {
filterArray.push("daily.temperature_2m_max");
}
if (temperature_2m_min) {
filterArray.push("daily.temperature_2m_min");
}
if (temperature_2m_mean) {
filterArray.push("daily.temperature_2m_mean");
}
if (precipitation_sum) {
filterArray.push("daily.precipitation_sum");
}
if (precipitation_hours) {
filterArray.push("daily.precipitation_hours");
}
if (wind_speed_10m_max) {
filterArray.push("daily.wind_speed_10m_max");
}
if (wind_gusts_10m_max) {
filterArray.push("daily.wind_gusts_10m_max");
}
if (wind_direction_10m_dominant) {
filterArray.push("daily.wind_direction_10m_dominant");
}
let filterString = filterArray.join(",");
console.log("FilterString = " + filterString);
const apiUrl = `http://localhost:8080/currentweather?q=${city_text}&filter=${filterString}`;
fetch(apiUrl)
.then((response) => {
if (!response.ok) {
......
......@@ -228,37 +228,131 @@ const WeatherForecastData = (props) => {
</div>
);
function getData() {
const city = document.getElementById("city").value;
const region = document.getElementById("region").value;
const country = document.getElementById("country").value;
const latitude = document.getElementById("latitude").value;
const longitude = document.getElementById("longitude").value;
const temperature = document.getElementById("temperature").checked;
const isDay = document.getElementById("isDay").checked;
const condition = document.getElementById("condition").checked;
const pressure = document.getElementById("pressure").checked;
const precipitation = document.getElementById("precipitation").checked;
const humidity = document.getElementById("humidity").checked;
const cloud = document.getElementById("cloud").checked;
const feelslikeTemp = document.getElementById("feelslikeTemp").checked;
const visibility = document.getElementById("visibility").checked;
const uv = document.getElementById("uv").checked;
const gust = document.getElementById("gust").checked;
const airquality = boolToWord(
document.getElementById("airquality").checked
);
const unitTemperature = document.getElementById("unitTemperature").value;
const unitWindSpeed = document.getElementById("unitWindSpeed").value;
const unitPressure = document.getElementById("unitPressure").value;
const unitPrecipitation =
document.getElementById("unitPrecipitation").value;
const output = document.getElementById("output").value;
const format = document.getElementById("format").value;
const apiKey = "1244099aeaee4b179e6111803241304";
const apiUrl = `https://api.weatherapi.com/v1/current.${format}?key=${apiKey}&q=${city}&aqi=${airquality}`;
function getData() {
const city = document.getElementById("city_text").value;
const region = document.getElementById("region_text").value;
const country = document.getElementById("country_text").value;
const latitude = document.getElementById("latitude_text").value;
const longitude = document.getElementById("longitude_text").value;
const name = document.getElementById("name").checked;
const regionCheckbox = document.getElementById("region").checked;
const countryCheckbox = document.getElementById("country").checked;
const lon = document.getElementById("lon").checked;
const lat = document.getElementById("lat").checked;
const tz_id = document.getElementById("tz_id").checked;
const localtime_epoch = document.getElementById("localtime_epoch").checked;
const localtime = document.getElementById("localtime").checked;
const last_updated_epoch = document.getElementById("last_updated_epoch").checked;
const last_updated = document.getElementById("last_updated").checked;
const date = document.getElementById("date").checked;
const date_epoch = document.getElementById("date_epoch").checked;
const maxtemp = document.getElementById("maxtemp").checked;
const mintemp = document.getElementById("mintemp").checked;
const avgtemp = document.getElementById("avgtemp").checked;
const maxwind = document.getElementById("maxwind").checked;
const totalprecip = document.getElementById("totalprecip").checked;
const avgvis = document.getElementById("avgvis").checked;
const avghumidity = document.getElementById("avghumidity").checked;
const daily_will_it_rain = document.getElementById("daily_will_it_rain").checked;
const daily_chance_of_rain = document.getElementById("daily_chance_of_rain").checked;
const daily_will_it_snow = document.getElementById("daily_will_it_snow").checked;
const daily_chance_of_snow = document.getElementById("daily_chance_of_snow").checked;
const condition_text = document.getElementById("condition_text").checked;
const condition_icon = document.getElementById("condition_icon").checked;
const condition_code = document.getElementById("condition_code").checked;
const uv = document.getElementById("uv").checked;
const sunrise = document.getElementById("sunrise").checked;
const sunset = document.getElementById("sunset").checked;
const moonrise = document.getElementById("moonrise").checked;
const moonset = document.getElementById("moonset").checked;
const moon_phase = document.getElementById("moon_phase").checked;
const moon_illumination = document.getElementById("moon_illumination").checked;
const hour_time_epoch = document.getElementById("hour_time_epoch").checked;
const hour_time = document.getElementById("hour_time").checked;
const hour_temp = document.getElementById("hour_temp").checked;
const hour_is_day = document.getElementById("hour_is_day").checked;
const hour_condition_text = document.getElementById("hour_condition_text").checked;
const hour_condition_icon = document.getElementById("hour_condition_icon").checked;
const hour_condition_code = document.getElementById("hour_condition_code").checked;
const hour_wind = document.getElementById("hour_wind").checked;
const hour_wind_degree = document.getElementById("hour_wind_degree").checked;
const hour_wind_dir = document.getElementById("hour_wind_dir").checked;
const hour_pressure = document.getElementById("hour_pressure").checked;
const hour_precip = document.getElementById("hour_precip").checked;
const hour_humidity = document.getElementById("hour_humidity").checked;
const hour_cloud = document.getElementById("hour_cloud").checked;
const hour_feelslike = document.getElementById("hour_feelslike").checked;
const hour_windchill = document.getElementById("hour_windchill").checked;
const hour_heatindex = document.getElementById("hour_heatindex").checked;
const hour_dewpoint = document.getElementById("hour_dewpoint").checked;
const hour_vis = document.getElementById("hour_vis").checked;
const hour_gust = document.getElementById("hour_gust").checked;
const hour_uv = document.getElementById("hour_uv").checked;
let filterArray = [];
if (name) filterArray.push("name");
if (regionCheckbox) filterArray.push("region");
if (countryCheckbox) filterArray.push("country");
if (lon) filterArray.push("lon");
if (lat) filterArray.push("lat");
if (tz_id) filterArray.push("tz_id");
if (localtime_epoch) filterArray.push("localtime_epoch");
if (localtime) filterArray.push("localtime");
if (last_updated_epoch) filterArray.push("last_updated_epoch");
if (last_updated) filterArray.push("last_updated");
if (date) filterArray.push("date");
if (date_epoch) filterArray.push("date_epoch");
if (maxtemp) filterArray.push("maxtemp");
if (mintemp) filterArray.push("mintemp");
if (avgtemp) filterArray.push("avgtemp");
if (maxwind) filterArray.push("maxwind");
if (totalprecip) filterArray.push("totalprecip");
if (avgvis) filterArray.push("avgvis");
if (avghumidity) filterArray.push("avghumidity");
if (daily_will_it_rain) filterArray.push("daily_will_it_rain");
if (daily_chance_of_rain) filterArray.push("daily_chance_of_rain");
if (daily_will_it_snow) filterArray.push("daily_will_it_snow");
if (daily_chance_of_snow) filterArray.push("daily_chance_of_snow");
if (condition_text) filterArray.push("condition_text");
if (condition_icon) filterArray.push("condition_icon");
if (condition_code) filterArray.push("condition_code");
if (uv) filterArray.push("uv");
if (sunrise) filterArray.push("sunrise");
if (sunset) filterArray.push("sunset");
if (moonrise) filterArray.push("moonrise");
if (moonset) filterArray.push("moonset");
if (moon_phase) filterArray.push("moon_phase");
if (moon_illumination) filterArray.push("moon_illumination");
if (hour_time_epoch) filterArray.push("hour_time_epoch");
if (hour_time) filterArray.push("hour_time");
if (hour_temp) filterArray.push("hour_temp");
if (hour_is_day) filterArray.push("hour_is_day");
if (hour_condition_text) filterArray.push("hour_condition_text");
if (hour_condition_icon) filterArray.push("hour_condition_icon");
if (hour_condition_code) filterArray.push("hour_condition_code");
if (hour_wind) filterArray.push("hour_wind");
if (hour_wind_degree) filterArray.push("hour_wind_degree");
if (hour_wind_dir) filterArray.push("hour_wind_dir");
if (hour_pressure) filterArray.push("hour_pressure");
if (hour_precip) filterArray.push("hour_precip");
if (hour_humidity) filterArray.push("hour_humidity");
if (hour_cloud) filterArray.push("hour_cloud");
if (hour_feelslike) filterArray.push("hour_feelslike");
if (hour_windchill) filterArray.push("hour_windchill");
if (hour_heatindex) filterArray.push("hour_heatindex");
if (hour_dewpoint) filterArray.push("hour_dewpoint");
if (hour_vis) filterArray.push("hour_vis");
if (hour_gust) filterArray.push("hour_gust");
if (hour_uv) filterArray.push("hour_uv");
let filterString = filterArray.join(",");
console.log("FilterString = " + filterString);
const apiUrl = `http://localhost:8080/currentweather?q=${city_text}&filter=${filterString}`;
fetch(apiUrl)
.then((response) => {
if (!response.ok) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment