core-forecastio Weather Core A module for displaying weather information. Uses the Forecast API fa fa-cloud \Xibo\Widget\Compatibility\WeatherWidgetCompatibility \Xibo\Widget\Validator\DisplayOrGeoValidator forecastio forecast %useDisplayLocation%_%latitude%_%longitude%_%units%_%lang% 2 1 1 html 60 weather_attribution Use the Display Location Use the location configured on the display 1 Latitude The Latitude for this widget #DEFAULT_LAT# 0 Longitude The Longitude for this widget #DEFAULT_LONG# 0 Units Select the units you would like to use. auto Language Select the language you would like to use. en Only show Daytime weather conditions Tick if you would like to only show the Daytime weather conditions. Horizontal Align How should this widget be horizontally aligned? center Vertical Align How 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); ]]>