{% extends "spel_base.html" %}
{% load static %}

{% block page_title %}Corpus{% endblock %}

{% block spel_content %}
    <section style="width: 1070px; margin: 0 auto">
      <div class="row">
        {% if current_ctt_id != '' %}
          <div class="col-md-7">
	        <h3>{{ demo_title }}</h3>
	        <p><strong>{{ proj_title }}</strong></p>
	        <p>{% if proj1_ldt_id %}<a href="?tag={{ tag }}&p={{ proj1_ldt_id }}">Extrait précédent</a>{% endif %}
	           {% if proj1_ldt_id and proj2_ldt_id %} - {% endif %}
	           {% if proj2_ldt_id %}<a href="?tag={{ tag }}&p={{ proj2_ldt_id }}">Extrait suivant</a>{% endif %}</p>
	        <p>{{ annot_title }}</p>
	        <p>{{ annot_description }}</p>
	        <p>{{ annot_tags|safe }}</p>
	      </div>
		  <div class="col-md-5">
			  <p>Tous les extraits :</p>
			  <div class="link-table">
			    <table class="table table-striped table-condensed">
			      {% for c in contents %}
			      <tr>
			        <td>{{ forloop.counter }}</td>
			        <td>{% if current_ctt_id != c.front_project.ldt_id %}<a href="?tag={{ tag }}&p={{ c.front_project.ldt_id }}">{% endif %}{{ c.title|slice:"7:" }}{% if current_ctt_id != c.front_project.ldt_id %}</a>{% endif %}</td>
			      </tr>
			      {% endfor %}
			    </table>
			  </div>
		  </div>
        {% else %}
          <h2>Démonstrateur : choisissez une scène</h2>
          <p><a href="?tag=demo1_theatre&p={{ proj1_ldt_id }}">Scène d'introduction - Duo Brick et Maggy [répliques 7-1 à 9-5]</a></p>
          <p><a href="?tag=demo2_theatre&p={{ proj2_ldt_id }}">Scène duo Brick et Grand Pa [répliques 51-13 à 56-15]</a></p>
        {% endif %}
      </div>
      <div id="LdtPlayer"></div>
      <div id="AnnotationsListContainer"></div>
    </section>
  {% if current_ctt_id != '' %}
    <script type="text/javascript" src="{% static 'spel/lib/jquery.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'spel/lib/jquery-ui.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'spel/metadataplayer/LdtPlayer-core.js' %}"></script>
    <!--script type="text/javascript" src="{% static 'spel/metadataplayer/spel-serializer.js' %}"></script-->
    <script type="text/javascript">
    function getURLParameter(name) {
        return decodeURI(
            (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
        );
    }
    $(document).ready(function(){
        // Get group array number
        var g = getURLParameter("g");
        var d = getURLParameter("d");
        var f = getURLParameter("f");
        var p = getURLParameter("p");// project id
        if(typeof g=="string"){
            
            IriSP.libFiles.defaultDir = "{% static 'spel/lib' %}";
            IriSP.widgetsDir = "{% static 'spel/metadataplayer' %}";
            var _metadata = {
                //url: "/data/" + d + "/" + g + "/cinelab" + ( (d!="opera") ? "_iri" : "" ) + ".json",
                url: "{% url 'projectjson_id' id='' %}" + p,
                //format: 'spel'
                format: 'ldt'
            };
            var _config = {
                width : 550,
                container : 'LdtPlayer',
                default_options: {
                    metadata: _metadata
                },
                css : "{% static 'spel/metadataplayer/LdtPlayer-core.css' %}",
                widgets: [
                    /*{
                        type: "Title"
                    },*/
                    {
                        type: "HtmlPlayer", /*ou HtmlPlayer si HTML5*/
                        //video: "/data/" + d + "/" + g + "/" + f,
                        height: 320
                    },
                    { type: "Slider" },
                    { type: "Controller" },
                    {
                        type: "Segments",
                        annotation_type: ["performance","discussion"]
                    },
                    {
                        type: "Annotation",
                        show_social: false,
                        show_annotation_type: true,
                        annotation_type: ["performance","discussion"]
                    },
                    /*{
                        type: "MultiSegments",
                    },*/
                    {
                        type: "Polemic",
                        annotation_type: "interpretation",
                        only_allow_zero_duration_annotations: false,
                        search_by_default: false,
                        polemics: [
                            {
                                keywords: [ "type_inter: Identification d'un problème" ],
                                color: "#c00000"
                            },
                            {
                                keywords: [ "type_inter: scène reprise" ],
                                color: "#008000"
                            },
                            {
                                keywords: [ "type_inter: intervention MES" ],
                                color: "#0000f0"
                            },
                            {
                                keywords: [ "type_inter: Adaptation du texte" ],
                                color: "#a6cee3"
                            },
                            {
                                keywords: [ "type_inter: Décision" ],
                                color: "#1f78b4"
                            },
                            {
                                keywords: [ "type_inter: performance d'un(e) comédien(ne)" ],
                                color: "#b2df8a"
                            },
                            {
                                keywords: [ "type_inter: Improvisation" ],
                                color: "#33a02c"
                            },
                            {
                                keywords: [ "type_inter: Allemande de la scène" ],
                                color: "#fb9a99"
                            },
                            {
                                keywords: [ "type_inter: Filage de la scène" ],
                                color: "#e31a1c"
                            },
                            {
                                keywords: [ "type_inter: Interpétation alternative de mise en scène" ],
                                color: "#fdbf6f"
                            },
                            {
                                keywords: [ "type_inter: Intervention de la technique" ],
                                color: "#ff7f00"
                            },
                            {
                                keywords: [ "type_inter: Question d'espace" ],
                                color: "#cab2d6"
                            },
                            {
                                keywords: [ "type_inter: Conflit" ],
                                color: "#6a3d9a"
                            },
                            {
                                keywords: [ "type_inter: Demande d'un(e) comédien(ne)" ],
                                color: "#ffff99"
                            },
                            {
                                keywords: [ "type_inter: Référence au réel" ],
                                color: "#b15928"
                            },
                            {
                                keywords: [ "type_inter: Interprétation du texte" ],
                                color: "#8e0152"
                            },
                            {
                                keywords: [ "type_inter: Parole à l'acteur/acrtrice" ],
                                color: "#7f3b08"
                            },
                            {
                                keywords: [ "type_inter: Parole à l'acteur/actrice" ],
                                color: "#7f3b08"
                            },
                            {
                                keywords: [ "type_inter: Doutes" ],
                                color: "#80cdc1"
                            },
                            {
                                keywords: [ "type_inter: Intervention assistant metteur en scène" ],
                                color: "#ffffcc"
                            },
                            {
                                keywords: [ "type_inter: Remise en cause" ],
                                color: "#0000f0"
                            },
                        ]
                    },
                    {
                        type: "Annotation",
                        annotation_type: "interpretation",
                        show_social: false,
                        arrow_position: 0
                    },
                    {
                        type: "SpelSyncHtml",
                        container: "AnnotationsListContainer",
                        height: 600,
                        width: 500,
                        src: ( (d!="opera") ? "{% url 'spel_ctb' %}" : "")
                    },
                    {
                        type: "Mediafragment"
                    }
                ]
            };
            _myPlayer = new IriSP.Metadataplayer(_config);
        }
    });
    </script>
  {% endif %}
{% endblock %}