{% extends "user_profile/user.html" %}
{% import "macros.html" as macros %}
{% import "user_profile/macros.html" as user_profile_macros %}
<!-- user_stats.html -->
{% block profilesection %}
    {% trans %}overview{% endtrans %}
{% endblock %}
{% block usercontent %}
    {% include "user_profile/user_info.html" %}
    <a name="questions"></a>
    {% spaceless %}
        <h2>{% trans counter=question_count %}<span class="count">{{counter}}</span> Question{% pluralize %}<span class="count">{{counter}}</span> Questions{% endtrans %}</h2>
    {% endspaceless %}
    {% include "user_profile/users_questions.html" %}
    <a name="answers"></a>
    {% spaceless %}
        <h2 style="clear:both;"><span class="count">{{ top_answer_count }}</span> {% trans counter=top_answer_count %}Answer{% pluralize %}Answers{% endtrans %}</h2>
    {% endspaceless %}
    <div class="user-stats-table">
        {% for top_answer in top_answers %}
        <div class="answer-summary">
            <a title="{{ top_answer.summary|collapse|escape }}"
                href="{% url question top_answer.thread._question_post().id %}{{ top_answer.thread.title|slugify }}#{{ top_answer.id }}">
                <span class="answer-votes {% if top_answer.accepted() %}answered-accepted{% endif %}"
                      title="{% trans answer_score=top_answer.score %}the answer has been voted for {{ answer_score }} times{% endtrans %} {% if top_answer.accepted() %}{% trans %}this answer has been selected as correct{% endtrans %}{%endif%}">
                    {{ top_answer.score }}
                </span>
            </a>
            <div class="answer-link">
                {% spaceless %}
                <a href="{% url question top_answer.thread._question_post().id %}{{ top_answer.thread.title|slugify }}#{{top_answer.id}}">{{ top_answer.thread.title|escape }}</a>
                {% endspaceless %}
                {% if top_answer.comment_count > 0 %}
                <span>
                    {% trans comment_count=top_answer.comment_count %}({{ comment_count }} comment){% pluralize %}the answer has been commented {{ comment_count }} times{% endtrans %}
                </span>
                {% endif %}
            </div>
        </div>
        {% endfor %}
    </div>
    <br/>
    <a name="votes"></a>
    {% spaceless %}
        <h2>{% trans cnt=total_votes %}<span class="count">{{cnt}}</span> Vote{% pluralize %}<span class="count">{{cnt}}</span> Votes {% endtrans %}</h2>
    {% endspaceless %}
    <div class="user-stats-table">
        <table>
            <tr>
                <td width="60">
                    <img style="cursor: default;" src="{{"/images/vote-arrow-up-on.png"|media}}" alt="{% trans %}thumb up{% endtrans %}" />
                        <span title="{% trans %}user has voted up this many times{% endtrans %}" class="vote-count">{{up_votes}}</span>
                </td>
                <td width="60">
                    <img style="cursor: default;" src="{{"/images/vote-arrow-down-on.png"|media}}" alt="{% trans %}thumb down{% endtrans %}" />
                        <span title="{% trans %}user voted down this many times{% endtrans %}" class="vote-count">{{down_votes}}</span>

                </td>
            </tr>
        </table>
    </div>
    <a name="tags"></a>
    {% spaceless %}
        <h2>{% trans counter=user_tags|length %}<span class="count">{{counter}}</span> Tag{% pluralize %}<span class="count">{{counter}}</span> Tags{% endtrans %}</h2>
    {% endspaceless %}
    <div class="user-stats-table">
        <table class="tags">
            <tr>
                <td valign="top">
                    <ul id="ab-user-tags" class="tags">
                    {% for tag in user_tags %}
                        <li>
                        {{ macros.tag_widget(
                            tag.name,
                            html_tag = 'div',
                            search_state = search_state,
                            truncate_long_tag = True,
                            extra_content =
                                '<span class="tag-number">&#215; ' ~
                                tag.user_tag_usage_count|intcomma ~
                                '</span>'
                           )
                        }}
                        </li>
                        {#
                        {% if loop.index is divisibleby 10 %}
                            </td>
                            <td width="180"  valign="top">
                        {% endif %}
                        #}
                    {% endfor %}
                    </ul>
                </td>
            </tr>
        </table>
    </div>
    {% if interesting_tag_names %}
        {{ user_profile_macros.tag_selection(interesting_tag_names, 'interesting') }}
    {% endif %}
    {% if ignored_tag_names %}
        {{ user_profile_macros.tag_selection(ignored_tag_names, 'ignored') }}
    {% endif %}
    {% if subscribed_tag_names %}
        {{ user_profile_macros.tag_selection(subscribed_tag_names, 'subscribed') }}
    {% endif %}
    {% if settings.BADGES_MODE == 'public' %}
    <a name="badges"></a>
    {% spaceless %}
    <h2>{% trans counter=total_badges %}<span class="count">{{counter}}</span> Badge{% pluralize %}<span class="count">{{counter}}</span> Badges{% endtrans %}</h2>
    {% endspaceless %}
    <div class="user-stats-table badges">
        <table>
            <tr>
                <td style="line-height:35px">
                    {% for badge, badge_user_awards in badges %}
                        <a
                            href="{{badge.get_absolute_url()}}"
                            title="{% trans description=badge.description %}{{description}}{% endtrans %}"
                            class="medal"
                        ><span class="{{ badge.css_class }}">&#9679;</span>&nbsp;{% trans name=badge.name %}{{name}}{% endtrans %}
                        </a>&nbsp;
                        <span class="tag-number">&#215;
                            <span class="badge-context-toggle">{{ badge_user_awards|length|intcomma }}</span>
                        </span>
                        <ul id="badge-context-{{ badge.id }}" class="badge-context-list" style="display:none">
                            {% for award in badge_user_awards %}
                                {% if award.content_object and award.content_object_is_post %}
                                <li>
                                    <a
                                        title="{{ award.content_object.get_snippet()|collapse }}"
                                        href="{{ award.content_object.get_absolute_url() }}"
                                    >{% if award.content_type.post_type == 'answer' %}{% trans %}Answer to:{% endtrans %}{% endif %} {{ award.content_object.thread.title|escape }}</a>
                                </li>
                                {% endif %}
                            {% endfor %}
                        </ul>
                        {% if loop.index is divisibleby 3 %}
                            </td></tr>
                            <tr><td style="line-height:35px">
                        {% endif %}
                    {% endfor %}
                </td>
            </tr>
        </table>
    </div>
    {% endif %}
{% endblock %}
{% block endjs %}
    {{ super() }}
    <script type="text/javascript">
        askbot['urls']['join_or_leave_group'] = '{% url join_or_leave_group %}';
        $(document).ready(function(){
            setup_badge_details_toggle();
            $.each($('.group-join-btn'), function(idx, elem){
                var group_join_btn = new GroupJoinButton();
                group_join_btn.decorate($(elem));
            });
        });
    </script>
    <script type='text/javascript' src='{{"/js/tag_selector.js"|media}}'></script>
{% endblock %}
<!-- end user_stats.html -->
