{% extends "CHRISTMAS/default.html" %}

{% block title %}
<title>{{'SITE_NAME' | app_config}}</title>
<meta name="description" content="{{'SITE_NAME' | app_config}} Help">
{% endblock %}

{% block subHeader %}
<div class="relative max-w-screen-2xl mx-auto px-4 py-4 grid grid-cols-12 rounded-t">
	<div class="absolute top-0 left-0 w-full h-full bg-gradient-to-t from-gray-300 to-gray-200 dark:bg-none dark:bg-gray-800 rounded-t sub-header-shadow dark:border-b dark:border-gray-700 sub-header"></div>
	<div class="relative col-span-full flex items-center">
		<div>
			<h1 class="font-bold text-xl font-heading leading-normal mb-0">
				Vote Analysis
			</h1>
			<ul class="flex space-x-2 text-xs text-gray-500 dark:text-gray-400 leading-normal mb-0">
				<li>
					<a href="/admin" class="text-gray-500 hover:underline">Admin Dashboard</a>
				</li>
				<li>
					<i class="fas fa-arrow-alt-right text-shadow fa-fw fa-sm"></i>
				</li>
				<li>
					<a href="#" class="text-gray-700 dark:text-gray-500 hover:underline">Vote Analysis</a>
				</li>
			</ul>
		</div>
	</div>
</div>
{% endblock %}

{% block content %}
<div class="col-span-full my-4 space-y-6">

	<div class="p-5 flex flex-col rounded-md bg-gray-300 dark:bg-gray-700 shadow-inset-t-white-10 border border-gray-400 dark:border-gray-900">
		<h2 class="font-bold text-lg font-heading leading-normal mb-0 capitalize">
			Vote Info
		</h2>
		<form action="/admin/alt_votes" method="get">
			<label class="label">
				Usernames
			</label>
			<div class="w-full flex space-x-2 items-center">
				<input id="link-input" type="text" class="form-input" name="u1" value="{{u1.username if u1 else ''}}" placeholder="User #1" required>
				<input id="link-input" type="text" class="form-input" name="u2" value="{{u2.username if u2 else ''}}" placeholder="User #2" oninput="document.getElementById('analysis-btn').disabled=false" required>
				<input id="analysis-btn" type="submit" value="Analyze" class="btn btn-primary">
			</div>
		</form>
	</div>

	{% if u1 and u2 %}
	<div class="p-5 flex flex-col rounded-md bg-gray-300 dark:bg-gray-700 shadow-inset-t-white-10 border border-gray-400 dark:border-gray-900">
		<h2 class="font-bold text-lg font-heading leading-normal mb-0 capitalize">
			Analysis
		</h2>
		<table class="w-full table table-striped mb-5">
			<thead class="bg-primary text-white">
				<tr>
					<th></th>
					<th>@{{u1.username}} only(% unique)</th>
					<th>Both</th>
					<th>@{{u2.username}} only (% unique)</th>
				</tr>
			</thead>

			<tr>
				<td><b>Post Upvotes</b></td>
				<td>{{data['u1_only_post_ups']}} ({{data['u1_post_ups_unique']}}%)</td>
				<td>{{data['both_post_ups']}}</td>
				<td>{{data['u2_only_post_ups']}} ({{data['u2_post_ups_unique']}}%)</td>
			</tr>
			<tr>
				<td><b>Post Downvotes</b></td>
				<td>{{data['u1_only_post_downs']}} ({{data['u1_post_downs_unique']}}%)</td>
				<td>{{data['both_post_downs']}}</td>
				<td>{{data['u2_only_post_downs']}} ({{data['u2_post_downs_unique']}}%)</td>
			</tr>
			<tr>
				<td><b>Comment Upvotes</b></td>
				<td>{{data['u1_only_comment_ups']}} ({{data['u1_comment_ups_unique']}}%)</td>
				<td>{{data['both_comment_ups']}}</td>
				<td>{{data['u2_only_comment_ups']}} ({{data['u2_comment_ups_unique']}}%)</td>
			</tr>
			<tr>
				<td><b>Comment Downvotes</b></td>
				<td>{{data['u1_only_comment_downs']}} ({{data['u1_comment_downs_unique']}}%)</td>
				<td>{{data['both_comment_downs']}}</td>
				<td>{{data['u2_only_comment_downs']}} ({{data['u2_comment_downs_unique']}}%)</td>
			</tr>
		</table>
	</div>

	<div class="p-5 flex flex-col rounded-md bg-gray-300 dark:bg-gray-700 shadow-inset-t-white-10 border border-gray-400 dark:border-gray-900">
		<h2 class="font-bold text-lg font-heading leading-normal mb-0 capitalize">
			Link Acocunts
		</h2>
		{% if u2 in u1.alts %}
		<p>Accounts are known alts of eachother.</p>
		{% else %}

		<p>Two accounts controlled by different people should have most uniqueness percentages at or above 70-80%</p>
		<p>A sockpuppet account will have its uniqueness percentages significantly lower.</p>

		<button class="btn btn-gray" onclick="document.getElementById('link-form').classList.toggle('hidden');">
			Link Accounts
		</button>

		<form action="/admin/link_accounts" method="post" id="link-form" class="hidden mt-2">
			<input type="hidden" name="formkey" value="{{v.formkey}}">
			<input type="hidden" name="u1" value="{{u1.id}}">
			<input type="hidden" name="u2" value="{{u2.id}}">
			<input type="submit" class="btn btn-red" value="Confirm Link: @{{u1.username}} and @{{u2.username}}">
		</form>
	</div>

	{% endif %}

	{% endif %}

</div>
{% endblock %}