Commit 3c0e9b8d authored by EnesKarakas's avatar EnesKarakas
Browse files

Merge branch 'devbackend' of...

Merge branch 'devbackend' of https://transfer.hft-stuttgart.de/gitlab/22kaen1bdi/swp_ss24_wetterdaten_sammeln into devbackend
parents f1792a8c c3e5e23f
...@@ -15,26 +15,11 @@ const Currentdata = (props) => { ...@@ -15,26 +15,11 @@ const Currentdata = (props) => {
return ( return (
<div className="home-container"> <div className="home-container">
<div className="thq-grid-3"> <div>
<div className="thq-grid-5">
<div class="filter"> <div class="filter">
<label htmlFor="location">Location:</label> <label for="location">Location:</label>
<input <input type="text" id="city_text" placeholder="Location" />
type="text"
id="city_text"
placeholder="Location"
value={query}
onChange={handleInputChange}
/>
{data.map((item) => (
<ListItem
key={item.id}
name={item.name}
country={item.country}
region={item.region}
lat={item.lat}
lon={item.lon}
/>
))}
<br /> <br />
<label for="region">Region:</label> <label for="region">Region:</label>
<input type="text" id="region_text" placeholder="Region" /> <input type="text" id="region_text" placeholder="Region" />
...@@ -84,7 +69,11 @@ const Currentdata = (props) => { ...@@ -84,7 +69,11 @@ const Currentdata = (props) => {
/> />
<label> Last Updated Epoch</label> <label> Last Updated Epoch</label>
<br /> <br />
<input type="checkbox" id="last_updated" className="checkBoxFilter" /> <input
type="checkbox"
id="last_updated"
className="checkBoxFilter"
/>
<label> Last Updated</label> <label> Last Updated</label>
<br /> <br />
<input type="checkbox" id="temp_c" className="checkBoxFilter" /> <input type="checkbox" id="temp_c" className="checkBoxFilter" />
...@@ -119,7 +108,11 @@ const Currentdata = (props) => { ...@@ -119,7 +108,11 @@ const Currentdata = (props) => {
<input type="checkbox" id="wind" className="checkBoxFilter" /> <input type="checkbox" id="wind" className="checkBoxFilter" />
<label for="wind">Wind </label> <label for="wind">Wind </label>
<br /> <br />
<input type="checkbox" id="wind_degree" className="checkBoxFilter" /> <input
type="checkbox"
id="wind_degree"
className="checkBoxFilter"
/>
<label for="wind_degree">Wind Degree</label> <label for="wind_degree">Wind Degree</label>
<br /> <br />
<input type="checkbox" id="wind_dir" className="checkBoxFilter" /> <input type="checkbox" id="wind_dir" className="checkBoxFilter" />
...@@ -214,6 +207,15 @@ const Currentdata = (props) => { ...@@ -214,6 +207,15 @@ const Currentdata = (props) => {
/> />
<label for="air_quality_gb_defra_index">GB DEFRA Index</label> <label for="air_quality_gb_defra_index">GB DEFRA Index</label>
<br /> <br />
<div>
<label for="units">Choose a unit:</label>
<select name="unnits" id="units">
<option value="world">Rest of The World</option>
<option value="american">
American units: /eagles per shool shootings
</option>
</select>
</div>
<div> <div>
<button className="thq-button-filled" onClick={getData}> <button className="thq-button-filled" onClick={getData}>
Generate Generate
...@@ -230,11 +232,15 @@ const Currentdata = (props) => { ...@@ -230,11 +232,15 @@ const Currentdata = (props) => {
<br /> <br />
<input className="input" type="text" id="apiUrloutput" readOnly /> <input className="input" type="text" id="apiUrloutput" readOnly />
</div> </div>
<button className="APIButton" onClick={searchAPI}>
City api
</button>
<br /> <br />
<br /> <br />
</div> </div>
</div> </div>
</div> </div>
</div>
); );
function getData() { function getData() {
......
...@@ -7,137 +7,122 @@ const HistoricalWeatherData = (props) => { ...@@ -7,137 +7,122 @@ const HistoricalWeatherData = (props) => {
<div className="home-container"> <div className="home-container">
<div> <div>
<div className="thq-grid-5"> <div className="thq-grid-5">
<div class="filter">
<div class="filter"> <div class="filter">
<label for="location">Location:</label> <label for="location">Location:</label>
<input type="text" id="location" placeholder="Location" /> <input type="text" id="city_text" placeholder="Location" />
<br /> <br />
<label for="region">Region:</label> <label for="region">Region:</label>
<input type="text" id="region" placeholder="Region" /> <input type="text" id="region_text" placeholder="Region" />
<br /> <br />
<label>Country:</label> <label>Country:</label>
<input type="text" id="country" placeholder="Country" /> <input type="text" id="country_text" placeholder="Country" />
<br /> <br />
<label>Latitude:</label> <label>Latitude:</label>
<input type="text" id="latitude" placeholder="Latitude" /> <input type="text" id="latitude_text" placeholder="Latitude" />
<label>Longitude:</label> <label>Longitude:</label>
<input type="text" id="longitude" placeholder="Longitude" /> <input type="text" id="longitude_text" placeholder="Longitude" />
<br />
</div>
<div>
<input type="checkbox" id="name" className="checkBoxFilter" />
<label> City Name</label>
<br />
<input type="checkbox" id="region" className="checkBoxFilter" />
<label> Region</label>
<br />
<input type="checkbox" id="country" className="checkBoxFilter" />
<label> Country</label>
<br />
<input type="checkbox" id="lon" className="checkBoxFilter" />
<label> Longitude</label>
<br />
<input type="checkbox" id="lat" className="checkBoxFilter" />
<label> Latitude</label>
<br />
<input type="checkbox" id="tz_id" className="checkBoxFilter" />
<label> Timezone Id</label>
<br />
<input type="checkbox" id="localtime_epoch" className="checkBoxFilter" />
<label> Localtime Epoch</label>
<br />
<input type="checkbox" id="localtime" className="checkBoxFilter" />
<label> Localtime</label>
<br />
<input type="checkbox" id="last_updated_epoch" className="checkBoxFilter" />
<label> Last Updated Epoch</label>
<br /> <br />
<input type="checkbox" id="last_updated" className="checkBoxFilter" /> <label>Time Zone:</label>
<label> Last Updated</label> <input type="text" id="timezone_text" placeholder="Timezone" />
<br /> <br />
<input type="checkbox" id="temp_c" className="checkBoxFilter" /> </div>
<label for="temp_c">Temp C</label> <input type="checkbox" id="latitude" class="checkBoxFilter" />
<label for="latitude">Latitude</label>
<br /> <br />
<input type="checkbox" id="temp_f" className="checkBoxFilter" /> <input type="checkbox" id="longitude" class="checkBoxFilter" />
<label for="temp_f">Temp F</label> <label for="longitude">Longitude</label>
<br /> <br />
<input type="checkbox" id="id_day" className="checkBoxFilter" /> <input type="checkbox" id="generationtime_ms" class="checkBoxFilter" />
<label for="id_day">ID Day</label> <label for="generationtime_ms">Generation Time (ms)</label>
<br /> <br />
<input type="checkbox" id="condition_text" className="checkBoxFilter" /> <input type="checkbox" id="utc_offset_seconds" class="checkBoxFilter" />
<label for="condition_text">Condition Text</label> <label for="utc_offset_seconds">UTC Offset (Seconds)</label>
<br /> <br />
<input type="checkbox" id="condition_icon" className="checkBoxFilter" /> <input type="checkbox" id="timezone" class="checkBoxFilter" />
<label for="condition_icon">Condition Icon</label> <label for="timezone">Timezone</label>
<br /> <br />
<input type="checkbox" id="condition_code" className="checkBoxFilter" /> <input type="checkbox" id="timezone_abbreviation" class="checkBoxFilter" />
<label for="condition_code">Condition Code</label> <label for="timezone_abbreviation">Timezone Abbreviation</label>
<input type="checkbox" id="wind" className="checkBoxFilter" />
<label for="wind">Wind </label>
<br /> <br />
<input type="checkbox" id="wind_degree" className="checkBoxFilter" /> <input type="checkbox" id="elevation" class="checkBoxFilter" />
<label for="wind_degree">Wind Degree</label> <label for="elevation">Elevation</label>
<br /> <br />
<input type="checkbox" id="wind_dir" className="checkBoxFilter" /> <p>Hourly</p>
<label for="wind_dir">Wind Direction</label>
<br /> <br />
<input type="checkbox" id="pressure" className="checkBoxFilter" /> <input type="checkbox" id="hourly_time" class="checkBoxFilter" />
<label for="pressure">Pressure</label> <label for="hourly_time">Hourly Time</label>
<br /> <br />
<input type="checkbox" id="precip" className="checkBoxFilter" /> <input type="checkbox" id="temperature_2m" class="checkBoxFilter" />
<label for="precip">Precip</label> <label for="temperature_2m">Temperature 2m</label>
<br /> <br />
<input type="checkbox" id="humidity" className="checkBoxFilter" /> <input type="checkbox" id="relative_humidity_2m" class="checkBoxFilter" />
<label for="humidity">Humidity</label> <label for="relative_humidity_2m">Relative Humidity 2m</label>
<br /> <br />
<input type="checkbox" id="cloud" className="checkBoxFilter" /> <input type="checkbox" id="precipitation" class="checkBoxFilter" />
<label for="cloud">Cloud</label> <label for="precipitation">Precipitation</label>
<br /> <br />
<input type="checkbox" id="feelslike" className="checkBoxFilter" /> <input type="checkbox" id="surface_pressure" class="checkBoxFilter" />
<label for="feelslike">Feelslike</label> <label for="surface_pressure">Surface Pressure</label>
<br /> <br />
<input type="checkbox" id="windchill" className="checkBoxFilter" /> <input type="checkbox" id="wind_speed_10m" class="checkBoxFilter" />
<label for="windchill">Windchill</label> <label for="wind_speed_10m">Wind Speed 10m</label>
<br /> <br />
<input type="checkbox" id="heatindex" className="checkBoxFilter" /> <input type="checkbox" id="wind_direction_10m" className="checkBoxFilter" />
<label for="heatindex">Heatindex</label> <label for="wind_direction_10m">Wind Direction 10m</label>
<br /> <br />
<input type="checkbox" id="dewpoint" className="checkBoxFilter" /> <input type="checkbox" id="wind_gusts_10m" className="checkBoxFilter" />
<label for="dewpoint">Dewpoint</label> <label for="wind_gusts_10m">Wind Gusts 10m</label>
<br /> <br />
<input type="checkbox" id="vis" className="checkBoxFilter" /> <p>Dayly</p>
<label for="vis">Visibility </label>
<br /> <br />
<input type="checkbox" id="uv" className="checkBoxFilter" /> <input type="checkbox" id="daily_time" class="checkBoxFilter" />
<label for="uv">UV Index</label> <label for="daily_time">Daily Time</label>
<br /> <br />
<input type="checkbox" id="gust" className="checkBoxFilter" /> <input type="checkbox" id="temperature_2m_max" class="checkBoxFilter" />
<label for="gust">Gust </label> <label for="temperature_2m_max">Temperature 2m Max</label>
<br /> <br />
<input type="checkbox" id="air_quality_co" className="checkBoxFilter" /> <input type="checkbox" id="temperature_2m_min" class="checkBoxFilter" />
<label for="air_quality_co">Air Quality CO</label> <label for="temperature_2m_min">Temperature 2m Min</label>
<br /> <br />
<input type="checkbox" id="air_quality_no2" className="checkBoxFilter" /> <input type="checkbox" id="temperature_2m_mean" class="checkBoxFilter" />
<label for="air_quality_no2">Air Quality NO2</label> <label for="temperature_2m_mean">Temperature 2m Mean</label>
<br /> <br />
<input type="checkbox" id="air_quality_o3" className="checkBoxFilter" /> <input type="checkbox" id="precipitation_sum" class="checkBoxFilter" />
<label for="air_quality_o3">Air Quality O3</label> <label for="precipitation_sum">Precipitation Sum</label>
<br /> <br />
<input type="checkbox" id="air_quality_so2" className="checkBoxFilter" /> <input type="checkbox" id="precipitation_hours" class="checkBoxFilter" />
<label for="air_quality_so2">Air Quality SO2</label> <label for="precipitation_hours">Precipitation Hours</label>
<br /> <br />
<input type="checkbox" id="air_quality_pm2_5" className="checkBoxFilter" /> <input type="checkbox" id="wind_speed_10m_max" class="checkBoxFilter" />
<label for="air_quality_pm2_5">Air Quality PM2.5</label> <label for="wind_speed_10m_max">Wind Speed 10m Max</label>
<br /> <br />
<input type="checkbox" id="air_quality_pm10" className="checkBoxFilter" /> <input type="checkbox" id="wind_gusts_10m_max" class="checkBoxFilter" />
<label for="air_quality_pm10">Air Quality PM10</label> <label for="wind_gusts_10m_max">Wind Gusts 10m Max</label>
<br /> <br />
<input type="checkbox" id="air_quality_us_epa_index" className="checkBoxFilter" /> <input type="checkbox" id="wind_direction_10m_dominant" class="checkBoxFilter" />
<label for="air_quality_us_epa_index">US EPA Index</label> <label for="wind_direction_10m_dominant">Wind Direction 10m Dominant</label>
<br /> <br />
<input type="checkbox" id="air_quality_gb_defra_index" className="checkBoxFilter" /> <div>
<label for="air_quality_gb_defra_index">GB DEFRA Index</label> <label for="units">Choose a unit:</label>
<select name="unnits" id="units">
<option value="world">Rest of The World</option>
<option value="american">American units: /eagles per shool shootings</option>
</select>
</div>
<div class="output">
<h2>Output:</h2>
<br /> <br />
<pre id="weatherData"></pre>
</div>
<div id="apiUrl">
<label>API URL:</label>
<br /> <br />
<input className="input" type="text" id="apiUrloutput" readOnly />
</div>
<button className="APIButton" onClick={searchAPI}>
City api
</button>
<br /> <br />
<br /> <br />
</div> </div>
...@@ -147,35 +132,119 @@ const HistoricalWeatherData = (props) => { ...@@ -147,35 +132,119 @@ const HistoricalWeatherData = (props) => {
); );
function getData() { function getData() {
const city = document.getElementById("city").value; const city_text = document.getElementById("city_text").value;
const region = document.getElementById("region").value; const region_text = document.getElementById("region_text").value;
const country = document.getElementById("country").value; const country_text = document.getElementById("country_text").value;
const latitude = document.getElementById("latitude").value; const latitude_text = document.getElementById("latitude_text").value;
const longitude = document.getElementById("longitude").value; const longitude_text = document.getElementById("longitude_text").value;
const temperature = document.getElementById("temperature").checked; const timezone_text = document.getElementById("timezone_text").value;
const isDay = document.getElementById("isDay").checked;
const condition = document.getElementById("condition").checked; //Checkboxes
const pressure = document.getElementById("pressure").checked; 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 precipitation = document.getElementById("precipitation").checked;
const humidity = document.getElementById("humidity").checked; const surface_pressure = document.getElementById("surface_pressure").checked;
const cloud = document.getElementById("cloud").checked; const wind_speed_10m = document.getElementById("wind_speed_10m").checked;
const feelslikeTemp = document.getElementById("feelslikeTemp").checked; const wind_direction_10m = document.getElementById("wind_direction_10m").checked;
const visibility = document.getElementById("visibility").checked; const wind_gusts_10m = document.getElementById("wind_gusts_10m").checked;
const uv = document.getElementById("uv").checked; const daily_time = document.getElementById("daily_time").checked;
const gust = document.getElementById("gust").checked; const temperature_2m_max = document.getElementById("temperature_2m_max").checked;
const airquality = boolToWord( const temperature_2m_min = document.getElementById("temperature_2m_min").checked;
document.getElementById("airquality").checked const temperature_2m_mean = document.getElementById("temperature_2m_mean").checked;
); const precipitation_sum = document.getElementById("precipitation_sum").checked;
const unitTemperature = document.getElementById("unitTemperature").value; const precipitation_hours = document.getElementById("precipitation_hours").checked;
const unitWindSpeed = document.getElementById("unitWindSpeed").value; const wind_speed_10m_max = document.getElementById("wind_speed_10m_max").checked;
const unitPressure = document.getElementById("unitPressure").value; const wind_gusts_10m_max = document.getElementById("wind_gusts_10m_max").checked;
const unitPrecipitation = const wind_direction_10m_dominant = document.getElementById("wind_direction_10m_dominant").checked;
document.getElementById("unitPrecipitation").value;
const output = document.getElementById("output").value;
const format = document.getElementById("format").value;
const apiKey = "1244099aeaee4b179e6111803241304"; let filterArray = [];
const apiUrl = `https://api.weatherapi.com/v1/current.${format}?key=${apiKey}&q=${city}&aqi=${airquality}`;
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) fetch(apiUrl)
.then((response) => { .then((response) => {
......
...@@ -9,11 +9,63 @@ const WeatherForecastData = (props) => { ...@@ -9,11 +9,63 @@ const WeatherForecastData = (props) => {
<div className="thq-grid-5"> <div className="thq-grid-5">
<div class="filter"> <div class="filter">
<div> <div>
<input type="checkbox" id="last_updated_epoch" class="checkBoxFilter" /> <label for="location">Location:</label>
<label for="last_updated_epoch">Last Updated Epoch</label> <input type="text" id="city_text" placeholder="Location" />
<br /> <br />
<input type="checkbox" id="last_updated" class="checkBoxFilter" /> <label for="region">Region:</label>
<label for="last_updated">Last Updated</label> <input type="text" id="region_text" placeholder="Region" />
<br />
<label>Country:</label>
<input type="text" id="country_text" placeholder="Country" />
<br />
<label>Latitude:</label>
<input type="text" id="latitude_text" placeholder="Latitude" />
<label>Longitude:</label>
<input type="text" id="longitude_text" placeholder="Longitude" />
<br />
</div>
<div>
<input type="checkbox" id="name" className="checkBoxFilter" />
<label> City Name</label>
<br />
<input type="checkbox" id="region" className="checkBoxFilter" />
<label> Region</label>
<br />
<input type="checkbox" id="country" className="checkBoxFilter" />
<label> Country</label>
<br />
<input type="checkbox" id="lon" className="checkBoxFilter" />
<label> Longitude</label>
<br />
<input type="checkbox" id="lat" className="checkBoxFilter" />
<label> Latitude</label>
<br />
<input type="checkbox" id="tz_id" className="checkBoxFilter" />
<label> Timezone Id</label>
<br />
<input
type="checkbox"
id="localtime_epoch"
className="checkBoxFilter"
/>
<label> Localtime Epoch</label>
<br />
<input type="checkbox" id="localtime" className="checkBoxFilter" />
<label> Localtime</label>
<br />
<input
type="checkbox"
id="last_updated_epoch"
className="checkBoxFilter"
/>
<label> Last Updated Epoch</label>
<br />
<input
type="checkbox"
id="last_updated"
className="checkBoxFilter"
/>
<label> Last Updated</label>
<br /> <br />
<input type="checkbox" id="date" class="checkBoxFilter" /> <input type="checkbox" id="date" class="checkBoxFilter" />
<label for="date">Date</label> <label for="date">Date</label>
...@@ -148,6 +200,34 @@ const WeatherForecastData = (props) => { ...@@ -148,6 +200,34 @@ const WeatherForecastData = (props) => {
<label for="hour_uv">Hour UV</label> <label for="hour_uv">Hour UV</label>
<br /> <br />
<br /> <br />
<div>
<label for="units">Choose a unit:</label>
<select name="unnits" id="units">
<option value="world">Rest of The World</option>
<option value="american">American units: /eagles per shool shootings</option>
</select>
</div>
<div>
<button className="thq-button-filled" onClick={getData}>
Generate
</button>
</div>
<br />
<div class="output">
<h2>Output:</h2>
<br />
<pre id="weatherData"></pre>
</div>
<div id="apiUrl">
<label>API URL:</label>
<br />
<input className="input" type="text" id="apiUrloutput" readOnly />
</div>
<button className="APIButton" onClick={searchAPI}>
City api
</button>
<br />
<br />
</div> </div>
</div> </div>
</div> </div>
...@@ -156,35 +236,129 @@ const WeatherForecastData = (props) => { ...@@ -156,35 +236,129 @@ const WeatherForecastData = (props) => {
); );
function getData() { function getData() {
const city = document.getElementById("city").value; const city = document.getElementById("city_text").value;
const region = document.getElementById("region").value; const region = document.getElementById("region_text").value;
const country = document.getElementById("country").value; const country = document.getElementById("country_text").value;
const latitude = document.getElementById("latitude").value; const latitude = document.getElementById("latitude_text").value;
const longitude = document.getElementById("longitude").value; const longitude = document.getElementById("longitude_text").value;
const temperature = document.getElementById("temperature").checked;
const isDay = document.getElementById("isDay").checked; const name = document.getElementById("name").checked;
const condition = document.getElementById("condition").checked; const regionCheckbox = document.getElementById("region").checked;
const pressure = document.getElementById("pressure").checked; const countryCheckbox = document.getElementById("country").checked;
const precipitation = document.getElementById("precipitation").checked; const lon = document.getElementById("lon").checked;
const humidity = document.getElementById("humidity").checked; const lat = document.getElementById("lat").checked;
const cloud = document.getElementById("cloud").checked; const tz_id = document.getElementById("tz_id").checked;
const feelslikeTemp = document.getElementById("feelslikeTemp").checked; const localtime_epoch = document.getElementById("localtime_epoch").checked;
const visibility = document.getElementById("visibility").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 uv = document.getElementById("uv").checked;
const gust = document.getElementById("gust").checked; const sunrise = document.getElementById("sunrise").checked;
const airquality = boolToWord( const sunset = document.getElementById("sunset").checked;
document.getElementById("airquality").checked const moonrise = document.getElementById("moonrise").checked;
); const moonset = document.getElementById("moonset").checked;
const unitTemperature = document.getElementById("unitTemperature").value; const moon_phase = document.getElementById("moon_phase").checked;
const unitWindSpeed = document.getElementById("unitWindSpeed").value; const moon_illumination = document.getElementById("moon_illumination").checked;
const unitPressure = document.getElementById("unitPressure").value; const hour_time_epoch = document.getElementById("hour_time_epoch").checked;
const unitPrecipitation = const hour_time = document.getElementById("hour_time").checked;
document.getElementById("unitPrecipitation").value; const hour_temp = document.getElementById("hour_temp").checked;
const output = document.getElementById("output").value; const hour_is_day = document.getElementById("hour_is_day").checked;
const format = document.getElementById("format").value; 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;
const apiKey = "1244099aeaee4b179e6111803241304"; let filterArray = [];
const apiUrl = `https://api.weatherapi.com/v1/current.${format}?key=${apiKey}&q=${city}&aqi=${airquality}`;
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("hourly_time_epoch");
if (hour_time) filterArray.push("hourly_time");
if (hour_temp) filterArray.push("hourly_temp");
if (hour_is_day) filterArray.push("hourly_is_day");
if (hour_condition_text) filterArray.push("hourly_condition_text");
if (hour_condition_icon) filterArray.push("hourly_condition_icon");
if (hour_condition_code) filterArray.push("hourly_condition_code");
if (hour_wind) filterArray.push("hourly_wind");
if (hour_wind_degree) filterArray.push("hourly_wind_degree");
if (hour_wind_dir) filterArray.push("hourly_wind_dir");
if (hour_pressure) filterArray.push("hourly_pressure");
if (hour_precip) filterArray.push("hourly_precip");
if (hour_humidity) filterArray.push("hourly_humidity");
if (hour_cloud) filterArray.push("hourly_cloud");
if (hour_feelslike) filterArray.push("hourly_feelslike");
if (hour_windchill) filterArray.push("hourly_windchill");
if (hour_heatindex) filterArray.push("hourly_heatindex");
if (hour_dewpoint) filterArray.push("hourly_dewpoint");
if (hour_vis) filterArray.push("hourly_vis");
if (hour_gust) filterArray.push("hourly_gust");
if (hour_uv) filterArray.push("hourly_uv");
let filterString = filterArray.join(",");
console.log("FilterString = " + filterString);
const apiUrl = `http://localhost:8080/currentweather?q=${city_text}&filter=${filterString}`;
fetch(apiUrl) fetch(apiUrl)
.then((response) => { .then((response) => {
......
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