<commit_before>{% if request.is_ajax() %}
    {%- import "shuup/front/macros/general.jinja" as macros with context -%}
    {%- import "shuup/front/macros/checkout.jinja" as checkout_macros with context -%}
{% else %}
    {% extends "shuup/front/base.jinja" %}

    {% block title %}{% trans %}Checkout{% endtrans %}{% endblock %}
    {% block content_title %}{% trans %}Checkout{% endtrans %}{% endblock %}

    {% block before_content_title %}{% endblock %}
{% endif %}

{% block content %}
    <div id="ajax_content">
        {% if view and view.phases %}
            <div class="panel-group"
                 id="accordion"
                 role="tablist"
                 aria-multiselectable="true">
                {% for phase in view.phases if phase.is_visible_for_user() %}
                <div class="panel panel-primary">
                    <div class="panel-heading" role="tab" id="headingOne">
                        <h4 class="panel-title">
                            <a role="button"
                               data-toggle="collapse"
                               data-parent="#accordion"
                               class="phase-control"
                               data-phase="{{ phase.identifier }}"
                               href="#phase-{{ phase.identifier }}"
                               aria-expanded="true"
                               aria-controls="collapseOne">
                            <span class="phase-index">{{ loop.index }}</span>. {{ phase.title }}
                            </a>
                        </h4>
                    </div>
                    <div id="phase-{{ phase.identifier }}"
                         class="panel-collapse collapse{% if phase.is_current %} in{% endif %}"
                         role="tabpanel"
                         aria-labelledby="headingOne">
                        <div class="panel-body">
                            {% if phase.is_current %}
                                <script>window.currentPhase="{{ phase.identifier }}";</script>
                                {% block checkout_phase_content %}{% endblock %}
                            {% endif %}
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
        {% endif %}
    </div>
{% endblock %}

{% block extrajs %}
    <script>
        window.submitCheckoutPhaseForm = function submitCheckoutPhaseForm(form) {
            var data = $(form).serialize();
            if (!data.includes("csrfmiddlewaretoken")) {  // no csrftoken no post
                return false;
            }
            const currentPhase = window.currentPhase;
            $.ajax({
                type: "post",
                url: "/checkout/" + window.currentPhase + "/",
                data: data,
                success: function (response) {
                    $("#ajax_content").html(response);
                    window.scrollTo(0, $("#ajax_content").offset().top);
                    if (currentPhase != window.currentPhase && form.hasClass("single-page-refresh-after")) {
                        location.reload();
                    }
                }
            });
        };

        window.moveToPhase = function moveToPhase(phase) {
            if (phase !== window.currentPhase) {
                $.ajax({
                    type: "get",
                    url: "/checkout/" + phase + "/",
                    success: function (response) {
                        $("#ajax_content").html(response);
                    }
                });
            }<commit_msg>Fix javascript type error in shop checkout<commit_after>{% if request.is_ajax() %}
    {%- import "shuup/front/macros/general.jinja" as macros with context -%}
    {%- import "shuup/front/macros/checkout.jinja" as checkout_macros with context -%}
{% else %}
    {% extends "shuup/front/base.jinja" %}

    {% block title %}{% trans %}Checkout{% endtrans %}{% endblock %}
    {% block content_title %}{% trans %}Checkout{% endtrans %}{% endblock %}

    {% block before_content_title %}{% endblock %}
{% endif %}

{% block content %}
    <div id="ajax_content">
        {% if view and view.phases %}
            <div class="panel-group"
                 id="accordion"
                 role="tablist"
                 aria-multiselectable="true">
                {% for phase in view.phases if phase.is_visible_for_user() %}
                <div class="panel panel-primary">
                    <div class="panel-heading" role="tab" id="headingOne">
                        <h4 class="panel-title">
                            <a role="button"
                               data-toggle="collapse"
                               data-parent="#accordion"
                               class="phase-control"
                               data-phase="{{ phase.identifier }}"
                               href="#phase-{{ phase.identifier }}"
                               aria-expanded="true"
                               aria-controls="collapseOne">
                            <span class="phase-index">{{ loop.index }}</span>. {{ phase.title }}
                            </a>
                        </h4>
                    </div>
                    <div id="phase-{{ phase.identifier }}"
                         class="panel-collapse collapse{% if phase.is_current %} in{% endif %}"
                         role="tabpanel"
                         aria-labelledby="headingOne">
                        <div class="panel-body">
                            {% if phase.is_current %}
                                <script>window.currentPhase="{{ phase.identifier }}";</script>
                                {% block checkout_phase_content %}{% endblock %}
                            {% endif %}
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
        {% endif %}
    </div>
{% endblock %}

{% block extrajs %}
    <script>
        window.submitCheckoutPhaseForm = function submitCheckoutPhaseForm(form) {
            var data = $(form).serialize();
            if (!data.includes("csrfmiddlewaretoken")) {  // no csrftoken no post
                return false;
            }
            const currentPhase = window.currentPhase;
            $.ajax({
                type: "post",
                url: "/checkout/" + window.currentPhase + "/",
                data: data,
                success: function (response) {
                    $("#ajax_content").html(response);
                    window.scrollTo(0, $("#ajax_content").offset().top);
                    if (currentPhase != window.currentPhase && $(form).hasClass("single-page-refresh-after")) {
                        location.reload();
                    }
                }
            });
        };

        window.moveToPhase = function moveToPhase(phase) {
            if (phase !== window.currentPhase) {
                $.ajax({
                    type: "get",
                    url: "/checkout/" + phase + "/",
                    success: function (response) {
                        $("#ajax_content").html(response);
                    }
                });
            }
{'fraction_non_alphanumeric': 0.13418662262592898, 'fraction_numerical': 0.0008257638315441783, 'mean_word_length': 1.1934802293993358, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5628760', 'n_tokens_mistral': 1889, 'n_tokens_neox': 1702, 'n_words': 338}