Check weather data
This commit is contained in:
17
inc/Feed.php
17
inc/Feed.php
@@ -232,13 +232,24 @@ class Feed extends PhpObject {
|
|||||||
$sApiUrl = self::WEATHER_HOOK.'/'.$asLatLng[0].','.$asLatLng[1].'/'.$iTimeStamp.'?'.http_build_query(self::WEATHER_PARAM);
|
$sApiUrl = self::WEATHER_HOOK.'/'.$asLatLng[0].','.$asLatLng[1].'/'.$iTimeStamp.'?'.http_build_query(self::WEATHER_PARAM);
|
||||||
$asWeather = json_decode(file_get_contents($sApiUrl), true);
|
$asWeather = json_decode(file_get_contents($sApiUrl), true);
|
||||||
|
|
||||||
|
if(array_key_exists('currentConditions', $asWeather)) { //Current conditions
|
||||||
|
$sWeatherIcon = $asWeather['currentConditions']['icon'];
|
||||||
|
$sWeatherCond = $asWeather['currentConditions']['conditions'];
|
||||||
|
$sWeatherTemp = $asWeather['currentConditions']['temp'];
|
||||||
|
}
|
||||||
|
else { //Daily Conditions
|
||||||
|
$sWeatherIcon = $asWeather['days'][0]['icon'];
|
||||||
|
$sWeatherCond = $asWeather['days'][0]['conditions'];
|
||||||
|
$sWeatherTemp = $asWeather['days'][0]['temp'];
|
||||||
|
}
|
||||||
|
|
||||||
//Get Condition ID
|
//Get Condition ID
|
||||||
$sCondKey = (new Translator(self::WEATHER_PARAM['lang']))->getTranslationKey($asWeather['currentConditions']['conditions']);
|
$sCondKey = (new Translator(self::WEATHER_PARAM['lang']))->getTranslationKey($sWeatherCond);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'weather_icon' => $asWeather['currentConditions']['icon'],
|
'weather_icon' => $sWeatherIcon,
|
||||||
'weather_cond' => $sCondKey,
|
'weather_cond' => $sCondKey,
|
||||||
'weather_temp' => floatval($asWeather['currentConditions']['temp'])
|
'weather_temp' => floatval($sWeatherTemp)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -624,10 +624,12 @@ function addSpotMessages(aoMessages) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Weather
|
//Weather
|
||||||
$Tooltip.append($('<p>', {'class':'weather', 'title':oSpot.lang(oMsg.weather_cond)})
|
if(oMsg.weather_icon) {
|
||||||
.addIcon('fa-'+oMsg.weather_icon+' fa-fw fa-lg', true)
|
$Tooltip.append($('<p>', {'class':'weather', 'title':oSpot.lang(oMsg.weather_cond)})
|
||||||
.append(oMsg.weather_temp+'°C')
|
.addIcon('fa-'+oMsg.weather_icon+' fa-fw fa-lg', true)
|
||||||
);
|
.append(oMsg.weather_temp+'°C')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//Tooltip: Medias
|
//Tooltip: Medias
|
||||||
if(oMsg.medias) {
|
if(oMsg.medias) {
|
||||||
@@ -818,7 +820,7 @@ function getPost(asPost) {
|
|||||||
.append($('<p>').addIcon('fa-time', true).append(sAbsTime))
|
.append($('<p>').addIcon('fa-time', true).append(sAbsTime))
|
||||||
.append(bTimeDiff?$('<p>').addIcon('fa-timezone', true).append(oSpot.lang('local_time', sAbsTimeLocal)):'')
|
.append(bTimeDiff?$('<p>').addIcon('fa-timezone', true).append(oSpot.lang('local_time', sAbsTimeLocal)):'')
|
||||||
.append($('<a>', {'class':'drill'})
|
.append($('<a>', {'class':'drill'})
|
||||||
.append($('<span>', {'class':'weather', 'title':oSpot.lang(asPost.weather_cond)}).addIcon('fa-'+asPost.weather_icon, true).append(asPost.weather_temp+'°C'))
|
.append((!asPost.weather_icon)?'':$('<span>', {'class':'weather', 'title':oSpot.lang(asPost.weather_cond)}).addIcon('fa-'+asPost.weather_icon, true).append(asPost.weather_temp+'°C'))
|
||||||
.append($('<img>', {'class':'staticmap', title: oSpot.lang('click_zoom'), src: getWmtsApiUrl('static', asPost.latitude, asPost.longitude, 13)}))
|
.append($('<img>', {'class':'staticmap', title: oSpot.lang('click_zoom'), src: getWmtsApiUrl('static', asPost.latitude, asPost.longitude, 13)}))
|
||||||
.append($('<span>', {'class': 'drill-icon fa-stack'})
|
.append($('<span>', {'class': 'drill-icon fa-stack'})
|
||||||
.addIcon('fa-message fa-stack-2x')
|
.addIcon('fa-message fa-stack-2x')
|
||||||
|
|||||||
Reference in New Issue
Block a user