schema_info_part.html 2.45 KB
Newer Older
Pierre Dittgen's avatar
Pierre Dittgen committed
1 2
<h5 class="card-title">
    Schéma
3 4
    {% if schema_info.title %}
    « {{ schema_info.title }} »
Pierre Dittgen's avatar
Pierre Dittgen committed
5
    {% endif %}
6 7
    {% if schema_info.version %}
    <span class="badge badge-primary">{{ schema_info.version }}</span>
Pierre Dittgen's avatar
Pierre Dittgen committed
8
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
9
</h5>
10 11
{% if schema_info.description %}
<h6 class="card-subtitle mb-2 text-muted">{{ schema_info.description }}</h6>
Pierre Dittgen's avatar
Pierre Dittgen committed
12
{% endif %}
13
{% if schema_info.author or schema_info.contributor %}
Pierre Dittgen's avatar
Pierre Dittgen committed
14
<p>
15 16
    {% if schema_info.author %}
    Auteur : {{ schema_info.author }}
Pierre Dittgen's avatar
Pierre Dittgen committed
17
    {% endif %}
18 19
    {% if schema_info.contributor %}
    <br />Contributeur(s) : {{ schema_info.contributor }}
Pierre Dittgen's avatar
Pierre Dittgen committed
20 21 22
    {% endif %}
</p>
{% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
23
{% if schema_info.doc_url or schema_info.url %}
Pierre Dittgen's avatar
Pierre Dittgen committed
24
<p>
25 26
    {% if schema_info.doc_url %}
    <a href="{{ schema_info.doc_url }}" target="_blank" class="card-link">Documentation</a>
Pierre Dittgen's avatar
Pierre Dittgen committed
27
    {% endif %}
Pierre Dittgen's avatar
Pierre Dittgen committed
28 29 30 31 32 33 34
    {% if schema_info.url %}
    Source : <a href="{{ schema_info.url }}" target="_blank" title="{{ schema_info.url }}" class="card-link">{{ schema_info.url | truncate(40) }}</a>
    {% endif %}
</p>
{% endif %}
{% if schema_versions %}
<p>
35
    Changer de version Git :
Pierre Dittgen's avatar
Pierre Dittgen committed
36 37 38 39 40
    <select id="version_select">
        {% for sv in schema_versions %}
        <option{% if sv == schema_current_version %} selected="selected"{% endif %}>{{ sv }}</option>
        {% endfor %}
    </select>
Pierre Dittgen's avatar
Pierre Dittgen committed
41
</p>
Pierre Dittgen's avatar
Pierre Dittgen committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
<script>
    var vbox = $('#version_select');
    vbox.on('change', function() {

        // Extract base url and query string
        var current_url = document.location.href;
        var base_url = current_url;
        var query_string = "";
        var qidx = current_url.indexOf('?');
        if (qidx != -1) {
            query_string = current_url.substring(qidx+1);
            base_url = current_url.substring(0, qidx);
        }

        // Transforms query string into parameter dictionary
        // ignoring schema_ref parameter if exists
        var params = query_string.split("&");
        var param_dict = {};
        for (var i=0; i<params.length; i++) {
            var pair = params[i].split('=');
            if (pair[0] != 'schema_ref') {
                param_dict[pair[0]] = pair[1];
            }
        }
        param_dict['schema_ref'] = encodeURIComponent(vbox.val());

        // Build new URL to redirect to
        var param_list = [];
        for (p in param_dict) {
            param_list.push(p + '=' + param_dict[p]);
        }
        var new_url = base_url + '?' + param_list.join('&');
        document.location.href = new_url;
    })
</script>
{% endif %}