<!DOCTYPE html>

<html>
<head>
	<title>AIL-Framework</title>
	<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png')}}">
	<!-- Core CSS -->
	<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet">
	<link href="{{ url_for('static', filename='css/dataTables.bootstrap.min.css') }}" rel="stylesheet">

	<!-- JS -->
	<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
	<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script>
	<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script>


</head>

<body>

	{% include 'nav_bar.html' %}

	<div class="container-fluid">
		<div class="row">

			{% include 'crawler/menu_sidebar.html' %}

			<div class="col-12 col-lg-10" id="core_content">

				<div class="card-deck justify-content-center mx-0">
					<div class="card border-dark mt-2">
						<div class="card-header bg-dark text-white">
							Blacklisted {{type_name}}s
						</div>
					  <div class="card-body text-dark">

							<div class="row">
						    <div class="col-12 col-md-6">
									<div class="card text-center border-danger">
										<div class="card-body text-danger">
											<h5 class="card-title">Blacklist {{type_name}}</h5>
												<input type="text" class="form-control {%if blacklist_domain is not none %}{%if blacklist_domain==1 %}is-valid{% else %}is-invalid{%endif%}{%endif%}" id="blacklist_domain_input" placeholder="{{type_name}} Address">
												<div class="invalid-feedback">
													{%if blacklist_domain==2 %}
														This {{type_name}} is already blacklisted
													{% else %}
														Incorrect {{type_name}} address
													{% endif %}
												</div>
												<div class="valid-feedback">
													{{type_name}} Blacklisted
												</div>
												<button type="button" class="btn btn-danger mt-2" onclick="window.location.href ='{{ url_for('hiddenServices.blacklist_domain') }}?redirect=0&type={{type}}&domain='+$('#blacklist_domain_input').val();">Blacklist {{type_name}}</button>
										</div>
									</div>
								</div>
								<div class="col-12 col-md-6 mt-4 mt-md-0">
									<div class="card text-center border-success">
										<div class="card-body">
											<h5 class="card-title">Unblacklist {{type_name}}</h5>
												<input type="text" class="form-control {%if unblacklist_domain is not none %}{%if unblacklist_domain==1 %}is-valid{% else %}is-invalid{%endif%}{%endif%}" id="unblacklist_domain_input" placeholder="{{type_name}} Address">
												<div class="invalid-feedback">
													{%if unblacklist_domain==2 %}
														This {{type_name}} is not blacklisted
													{% else %}
														Incorrect {{type_name}} address
													{% endif %}
												</div>
												<div class="valid-feedback">
													{{type_name}} Unblacklisted
												</div>
												<button type="button" class="btn btn-outline-secondary mt-2" onclick="window.location.href ='{{ url_for('hiddenServices.unblacklist_domain') }}?redirect=0&type={{type}}&domain='+$('#unblacklist_domain_input').val();">Unblacklist {{type_name}}</button>
										</div>
									</div>
								</div>
							</div>

							<div class="row mt-4">
						    <div class="col-12 col-xl-6">
									<table class="table table-striped table-bordered table-hover" id="myTable_1">
										<thead class="thead-dark">
											<tr>
												<th style="max-width: 800px;">{{type_name}}</th>
												<th style="max-width: 800px;">Unblacklist {{type_name}}</th>
											</tr>
										</thead>
										<tbody>
											{% for domain in list_blacklisted_1 %}
											<tr>
												<td>{{domain}}</td>
												<td>
													<a href="{{ url_for('hiddenServices.unblacklist_domain') }}?page={{page}}&domain={{domain}}&type={{type}}">
														<button type="button" class="btn btn-outline-danger">UnBlacklist {{type_name}}</button>
													</a>
												</td>
											</tr>
											{% endfor %}
										</tbody>
									</table>
								</div>
								<div class="col-12 col-xl-6">
									<table class="table table-striped table-bordered table-hover" id="myTable_2">
										<thead class="thead-dark">
											<tr>
												<th style="max-width: 800px;">{{type_name}}</th>
												<th style="max-width: 800px;">Unblacklist {{type_name}}</th>
											</tr>
										</thead>
										<tbody>
											{% for domain in list_blacklisted_2 %}
											<tr>
												<td>{{domain}}</td>
												<td>
													<a href="{{ url_for('hiddenServices.unblacklist_domain') }}?page={{page}}&domain={{domain}}&type={{type}}">
														<button type="button" class="btn btn-outline-danger">UnBlacklist {{type_name}}</button>
													</a>
												</td>
											</tr>
											{% endfor %}
										</tbody>
									</table>
								</div>
						  </div>
						</div>
					</div>

				</div>

				<div class="d-flex justify-content-center">
					<nav class="mt-4" aria-label="...">
						<ul class="pagination">
							<li class="page-item {%if page==1%}disabled{%endif%}">
								<a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page-1}}">Previous</a>
							</li>

							{%if page>3%}
								<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page=1">1</a></li>
								<li class="page-item disabled"><a class="page-link" aria-disabled="true" href="#">...</a></li>
								<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page-1}}">{{page-1}}</a></li>
								<li class="page-item active"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page}}">{{page}}</a></li>
							{%else%}
							{%if page>2%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page-2}}">{{page-2}}</a></li>{%endif%}
							{%if page>1%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page-1}}">{{page-1}}</a></li>{%endif%}
							<li class="page-item active"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page}}">{{page}}</a></li>
							{%endif%}

							{%if nb_page_max-page>3%}
								<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page+1}}">{{page+1}}</a></li>
								<li class="page-item disabled"><a class="page-link" aria-disabled="true" href="#">...</a></li>
								<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{nb_page_max}}">{{nb_page_max}}</a></li>
							{%else%}
								{%if nb_page_max-page>2%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{nb_page_max-2}}">{{nb_page_max-2}}</a></li>{%endif%}
								{%if nb_page_max-page>1%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{nb_page_max-1}}">{{nb_page_max-1}}</a></li>{%endif%}
								{%if nb_page_max-page>0%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{nb_page_max}}">{{nb_page_max}}</a></li>{%endif%}
							{%endif%}



							<li class="page-item {%if page==nb_page_max%}disabled{%endif%}">
								<a class="page-link" href="{{ url_for('hiddenServices.blacklisted_domains') }}?page={{page+1}}" aria-disabled="true">Next</a>
							</li>
						</ul>
					</nav>
				</div>

			</div>
		</div>
	</div>

</body>

<script>
var table
$(document).ready(function(){

		table = $('#myTable_1').DataTable(
			{
				/*"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
				"iDisplayLength": 10,*/
				"order": [[ 0, "asc" ]]
			}
		);

		table = $('#myTable_2').DataTable(
			{
				/*"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
				"iDisplayLength": 10,*/
				"order": [[ 0, "asc" ]]
			}
		);
		$("#page-Crawler").addClass("active");
});

function toggle_sidebar(){
	if($('#nav_menu').is(':visible')){
		$('#nav_menu').hide();
		$('#side_menu').removeClass('border-right')
		$('#side_menu').removeClass('col-lg-2')
		$('#core_content').removeClass('col-lg-10')
	}else{
		$('#nav_menu').show();
		$('#side_menu').addClass('border-right')
		$('#side_menu').addClass('col-lg-2')
		$('#core_content').addClass('col-lg-10')
	}
}
</script>
