<commit_before>{#
/**
 * Copyright (C) 2020 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% trans "Weather" %}
{% endblock %}

{% block formButtons %}
    {% if currentUser.isSuperAdmin() and settings.SERVER_MODE == "Test" %}
        {% trans "Export Template" %}, formHelpers.requestTab("forecast"| "{{ url_for("module.widget.tab.form", {tab: "exporttemplate", id: module.widget.widgetId}) }}")
    {% endif %}
    {% trans "Get Forecast" %}, formHelpers.requestTab("forecast"| "{{ url_for("module.widget.tab.form", {tab: "forecast", id: module.widget.widgetId}) }}")
{% endblock %}

{% block extra %}{{ module.templatesAvailable()|json_encode|raw }}{% endblock %}

{% block formHtml %}
    <div class="row">
        <ul class="nav nav-tabs" role="tablist">
            <li class="nav-item"><a class="nav-link active" href="#general" role="tab" data-toggle="tab"><span>{% trans "General" %}</span></a></li>
            <li class="nav-item"><a class="nav-link" href="#configurationTab" role="tab" data-toggle="tab"><span>{% trans "Configuration" %}</span></a></li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                    {% trans "Templates" %}<span class="caret"></span>
                </a>
                <div class="dropdown-menu">
                    <a class="dropdown-item" href="#templatePreset" role="tab" data-toggle="tab"><span>{% trans "Preset" %}</span></a>
                    <a class="dropdown-item" href="#backgroundTab" role="tab" data-toggle="tab"><span>{% trans "Backgrounds" %}</span></a>
                    <a class="dropdown-item template-override-controls" href="#templateTab"  role="tab" data-toggle="tab"><span>{% trans "Main Template" %}</span></a>
                    <a class="dropdown-item template-override-controls" href="#optionalStylesheetTab"  role="tab" data-toggle="tab"><span>{% trans "Optional Stylesheet" %}</span></a>
                    <a class="dropdown-item" href="#optionalJavascript" role="tab" data-toggle="tab"><span>{% trans "Optional JavaScript" %}</span></a>
                </div>
            </li>
            <li class="nav-item"><a class="nav-link" href="#cacheTab" role="tab" data-toggle="tab"><span>{% trans "Caching" %}</span></a></li>
            <li class="nav-item"><a class="nav-link" href="#forecast" role="tab" data-toggle="tab"><span>{% trans "Forecast" %}</span></a></li>
        </ul>
        <div class="col-md-12">
            <form id="forecastEditForm" class="XiboForm form-horizontal" method="put" action="{{ url_for("module.widget.edit", {id: module.widget.widgetId}) }}">
                <div class="tab-content">
                    <div class="tab-pane active" id="general">
                        {% set title %}{% trans "Name" %}{% endset %}
                        {% set helpText %}{% trans "An optional name for this widget" %}{% endset %}
                        {{ forms.input("name", title, module.getOption("name"), helpText) }}

                        {% set title %}{% trans "Set a duration?" %}{% endset %}
                        {% set helpText %}{% trans "Select to provide a specific duration for this Widget" %}{% endset %}
                        {{ forms.checkbox("useDuration", title, module.getUseDuration(), helpText) }}

                        {% set title %}{% trans "Duration" %}{% endset %}
                        {% set helpText %}{% trans "The duration in seconds this item should be displayed." %}{% endset %}
                        {{ forms.number("duration", title, module.getDuration(), helpText, "duration-fields", "required") }}

                        {% set title %}{% trans "Enable Stats Collection?" %}{% endset %}
                        {% set helpText %}{% trans "Enable the collection of Proof of Play statistics for this Widget. Ensure that ‘Enable Stats Collection’ is set to ‘On’ in the Display Settings." %}{% endset %}
                        {% set offOption %}{% trans "Off" %}{% endset %}
                        {% set onOption %}{% trans "On" %}{% endset %}
                        {% set inheritOption %}{% trans "Inherit" %}{% endset %}
                        {% set options = [
                            { id: "Off", value: offOption },
                            { id: "On", value: onOption },
                            { id: "Inherit", value: inheritOption }
                        ] %}
                        {{ forms.dropdown("enableStat", "single", title, module.getOption("enableStat", theme.getSetting("WIDGET_STATS_ENABLED_DEFAULT")), options, "id", "value", helpText) }}
                    </div>

                    <div class="tab-pane" id="configurationTab">
                        {% set title %}{% trans "Weather type" %}{% endset %}
                        {% set helpText %}{% trans "Choose between the current or forecast views" %}{% endset %}
                        {% set currentText %}{% trans "Current" %}{% endset %}
                        {% set forecastText %}{% trans "Forecast" %}{% endset %}
                        {% set options = [
                            { id: "current", value: currentText },
                            { id: "forecast", value: forecastText }
                        ] %}
                        {{ forms.dropdown("weatherType", "single", title, module.getOption("weatherType", "current"), options, "id", "value", helpText) }}

                        {% set title %}{% trans "Use the Display Location" %}{% endset %}
                        {% set helpText %}{% trans "Use the location configured on the display" %}{% endset %}
                        {{ forms.checkbox("useDisplayLocation", title, module.getOption("useDisplayLocation", 1), helpText) }}

                        {% set title %}{% trans "Latitude" %}{% endset %}
                        {% set helpText %}{% trans "The Latitude for this widget" %}{% endset %}
                        {{ forms.number("latitude", title, module.getOption("latitude"), helpText, "locationControls") }}

                        {% set title %}{% trans "Longitude" %}{% endset %}
                        {% set helpText %}{% trans "The Longitude for this widget" %}{% endset %}
                        {{ forms.number("longitude", title, module.getOption("longitude"), helpText, "locationControls") }}
                        
                        {% set title %}{% trans "Days Offset" %}{% endset %}
                        {% set helpText %}{% trans "Starting day offset" %}{% endset %}
                        {{ forms.number("dayOffset", title, module.getOption("dayOffset", 0), helpText, "forecastViewControls", "") }}

                        {% set title %}{% trans "Number of days" %}{% endset %}
                        {% set helpText %}{% trans "Number of days ( less than one week ) to display counting from the offset value onwards" %}{% endset %}
                        {{ forms.number("numDays", title, module.getOption("numDays", 1), helpText, "forecastViewControls", "required") }}

                        {% set title %}{% trans "Days Columns" %}{% endset %}
                        {% set helpText %}{% trans "Number of columns to display" %}{% endset %}
                        {{ forms.number("daysCols", title, module.getOption("daysCols", 1), helpText, "forecastViewControls", "required") }}

                        {% set title %}{% trans "Days Rows" %}{% endset %}
                        {% set helpText %}{% trans "Number of rows to display" %}{% endset %}
                        {{ forms.number("daysRows", title, module.getOption("daysRows", 1), helpText, "forecastViewControls", "required") }}

                        {% set title %}{% trans "Units" %}{% endset %}
                        {% set helpText %}{% trans "Select the units you would like to use." %}{% endset %}
                        {{ forms.dropdown("units", "single", title, module.getOption("units"), module.unitsAvailable(), "id", "value", helpText) }}

                        {% set title %}{% trans "Language" %}{% endset %}
                        {% set helpText %}{% trans "Select the language you would like to use." %}{% endset %}
                        {{ forms.dropdown("lang", "single", title, module.getOption("lang", "en"), module.supportedLanguages(), "id", "value", helpText) }}

                        {% set title %}{% trans "Only show Daytime weather conditions" %}{% endset %}
                        {% set helpText %}{% trans "Tick if you would like to only show the Daytime weather conditions." %}{% endset %}
                        {{ forms.checkbox("dayConditionsOnly", title, module.getOption("dayConditionsOnly"), helpText) }}
                    </div>

                    <div class="tab-pane" id="backgroundTab">
                        {% set title %}{% trans "Show main background?" %}{% endset %}
                        {% set nameDefault %}{% trans "Default" %}{% endset %}
                        {% set helpText %}{% trans "Show background in the main widget container" %}{% endset %}
                        {{ forms.checkbox("showMainBackground", title, module.getOption("showMainBackground", 0), helpText) }}

                        {% set attributes = [
                            { name: "data-allow-clear", value: "true" },
                            { name: "data-placeholder--id", value: null },
                            { name: "data-placeholder--value", value: "" },
                            { name: "data-search-url", value: url_for("library.search") },
                            { name: "data-search-term", value: "media" },
                            { name: "data-search-term-tags", value: "tags" },
                            { name: "data-width", value: "100%" },
                            { name: "data-id-property", value: "mediaId" },
                            { name: "data-text-property", value: "name" },
                            { name: "data-filter-options", value: '{"type":"image"}' }
                        ] %}

                        {% set backgroundTranslations = {
                            "cloudy-image": "Cloudy"|trans,
                            "day-cloudy-image": "Cloudy day"|trans,
                            "day-sunny-image": "Clear"|trans,
                            "fog-image": "Fog"|trans,
                            "hail-image": "Hail"|trans,
                            "night-clear-image": "Clear night"|trans,
                            "night-partly-cloudy-image": "Cloudy night"|trans,
                            "rain-image": "Raining"|trans,
                            "snow-image": "Snowing"|trans,
                            "windy-image": "Windy"|trans
                        } %}

                        {% set backgroundOptions = [{"mediaId": "", "name": ""}]|merge(module.getBackgroundOptions()) %}
                        {% set getBackgroundList = module.getBackgroundList() %}

                        {% set backgroundListMessage %}{% trans "Select images from the media library to replace the default weather backgrounds. The images will be used both for main background and daily backgrounds." %}{% endset %}
                        {{ forms.message(backgroundListMessage, "") }}

                        {% for backgroundEl in getBackgroundList %}
                            {% if module.getOption(backgroundEl) != backgroundEl %}
                                {% set elOption = module.getOption(backgroundEl) %}
                            {% else %}
                                {% set elOption = "" %}
                            {% endif %} 

                            {% set title = attribute(backgroundTranslations, backgroundEl) %}
                            {{ forms.dropdown(backgroundEl, "single", title, elOption, backgroundOptions, "mediaId", "name", "", "pagedSelect", "", "", "", attributes) }}
                        {% endfor %}
                    </div>

                    <div class="tab-pane" id="templatePreset">
                        {% set title %}{% trans "Weather Template" %}{% endset %}
                        {% set helpText %}{% trans "Select the template you would like to apply. This can be overridden using the check box below." %}{% endset %}
                        {{ forms.dropdown("templateId", "single", title, module.getOption("templateId"), module.templatesAvailable(), "id", "value", helpText, "template-selector-control localSelect selectPickerWithImage weather-type-targets", null, null, null, [{ name: "data-minimum-results-for-search", value: "Infinity" }, { name: "data-minimum-results-for-search", value: "Infinity" },{ name: "data-width", value: "100%" }], optionGroups, "image", "type") }}

                        {% set title %}{% trans "Override the template?" %}{% endset %}
                        {% set helpText %}{% trans "Tick if you would like to override the template." %}{% endset %}
                        {{ forms.checkbox("overrideTemplate", title, module.getOption("overrideTemplate"), helpText) }}

                        {% set useTemplatesMessage %}
                            {% trans "With Override the Template selected enter your own text, html and css by using the Templates drop down menu in the tab header above." %}                     
                        {% endset %}
                        {{ forms.message(useTemplatesMessage, 'template-override-controls') }}

                        {% set title %}{% trans "Original Width" %}{% endset %}
                        {% set helpText %}{% trans "This is the intended width of the template and is used to scale the Widget within its region when the template is applied." %}{% endset %}
                        {{ forms.number("widgetOriginalWidth", title, module.getOption("widgetOriginalWidth", undefined), helpText, "template-override-controls", "", "number") }}

                        {% set title %}{% trans "Original Height" %}{% endset %}
                        {% set helpText %}{% trans "This is the intended height of the template and is used to scale the Widget within its region when the template is applied." %}{% endset %}
                        {{ forms.number("widgetOriginalHeight", title, module.getOption("widgetOriginalHeight", undefined), helpText, "template-override-controls", "", "number") }}
                    </div>

                    <div class="tab-pane" id="templateTab">
                        <div class="form-content-title row">
                            <h4 class="col-6 text-left">{% trans "Forecast Template" %}</h4>
                        </div>

                        <div class="editor-messages">
                            {% set simpleTextEditorMessage %}
                                {% trans "Enter text or HTML in the box below." %}<br>
                            {% endset %}
                            {{ forms.message(simpleTextEditorMessage, 'template-advanced-editor-hide') }}

                            {% set simpleTextEditorMessage2 %}
                                {% trans "Enter the text to display. The red rectangle reflects the size of the region you are editing." %}
                                {% trans "Shift+Enter will drop a single line. Enter alone starts a new paragraph." %}
                            {% endset %}
                            {{ forms.message(simpleTextEditorMessage2, 'template-advanced-editor-show') }}
                        </div>

                        <div class="ckeditor_controls inline-editor-hide container-fluid" data-linked-to="template">
                            <div class="form-group row localSelect">
                                <label class="col-sm-2 control-label" for="ckeditor_snippets_select">{% trans "Snippets" %}</label>
                                <div class="col-sm-10 ckeditor_select_container weather-type-targets">
                                    {% set weatherSnippets = module.getWeatherSnippets() %}

                                    <select id="ckeditor_snippets_select" 
                                        class="ckeditor_snippets_select form-control"
                                        data-linked-to="template"
                                        data-filter-class="">
                                        <option value=""></option>

                                        {% for snippet in weatherSnippets.current %}
                                            <option value="{{ snippet }}" data-filter-class="current">{{ snippet }}</option>
                                        {% endfor %}

                                        {% for snippet in weatherSnippets.forecast %}
                                            <option value="{{ snippet }}" data-filter-class="forecast">{{ snippet }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                        </div>

                        {% set helpText %}{% trans "Enter the template for the current forecast. For a list of substitutions click Get Forecast below." %}{% endset %}
                        {{ forms.textarea("template", "", module.getOption("template"), helpText, "template-override-controls", "required", 10) }}
                    </div>

                    <div class="tab-pane" id="optionalStylesheetTab">
                        <div class="form-content-title">
                            <h4>{% trans "CSS Style Sheet" %}</h4>
                        </div>

                        {% set helpText %}{% trans "Enter a CSS style sheet to style the weather widget" %}{% endset %}
                        {{ forms.textarea("styleSheet", "", module.getOption("styleSheet"), helpText, "template-override-controls", "", 10) }}
                    </div>

                    <div class="tab-pane" id="optionalJavascript">
                        <div class="form-content-title">
                            <h4>{% trans "Optional JavaScript" %}</h4>
                        </div>

                        {{ forms.textarea("javaScript", "", module.getRawNode("javaScript"), "", "", "", 10) }}
                    </div>
                    
                    <div class="tab-pane" id="cacheTab">
                        {% set title %}{% trans "Update Interval (mins)" %}{% endset %}
                        {% set helpText %}{% trans "Please enter the update interval in minutes. This should be kept as high as possible. For example, if the data will only change once per hour this could be set to 60." %}{% endset %}
                        {{ forms.number("updateInterval", title, module.getOption("updateInterval", 60), helpText, "", "required") }}
                    </div>

                    <div class="tab-pane" id="forecast">
                        {% set message %}{% trans "Please press Get Forecast" %}{% endset %}
                        {{ forms.message(message) }}  
                    </div>
                </div>
                
                {% if module.getSetting("apiKey") == "" %}
                    {% set message %}{% trans "The Weather Widget has not been configured yet, please ask your CMS Administrator to look at it for you." %}{% endset %}
                    {{ forms.message(message, "alert alert-danger") }}
                {% endif %}
            </form>
        </div>
    </div>
{% endblock %}<commit_msg>Weather Tiles : make sure we check both darkSky and owm api key in the Widget edit form xibosignage/xibo#2588<commit_after>{#
/**
 * Copyright (C) 2020 Xibo Signage Ltd
 *
 * Xibo - Digital Signage - http://www.xibo.org.uk
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
#}

{% extends "form-base.twig" %}
{% import "forms.twig" as forms %}

{% block formTitle %}
    {% trans "Weather" %}
{% endblock %}

{% block formButtons %}
    {% if currentUser.isSuperAdmin() and settings.SERVER_MODE == "Test" %}
        {% trans "Export Template" %}, formHelpers.requestTab("forecast"| "{{ url_for("module.widget.tab.form", {tab: "exporttemplate", id: module.widget.widgetId}) }}")
    {% endif %}
    {% trans "Get Forecast" %}, formHelpers.requestTab("forecast"| "{{ url_for("module.widget.tab.form", {tab: "forecast", id: module.widget.widgetId}) }}")
{% endblock %}

{% block extra %}{{ module.templatesAvailable()|json_encode|raw }}{% endblock %}

{% block formHtml %}
    <div class="row">
        <ul class="nav nav-tabs" role="tablist">
            <li class="nav-item"><a class="nav-link active" href="#general" role="tab" data-toggle="tab"><span>{% trans "General" %}</span></a></li>
            <li class="nav-item"><a class="nav-link" href="#configurationTab" role="tab" data-toggle="tab"><span>{% trans "Configuration" %}</span></a></li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                    {% trans "Templates" %}<span class="caret"></span>
                </a>
                <div class="dropdown-menu">
                    <a class="dropdown-item" href="#templatePreset" role="tab" data-toggle="tab"><span>{% trans "Preset" %}</span></a>
                    <a class="dropdown-item" href="#backgroundTab" role="tab" data-toggle="tab"><span>{% trans "Backgrounds" %}</span></a>
                    <a class="dropdown-item template-override-controls" href="#templateTab"  role="tab" data-toggle="tab"><span>{% trans "Main Template" %}</span></a>
                    <a class="dropdown-item template-override-controls" href="#optionalStylesheetTab"  role="tab" data-toggle="tab"><span>{% trans "Optional Stylesheet" %}</span></a>
                    <a class="dropdown-item" href="#optionalJavascript" role="tab" data-toggle="tab"><span>{% trans "Optional JavaScript" %}</span></a>
                </div>
            </li>
            <li class="nav-item"><a class="nav-link" href="#cacheTab" role="tab" data-toggle="tab"><span>{% trans "Caching" %}</span></a></li>
            <li class="nav-item"><a class="nav-link" href="#forecast" role="tab" data-toggle="tab"><span>{% trans "Forecast" %}</span></a></li>
        </ul>
        <div class="col-md-12">
            <form id="forecastEditForm" class="XiboForm form-horizontal" method="put" action="{{ url_for("module.widget.edit", {id: module.widget.widgetId}) }}">
                <div class="tab-content">
                    <div class="tab-pane active" id="general">
                        {% set title %}{% trans "Name" %}{% endset %}
                        {% set helpText %}{% trans "An optional name for this widget" %}{% endset %}
                        {{ forms.input("name", title, module.getOption("name"), helpText) }}

                        {% set title %}{% trans "Set a duration?" %}{% endset %}
                        {% set helpText %}{% trans "Select to provide a specific duration for this Widget" %}{% endset %}
                        {{ forms.checkbox("useDuration", title, module.getUseDuration(), helpText) }}

                        {% set title %}{% trans "Duration" %}{% endset %}
                        {% set helpText %}{% trans "The duration in seconds this item should be displayed." %}{% endset %}
                        {{ forms.number("duration", title, module.getDuration(), helpText, "duration-fields", "required") }}

                        {% set title %}{% trans "Enable Stats Collection?" %}{% endset %}
                        {% set helpText %}{% trans "Enable the collection of Proof of Play statistics for this Widget. Ensure that ‘Enable Stats Collection’ is set to ‘On’ in the Display Settings." %}{% endset %}
                        {% set offOption %}{% trans "Off" %}{% endset %}
                        {% set onOption %}{% trans "On" %}{% endset %}
                        {% set inheritOption %}{% trans "Inherit" %}{% endset %}
                        {% set options = [
                            { id: "Off", value: offOption },
                            { id: "On", value: onOption },
                            { id: "Inherit", value: inheritOption }
                        ] %}
                        {{ forms.dropdown("enableStat", "single", title, module.getOption("enableStat", theme.getSetting("WIDGET_STATS_ENABLED_DEFAULT")), options, "id", "value", helpText) }}
                    </div>

                    <div class="tab-pane" id="configurationTab">
                        {% set title %}{% trans "Weather type" %}{% endset %}
                        {% set helpText %}{% trans "Choose between the current or forecast views" %}{% endset %}
                        {% set currentText %}{% trans "Current" %}{% endset %}
                        {% set forecastText %}{% trans "Forecast" %}{% endset %}
                        {% set options = [
                            { id: "current", value: currentText },
                            { id: "forecast", value: forecastText }
                        ] %}
                        {{ forms.dropdown("weatherType", "single", title, module.getOption("weatherType", "current"), options, "id", "value", helpText) }}

                        {% set title %}{% trans "Use the Display Location" %}{% endset %}
                        {% set helpText %}{% trans "Use the location configured on the display" %}{% endset %}
                        {{ forms.checkbox("useDisplayLocation", title, module.getOption("useDisplayLocation", 1), helpText) }}

                        {% set title %}{% trans "Latitude" %}{% endset %}
                        {% set helpText %}{% trans "The Latitude for this widget" %}{% endset %}
                        {{ forms.number("latitude", title, module.getOption("latitude"), helpText, "locationControls") }}

                        {% set title %}{% trans "Longitude" %}{% endset %}
                        {% set helpText %}{% trans "The Longitude for this widget" %}{% endset %}
                        {{ forms.number("longitude", title, module.getOption("longitude"), helpText, "locationControls") }}
                        
                        {% set title %}{% trans "Days Offset" %}{% endset %}
                        {% set helpText %}{% trans "Starting day offset" %}{% endset %}
                        {{ forms.number("dayOffset", title, module.getOption("dayOffset", 0), helpText, "forecastViewControls", "") }}

                        {% set title %}{% trans "Number of days" %}{% endset %}
                        {% set helpText %}{% trans "Number of days ( less than one week ) to display counting from the offset value onwards" %}{% endset %}
                        {{ forms.number("numDays", title, module.getOption("numDays", 1), helpText, "forecastViewControls", "required") }}

                        {% set title %}{% trans "Days Columns" %}{% endset %}
                        {% set helpText %}{% trans "Number of columns to display" %}{% endset %}
                        {{ forms.number("daysCols", title, module.getOption("daysCols", 1), helpText, "forecastViewControls", "required") }}

                        {% set title %}{% trans "Days Rows" %}{% endset %}
                        {% set helpText %}{% trans "Number of rows to display" %}{% endset %}
                        {{ forms.number("daysRows", title, module.getOption("daysRows", 1), helpText, "forecastViewControls", "required") }}

                        {% set title %}{% trans "Units" %}{% endset %}
                        {% set helpText %}{% trans "Select the units you would like to use." %}{% endset %}
                        {{ forms.dropdown("units", "single", title, module.getOption("units"), module.unitsAvailable(), "id", "value", helpText) }}

                        {% set title %}{% trans "Language" %}{% endset %}
                        {% set helpText %}{% trans "Select the language you would like to use." %}{% endset %}
                        {{ forms.dropdown("lang", "single", title, module.getOption("lang", "en"), module.supportedLanguages(), "id", "value", helpText) }}

                        {% set title %}{% trans "Only show Daytime weather conditions" %}{% endset %}
                        {% set helpText %}{% trans "Tick if you would like to only show the Daytime weather conditions." %}{% endset %}
                        {{ forms.checkbox("dayConditionsOnly", title, module.getOption("dayConditionsOnly"), helpText) }}
                    </div>

                    <div class="tab-pane" id="backgroundTab">
                        {% set title %}{% trans "Show main background?" %}{% endset %}
                        {% set nameDefault %}{% trans "Default" %}{% endset %}
                        {% set helpText %}{% trans "Show background in the main widget container" %}{% endset %}
                        {{ forms.checkbox("showMainBackground", title, module.getOption("showMainBackground", 0), helpText) }}

                        {% set attributes = [
                            { name: "data-allow-clear", value: "true" },
                            { name: "data-placeholder--id", value: null },
                            { name: "data-placeholder--value", value: "" },
                            { name: "data-search-url", value: url_for("library.search") },
                            { name: "data-search-term", value: "media" },
                            { name: "data-search-term-tags", value: "tags" },
                            { name: "data-width", value: "100%" },
                            { name: "data-id-property", value: "mediaId" },
                            { name: "data-text-property", value: "name" },
                            { name: "data-filter-options", value: '{"type":"image"}' }
                        ] %}

                        {% set backgroundTranslations = {
                            "cloudy-image": "Cloudy"|trans,
                            "day-cloudy-image": "Cloudy day"|trans,
                            "day-sunny-image": "Clear"|trans,
                            "fog-image": "Fog"|trans,
                            "hail-image": "Hail"|trans,
                            "night-clear-image": "Clear night"|trans,
                            "night-partly-cloudy-image": "Cloudy night"|trans,
                            "rain-image": "Raining"|trans,
                            "snow-image": "Snowing"|trans,
                            "windy-image": "Windy"|trans
                        } %}

                        {% set backgroundOptions = [{"mediaId": "", "name": ""}]|merge(module.getBackgroundOptions()) %}
                        {% set getBackgroundList = module.getBackgroundList() %}

                        {% set backgroundListMessage %}{% trans "Select images from the media library to replace the default weather backgrounds. The images will be used both for main background and daily backgrounds." %}{% endset %}
                        {{ forms.message(backgroundListMessage, "") }}

                        {% for backgroundEl in getBackgroundList %}
                            {% if module.getOption(backgroundEl) != backgroundEl %}
                                {% set elOption = module.getOption(backgroundEl) %}
                            {% else %}
                                {% set elOption = "" %}
                            {% endif %} 

                            {% set title = attribute(backgroundTranslations, backgroundEl) %}
                            {{ forms.dropdown(backgroundEl, "single", title, elOption, backgroundOptions, "mediaId", "name", "", "pagedSelect", "", "", "", attributes) }}
                        {% endfor %}
                    </div>

                    <div class="tab-pane" id="templatePreset">
                        {% set title %}{% trans "Weather Template" %}{% endset %}
                        {% set helpText %}{% trans "Select the template you would like to apply. This can be overridden using the check box below." %}{% endset %}
                        {{ forms.dropdown("templateId", "single", title, module.getOption("templateId"), module.templatesAvailable(), "id", "value", helpText, "template-selector-control localSelect selectPickerWithImage weather-type-targets", null, null, null, [{ name: "data-minimum-results-for-search", value: "Infinity" }, { name: "data-minimum-results-for-search", value: "Infinity" },{ name: "data-width", value: "100%" }], optionGroups, "image", "type") }}

                        {% set title %}{% trans "Override the template?" %}{% endset %}
                        {% set helpText %}{% trans "Tick if you would like to override the template." %}{% endset %}
                        {{ forms.checkbox("overrideTemplate", title, module.getOption("overrideTemplate"), helpText) }}

                        {% set useTemplatesMessage %}
                            {% trans "With Override the Template selected enter your own text, html and css by using the Templates drop down menu in the tab header above." %}                     
                        {% endset %}
                        {{ forms.message(useTemplatesMessage, 'template-override-controls') }}

                        {% set title %}{% trans "Original Width" %}{% endset %}
                        {% set helpText %}{% trans "This is the intended width of the template and is used to scale the Widget within its region when the template is applied." %}{% endset %}
                        {{ forms.number("widgetOriginalWidth", title, module.getOption("widgetOriginalWidth", undefined), helpText, "template-override-controls", "", "number") }}

                        {% set title %}{% trans "Original Height" %}{% endset %}
                        {% set helpText %}{% trans "This is the intended height of the template and is used to scale the Widget within its region when the template is applied." %}{% endset %}
                        {{ forms.number("widgetOriginalHeight", title, module.getOption("widgetOriginalHeight", undefined), helpText, "template-override-controls", "", "number") }}
                    </div>

                    <div class="tab-pane" id="templateTab">
                        <div class="form-content-title row">
                            <h4 class="col-6 text-left">{% trans "Forecast Template" %}</h4>
                        </div>

                        <div class="editor-messages">
                            {% set simpleTextEditorMessage %}
                                {% trans "Enter text or HTML in the box below." %}<br>
                            {% endset %}
                            {{ forms.message(simpleTextEditorMessage, 'template-advanced-editor-hide') }}

                            {% set simpleTextEditorMessage2 %}
                                {% trans "Enter the text to display. The red rectangle reflects the size of the region you are editing." %}
                                {% trans "Shift+Enter will drop a single line. Enter alone starts a new paragraph." %}
                            {% endset %}
                            {{ forms.message(simpleTextEditorMessage2, 'template-advanced-editor-show') }}
                        </div>

                        <div class="ckeditor_controls inline-editor-hide container-fluid" data-linked-to="template">
                            <div class="form-group row localSelect">
                                <label class="col-sm-2 control-label" for="ckeditor_snippets_select">{% trans "Snippets" %}</label>
                                <div class="col-sm-10 ckeditor_select_container weather-type-targets">
                                    {% set weatherSnippets = module.getWeatherSnippets() %}

                                    <select id="ckeditor_snippets_select" 
                                        class="ckeditor_snippets_select form-control"
                                        data-linked-to="template"
                                        data-filter-class="">
                                        <option value=""></option>

                                        {% for snippet in weatherSnippets.current %}
                                            <option value="{{ snippet }}" data-filter-class="current">{{ snippet }}</option>
                                        {% endfor %}

                                        {% for snippet in weatherSnippets.forecast %}
                                            <option value="{{ snippet }}" data-filter-class="forecast">{{ snippet }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                            </div>
                        </div>

                        {% set helpText %}{% trans "Enter the template for the current forecast. For a list of substitutions click Get Forecast below." %}{% endset %}
                        {{ forms.textarea("template", "", module.getOption("template"), helpText, "template-override-controls", "required", 10) }}
                    </div>

                    <div class="tab-pane" id="optionalStylesheetTab">
                        <div class="form-content-title">
                            <h4>{% trans "CSS Style Sheet" %}</h4>
                        </div>

                        {% set helpText %}{% trans "Enter a CSS style sheet to style the weather widget" %}{% endset %}
                        {{ forms.textarea("styleSheet", "", module.getOption("styleSheet"), helpText, "template-override-controls", "", 10) }}
                    </div>

                    <div class="tab-pane" id="optionalJavascript">
                        <div class="form-content-title">
                            <h4>{% trans "Optional JavaScript" %}</h4>
                        </div>

                        {{ forms.textarea("javaScript", "", module.getRawNode("javaScript"), "", "", "", 10) }}
                    </div>
                    
                    <div class="tab-pane" id="cacheTab">
                        {% set title %}{% trans "Update Interval (mins)" %}{% endset %}
                        {% set helpText %}{% trans "Please enter the update interval in minutes. This should be kept as high as possible. For example, if the data will only change once per hour this could be set to 60." %}{% endset %}
                        {{ forms.number("updateInterval", title, module.getOption("updateInterval", 60), helpText, "", "required") }}
                    </div>

                    <div class="tab-pane" id="forecast">
                        {% set message %}{% trans "Please press Get Forecast" %}{% endset %}
                        {{ forms.message(message) }}  
                    </div>
                </div>
                
                {% if module.getSetting("apiKey") == "" and module.getSetting("owmApiKey") == "" %}
                    {% set message %}{% trans "The Weather Widget has not been configured yet, please ask your CMS Administrator to look at it for you." %}{% endset %}
                    {{ forms.message(message, "alert alert-danger") }}
                {% endif %}
            </form>
        </div>
    </div>
{% endblock %}
{'fraction_non_alphanumeric': 0.1452470179048179, 'fraction_numerical': 0.0021064491635437335, 'mean_word_length': 1.6950953858340485, 'pattern_counts': {'":': 26, '<': 227, '<?xml version=': 0, '>': 227, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 64, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2337944', 'n_tokens_mistral': 10626, 'n_tokens_neox': 9660, 'n_words': 2757}