<!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">
    <title>Doxbin (Admin) - Flag History</title>
    @include('_scripts', ['adminPage' => 1])
    <meta name="robots" content="noindex">
    <script src="https://{{$currentDomain}}/legacy/jscolor.js"></script>
    <link rel="stylesheet" href="https://{{$currentDomain}}/legacy/index.css">
    <script type="text/javascript" src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
    
    <style>
        body{
            position:relative;
        }
        *{
            box-sizing: border-box;
        }
        @media only screen and (max-width: 992px){
        }
        textarea{
            background-color: #282828;
            border: none;
            border-radius: 2px;
            color: white;
        }
        .blacklist-container td{
            padding: 3px;
        }
        .blacklist-container tr:hover{
            background-color: #323232;
        }
        .blacklist-container tr{
            background-color: #444444;
        }
        a.button{
            display: inline-block;
            padding: 5px 8px;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: auto;
        }
        .add-to-blacklist > div > a.button{
            display: inline-block;
            padding: 5px 8px;
            border: solid 1px #00ff00;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: 50%;
        }
        .add-to-blacklist > div > a.button:hover{
            text-decoration: none;
            color: white;
            background-color: #1D1D1D;
        }
        .add-to-blacklist{
            width: 50%;
        }
        @media only screen and (max-width: 600px){
            .add-to-blacklist > div > a.button{
                width: 100%;
            }
            .add-to-blacklist{
                width: 100%;
            }
        }
        .center {
            text-align: center;
        }
        .add{
            background-color: green;
        }
        .add:hover{
            background-color: #1b6e10;
        }

        a.confirm{
            background-color: green;
            font-size: 15px;
            font-weight: bold;
            padding: 7px 10px;
        }
        a.confirm:hover{
            background-color: #1b6e10;
        }
        .word-container{
            background-color: #282828;
            width: 50%;
            border-radius: 7px;
            margin-top: 20px;
            box-shadow: 0 1px 3px #181a1f;
            padding: 0px 10px;
            position:relative;
            display: inline-block;
            -webkit-box-shadow: inset 0px 0px 3px 0px rgba(0,0,0,0.75);
            -moz-box-shadow: inset 0px 0px 3px 0px rgba(0,0,0,0.75);
            box-shadow: inset 0px 0px 3px 0px rgba(0,0,0,0.75);
        }

        .word-container .word-row{
            padding: 10px 10px;
            border-bottom: solid 1px gray;
        }
        .word-container .word-row:last-of-type{
            border: none;
        }
        .row {
            display: -ms-flexbox;
            display: flex;
            -ms-flex-wrap: wrap;
            flex-wrap: wrap;
            margin-right: -15px;
            margin-left: -15px;
        }
        .col {
            position: relative;
            width: 100%;
            padding-right: 15px;
            padding-left: 15px;
            -ms-flex-preferred-size: 0;
            flex-basis: 0;
            -ms-flex-positive: 1;
            flex-grow: 1;
            max-width: 100%;
        }
        .top-btn, .top-btn p{
            display: block;
            outline: none;
            background: #303030;
            letter-spacing: .5px;
            line-height: 1.5;
            border-right: 1px solid #26282e;
            padding: 12px 0;
            font-size: 14px;
            font-weight: 600;
            text-align: center;
            cursor: pointer;
            color: #a8a8a8;
            margin: 0;
        }

        .top-btn-disabled, .top-btn-disabled p{
            display: block;
            outline: none;
            background: #292929;
            letter-spacing: .5px;
            line-height: 1.5;
            border-right: 1px solid #26282e;
            padding: 12px 0;
            font-size: 14px;
            font-weight: 600;
            text-align: center;
            cursor: not-allowed;
            color: #5d5d5d;
            margin: 0;
        }
        .top-btn:hover, .top-btn p:hover{
            color: white !important;
            text-decoration: none;
        }
        .top-btn p:focus{
            color: #a8a8a8;
            text-decoration: none;
        }
        .active p{
            color: white;
        }
        .checkbox{
            height: 0;
            width: 0;
            visibility: hidden;
        }
        .checkbox-label {
            cursor: pointer;
            text-indent: -9999px;
            width: 60px;
            height: 30px;
            background: grey;
            display: block;
            border-radius: 100px;
            position: relative;
            transition: 0.3s;
        }
        .checkbox-label:after {
            content: '';
            position: absolute;
            top: 3px;
            left: 4px;
            width: 24px;
            height: 24px;
            background: #fff;
            border-radius: 90px;
            transition: 0.3s;
        }
        .checkbox:checked + label {
            background: #4cba30;
            transition: 0.3s;
        }
        .checkbox:checked + .checkbox-label:after {
            left: calc(100% - 5px);
            transform: translateX(-100%);
        }
        /* .checkbox-label:active:after {
            width: 30px;
        } */
        .word-container input[type=text]{
            background-color: rgb(31,31,31);
            border: solid 1px rgb(26,26,26);  
        }
        .word-row input.role-weight{
            color: white;
            background: #282828;
            border: none;
            display: inline-block;
            -webkit-font-smoothing: antialiased;
            outline: none;
            padding: 2px;
            width: 30px;
            height: 100%;
            float: left;
            text-align: center;
            margin-right: 7px;
            border-right: solid 1px gray;
            border-radius: 0;
        }
        label.redirect-label{
            margin:0;
            display:inline-block;
            background-color:#272727;
            padding:6px 0 6px 6px;
            line-height: 1.2;
            border-radius: 2px 0 0 2px;
            font-weight:400;
        }
        input.redirect-input{
            padding: 6px 6px 6px 0;
            background-color: #272727;
            border-radius: 0 2px 2px 0;
        }

        .anx{
            font-size: 17px;
        }

        .anxs{
            font-size: 19px;
        }

        .b-wrd{
            display: inline;
            color: white;
            font-size: 15px;
        }
        @media only screen and (max-width: 900px) {
        .word-container {
            width:100%;
        }
        }

        @media screen and (max-width:500px){
            body{
                font-size: 10px;
            }
            .col-md-12{
                padding: 0;
                width: 100%;
            }
            .col-md-7{
                padding: 0;
                width: 100%;
            }
            .top-btn, .top-btn p{
                font-size: 10px;
            }
            .anx{
                font-size: 14px;
            }
            .anxs{
                font-size: 16px;
            }
            a.confirm{
                font-size: 13px;
            }
            .b-wrd{
                font-size: 12px;
            }
        }
        
        
        input.search-input{
            padding: 2px 3px;
            background-color: #282828;
            outline: none;
            border: none;
            width: 100%;
        }


        .search-button{
            padding: 3px;
            /* background-color: #282828; */
            outline: none;
            border: none;
            color: white;
            display: inline-block;
            padding: 5px 8px;
            background-color: #272727;
            color: white;
            border-radius: 2px;
            text-transform: uppercase;
            font-size: 15px;
            font-weight: bold;
            margin: 0;
            width: auto;
        }

        .search-button:focus{
            text-decoration: none;
        }
        .button:hover{
            background-color: #232323;
            text-decoration:none;
        }
        .button.button-red{
            border: solid 1px #ff0000;
        }
        .button.button-green{
            border: solid 1px #00ff00;
        }
        .button.button-green{
            border: solid 1px #0000ff;
        }
        #search-table td {
            padding: 3px;
        }
        #search-table {
            background-color: inherit;
        }
        .button-small {
            padding: 2px 3px;
            font-size: 14px;
        }
        select, option {
            color: white;
            background: #282828;
            border: 0;
            border-radius: 2px;
            display: inline-block;
            -webkit-font-smoothing: antialiased;
            outline: none;
            padding: 3px;
            width: 200px;
        }
        td label {
            margin: 0;
        }
        </style>
</head>
<body style="min-height: 100%;height:100%">
    {!! csrf_field() !!}
        @include('_nav')
        <div class="nav-space"></div>
        <div class="page">
            @include('_admin_sidebar')
            <div class="page-content">
                <div class="search-box">
                    <form action="" method="GET">
                        <input type="hidden" name="search" value="1">
                        <table id="search-table">
                            <tr>
                                <td>
                                    <label for="userid">Flagged by:</label>
                                </td>
                                <td>
                                    <input class="search-input" type="number" id="userid" name="userid" value="{{$formData['userid']}}" placeholder="User ID...">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="pasteid">Paste ID:</label>
                                </td>
                                <td>
                                    <input class="search-input" type="number" id="pasteid" name="pasteid" value="{{$formData['pasteid']}}" placeholder="Paste ID...">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="handledby">Handled by:</label>
                                </td>
                                <td>
                                    <input class="search-input" type="number" id="handledby" name="handledby" value="{{$formData['handledby']}}" placeholder="User ID...">
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="status">Status:</label>
                                </td>
                                <td>
                                    <select name="status" id="status">
                                        <option value="" {{is_null($formData['status']) ? 'selected' : '' }}>(none)</option>
                                @php
                                $count = 0;
                                @endphp
                                @foreach($statuses as $status)
                                        <option value="{{$count}}" {{!is_null($formData['status']) && $formData['status'] == $count ? 'selected' : ''}}>{{$status}}</option>
                                    @php
                                    $count++;
                                    @endphp
                                @endforeach
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <label for="limit">Results:</label>
                                </td>
                                <td>
                                    <input class="search-input" type="number" id="limit" name="limit" value="{{$formData['limit']}}" placeholder="Amount of results..." {!! ($myUser->isMod() || $myUser->isDeveloper() ? 'max="1000"' : '') !!}>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <span>{{($flagCount > 0 ? $flagCount : 'No') . str_plural(' result', $flagCount)}}</span>
                                </td>
                                <td style="text-align: right;">
                                    <input class="button button-green button-small search-button" type="submit" name="submit" value="Search" style="width: 50%;">
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>

                <div class="flags">
            @if($flagCount > 0)
            
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            {{-- <th class="text-center">ID</th> --}}
                            <th>Paste</th>
                            <th>Council</th>
                            <th>Reason</th>
                            <th class="text-center">Flagged at</th>
                            <th class="text-center">Status</th>
                            <th class="text-center">Handled by</th>
                            <th class="text-center">Handled at</th>
                            {{-- <th class="text-center">Actions</th> --}}
                        </tr>
                    </thead>
                    <tbody>
            @foreach ($flags as $flag)
            @php
            $council = 0;
            if($flag->uid == 0){
                $council = 0;
            }else{
                $council = \App\User::find($flag->uid);
                if(is_null($council)){
                    continue;
                }
            }
            $handledby = null;
            if($flag->handled_by != null){
            $handledby = \App\User::find($flag->handled_by);
            if(is_null($handledby)){
            continue;
            }
            }
            
            $paste = \App\Paste::find($flag->pid);
            if(is_null($paste)){
            continue;
            }
            @endphp
                        <tr class="doxentry">
                            {{-- <td style="width: 60px;" class="text-center">{{ $flag->id }}</td> --}}
                            <td style="width: 60px;"><a href="/upload/{{$paste->link}}">{{ $paste->title }}</a></td>
                            <td>
                                @if ($council)
                                    {!! $council->getNameHtml(false, true) !!}
                                @else
                                    <b style="color: red">Doxbin</b>
                                @endif
                            </td>
                            <td>{{ $flag->reason }}</td>
                            <td class="text-center" title="{{ date('M jS, Y H:m', floor($flag->date / 1000)) }}">{{ age($flag->date) }}</td>
                            <td style="width: 90px;" class="text-center">{{ $statuses[$flag->status] }}</td>
                            @if($handledby == null)
                            <td class="text-center">---</td>
                            <td class="text-center">---</td>
                            @else
                            <td class="text-center">{!! $handledby->getNameHtml(false, true) !!}</a></td>
                            <td class="text-center" title="{{ date('M jS, Y H:m', floor($flag->handled_at / 1000)) }}">{{ age($flag->handled_at) }}</td>
            
                            @endif
                        </tr>
            @endforeach
                    </tbody>
                </table>
            @endif
            </div>
</div>
<script src="https://{{$currentDomain}}/legacy/admin.js"></script>
<script>
    function delWord(id){
        $.post('https://{{$currentDomain}}/admin/api/blacklist', {
            _token: $('input[name=_token]').val(),
            id: id,
            type: 'del',
        }, function(resp){
            if(resp.status == "done"){
                window.location = '/admin?sel=blacklist';
            }
        });
    }
    $(document).ready(function(e){
        
        var logsDropdown = false;
        $('#logs-button').on('click', function(e){
            if(!logsDropdown){
                $('.logs-dropdown').show();
                logsDropdown = true;
            }else{
                $('.logs-dropdown').hide();
                logsDropdown = false;
            }
            e.preventDefault();
        });
        
        $('#blacklist-add').on('click', function(e){
            $.post('/admin/api/add-to-blacklist', {
                _token: $('input[name=_token]').val(),
                alias: $('#alias').val(),
                email: $('#email').val(),
                words: $('#words').val(),
                info: $('#info').val(),
            }, function(resp){
                if(resp.status == "done"){
                    location.reload();
                }else{
                    alert(resp.msg);
                }
            });
            e.preventDefault();
        });
        
        $('.blacklist-remove').on('click', function(e){
            $.post('/admin/api/blacklist/delete', {
                _token: $('input[name=_token]').val(),
                id: $(this).attr('id'),
            }, function(resp){
                if(resp.status == "done"){
                    location.reload();
                }else{
                    alert(resp.msg);
                }
            });
            e.preventDefault();
        });
    });
</script>
</body>
</html>