Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Forecast Temperature when using OpenWeatherMap #18

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
80 changes: 80 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"SettingWidget2ID",
"SettingWidget3ID"
],

"resources": {
"media": [
{
Expand Down
Binary file added src/.DS_Store
Binary file not shown.
16 changes: 9 additions & 7 deletions src/pkjs/weather_owm.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,19 @@ function getIconForConditionCode(conditionCode, isNight) {
function extractFakeDailyForecast(json) {
var todaysForecast = {};

// find the max and min of those temperatures
todaysForecast.highTemp = -Number.MAX_SAFE_INTEGER;
todaysForecast.lowTemp = Number.MAX_SAFE_INTEGER;
// Set the high and low temp to the first interval's values. Avoids returning an invalid number as the temperature.
todaysForecast.highTemp = json.list[0].main.temp_max;
todaysForecast.lowTemp = json.list[0].main.temp_min;

for(var i = 0; i < json.list.length; i++) {
if(todaysForecast.highTemp < json.list[i].main.temp_max) {
//Iterates from 1 instead of 0 because we already stored those values
for(var i = 1; i < json.list.length; i++) {
if(json.list[i].main.temp_max < todaysForecast.highTemp) {
todaysForecast.highTemp = json.list[i].main.temp_max;
//console.log('High temp updated to: ' + todaysForecast.highTemp);
}

if(todaysForecast.lowTemp > json.list[i].main.temp_min) {
if(json.list[i].main.temp_min < todaysForecast.lowTemp) {
todaysForecast.lowTemp = json.list[i].main.temp_min;
//console.log('Low temp updated to: ' + todaysForecast.lowTemp);
}
}

Expand Down