@php
$admin = 0;
$mod = 0;
$isDeveloperOrHigher = false;
$isModOrHigher = false;
$council = 0;
$isAdminOrHigher = false;
if($myUser != null){
	$admin = $myUser->isAdmin();
	$mod = $myUser->isMod();
    $isDeveloperOrHigher = $myUser->isDeveloper(true);
    $isModOrHigher = $myUser->isMod(true);
    $isAdminOrHigher = $myUser->isAdmin(true);
    $council = $myUser->isCouncil();
}
@endphp
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="robots" content="noindex">
	
    <title>Search - Doxbin</title>
    <link rel="stylesheet" href="/legacy/index.css">
    @include('_scripts')
	<style>
	input[type=text]{
		line-height: 1.2;
		color: white;
		background: #282828;
		border: 0;
		border-radius: 2px;
		display: inline-block;
		-webkit-font-smoothing: antialiased;
		outline: none;
		padding: 7px 5px;
		width: 200px;
	}
	input[type=text]::placeholder{
		color: rgb(167, 167, 167);
	}
	input[type=submit]{
		line-height: 1.2;
		color: white;
		background: #282828;
		border: 0;
		border-radius: 2px;
		display: inline-block;
		-webkit-font-smoothing: antialiased;
		outline: none;
		padding: 7px 5px;
	}
	input{
		font-size: 100%;
	}
    .admin-text{
        color: red;
        font-weight: bold;
    }
	table.table tbody tr.hidden-post{
		background-color: #421414 !important;
	}
	table.table tbody tr.hidden-post:hover{
		background-color: #381111 !important;
	}

/* ---- */
.announcement.a-1{
    font-size: 23px;
}
.announcement.a-2{
    font-size: 16px;
    margin-top: 15px;
}

@media screen and (max-width:500px){
    body{
        font-size: 10px;
    }
    .col-md-12{
        padding: 0;
        width: 100%;
    }
    .col-md-7{
        padding: 0;
        width: 100%;
    }
    .pagination a, .pagination p{
        min-width: 25px;
        min-height: 25px;
    }
    .announcement.a-1{
        font-size: 17px;
    }
    .announcement.a-2{
        font-size: 14px;
    }
    
}
	</style>
</head>

<body>
    @include('_nav')
    <div class="col-md-12">
        <div class="col-md-12" style="margin-top: 60px; float:none;">
<div align="center">
                @include('_ascii')
                <noscript><p style="color: red; padding: 0px 0px 10px 0px; text-align: center; margin: 0;">Searching requires JavaScript to function correctly.<br>Alternatively, you can type <u>https://{{$currentDomain}}/search/{query}</u> in the address bar.</p></noscript>
				<div id="error-msg" style="color: red; padding: 0px 0px 10px 0px; text-align: center; margin: 0;"></div>
				<form id="search-form" method="POST" action="search">
                    @if(!is_null($myUser))
						<input type="radio" name="search-option" id="search_title" value="title" {!! ($searchColumn == 'title' ? 'checked="checked"' : '') !!} style="margin: 0;"><label for="search_title" style="margin: 0 0 0 5px;font-weight:normal;">Search in title</label><br>
						<input type="radio" name="search-option" id="search_paste" value="content" {!! ($searchColumn == 'content' ? 'checked="checked"' : '') !!} style="margin: 0;"><label for="search_paste" style="margin: 0 0 0 5px;font-weight:normal;">Search in paste</label><br>
                    @endif
                    {!! csrf_field() !!}
					<input name="search-query" type="text" placeholder="Search for..." value="{{$query}}">
					<input type="submit" value="Search"><br>
				</form>
				<br>
				@if($limited == 0)
				<p>Showing {{$pasteCount}} result(s) for '<b>{{$query}}</b>'</p>
				@endif
            </div>
        </div>
        <div class="col-md-7" style="float:none;margin:auto;padding:0;">
@if($limited == 1)
				<h4 style="color:red; text-align:center;">Wait {{ $remaining }} second(s) before searching again.</h4>
@elseif($results->count() > 0)
				<table class="table table-striped table-hover">
					<thead>
						<tr>
							<th colspan="3">Title</th>
							<th class="clickable text-center auto-size" id="commentsorder" style="width: 105px;">Comments @if ($order == "comments") @if($type == "desc") ⯆ @else ⯅ @endif @endif</th>
							<th class="clickable text-center auto-size" id="viewsorder">Views @if ($order == "views") @if($type == "desc") ⯆ @else ⯅ @endif @endif</th>
							<th colspan="2" class="text-center">Created by</th>
							<th class="clickable text-center r-hide" id="dateorder" style="width: 120px">Added @if ($order == "date") @if($type == "desc") ⯆ @else ⯅ @endif @endif</th>
							@if ($admin == 1)
							<th class="text-center" style="color:red;">Actions</th>
							@endif
						</tr>
					</thead>
					<tbody>
	@foreach ($results as $paste)
		@if($paste->private)
			@if(is_null($myUser) || $myUser->id != $paste->created_by)
				@continue
			@endif
		@endif
		@if (!$paste->hidden || $isModOrHigher)
			@php
			if ($paste->created_by == 0) {
				$user = null;
			} else {
                $user = createUserFromObjectWithUserInfo($paste, 'created_by');
			}
			@endphp
	
						<tr class="doxentry {{ $council && ($paste->flagged == 1 || $paste->flagged == 2 && ($paste->last_edited == null || $paste->last_edited < $paste->flagdate)) ? 'hidden-post' : '' }}{{ $paste->hidden == 1 ? 'hidden-post' : '' }} {{ !is_null($user) ? $user->pasteHighlightColor() : '' }}" id="{{$paste->id}}">
	
						<td colspan="3" style="overflow: hidden;text-overflow: ellipsis;">
							<a title="{{ $paste->title }}" href="https://{{$currentDomain}}/upload/{{$paste->link}}">{!! $paste->getIcons() !!}{{$paste->title}}</a>
						</td>
	
						<td style="width: 105px;" class="text-center">
							{{  $paste->disable_cmts == 1 ? '-' : $paste->comments   }}
						</td>
	
						<td class="text-center">
							{{$paste->views}}
						</td>
	
						<td colspan="2" style="padding-bottom: 0; max-width: 140px;" class="text-center">
							{!! App\User::getNameHtmlOrAnonymous($paste->created_by == 0 ? null : $user, true) !!}
						</td>
	

						<td style="width: 120px" class="text-center r-hide">{{$paste->created_at->format('M jS, Y')}}</td>
			@if ($isDeveloperOrHigher)
						<td class="text-center admin-select">
							<a id="hide{{$paste->id}}" onclick="removePaste({{$paste->id}})" style="color:red;" href="javascript:void(0)">{{ ($paste->hidden == 1 ? 'Unhide' : 'Hide') }}</a>
						</td>
			@endif
					</tr>
		@endif
	@endforeach
				</tbody>
			</table>
@endif
        </div>
    </div>

	@if ($isDeveloperOrHigher)
    <script src="{{ asset('/legacy/admin.js') }}"></script>
	<script>
	function hideDox(id){
		$.post("/", {_token: $('input[name=_token]').val(), hide_dox: 1, dox_id: id}, function(resp){
			if(resp.status == "done"){
                if(resp.hidden == 1){
                    $(`#${id}`).css('background-color', '#421414');
                    $(`#hide${id}`).text('Unhide');
                }else{
                    $(`#${id}`).css('background-color', '');
                    $(`#hide${id}`).text('Hide');
                }
			}
		});
	}
	</script>
	@endif
    {{-- <script type="text/javascript" src="https://v2.bytefend.com/libs.js" defer></script>
    <script type="text/javascript" src="https://v2.bytefend.com/api.js" defer></script> --}}
</body>
</html>