{% extends 'admin/admin.html' %}

{% block css %}
    <style>
        * {
            font-family: "Microsoft YaHei";
        }

        .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
            vertical-align: middle;
            text-align: center;
        }

    </style>
{% endblock %}

{% block content %}
    <section class="content-header">
        <h1>豪豪视频管理系统</h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 视频管理</a></li>
            <li class="active">修改视频</li>
        </ol>
    </section>
    <section class="content" id="showcontent">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">修改视频</h3>
                    </div>
                    <form role="form" method="post" enctype="multipart/form-data">
                        <div class="box-body">
                            {# 修改视频成功时的消息提示(category_filter:分类闪现) #}
                            {% for msg in get_flashed_messages(category_filter=['ok']) %}
                                <div class="alert alert-success alert-dismissible">
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                    <h4><i class="icon fa fa-check"></i> 恭喜您,操作成功 !</h4>
                                        {{ msg }}
                                </div>
                            {% endfor %}
                            {# 修改视频失败时的消息提示 #}
                            {% for msg in get_flashed_messages(category_filter=['err']) %}
                                <div class="alert alert-danger alert-dismissible">
                                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                                    <h4><i class="icon fa fa-ban"></i> 抱歉,操作失败!</h4>
                                        {{ msg }}
                                </div>
                            {% endfor %}
                            <div class="form-group">
                                <label for="input_title">{{ form.title.label }}</label>
                                {{ form.title(value=movie.title) }}  {# value赋予标签初值 #}

                                {% for err in form.title.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_url">{{ form.url.label }}</label>
                                {{ form.url }}

                                {% for err in form.url.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                                <div style="margin-top:5px;">
                                    <div id="moviecontainer"></div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="input_info">{{ form.info.label }}</label>
                                {{ form.info }}

                                {% for err in form.info.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_logo">{{ form.logo.label }}</label>
                                {{ form.logo }}

                                {% for err in form.logo.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                                <img src="{{ url_for('static',filename='uploads/' + movie.logo) }}" style="margin-top:5px;" class="img-responsive"
                                     alt="">
                            </div>
                            <div class="form-group">
                                <label for="input_star">{{ form.star.label }}</label>
                                {{ form.star }}

                                {% for err in form.star.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_tag_id">{{ form.tag_id.label }}</label>
                                {{ form.tag_id }}

                                {% for err in form.tag_id.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_area">{{ form.area.label }}</label>
                                {{ form.area(value=movie.area) }}

                                {% for err in form.area.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_length">{{ form.length.label }}</label>
                                {{ form.length(value=movie.length) }}

                                {% for err in form.length.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                            <div class="form-group">
                                <label for="input_release_time">{{ form.release_time.label }}</label>
                                {{ form.release_time(value=movie.release_time) }}

                                {% for err in form.release_time.errors  %}
                                        <div class="col-md-12">
                                            <font style="color:red">{{ err }}</font>
                                        </div>
                                {% endfor %}
                            </div>
                        </div>
                        <div class="box-footer">
                            {{ form.submit }}
                            {{ form.csrf_token }}
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

{% block js %}
    <script>
        $(document).ready(function () {
            $('#g-3').addClass('active');
            $('#g-3-1').addClass('active');
        });
    </script>

    <!--播放页面-->
    <script src="{{ url_for('static',filename='jwplayer/jwplayer.js') }}"></script>
    <script type="text/javascript">
        jwplayer.key = "P9VTqT/X6TSP4gi/hy1wy23BivBhjdzVjMeOaQ==";

    </script>
    <script type="text/javascript">
        jwplayer("moviecontainer").setup({
            flashplayer: "{{ url_for('static',filename='jwplayer/jwplayer.flash.swf') }}",
            playlist: [{
                file: "{{ url_for('static',filename='uploads/'+movie.url) }}",
                title: {{ movie.title }}
            }],
            modes: [{
                type: "html5"
            }, {
                type: "flash",
                src: "{{ url_for('static',filename='jwplayer/jwplayer.flash.swf') }}"
            }, {
                type: "download"
            }],
            skin: {
                name: "vapor"
            },
            "playlist.position": "left",
            "playlist.size": 200,
            height: 250,
            width: 387,
        });

    </script>

    <script>
        $(document).ready(function () {
            $('#input_release_time').datepicker({
                autoclose: true,
                format: 'yyyy-mm-dd',
                language: 'zh-CN',
            });
        });

    </script>

{% endblock %}