<html>
  <head>
    <title>نیکاس - مدیریت</title>
    <link
      type="text/css"
      href="{{ nikas_host_script }}/css/nikas.css"
      rel="stylesheet"
    />
    <link
      type="text/css"
      href="{{ nikas_host_script }}/css/admin.css"
      rel="stylesheet"
    />
    <link
      rel="shortcut icon"
      href="{{ nikas_host_script }}/img/favicon.ico"
      type="image/x-icon"
    />
    <link
      rel="icon"
      href="{{ nikas_host_script }}/img/favicon.ico"
      type="image/x-icon"
    />
    <script
      type="text/javascript"
      src="{{ nikas_host_script }}/js/admin.js"
    ></script>
  </head>
  <body>
    <div class="wrapper">
      <div class="header-container">
        <div class="header">
          <header>
            <img
              class="logo"
              src="{{ nikas_host_script }}/img/logo.png"
              alt="logo"
            />
            <div class="title">
              <a href="#">
                <h1>نیکاس</h1>
              </a>
            </div>
          </header>
          <div class="logout">
            <a href="/logout">خروج</a>
          </div>
        </div>
      </div>
      <div class="outer">
        <div class="filters">
          <div class="mode">
            <a href="?mode=4&page={{ page }}&order_by={{ order_by }}">
              <span
                class="label label-staled {% if mode == 4 %}active{% endif %}"
              >
                قدیمی ({{ counts.get(4, 0) }})
              </span>
            </a>
            <a href="?mode=1&page={{ page }}&order_by={{ order_by }}">
              <span
                class="label label-valid {% if mode == 1 %}active{% endif %}"
              >
                تایید شده ({{ counts.get(1, 0) }})
              </span>
            </a>
            <a href="?mode=2&page={{ page }}&order_by={{ order_by }}">
              <span
                class="label label-pending {% if mode == 2 %}active{% endif %}"
              >
                در انتظار بررسی ({{ counts.get(2, 0) }})
              </span>
            </a>
          </div>
          <div class="group">
            دسته بندی بر اساس منبع <input type="checkbox" {% if order_by ==
            "tid" %}checked{% endif %}
            onClick="javascript:window.location='?mode={{ mode }}&page={{ page
            }}&order_by={% if order_by == "tid" %}id{% else %}tid{% endif %}';"
            />
          </div>
          <div class="pagination">
            صفحه {% if page > 0 %}
            <a href="?mode={{ mode }}&page={{ page - 1 }}"> « </a>
            {% endif %}
            <input type="text" size="1" name="page" value="{{ page }}" />
            {% if page < max_page %}
            <a href="?mode={{ mode }}&page={{ page + 1 }}"> » </a>
            {% endif %} از {{ max_page }}
          </div>
        </div>
        <div class="filters order">
          ترتیب : {% for order in ['شماره', 'تاریخ ثبت', 'تاریخ ویرایش', 'لایک',
          'دیس لایک'] %}
          <a
            href="?mode={{ mode }}&page={{ page }}&order_by={{ order }}&asc={{ 1 - asc }}"
          >
            <span
              class="label label-valid {% if order == order_by %}active{% endif %}"
            >
              {{ order }} {% if order == order_by %} {% if asc %} ↑ {% else %} ↓
              {% endif %} {% else %} ↓ {% endif %}
            </span>
          </a>
          {% endfor %}
        </div>
      </div>
      <div id="nikas-root">
        {% set thread_id = "no_id" %} {% for comment in comments %} {% if
        order_by == "tid" %} {% if thread_id != comment.tid %} {% set thread_id
        = comment.tid %}
        <h2 class="thread-title">
          {{ comment.title }} (<a href="{{ comment.uri }}">{{ comment.uri }}</a
          >)
        </h2>
        {% endif %} {% endif %}
        <div class="nikas-comment" id="nikas-{{ comment.id }}">
          {% if conf.avatar %}
          <div class="avatar">svg(data-hash='#{{ comment.hash }}')</div>
          {% endif %}
          <div class="text-wrapper">
            <div class="nikas-comment-header" role="meta">
              {% if order_by != "tid" %}
              <div class="address">
                <span>منبع</span> : {{ comment.title or 'ثبت نشده است' }}
                <span style="margin-right: 25px">صفحه</span> :
                <a href="{{ comment.uri }}">{{ comment.uri }}</a>
              </div>
              <br />
              {% endif %}
              <span class="author-title">فرستنده : </span
              ><span class="author" id="nikas-author-{{ comment.id }}">
                {% if comment.author %} {{ comment.author }} {% else %} ناشناس
                {% endif %}
              </span>
              {% if comment.email %} (
              <a href="mailto:{{ comment.email }}" rel="nofollow" class="email"
                >ایمیل :
              </a>
              <span id="nikas-email-{{ comment.id }}">{{ comment.email }}</span>
              ) {% else %}
              <span id="nikas-email-{{ comment.id }}"></span>
              {% endif %} {% if comment.website %} (
              <a href="{{ comment.website }}" rel="nofollow" class="website"
                >وب سایت :
              </a>
              <span id="nikas-website-{{ comment.id }}"
                >{{ comment.website }}</span
              >
              ) {% else %}
              <span id="nikas-website-{{ comment.id }}"></span>
              {% endif %}
              <span class="spacer"> &bull;</span>
              <time>{{ comment.created | datetimeformat }}</time>
              <span class="note">
                {% if comment.mode == 1 %}
                <span class="label label-valid">تایید شده</span>
                {% elif comment.mode == 2 %}
                <span class="label label-pending">در انتظار تایید</span>
                {% elif comment.mode == 4 %}
                <span class="label label-staled">قدیمی</span>
                {% endif %}
              </span>
            </div>
            <div class="text">
              {% if comment.mode == 4 %}
              <strong>HIDDEN</strong>. Original text: <br />
              {% endif %}
              <div id="nikas-text-{{ comment.id }}">{{ comment.text }}</div>
            </div>
            <div class="nikas-comment-footer">
              {% if conf.votes and comment.likes - comment.dislikes != 0 %}
              <span class="votes">{{ comment.likes - comment.dislikes }}</span>
              {% endif %}
              <span class="spacer"></span>
              <a
                id="edit-btn-{{ comment.id }}"
                class="edit"
                onClick="javascript:start_edit({{ comment.id }})"
                >ویرایش</a
              >
              <a
                id="stop-edit-btn-{{ comment.id }}"
                class="hidden edit"
                onClick="javascript:stop_edit({{ comment.id }})"
                >لغو</a
              >
              <a
                id="send-edit-btn-{{ comment.id }}"
                class="hidden edit"
                onClick="javascript:send_edit({{ comment.id }}, '{{ comment.hash }}','{{ nikas_host_script }}')"
                >ارسال</a
              >
              {% if comment.mode != 4 %}
              <a
                class="delete"
                onClick="javascript:delete_com({{ comment.id }}, '{{ comment.hash }}', '{{ nikas_host_script }}')"
              >
                حذف
              </a>
              {% endif %} {% if comment.mode == 2 %}
              <a
                class="validate"
                onClick="javascript:validate_com({{ comment.id }}, '{{ comment.hash }}', '{{ nikas_host_script }}')"
                >تایید</a
              >
              {% endif %}
            </div>
          </div>
        </div>
        {% endfor %}
      </div>
    </div>
  </body>
</html>
