{% extends "base.html" %}

{% load i18n %}

{% block toolbar %}{% endblock %}
{% block content %}

<pre class="alert alert-info">{{ docstring.strip }}</pre>
    <div class="row" style="padding-left: 40px">

        <div id="function_form" class="container-fluid pull-left">
            <h2>{{ function_name }}()</h2>
            <form action="{{function_name}}" method="post">
            <table>
            {{ form }}
            </table>
            <INPUT id="zesubmit" type="submit" class="btn" value="Call {{ function_name }}()">
            </form>
        </div>
        <div class="container-fluid pull-left">
            <h2>{% trans "Examples:" %}</h2>
            {% trans "Using curl:" %}
            <div class="well">
                curl -X POST \<br>
                {% for i in form %}
                    -d "{{ i.name }}={{ i.value }}" \<br>
                {% endfor %}
                <a href="" id="current_url"></a>
            </div>
            {% trans "Using javascript:" %}

<pre class="well">
&lt;script src=&quot;<a href="{% url "rest.views.list_modules" %}/{{ module_name }}.js">{% url "rest.views.list_modules" %}/rest/{{ module_name }}.js</a>&quot;&gt;&lt;/script&gt;

&lt;script&gt;
parameters = {
{% for i in form %}    "{{ i.name }}":"{{ i.value }}",
{% endfor %}};

adagios.rest.{{ module_name }}.{{ function_name }}(parameters)
    .done(function(data) {
        console.log("Got this response from server: " + data);
    })
    .fail(function(data) {
        alert("Error with rest call: " + data.responseText);
    });
&lt;/script&gt;
</pre>
     </div>

    </div>
{% endblock %}

{% block footer %}
    {{ block.super }}

    <script>
        $(document).ready(function() {
        $("#current_url").text(document.URL.split('?')[0]);
    });
</script>

{% endblock %}
