{% filter remove_whitespace %}
{# Automatically removes unnecessary whitespace #}
<div class="ban">
	{% if ban.expires and time() >= ban.expires %}
		<h2>{% trans %}You were banned! ;_;{% endtrans %}</h2>
	{% else %}
		<h2>{% trans %}You are banned! ;_;{% endtrans %}</h2>
	{% endif %}
	<p>
		{% if ban.expires and time() >= ban.expires %}
			{% trans %}You were banned from{% endtrans %}
		{% else %}
			{% trans %}You have been banned from{% endtrans %}
		{% endif %}
			{% if ban.board %}
				 <strong>{{ config.board_abbreviation|sprintf(ban.board) }}</strong>
			{% else %}
				 {% trans %}all boards{% endtrans %}
			{% endif %}
			{% if ban.reason %}
				 {% trans %}for the following reason:{% endtrans %}
			{% else %}
				 {% trans %}for an unspecified reason.{% endtrans %}
			{% endif %}
	</p>
	{% if ban.reason %}
		<p class="reason">
			{{ ban.reason }}
		</p>
	{% endif %}
	<p>
		{% trans %}Your ban was filed on{% endtrans %} 
			<strong>{{ ban.set|date(config.ban_date) }}</strong> {% trans %}and{% endtrans %} <span id="expires">
		{% if ban.expires and time() >= ban.expires %}
			{% trans %} has since expired. Refresh the page to continue.{%  endtrans %}
		{% elseif ban.expires %}
			{% trans %}expires{% endtrans %} <span id="countdown">{{ ban.expires|until }}</span> {% trans %}from now, which is on{% endtrans %} 
			<strong>
				{{ ban.expires|date(config.ban_date) }}
			</strong>
			<script>
				var secondsLeft = {{ ban.expires - time() }};
				var end = new Date().getTime() + secondsLeft*1000;
				function updateExpiresTime() {
					countdown.firstChild.nodeValue = until(end);
				}
				function until(end) {
					var now = new Date().getTime();
					var diff = Math.round((end - now) / 1000);
					if (diff < 0) {
						document.getElementById("expires").innerHTML = "{% trans %}has since expired. Refresh the page to continue.{% endtrans %}";
						clearInterval(int);
						return "";
					} else if (diff < 60) {
						return diff + " second" + (diff == 1 ? "" : "s");
					} else if (diff < 60*60) {
						return (num = Math.round(diff/(60))) + " minute" + (num == 1 ? "" : "s");
					} else if (diff < 60*60*24) {
						return (num = Math.round(diff/(60*60))) + " hour" + (num == 1 ? "" : "s");
					} else if (diff < 60*60*24*7) {
						return (num = Math.round(diff/(60*60*24))) + " day" + (num == 1 ? "" : "s");
					} else if (diff < 60*60*24*365) {
						return (num = Math.round(diff/(60*60*24*7))) + " week" + (num == 1 ? "" : "s");
					} else {
						return (num = Math.round(diff/(60*60*24*365))) + " year" + (num == 1 ? "" : "s");
					}
				}
				var countdown = document.getElementById("countdown");
				
				updateExpiresTime();
				var int = setInterval(updateExpiresTime, 1000);
			</script>
		{% else %}
			<em>{% trans %}will not expire{% endtrans %}</em>.
		{% endif %}
		</span>
	</p>
	<p>{% trans %}Your IP address is{% endtrans %} <strong>{{ ban.ip }}</strong>.</p>

	{% if config.ban_page_extra %}
		<p>{{ config.ban_page_extra }}</p>
	{% endif %}
</div>
{% endfilter %}

