<!-- This page serves the automatic html form elements display -->
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    <script type="text/javascript">
        $('#execute').bind('click', function() {
            $('#execute').html('Processing <i class="fa fa-spinner fa-pulse fa-fw"></i>');
            $("#execute").attr("disabled", true);
            $('#action_form').submit();
            return false;
        });
    </script>
</head>
<div class="card-header">Set options</div>
<div class="card-body">
    <form id="action_form" method="POST" action="{{ url_for('action') }}">
        <input name="_csrf_token" type="hidden" value="{{ csrf_token() }}">
        {% for type, data in grouped_form_data.items() %}
            {% set opts = data[0] %}
            {% set names = data[1] %}
            {% set labels = data[2] %}
            {% for name in names %}
                {% set i = loop.index - 1 %}
                <div class="row justify-content-left">
                    {% if type == "select" %}
                        <div class="col-auto">
                            <select class="form-control" multiple size="3" name="{{ names[i] }}">
                                {% for e in opts[i] %}
                                    <option value="{{ e }}">{{ e }}</option>
                                {% endfor %}
                            </select>
                            <p><small>ctrl to select multiple</small></p>
                        </div>
                    {% elif type == "range" %}
                        <div class="col-2 col-slider">
                            <input type="{{ type }}" {{ opts[i] }} class="custom-range" name="{{ names[i] }}" oninput="show_value(this.name,this.value)">
                            {% set input = opts[i] %}
                            <button id="{{ names[i] }}" class="disp-value" disabled>{{ input|gdsv }}</button>
                        </div>
                    {% else %}
                        <div class="col-auto">
                            <input class="{{ type }}" type="{{ type }}" {{ opts[i] }} name="{{ names[i] }}">
                        </div>
                    {% endif %}
                    <div class="col-auto" id="label">
                        <label class="col-form-label"><b><pre class="form">{{ labels[i] }}</pre></b></label>
                    </div>
                </div>
            {% endfor %}
        {% endfor %}
        <div class="divider-vertical">
            <button id="execute" type="submit" class="btn btn-outline-dark ml-2">GO</button>
        </div>
    </form>
</div>
