<!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.bootstrap4.min.css') }}" rel="stylesheet">

	<!-- JS -->
	<script src="{{ url_for('static', filename='js/jquery.js')}}"></script>
	<script src="{{ url_for('static', filename='js/bootstrap4.min.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">

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

				{%if last_domains%}
					<div class="table-responsive mt-1 mb-3 table-hover table-borderless table-striped">
						<table class="table">
							<thead class="thead-dark">
									<tr>
										<th>Domain</th>
										<th>First Seen</th>
										<th>Last Check</th>
										<th>Status</th>
									</tr>
							</thead>
							<tbody id="tbody_last_crawled">
									{% for metadata_domain in last_domains %}
										<tr>
											<td><a target="_blank" href="{{ url_for('hiddenServices.show_domain') }}?domain={{ metadata_domain['domain'] }}&port={{metadata_domain['port']}}&epoch={{metadata_domain['epoch']}}">{{ metadata_domain['domain_name'] }}</a></td>
											<td>{{'{}/{}/{}'.format(metadata_domain['first_seen'][0:4], metadata_domain['first_seen'][4:6], metadata_domain['first_seen'][6:8])}}</td>
											<td>{{'{}/{}/{}'.format(metadata_domain['last_check'][0:4], metadata_domain['last_check'][4:6], metadata_domain['last_check'][6:8])}}</td>
											<td><div style="color:{{metadata_domain['status_color']}}; display:inline-block">
														<i class="fas {{metadata_domain['status_icon']}} "></i>
														{{metadata_domain['status_text']}}
													</div>
											</td>
										</tr>
									{% endfor %}
							</tbody>
						</table>
					</div>
				{%endif%}

				<div class="row">
					<div class="col-lg-6">
						<div class="table-responsive mt-1 table-hover table-borderless table-striped">
							<table class="table" id="myTable_1">
								<thead class="thead-dark">
										<tr>
											<th>Onion Url</th>
											<th></th>
											<th>Next Check</th>
											<th></th>
											<th></th>
										</tr>
								</thead>
								<tbody id="tbody_last_crawled">
										{% for metadata_domain in auto_crawler_domain_onions_metadata %}
											<tr>
												<td><a target="_blank" href="{{ url_for('hiddenServices.show_domain') }}?domain={{ metadata_domain['domain'] }}&port={{metadata_domain['port']}}&epoch={{metadata_domain['epoch']}}">{{ metadata_domain['url'] }}</a></td>
												<td><a class="btn btn-outline-danger px-1 py-0" href="{{ url_for('hiddenServices.remove_auto_crawler') }}?url={{ metadata_domain['url'] }}&page={{page}}">
													<i class="fas fa-trash-alt"></i></a>
												</td>
												<td>{{metadata_domain['epoch']}}</td>
												<td><div style="color:{{metadata_domain['status_color']}}; display:inline-block">
															<i class="fas {{metadata_domain['status_icon']}} "></i>
															{{metadata_domain['status_text']}}
														</div>
												</td>
												<td>
													<button class="btn btn-outline-secondary px-1 py-0 disabled"><i class="fas fa-pencil-alt"></i></button>
												</td>
											</tr>
										{% endfor %}
								</tbody>
							</table>
						</div>
					</div>
					<div class="col-lg-6">
						<div class="table-responsive mt-1 table-hover table-borderless table-striped">
							<table class="table" id="myTable_2">
								<thead class="thead-dark">
										<tr>
											<th>Regular Url</th>
											<th></th>
											<th>Next Check</th>
											<th></th>
											<th></th>
										</tr>
								</thead>
								<tbody id="tbody_last_crawled">
										{% for metadata_domain in auto_crawler_domain_regular_metadata %}
											<tr>
												<td><a target="_blank" href="{{ url_for('hiddenServices.show_domain') }}?domain={{ metadata_domain['domain'] }}&port={{metadata_domain['port']}}&epoch={{metadata_domain['epoch']}}">{{ metadata_domain['url'] }}</a></td>
												<td><a class="btn btn-outline-danger px-1 py-0" href="{{ url_for('hiddenServices.remove_auto_crawler') }}?url={{ metadata_domain['url'] }}&page={{page}}">
													<i class="fas fa-trash-alt"></i></a>
												</td>
												<td>{{metadata_domain['epoch']}}</td>
												<td><div style="color:{{metadata_domain['status_color']}}; display:inline-block">
															<i class="fas {{metadata_domain['status_icon']}} "></i>
															{{metadata_domain['status_text']}}
														</div>
												</td>
												<td>
													<button class="btn btn-outline-secondary px-1 py-0 disabled"><i class="fas fa-pencil-alt"></i></button>
												</td>
											</tr>
										{% endfor %}
								</tbody>
							</table>
						</div>
					</div>
				</div>

				<hr class="mt-4">

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

							{%if page>3%}
								<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.auto_crawler') }}?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.auto_crawler') }}?page={{page-1}}">{{page-1}}</a></li>
								<li class="page-item active"><a class="page-link" href="{{ url_for('hiddenServices.auto_crawler') }}?page={{page}}">{{page}}</a></li>
							{%else%}
							{%if page>2%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.auto_crawler') }}?page={{page-2}}">{{page-2}}</a></li>{%endif%}
							{%if page>1%}<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.auto_crawler') }}?page={{page-1}}">{{page-1}}</a></li>{%endif%}
							<li class="page-item active"><a class="page-link" href="{{ url_for('hiddenServices.auto_crawler') }}?page={{page}}">{{page}}</a></li>
							{%endif%}

							{%if nb_page_max-page>3%}
								<li class="page-item"><a class="page-link" href="{{ url_for('hiddenServices.auto_crawler') }}?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.auto_crawler') }}?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.auto_crawler') }}?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.auto_crawler') }}?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.auto_crawler') }}?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.auto_crawler') }}?page={{page+1}}" aria-disabled="true">Next</a>
							</li>
						</ul>
					</nav>
				</div>

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


</body>

<script>
$(document).ready(function(){
	$("#page-Crawler").addClass("active");
	$("#nav_auto_crawler").addClass("active");

	table1 = $('#myTable_1').DataTable(
	{
		//"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
		//"iDisplayLength": 5,
		//"order": [[ 0, "desc" ]]
		columnDefs: [
   		{ orderable: false, targets: [-1, -4] }
		]
	});

	table2 = $('#myTable_2').DataTable(
	{
		//"aLengthMenu": [[5, 10, 15, 20, -1], [5, 10, 15, 20, "All"]],
		//"iDisplayLength": 5,
		//"order": [[ 0, "desc" ]]
		columnDefs: [
   		{ orderable: false, targets: [-1, -4] }
		]
	});
});

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>
