Browse Source

Minor update

- Added air quality.
- Added use for `$config_development` in `site-config.php` regarding the CDN.
- Improvements.
branch
Airikr 2 weeks ago
parent
commit
6cef14d4eb
  1. 3
      .htaccess
  2. 19
      configs/default-language.php
  3. 9
      index.php
  4. 35
      javascripts/main.js
  5. 175
      page-settings.php
  6. 4
      site-config.php
  7. 28
      site-header.php
  8. 92
      stylesheets/desktop.css
  9. 4
      stylesheets/portable.css
  10. 7
      stylesheets/theme-dark.css
  11. 9
      stylesheets/theme-light.css
  12. 90
      weather-data.php

3
.htaccess

@ -74,9 +74,6 @@ LimitRequestBody 10240000
RewriteRule ^update-language$ configs/default-language.php
RewriteRule ^update-settings$ configs/website-settings.php
RewriteRule ^update-settings/go$ configs/website-settings.php?go=
RewriteRule ^search-place:(.*)$ ajax/search-place.php?val=$1

19
configs/default-language.php

@ -102,6 +102,7 @@
'details_uvindex' => 'UV index',
'details_visibility' => 'Visibility',
'details_precipitation' => 'Precipitation',
'details_airquality' => 'Air quality',
'subtitle_forecast_48h' => '48 hours forecast',
'subtitle_forecast_7d' => '7 hours forecast at 11:00',
'message_moredatalateron' => 'More data will be added eventually'
@ -117,7 +118,7 @@
'subtitle_using' => 'Uses',
'opensource' => '<p>'.$config_title.' are free, licensed under <b>GNU GPLv3</b>. Go to '.link_('git.airikr.me/serenum', 'https://git.airikr.me/serenum').' to see the source code.</p>',
'privacy' => '<p>We have strict privacy rules. '.$config_title.' does not log anything about your visit - period.</p><p>For more info, choose "Privacy" in the footer.</p>',
'install' => '<p>You can install '.$config_title.' on your own server. The installation are very basic and do not require much experience. Read '.link_('INSTALL.md', 'https://git.airikr.me/serenum/website/src/branch/master/INSTALL.md').' to get started.</p>',
'install' => '<p>You can install '.$config_title.' on your own server. The installation are very basic and do not require much experience. Read '.link_('INSTALL.md', 'https://git.airikr.me/serenum/website/src/branch/branch/INSTALL.md').' to get started.</p>',
'contactus' => '<p>You can contact us via email (<b>hi@serenum.org</b>) and via '.link_('Telegram', 'https://telegram.org').' by joining our group with the following link: '.link_('t.me/'.strtolower($config_title).'foss', 'https://t.me/'.strtolower($config_title).'foss').'</p>',
'using' => '<p>Below you can see what we are using to make '.$config_title.' work.</p>'
],
@ -230,6 +231,15 @@
],
'air_quality' => [
'fair' => 'Fair',
'good' => 'Good',
'moderate' => 'Moderate',
'poor' => 'Poor',
'verypoor' => 'Very poor'
],
'various' => [
'days' => [
'mon' => 'Monday',
@ -242,7 +252,12 @@
'today' => 'Today',
'tomorrow' => 'Tomorrow'
],
'map_contributors' => 'Contributers'
'map' => [
'fullscreen' => [
'enter' => 'Enter fullscreen',
'exit' => 'Exit fullscreen'
]
]
]
];

9
index.php

@ -129,6 +129,15 @@
echo '<div class="value"></div>';
echo '</div>';
echo '<div class="item air-quality">';
echo '<div class="label">';
echo $lang->page_weather->details_airquality;
echo '</div>';
echo '<div class="value"></div>';
echo '</div>';
echo '</div>';
echo '</div>';

35
javascripts/main.js

@ -36,9 +36,18 @@ $(document).ready(function () {
message_error_api_429 = l.page_weather.error_429;
message_error_failed = l.page_weather.error_failed;
map_fullscreen_tooltip_enter = l.various.map.fullscreen.enter;
map_fullscreen_tooltip_exit = l.various.map.fullscreen.exit;
dayname_today = l.various.days.today;
dayname_tomorrow = l.various.days.tomorrow;
airquality_fair = l.air_quality.fair;
airquality_good = l.air_quality.good;
airquality_moderate = l.air_quality.moderate;
airquality_poor = l.air_quality.poor;
airquality_verypoor = l.air_quality.verypoor;
weather_01800 = l.weather.w01800,
weather_02801 = l.weather.w02801,
weather_03802 = l.weather.w03802,
@ -369,6 +378,7 @@ $(document).ready(function () {
var settings_time = $('div#settings').attr('data-time');
var apikey = $('div#settings').attr('data-apikey');
// console.log(folder_name + 'weather-data/lat:' + latitude + ',lng:' + longitude + '/settings:' + settings_unit + ',' + settings_language + ',' + settings_decimal + ',' + settings_time + (apikey != '' ? '/apikey:' + apikey : ''));
var json_call = $.getJSON(folder_name + 'weather-data/lat:' + latitude + ',lng:' + longitude + '/settings:' + settings_unit + ',' + settings_language + ',' + settings_decimal + ',' + settings_time + (apikey != '' ? '/apikey:' + apikey : ''), function(d) {
if(typeof d.error === 'undefined') {
$('.loading').hide();
@ -376,6 +386,18 @@ $(document).ready(function () {
displaymap(latitude, longitude, false, false, false);
if(d.ai.qu == 1) {
var air_quality = airquality_good;
} else if(d.ai.qu == 2) {
var air_quality = airquality_fair;
} else if(d.ai.qu == 3) {
var air_quality = airquality_moderate;
} else if(d.ai.qu == 4) {
var air_quality = airquality_poor;
} else if(d.ai.qu == 5) {
var air_quality = airquality_verypoor;
}
$('.weather > .report > .short > .datetime').html(moment.unix(d.ts_pl).format('YYYY-MM-DD, ' + (settings_time == '24h' ? 'HH:mm' : 'h:mm a')));
$('.weather > .report > .short > .current > .temperature').html(temperature(d.tp, settings_unit, settings_decimal));
$('.weather > .report > .short > .weather-text').text(capitalizeFirstLetter(weather_name[d.wt_ic.slice(0, -1) + '-' + d.wt_id]));
@ -390,6 +412,7 @@ $(document).ready(function () {
$('.weather > .report > .details > .item.clouds > .value').text(format('0' + (settings_decimal == 'dot' ? '.' : ',') + '#', d.cl) + '%');
$('.weather > .report > .details > .item.visibility > .value').text(format('0' + (settings_decimal == 'dot' ? '.' : ',') + '#', d.vi) + ' ' + (settings_unit == 'metric' ? 'km' : 'mi'));
$('.weather > .report > .details > .item.precipitation > .value').text(format('0' + (settings_decimal == 'dot' ? '.' : ',') + '##', d.pr_1h) + ' mm');
$('.weather > .report > .details > .item.air-quality > .value').html(d.ai.qu + ' AQI<div class="explaination ' + air_quality.toLowerCase().replace(/\s+/g, '') + '">' + air_quality.toLowerCase() + '</div>');
$.each(d.hr.da, function(k, v) {
var get_today = moment(v.ts_str.dt).tz(d.tz).format('X');
@ -410,6 +433,7 @@ $(document).ready(function () {
});
} else {
var errmsgs = {
'401': message_error_api_401,
@ -457,11 +481,18 @@ function displaymap(lat, lng, draggable = true, tapable = true, zoomscroll = tru
map = L.map('map', options).setView(coordinates, default_zoom);
marker = new L.marker(coordinates, { draggable: draggable }).addTo(map);
map.addControl(new L.Control.Fullscreen());
map.addControl(new L.Control.Fullscreen({
title: {
'false': map_fullscreen_tooltip_enter,
'true': map_fullscreen_tooltip_exit
}
}));
map.on('fullscreenchange', function() {
if(!map.isFullscreen()) {
map.panTo(coordinates);
var coordinates = marker.getLatLng();
var coordinates = new L.LatLng(coordinates.lat, coordinates.lng);
map.setView(coordinates, 8);
}
});

175
page-settings.php

@ -31,64 +31,75 @@
# echo '<form action="'.url('form:settings').'" method="POST" autocomplete="off" novalidate>';
echo '<form action="javascript:void(0)" method="GET" autocomplete="off" novalidate>';
if($config_allow_search == true) {
echo '<div class="side-by-side">';
if($config_allow_gps == true) {
echo '<div class="gps">';
echo '<h4>';
echo svgicon('gps');
echo $lang->page_settings->subtitle_gps;
echo '</h4>';
echo '<div class="desc">';
echo $lang->page_settings->desc_gps;
echo '</div>';
echo '<div class="side-by-side">';
echo '<div class="gps';
echo ($config_allow_gps == false ? ' disabled' : '');
echo '">';
echo '<div class="option">';
echo '<a href="javascript:void(0)" id="gps">';
echo $lang->page_settings->gps_fetch;
echo '</a>';
echo '<h4>';
echo svgicon('gps');
echo $lang->page_settings->subtitle_gps;
echo '</h4>';
echo '<span class="fetching">';
echo $lang->page_settings->gps_fetching;
echo '</span>';
echo '<div class="desc">';
echo $lang->page_settings->desc_gps;
echo '</div>';
echo '<span class="js-disabled">';
echo $lang->page_settings->gps_fetch;
echo '</span>';
echo '</div>';
echo '</div>';
}
echo '<div class="option">';
echo '<a href="javascript:void(0)" id="gps"'.($config_allow_gps == false ? ' class="hidden"' : '').'>';
echo $lang->page_settings->gps_fetch;
echo '</a>';
echo '<span class="gps-disabled'.($config_allow_gps == false ? '' : ' hidden').'">';
echo $lang->page_settings->gps_fetch;
echo '</span>';
echo '<div class="search'.($config_allow_gps == true ? ' gps-enabled' : '').'">';
echo '<h4>';
echo svgicon('search');
echo $lang->page_settings->subtitle_manualplace;
echo '</h4>';
echo '<span class="fetching">';
echo $lang->page_settings->gps_fetching;
echo '</span>';
echo '<div class="desc">';
echo '<div class="js-enabled">';
echo $lang->page_settings->desc_manualplace_jsenabled;
echo '</div>';
echo '<span class="js-disabled">';
echo $lang->page_settings->gps_fetch;
echo '</span>';
echo '</div>';
echo '<div class="js-disabled">';
echo $lang->page_settings->desc_manualplace_jsdisabled;
echo '</div>';
echo '</div>';
echo '<div class="search';
echo ($config_allow_search == false ? ' disabled' : '');
echo '">';
echo '<h4>';
echo svgicon('search');
echo $lang->page_settings->subtitle_manualplace;
echo '</h4>';
echo '<div class="desc">';
echo '<div class="js-enabled">';
echo $lang->page_settings->desc_manualplace_jsenabled;
echo '</div>';
echo '<div class="js-disabled">';
echo $lang->page_settings->desc_manualplace_jsdisabled;
echo '</div>';
echo '</div>';
echo '<div class="items '.($config_allow_gps == true ? 'column' : 'row').'">';
echo '<div class="items">';
echo '<div class="place">';
echo '<div class="item">';
echo '<div class="label">';
echo $lang->page_settings->field_place;
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-search-place">';
echo '<input type="text" name="field-search-place"';
echo ($config_allow_search == false ? ' disabled' : '');
echo '>';
echo '</div>';
echo '</div>';
@ -98,29 +109,32 @@
echo '</div></div>';
echo '<div class="result"></div>';
echo '</div>';
echo '<div class="item coordinates">';
echo '<div class="label">';
echo $lang->page_settings->field_coordinates;
echo '</div>';
echo '<div class="item coordinates">';
echo '<div class="label">';
echo $lang->page_settings->field_coordinates;
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-search-coordinates" placeholder="'.$config_default_coordinates_latitude.','.$config_default_coordinates_longitude.'" value="';
if($cookie_exists == true) {
echo $cs_coordinates;
} else {
echo (($latitude_shorten == null AND $longitude_shorten == null) ? $config_default_coordinates_latitude.','.$config_default_coordinates_longitude : $latitude_shorten.','.$longitude_shorten);
}
echo '">';
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-search-coordinates" placeholder="'.$config_default_coordinates_latitude.','.$config_default_coordinates_longitude.'" value="';
if($cookie_exists == true) {
echo $cs_coordinates;
} else {
echo (($latitude_shorten == null AND $longitude_shorten == null) ? $config_default_coordinates_latitude.','.$config_default_coordinates_longitude : $latitude_shorten.','.$longitude_shorten);
}
echo '"';
echo ($config_allow_search == false ? ' disabled' : '');
echo '>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '</div>';
@ -203,39 +217,42 @@
if($config_allow_own_apikey == true) {
echo '<div class="apikey">';
echo '<h4>';
echo svgicon('key');
echo $lang->page_settings->subtitle_apikey;
echo '</h4>';
echo '<div class="apikey';
echo ($config_allow_own_apikey == false ? ' disabled' : '');
echo '">';
echo '<div class="desc">';
echo $lang->page_settings->desc_apikey;
echo '</div>';
echo '<h4>';
echo svgicon('key');
echo $lang->page_settings->subtitle_apikey;
echo '</h4>';
echo '<div class="desc">';
echo $lang->page_settings->desc_apikey;
echo '</div>';
echo '<div class="items">';
echo '<div class="item">';
echo '<div class="label">';
echo $lang->page_settings->field_apikey;
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-api-key"';
if($cs_apikey == null) {
echo ($settings_apikey == null ? null : ' value="'.$settings_apikey.'"');
} else {
echo ' value="'.$cs_apikey.'"';
}
echo '>';
echo '<div class="items">';
echo '<div class="item">';
echo '<div class="label">';
echo $lang->page_settings->field_apikey;
echo '</div>';
echo '<div class="icon"><div>'.svgicon('clear').'</div></div>';
echo '</div>';
echo '<div class="field">';
echo '<input type="text" name="field-api-key"';
if($cs_apikey == null) {
echo ($settings_apikey == null ? null : ' value="'.$settings_apikey.'"');
} else {
echo ' value="'.$cs_apikey.'"';
}
echo ($config_allow_own_apikey == false ? ' disabled' : '');
echo '>';
echo '<div class="icon"><div>'.svgicon('clear').'</div></div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '</div>';

4
site-config.php

@ -14,9 +14,9 @@
$config_development = true; # BOOLEAN
# These are for the settings page, what will shown or not.
$config_allow_own_apikey = true; # BOOLEAN
$config_allow_search = true; # BOOLEAN
$config_allow_gps = true; # BOOLEAN
$config_allow_search = true; # BOOLEAN
$config_allow_own_apikey = true; # BOOLEAN
# Defines default values for the settings page.

28
site-header.php

@ -43,26 +43,26 @@
echo '<link type="text/css" rel="stylesheet preload" href="https://cdn.airikr.me/all.min.css">';
} else {
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/theme-'.$settings_theme.'.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.($config_development == true ? url('stylesheets/theme-'.$settings_theme.'.css?'.time(), true) : $cdnurl.'/css/theme-'.$settings_theme.'.css').'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/desktop.css?'.time(), true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.url('stylesheets/portable.css?'.time(), true).'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/pe-icon-7-weather.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/leaflet.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.$cdnurl.'/css/pretty-checkbox.min.css">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.($config_development == true ? url('stylesheets/pe-icon-7-weather.css?'.time(), true) : $cdnurl.'/css/pe-icon-7-weather.css').'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.($config_development == true ? url('stylesheets/leaflet.css?'.time(), true) : $cdnurl.'/css/leaflet.css').'">';
echo '<link type="text/css" rel="stylesheet preload" as="style" href="'.($config_development == true ? url('stylesheets/pretty-checkbox.min.css?'.time(), true) : $cdnurl.'/css/pretty-checkbox.min.css').'">';
}
echo '<script src="'.$cdnurl.'/js/jquery.min.js" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/jquery.min.js?'.time(), true) : $cdnurl.'/js/jquery.min.js').'" type="text/javascript"></script>';
echo '<script src="'.url('javascripts/main.js?'.time(), true).'" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/validator.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/moment.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/moment-timezone-with-data.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/format.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/leaflet.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/leaflet-fullscreen.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/jquery.nicescroll.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/clipboard.min.js" type="text/javascript"></script>';
echo '<script src="'.$cdnurl.'/js/js.cookie.min.js" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/validator.min.js?'.time(), true) : $cdnurl.'/js/validator.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/moment.min.js?'.time(), true) : $cdnurl.'/js/moment.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/moment-timezone-with-data.min.js?'.time(), true) : $cdnurl.'/js/moment-timezone-with-data.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/format.min.js?'.time(), true) : $cdnurl.'/js/format.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/leaflet.min.js?'.time(), true) : $cdnurl.'/js/leaflet.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/leaflet-fullscreen.min.js?'.time(), true) : $cdnurl.'/js/leaflet-fullscreen.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/jquery.nicescroll.min.js?'.time(), true) : $cdnurl.'/js/jquery.nicescroll.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/clipboard.min.js?'.time(), true) : $cdnurl.'/js/clipboard.min.js').'" type="text/javascript"></script>';
echo '<script src="'.($config_development == true ? url('javascripts/js.cookie.min.js?'.time(), true) : $cdnurl.'/js/js.cookie.min.js').'" type="text/javascript"></script>';
echo '</head>';
echo '<body>';

92
stylesheets/desktop.css

@ -391,6 +391,33 @@ section#weather > .weather > .report > .details > .item > .value {
margin-top: 5px;
}
section#weather > .weather > .report > .details > .item > .value > .explaination {
font-size: 0.780rem;
margin: 0 auto;
padding: 3px;
width: 70px;
}
section#weather > .weather > .report > .details > .item > .value > .explaination.good {
border-bottom: 2px solid var(--airquality_good);
}
section#weather > .weather > .report > .details > .item > .value > .explaination.fair {
border-bottom: 2px solid var(--airquality_fair);
}
section#weather > .weather > .report > .details > .item > .value > .explaination.moderate {
border-bottom: 2px solid var(--airquality_moderate);
}
section#weather > .weather > .report > .details > .item > .value > .explaination.poor {
border-bottom: 2px solid var(--airquality_poor);
}
section#weather > .weather > .report > .details > .item > .value > .explaination.verypoor {
border-bottom: 2px solid var(--airquality_verypoor);
}
section#weather > .weather > .forecast {
margin-top: 50px;
}
@ -507,6 +534,19 @@ section#settings > form > div:not(.side-by-side) {
flex-wrap: wrap;
}
section#settings > form > div > .disabled,
section#settings > form > .disabled {
cursor: not-allowed;
opacity: .4;
}
section#settings > form > div > .disabled > div > div > div > div > input,
section#settings > form > div > .disabled > div > div > div > input,
section#settings > form > .disabled > div > div > input {
background-color: var(--background_field_functiondisabled);
width: 100%;
}
section#settings > form > .side-by-side > .gps {
margin-right: 40px;
max-width: 250px;
@ -529,37 +569,22 @@ section#settings > form > .side-by-side > .search {
min-width: 410px;
}
section#settings > form > .side-by-side > .search.gps-enabled {
max-width: 410px;
}
section#settings > form > .side-by-side > .search > .desc {
max-width: 550px;
}
section#settings > form > .side-by-side > .search > .items.row {
align-items: flex-start;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
section#settings > form > .side-by-side > .search > .items.column > .item > div > input {
width: 410px;
}
section#settings > form > .side-by-side > .search > .items.column > .searching {
section#settings > form > .side-by-side > .search > .items > .place > .searching {
display: none;
}
section#settings > form > .side-by-side > .search > .items.column > .searching > div {
section#settings > form > .side-by-side > .search > .items > .place > .searching > div {
align-items: center;
display: flex;
flex-direction: column;
padding: 30px 0 20px 0;
}
section#settings > form > .side-by-side > .search > .items.column > .searching > div > svg {
section#settings > form > .side-by-side > .search > .items > .place > .searching > div > svg {
animation-name: spin;
animation-duration: 2500ms;
animation-iteration-count: infinite;
@ -567,29 +592,34 @@ section#settings > form > .side-by-side > .search > .items.column > .searching >
margin-bottom: 10px;
}
section#settings > form > .side-by-side > .search > .items.column > .result {
section#settings > form > .side-by-side > .search > .items > .place > .result {
display: none;
padding: 15px 5px;
}
section#settings > form > .side-by-side > .search > .items.column > .result > a {
section#settings > form > .side-by-side > .search > .items.column > .place > .result {
width: 410px;
}
section#settings > form > .side-by-side > .search > .items.row > .place > .result {
width: 440px;
}
section#settings > form > .side-by-side > .search > .items > .place > .result > a {
color: var(--color_text);
display: block;
padding: 5px;
text-decoration: none;
}
section#settings > form > .side-by-side > .search > .items.column > .item.coordinates {
section#settings > form > .side-by-side > .search > .items > .item.coordinates {
margin-top: 10px;
margin-left: 0;
}
section#settings > form > .side-by-side > .search > .items.row > .item > div > input[name="field-search-place"] {
width: 440px;
}
section#settings > form > .side-by-side > .search > .items.row > .item > div > input[name="field-search-coordinates"] {
width: 250px;
section#settings > form > .side-by-side > .search > .items > .place > .item > div > input,
section#settings > form > .side-by-side > .search > .items > .item > div > input {
width: 100%;
}
section#settings > form > .options > .items > .item > div > select[name="field-option-unit"] {
@ -627,6 +657,10 @@ section#settings > form > .apikey > .items > .item > .field > input[name="field-
width: 300px;
}
section#settings > form > .apikey.disabled > .items > .item > .field > input[name="field-api-key"] {
background-color: var(--background_field_functiondisabled);
}
section#settings > form > .apikey > .items > .item > .field > .icon {
display: none;
}
@ -978,6 +1012,10 @@ form > .button {
flex-wrap: wrap;
}
.hidden {
display: none;
}

4
stylesheets/portable.css

@ -102,6 +102,10 @@
justify-content: center;
}
section#weather > .weather > .report > .details {
justify-content: space-around;
}
section#weather > .weather > .report > .details {
margin-top: 30px;
width: 100%;

7
stylesheets/theme-dark.css

@ -2,6 +2,7 @@
--background: #18191a;
--background_field: #303133;
--background_field_error: #3b1d1c;
--background_field_functiondisabled: #2d3033;
--background_submit: #243b50;
--background_submit_disabled: #37393b;
--background_map: #111111;
@ -26,6 +27,12 @@
--color_icon_info: #94cbf7;
--color_icon_error: #f79494;
--airquality_good: #5ce247;
--airquality_fair: #e2d947;
--airquality_moderate: #e2c447;
--airquality_poor: #e24747;
--airquality_verypoor: #aa47e2;
--image_select_arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 15l-4.243-4.243 1.415-1.414L12 12.172l2.828-2.829 1.415 1.414z' fill='rgba(255,255,255,.7)'/%3E%3C/svg%3E");
--image_select_arrow_disabled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 15l-4.243-4.243 1.415-1.414L12 12.172l2.828-2.829 1.415 1.414z' fill='rgba(255,255,255,.3)'/%3E%3C/svg%3E");
}

9
stylesheets/theme-light.css

@ -2,10 +2,11 @@
--background: #ffffff;
--background_field: #ffffff;
--background_field_error: #fcebe8;
--background_field_functiondisabled: #d1d1d1;
--background_submit: #174d82;
--background_submit_disabled: #96a2ae;
--background_map: #eaeaea;
--background_intro: #f3f7fc;
--background_intro: #e1eef3;
--background_code: #fcf9e8;
--background_mapcontrols: #ffffff;
@ -26,6 +27,12 @@
--color_icon_info: #264d73;
--color_icon_error: #733326;
--airquality_good: #5ce247;
--airquality_fair: #e2d947;
--airquality_moderate: #e2c447;
--airquality_poor: #e24747;
--airquality_verypoor: #aa47e2;
--image_select_arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 15l-4.243-4.243 1.415-1.414L12 12.172l2.828-2.829 1.415 1.414z' fill='rgba(0,0,0,.7)'/%3E%3C/svg%3E");
--image_select_arrow_disabled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='24' height='24'%3E%3Cpath fill='none' d='M0 0h24v24H0z'/%3E%3Cpath d='M12 15l-4.243-4.243 1.415-1.414L12 12.172l2.828-2.829 1.415 1.414z' fill='rgba(0,0,0,.3)'/%3E%3C/svg%3E");
}

90
weather-data.php

@ -16,14 +16,16 @@
$exclude = [];
$url = @file_get_contents('https://api.openweathermap.org/data/2.5/onecall?lat='.$latitude_shorten.'&lon='.$longitude_shorten . (empty($exclude) ? '' : '&exclude='.implode(',', $exclude)).'&units='.$unit.'&lang='.$language.'&appid='.$apikey);
$data = json_decode($url);
$url_weather = @file_get_contents('https://api.openweathermap.org/data/2.5/onecall?lat='.$latitude_shorten.'&lon='.$longitude_shorten . (empty($exclude) ? '' : '&exclude='.implode(',', $exclude)).'&units='.$unit.'&lang='.$language.'&appid='.$apikey);
$url_air = @file_get_contents('http://api.openweathermap.org/data/2.5/air_pollution?lat='.$latitude_shorten.'&lon='.$longitude_shorten.'&appid='.$apikey);
$data_weather = json_decode($url_weather);
$data_air = json_decode($url_air);
# echo '<pre>'; var_dump($data); echo '</pre>';
# echo '<pre>'; var_dump($data_air); echo '</pre>';
if($url === false) {
if($url_weather === false) {
$error = error_get_last();
if(strpos($error['message'], '401') !== false) {
@ -47,9 +49,9 @@
} else {
foreach($data->daily AS $daily) {
foreach($data_weather->daily AS $daily) {
$timestamp = new DateTime(date('Y-m-d H:i', $daily->dt));
$timestamp->setTimeZone(new DateTimeZone($data->timezone));
$timestamp->setTimeZone(new DateTimeZone($data_weather->timezone));
$array_daily[] = [
'ts' => $daily->dt,
@ -81,9 +83,9 @@
];
}
foreach($data->hourly AS $hourly) {
foreach($data_weather->hourly AS $hourly) {
$timestamp = new DateTime(date('Y-m-d H:i', $hourly->dt));
$timestamp->setTimeZone(new DateTimeZone($data->timezone));
$timestamp->setTimeZone(new DateTimeZone($data_weather->timezone));
$array_hourly[] = [
'ts' => $hourly->dt,
@ -103,10 +105,10 @@
];
}
if(!empty($data->minutely)) {
foreach($data->minutely AS $minutely) {
if(!empty($data_weather->minutely)) {
foreach($data_weather->minutely AS $minutely) {
$timestamp = new DateTime(date('Y-m-d H:i', $minutely->dt));
$timestamp->setTimeZone(new DateTimeZone($data->timezone));
$timestamp->setTimeZone(new DateTimeZone($data_weather->timezone));
$array_minutely[] = [
'ts' => $minutely->dt,
@ -122,41 +124,57 @@
foreach($array_minutely AS $precipitation) {
$array_test[] = $precipitation['pr'];
if(!empty($array_minutely)) {
foreach($array_minutely AS $precipitation) {
$array_precip[] = $precipitation['pr'];
}
$precip = array_filter($array_precip);
$average = (count($precip) ? array_sum($precip) / count($precip) : null);
}
$precip = array_filter($array_test);
$average = (count($precip) ? array_sum($precip) / count($precip) : null);
$timezone_now = new DateTime('now', new DateTimeZone($data->timezone));
$timezone_now = new DateTime('now', new DateTimeZone($data_weather->timezone));
$json = [
'co' => [
'lat' => (float)$latitude_shorten,
'lng' => (float)$longitude_shorten
],
'tz' => $data->timezone,
'tz_os' => $data->timezone_offset,
'ts' => $data->current->dt,
'tz' => $data_weather->timezone,
'tz_os' => $data_weather->timezone_offset,
'ts' => $data_weather->current->dt,
'ts_pl' => strtotime($timezone_now->format('Y-m-d H:i:s')),
'ts_str' => [
'dt' => date('Y-m-d', $data->current->dt),
'tm' => date('H:i', $data->current->dt),
'dt' => date('Y-m-d', $data_weather->current->dt),
'tm' => date('H:i', $data_weather->current->dt),
],
'wt_id' => $data_weather->current->weather[0]->id,
'wt_ic' => $data_weather->current->weather[0]->icon,
'wt_ic_icon' => weathericon($data_weather->current->weather[0]->icon . $data_weather->current->weather[0]->id),
'wt_dc' => $data_weather->current->weather[0]->description,
'tp' => $data_weather->current->temp,
'tp_fl' => $data_weather->current->feels_like,
'tp_dp' => $data_weather->current->dew_point,
'cl' => $data_weather->current->clouds,
'ws' => $data_weather->current->wind_speed,
'wd' => $data_weather->current->wind_deg,
'pr' => $data_weather->current->pressure,
'hu' => $data_weather->current->humidity,
'uv' => $data_weather->current->uvi,
'vi' => ($unit == 'metric' ? ($data_weather->current->visibility * 0.001) : ($data_weather->current->visibility * 0.0006213711922)),
'pr_1h' => (empty($array_minutely) ? null : (float)number_format($average, 2)),
'ai' => [
'qu' => $data_air->list[0]->main->aqi,
'co' => [
'co' => $data_air->list[0]->components->co,
'no' => $data_air->list[0]->components->no,
'no2' => $data_air->list[0]->components->no2,
'o3' => $data_air->list[0]->components->o3,
'so2' => $data_air->list[0]->components->so2,
'pm2_5' => $data_air->list[0]->components->pm2_5,
'pm10' => $data_air->list[0]->components->pm10,
'nh3' => $data_air->list[0]->components->nh3
]
],
'wt_id' => $data->current->weather[0]->id,
'wt_ic' => $data->current->weather[0]->icon,
'wt_ic_icon' => weathericon($data->current->weather[0]->icon . $data->current->weather[0]->id),
'wt_dc' => $data->current->weather[0]->description,
'tp' => $data->current->temp,
'tp_fl' => $data->current->feels_like,
'tp_dp' => $data->current->dew_point,
'cl' => $data->current->clouds,
'ws' => $data->current->wind_speed,
'wd' => $data->current->wind_deg,
'pr' => $data->current->pressure,
'hu' => $data->current->humidity,
'uv' => $data->current->uvi,
'vi' => ($unit == 'metric' ? ($data->current->visibility * 0.001) : ($data->current->visibility * 0.0006213711922)),
'pr_1h' => (float)number_format($average, 2),
'mi' => [
'da' => (empty($array_minutely) ? null : $array_minutely)
],