core-forecastioWeatherCoreA module for displaying weather information. Uses the Forecast APIfa fa-cloud\Xibo\Widget\Compatibility\WeatherWidgetCompatibility\Xibo\Widget\Validator\DisplayOrGeoValidatorforecastioforecast%useDisplayLocation%_%latitude%_%longitude%_%units%_%lang%211html60weather_attributionUse the Display LocationUse the location configured on the display1LatitudeThe Latitude for this widget#DEFAULT_LAT#0LongitudeThe Longitude for this widget#DEFAULT_LONG#0UnitsSelect the units you would like to use.autoLanguageSelect the language you would like to use.enOnly show Daytime weather conditionsTick if you would like to only show the Daytime weather conditions.Horizontal AlignHow should this widget be horizontally aligned?centerVertical AlignHow should this widget be vertically aligned?middle 0) {
moment.locale(properties.lang);
} else {
moment.locale(globalOptions.locale);
}
// Make replacements [] with target data
var makeReplacement = function(html, item) {
// Make replacements [] with item data
var replacer = function(match, key) {
if (key === 'time' || key.indexOf('time|') === 0) {
if (key.indexOf('time|') === 0) {
return moment.unix(item.time).format(key.split('|')[1]);
}
// Else return the time
return moment.unix(item.time).format('h:mm a');
}
// If its [icon] or [wicon] and we have properties.dayConditionsOnly then return the day icon
if(properties.dayConditionsOnly == 1 && (key === 'icon' || key === 'wicon')) {
return item[key].replace('-night', '');
}
// If its [poweredBy] then return the powered by html
if (key === 'Attribution') {
return meta.Attribution;
}
return item[key];
};
return html.replace(/\[([^\]]+)\]/g, replacer);
}
// Get content container
var $content = $(target).find('#content');
// Clear content container
$content.empty();
// Get current day (main) template and clone its contents
var currentContainerHTML = $(target).find('.current-day-template').html();
if (currentContainerHTML) {
// Make replacements [] with current day data
currentContainerHTML = makeReplacement(currentContainerHTML, items[0]);
// Add current day (main) template to content container
$content.append(currentContainerHTML);
}
// Make replacements if we have bg-div
var bgDivHTML = $(target).find('.bg-div').prop('outerHTML');
if (bgDivHTML) {
// Make replacements [] with current day data
bgDivHTML = makeReplacement(bgDivHTML, items[0]);
// Replace bg-div with current day data
$(target).find('.bg-div').replaceWith(bgDivHTML);
}
// Get the forecast container from current day template
var $forecastContainer = $content.find('.forecast-container');
// Get the forecast template
var forecastTemplateHTML = $(target).find('.forecast-day-template').html();
// If we have a forecast container
// Get the number of days to show for the forecast
var daysNum = $forecastContainer.data('days-num');
// Check if we have forecast days to add
if (daysNum > 0) {
// Empty container
$forecastContainer.empty();
var slicer = function(day, index) {
// Check if we are within the number of days
if (index < daysNum) {
// Make replacements [] with forecast day data
var forecastDayHTML = makeReplacement(forecastTemplateHTML, day);
// Add forecast day to forecast container
$forecastContainer.append(forecastDayHTML);
}
};
// Add the forecast days
items.slice(1).forEach(slicer);
}
// Handle images and scaling
$content.xiboLayoutScaler(properties);
$(target).find("img").xiboImageRender(properties);
]]>